Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
3a9a59b7
Commit
3a9a59b7
authored
Jul 17, 2018
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #497
parent
a53b7908
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
11 deletions
+27
-11
detail.html
cps/templates/detail.html
+1
-1
discover.html
cps/templates/discover.html
+1
-1
index.html
cps/templates/index.html
+3
-3
web.py
cps/web.py
+22
-6
No files found.
cps/templates/detail.html
View file @
3a9a59b7
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
<h2>
{{entry.title}}
</h2>
<h2>
{{entry.title
|shortentitle(40)
}}
</h2>
<p
class=
"author"
>
<p
class=
"author"
>
{% for author in entry.authors %}
{% for author in entry.authors %}
<a
href=
"{{url_for('author', book_id=author.id ) }}"
>
{{author.name.replace('|',',')}}
</a>
<a
href=
"{{url_for('author', book_id=author.id ) }}"
>
{{author.name.replace('|',',')}}
</a>
...
...
cps/templates/discover.html
View file @
3a9a59b7
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"author"
>
<p
class=
"author"
>
{% for author in entry.authors %}
{% for author in entry.authors %}
<a
href=
"{{url_for('author', book_id=author.id) }}"
>
{{author.name.replace('|',',')}}
</a>
<a
href=
"{{url_for('author', book_id=author.id) }}"
>
{{author.name.replace('|',',')
|shortentitle(30)
}}
</a>
{% if not loop.last %}
{% if not loop.last %}
&
&
{% endif %}
{% endif %}
...
...
cps/templates/index.html
View file @
3a9a59b7
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
</div>
</div>
<div
class=
"meta"
>
<div
class=
"meta"
>
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"title"
>
{{entry.title|shortentitle}}
</p>
<p
class=
"author"
><a
href=
"{{url_for('author', book_id=entry.authors[0].id) }}"
>
{{entry.authors[0].name}}
</a></p>
<p
class=
"author"
><a
href=
"{{url_for('author', book_id=entry.authors[0].id) }}"
>
{{entry.authors[0].name
|shortentitle(30)
}}
</a></p>
{% if entry.ratings.__len__() > 0 %}
{% if entry.ratings.__len__() > 0 %}
<div
class=
"rating"
>
<div
class=
"rating"
>
{% for number in range((entry.ratings[0].rating/2)|int(2)) %}
{% for number in range((entry.ratings[0].rating/2)|int(2)) %}
...
@@ -53,10 +53,10 @@
...
@@ -53,10 +53,10 @@
</a>
</a>
</div>
</div>
<div
class=
"meta"
>
<div
class=
"meta"
>
<p
class=
"title"
>
{{entry.title|
truncate(60)
}}
</p>
<p
class=
"title"
>
{{entry.title|
shortentitle
}}
</p>
<p
class=
"author"
>
<p
class=
"author"
>
{% for author in entry.authors %}
{% for author in entry.authors %}
<a
href=
"{{url_for('author', book_id=author.id) }}"
>
{{author.name.replace('|',',')}}
</a>
<a
href=
"{{url_for('author', book_id=author.id) }}"
>
{{author.name.replace('|',',')
|shortentitle(30)
}}
</a>
{% if not loop.last %}
{% if not loop.last %}
&
&
{% endif %}
{% endif %}
...
...
cps/web.py
View file @
3a9a59b7
...
@@ -346,12 +346,28 @@ def remote_login_required(f):
...
@@ -346,12 +346,28 @@ def remote_login_required(f):
# custom jinja filters
# custom jinja filters
@
app
.
template_filter
(
'shortentitle'
)
@
app
.
template_filter
(
'shortentitle'
)
def
shortentitle_filter
(
s
):
def
shortentitle_filter
(
s
,
nchar
=
20
):
if
len
(
s
)
>
60
:
text
=
s
.
split
()
s
=
s
.
split
(
':'
,
1
)[
0
]
res
=
""
# result
if
len
(
s
)
>
60
:
sum
=
0
# overall length
s
=
textwrap
.
wrap
(
s
,
60
,
break_long_words
=
False
)[
0
]
+
' [...]'
for
line
in
text
:
return
s
if
sum
>=
60
:
res
+=
'...'
break
# if word longer than 20 chars truncate line and append '...', otherwise add whole word to result
# string, and summarize total length to stop at 60 chars
if
len
(
line
)
>
nchar
:
res
+=
line
[:(
nchar
-
3
)]
+
'[..] '
sum
+=
nchar
+
3
else
:
res
+=
line
+
' '
sum
+=
len
(
line
)
+
1
return
res
.
strip
()
#if len(s) > 20:
# s = s.split(':', 1)[0]
# if len(s) > 20:
# s = textwrap.wrap(s, 20, break_long_words=True)[0] + ' ...'
#return s
@
app
.
template_filter
(
'mimetype'
)
@
app
.
template_filter
(
'mimetype'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment