Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Rat Aint Tieba
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bing Chilling
Rat Aint Tieba
Commits
4dd1ea09
Commit
4dd1ea09
authored
1 year ago
by
John Xina
Browse files
Options
Downloads
Patches
Plain Diff
add user homepage
parent
0c1e2cef
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
app.py
+18
-2
18 additions, 2 deletions
app.py
templates/bar.html
+1
-1
1 addition, 1 deletion
templates/bar.html
templates/error.html
+1
-1
1 addition, 1 deletion
templates/error.html
templates/index.html
+1
-1
1 addition, 1 deletion
templates/index.html
templates/user.html
+64
-0
64 additions, 0 deletions
templates/user.html
with
85 additions
and
5 deletions
app.py
+
18
−
2
View file @
4dd1ea09
...
@@ -147,7 +147,23 @@ async def forum_view():
...
@@ -147,7 +147,23 @@ async def forum_view():
@app.route
(
'
/home/main
'
)
@app.route
(
'
/home/main
'
)
async
def
user_view
():
async
def
user_view
():
return
'
UNDER CONSTRUCTION
'
pn
=
int
(
request
.
args
.
get
(
'
pn
'
)
or
1
)
i
=
request
.
args
.
get
(
'
id
'
)
try
:
# try converting it to user_id, otherwise using the string.
i
=
int
(
i
)
except
:
pass
async
with
aiotieba
.
Client
()
as
tieba
:
try
:
hp
=
await
tieba
.
get_homepage
(
i
,
pn
)
except
ValueError
:
return
await
render_template
(
'
error.html
'
,
msg
=
'
您已超过最后页
'
)
if
len
(
hp
[
1
])
==
0
and
pn
>
1
:
return
await
render_template
(
'
error.html
'
,
msg
=
'
您已超过最后页
'
)
return
await
render_template
(
'
user.html
'
,
hp
=
hp
,
pn
=
pn
)
@app.route
(
'
/
'
)
@app.route
(
'
/
'
)
async
def
main_view
():
async
def
main_view
():
...
@@ -157,7 +173,7 @@ async def main_view():
...
@@ -157,7 +173,7 @@ async def main_view():
@app.errorhandler
(
RuntimeError
)
@app.errorhandler
(
RuntimeError
)
async
def
runtime_error_view
(
e
):
async
def
runtime_error_view
(
e
):
if
e
.
msg
:
if
hasattr
(
e
,
'
msg
'
)
:
return
await
render_template
(
'
error.html
'
,
msg
=
e
.
msg
)
return
await
render_template
(
'
error.html
'
,
msg
=
e
.
msg
)
return
await
render_template
(
'
error.html
'
,
msg
=
'
错误信息不可用
'
)
return
await
render_template
(
'
error.html
'
,
msg
=
'
错误信息不可用
'
)
...
...
This diff is collapsed.
Click to expand it.
templates/bar.html
+
1
−
1
View file @
4dd1ea09
...
@@ -85,7 +85,7 @@
...
@@ -85,7 +85,7 @@
</div>
</div>
</div>
</div>
<footer>
<footer>
<div><a
href=
"
https://0xacab.org/johnxina/rat
"
>
RAT Ain't Tieba
</a></div>
<div><a
href=
"
/
"
>
RAT Ain't Tieba
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat/-/blob/no-masters/LICENSE"
>
自豪地以 AGPLv3 释出
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat/-/blob/no-masters/LICENSE"
>
自豪地以 AGPLv3 释出
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat"
>
源代码
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat"
>
源代码
</a></div>
</footer>
</footer>
...
...
This diff is collapsed.
Click to expand it.
templates/error.html
+
1
−
1
View file @
4dd1ea09
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
<h1>
{{ msg }}
</h1>
<h1>
{{ msg }}
</h1>
</div>
</div>
<footer>
<footer>
<div><a
href=
"
https://0xacab.org/johnxina/rat
"
>
RAT Ain't Tieba
</a></div>
<div><a
href=
"
/
"
>
RAT Ain't Tieba
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat/-/blob/no-masters/LICENSE"
>
自豪地以 AGPLv3 释出
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat/-/blob/no-masters/LICENSE"
>
自豪地以 AGPLv3 释出
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat"
>
源代码
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat"
>
源代码
</a></div>
</footer>
</footer>
...
...
This diff is collapsed.
Click to expand it.
templates/index.html
+
1
−
1
View file @
4dd1ea09
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</form>
</form>
</div>
</div>
<footer>
<footer>
<div><a
href=
"
https://0xacab.org/johnxina/rat
"
>
RAT Ain't Tieba
</a></div>
<div><a
href=
"
/
"
>
RAT Ain't Tieba
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat/-/blob/no-masters/LICENSE"
>
自豪地以 AGPLv3 释出
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat/-/blob/no-masters/LICENSE"
>
自豪地以 AGPLv3 释出
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat"
>
源代码
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat"
>
源代码
</a></div>
</footer>
</footer>
...
...
This diff is collapsed.
Click to expand it.
templates/user.html
0 → 100644
+
64
−
0
View file @
4dd1ea09
<!DOCTYPE html>
<head>
<title>
{{ hp[0].show_name }}的个人资料 - RAT
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<link
href=
"/static/css/main.css"
rel=
"stylesheet"
>
<style>
.thread
{
border
:
solid
;
border-color
:
var
(
--bg-color
);
border-width
:
0
;
border-top-width
:
5px
;
border-bottom-width
:
5px
;
}
</style>
</head>
<body>
<header
class=
"bar-nav"
>
<img
src=
"/proxy/avatar/{{ hp[0].portrait }}"
></nav>
<div>
<div
class=
"title"
>
{{ hp[0].show_name }}
<small>
{{ hp[0].user_name }}
</small></div>
<div
class=
"description"
>
{{ hp[0].sign }}
</div>
<div
class=
"stats"
>
<small>
关注数: {{ hp[0].follow_num|intsep }}
</small>
<small>
粉丝数: {{ hp[0].fan_num|intsep }}
</small>
<small>
发帖数: {{ hp[0].post_num|intsep }}
</small>
<small>
关注贴吧数: {{ hp[0].forum_num|intsep }}
</small>
</div>
</div>
</header>
<div
class=
"list"
>
{% for t in hp[1] %}
<div
class=
"thread"
>
<div
class=
"summary"
>
<a
href=
"/p/{{ t.tid }}"
>
{{ t.text }}
</a>
</div>
</div>
{% endfor %}
</div>
<div
class=
"paginator"
>
{% if pn > 1 %}
<a
href=
"/home/main?id={{ hp[0].user_id }}&pn={{ 1 }}"
>
首页
</a>
{% endif %}
{% for i in range(5) %}
{% set np = pn - 5 + i %}
{% if np > 0 %}
<a
href=
"/home/main?id={{ hp[0].user_id }}&pn={{ np }}"
>
{{ np }}
</a>
{% endif %}
{% endfor %}
<a>
{{ pn }}
</a>
<a
href=
"/home/main?id={{ hp[0].user_id }}&pn={{ pn+1 }}"
>
下一页
</a>
</div>
<footer>
<div><a
href=
"/"
>
RAT Ain't Tieba
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat/-/blob/no-masters/LICENSE"
>
自豪地以 AGPLv3 释出
</a></div>
<div><a
href=
"https://0xacab.org/johnxina/rat"
>
源代码
</a></div>
</footer>
</body>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment