Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 724d264

Browse files
area in top, fix docker file
1 parent 29ad5ac commit 724d264

File tree

4 files changed

+97
-19
lines changed

4 files changed

+97
-19
lines changed

‎Dockerfile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM python:3.8-alpine as builder
22

3-
RUN apk update && apk add --no-cache tzdata ca-certificates alpine-sdk libressl-dev libffi-dev
3+
RUN apk update && apk add --no-cache tzdata ca-certificates alpine-sdk libressl-dev libffi-dev cargo
4+
45
COPY requirements.txt /requirements.txt
56
RUN pip3 install --user -r /requirements.txt && rm /requirements.txt
67

‎requirements.txt‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
requests
1+
requests==2.24.0
22
pytelegrambotapi==3.7.6
3-
beautifulsoup4
3+
beautifulsoup4==4.9.1
44
tgbot-ping
5-
redis
6-
apscheduler
7-
pymongo
8-
tornado
9-
cryptography
5+
redis==3.5.3
6+
apscheduler==3.6.3
7+
pymongo==3.11.2
8+
tornado==6.0.4
9+
cryptography==3.4.1

‎web/index.html‎

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,44 @@
5353
/*a:hover::after {*/
5454
/* display: block;*/
5555
/*}*/
56+
/* Style the tab */
57+
.tab {
58+
overflow: hidden;
59+
border: 1px solid #ccc;
5660

61+
/*background-color: #f1f1f1;*/
62+
}
63+
64+
/* Style the buttons inside the tab */
65+
.tab button {
66+
text-align: center;
67+
background-color: inherit;
68+
float: inherit;
69+
border: none;
70+
outline: none;
71+
cursor: pointer;
72+
padding: 14px 16px;
73+
transition: 0.3s;
74+
font-size: 17px;
75+
}
76+
77+
/* Change background color of buttons on hover */
78+
.tab button:hover {
79+
background-color: #ddd;
80+
}
81+
82+
/* Create an active/current tablink class */
83+
.tab button.active {
84+
background-color: #ccc;
85+
}
86+
87+
/* Style the tab content */
88+
.tabcontent {
89+
display: none;
90+
padding: 6px 12px;
91+
border: 1px solid #ccc;
92+
border-top: none;
93+
}
5794
</style>
5895
</head>
5996
<body>
@@ -71,11 +108,23 @@ <h2>本站数据库<b><a style="text-decoration: none;color: skyblue" href="http
71108
</label>
72109
<input type="submit" value="搜索">
73110
</form>
74-
<hr>
111+
<br>
75112
<div id="tv">
76113
<h2>大家都在看......</h2>
114+
<div class="tab">
115+
<button class="tablinks" onclick="openCity(event, 'US')">美剧</button>
116+
<button class="tablinks" onclick="openCity(event, 'JP')">日剧</button>
117+
</div>
118+
119+
120+
<div id="US" class="tabcontent">
121+
</div>
122+
123+
<div id="JP" class="tabcontent">
124+
</div>
125+
77126
</div>
78-
<hr>
127+
79128
<h2>相关资源</h2>
80129
<h3>
81130
联系我 <a style="text-decoration: none;color: green" href="https://t.me/BennyThink">Benny 小可爱</a>
@@ -107,19 +156,43 @@ <h3>
107156

108157
function showTop(data) {
109158

110-
let div = document.getElementById("tv");
111159
for (let i = 0; i < data.length; i++) {
112160
let info = data[i].data.info
161+
console.log(info.area)
162+
let div = HTMLElement
163+
164+
if (info.area === "美国") {
165+
div = document.getElementById("US");
166+
} else if (info.area === "日本") {
167+
div = document.getElementById("JP");
168+
}
113169
let name = `${info.cnname} ${info.enname} ${info.aliasname}`;
114170
let html = `<h4><a title="浏览量 ${info.views}" style="text-decoration: none;color: cornflowerblue" href="/resource.html?id=${info.id}">${name}</a></h4>`;
115171
let backup = div.innerHTML;
116172
div.innerHTML = backup + html;
117173

118174
}
119-
175+
a = document.getElementById("US");
176+
document.getElementsByClassName("tab")[0].firstElementChild.className += " active"
177+
a.style.display = "block"
120178
}
121179

122180
accessMetrics();
123181

182+
function openCity(evt, cityName) {
183+
var i, tabcontent, tablinks;
184+
tabcontent = document.getElementsByClassName("tabcontent");
185+
for (i = 0; i < tabcontent.length; i++) {
186+
tabcontent[i].style.display = "none";
187+
}
188+
tablinks = document.getElementsByClassName("tablinks");
189+
for (i = 0; i < tablinks.length; i++) {
190+
tablinks[i].className = tablinks[i].className.replace(" active", "");
191+
}
192+
document.getElementById(cityName).style.display = "block";
193+
console.log(evt)
194+
evt.currentTarget.className += " active";
195+
}
196+
124197
</script>
125198
</html>

‎web/server.py‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def search_resource(self):
9898
projection = {'_id': False,
9999
'data.info': True,
100100
}
101-
print(111,param)
101+
102102
data = self.mongo.db["yyets"].find({
103103
"$or": [
104104
{"data.info.cnname": {'$regex': f'.*{param}.*', "$options": "-i"}},
@@ -125,15 +125,19 @@ class TopHandler(BaseHandler):
125125

126126
@run_on_executor()
127127
def get_top_resource(self):
128-
top_type = self.get_query_argument("type", "all")
129128
projection = {'_id': False,
130129
'data.info': True,
131130
}
132-
if top_type == "all":
133-
data = self.mongo.db["yyets"].find({}, projection).sort("data.info.views", pymongo.DESCENDING).limit(10)
134-
else:
135-
data = []
136-
return dict(data=list(data))
131+
132+
us = self.mongo.db["yyets"].find({"data.info.area": "美国"}, projection).sort("data.info.views",
133+
pymongo.DESCENDING).limit(10)
134+
135+
jp = self.mongo.db["yyets"].find({"data.info.area": "日本"}, projection).sort("data.info.views",
136+
pymongo.DESCENDING).limit(10)
137+
us_data = list(us)
138+
jp_data = list(jp)
139+
us_data.extend(jp_data)
140+
return dict(data=us_data)
137141

138142
@gen.coroutine
139143
def get(self):

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /