Compare commits
No commits in common. "f66fa8138d543cc3621707ddd4e1d2fac76ce8cd" and "2fbf3ec0ebbf17f2cfb6068682ff138cb7fa8daa" have entirely different histories.
f66fa8138d
...
2fbf3ec0eb
|
@ -7,7 +7,6 @@ from io import BytesIO
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
from os.path import relpath, splitext
|
from os.path import relpath, splitext
|
||||||
import random
|
|
||||||
import re
|
import re
|
||||||
import readline
|
import readline
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -92,8 +91,6 @@ MULTIPART_RAR_TAIL_REGEX = re.compile(r'^(.+)\.part0*([^1]|[^0].+)\.rar$', re.I)
|
||||||
PDF_REFERENCED_IMAGE_REGEX = re.compile(r'(^|(?<=\s))/(?P<ref_name>\S+)\s+Do($|(?=\s))')
|
PDF_REFERENCED_IMAGE_REGEX = re.compile(r'(^|(?<=\s))/(?P<ref_name>\S+)\s+Do($|(?=\s))')
|
||||||
PDF_INLINE_IMAGE_REGEX = re.compile(r'(^|\s)(BI|ID|EI)($|\s)')
|
PDF_INLINE_IMAGE_REGEX = re.compile(r'(^|\s)(BI|ID|EI)($|\s)')
|
||||||
|
|
||||||
SUGGESTED_WORKS_COUNT = 10
|
|
||||||
|
|
||||||
debug_mode = False
|
debug_mode = False
|
||||||
def debug(s):
|
def debug(s):
|
||||||
if debug_mode:
|
if debug_mode:
|
||||||
|
@ -1015,23 +1012,18 @@ def similarity(a, b):
|
||||||
memoized_similarities[(shorter, longer)] = result
|
memoized_similarities[(shorter, longer)] = result
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def top(items, n, key, overflow=0):
|
def top(items, n, key):
|
||||||
winners = []
|
winners = []
|
||||||
for item in items:
|
for item in items:
|
||||||
score = key(item)
|
score = key(item)
|
||||||
if len(winners) < n or score >= winners[-1][1]:
|
if len(winners) < n or score > winners[-1][1]:
|
||||||
for i in range(len(winners) + 1):
|
for i in range(len(winners) + 1):
|
||||||
if i == len(winners) or score >= winners[i][1]:
|
if i == len(winners) or score > winners[i][1]:
|
||||||
winners.insert(i, (item, score))
|
winners.insert(i, (item, score))
|
||||||
break
|
break
|
||||||
while len(winners) > n and winners[-1][1] < winners[n-1][1]:
|
while len(winners) > n:
|
||||||
winners.pop()
|
winners.pop()
|
||||||
|
return [item for (item, score) in winners]
|
||||||
# shuffle followed by stable sort to randomly shuffle within each score tier
|
|
||||||
random.shuffle(winners)
|
|
||||||
winners.sort(key=lambda w: w[1], reverse=True)
|
|
||||||
|
|
||||||
return [item for (item, score) in winners[:n+overflow]]
|
|
||||||
|
|
||||||
def generate(args):
|
def generate(args):
|
||||||
jenv = Environment(
|
jenv = Environment(
|
||||||
|
@ -1088,7 +1080,7 @@ def generate(args):
|
||||||
if work['series'] and work['series'] == other_work['series']:
|
if work['series'] and work['series'] == other_work['series']:
|
||||||
return -1
|
return -1
|
||||||
return similarity(work['title'], other_work['title'])
|
return similarity(work['title'], other_work['title'])
|
||||||
suggested = top(works, SUGGESTED_WORKS_COUNT, suggestion_priority)
|
suggested = top(works, 6, suggestion_priority)
|
||||||
|
|
||||||
work_dir = site_dir / 'works' / work['id']
|
work_dir = site_dir / 'works' / work['id']
|
||||||
viewer_dir = work_dir / 'view'
|
viewer_dir = work_dir / 'view'
|
||||||
|
|
|
@ -139,19 +139,19 @@ body {
|
||||||
|
|
||||||
.work-info td, .work-info th {
|
.work-info td, .work-info th {
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
padding-top: 5px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.work-info tr.bubbles th {
|
.work-info td {
|
||||||
padding-top: 14px;
|
padding-top: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.work-info th {
|
.work-info th {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bubbles a {
|
.work-info-link {
|
||||||
background: #333;
|
background: #333;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
@ -159,10 +159,6 @@ body {
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.work-info table {
|
|
||||||
margin-bottom: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#suggested-subheader {
|
#suggested-subheader {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,33 +12,29 @@
|
||||||
<div class="work-info">
|
<div class="work-info">
|
||||||
<table>
|
<table>
|
||||||
{% if work['circle'] %}
|
{% if work['circle'] %}
|
||||||
<tr class="bubbles">
|
<tr>
|
||||||
<th>Circle</th>
|
<th>Circle</th>
|
||||||
<td><a href="{{ root() }}/circles/{{ urlcat(work['circle']) }}/{{ index() }}">{{ work['circle'] }}</a></td>
|
<td><a class="work-info-link" href="{{ root() }}/circles/{{ urlcat(work['circle']) }}/{{ index() }}">{{ work['circle'] }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if work['authors'] %}
|
{% if work['authors'] %}
|
||||||
<tr class="bubbles">
|
<tr>
|
||||||
<th>Authors</th>
|
<th>Authors</th>
|
||||||
<td>{% for author in work['authors'] %}<a href="{{ root() }}/authors/{{ urlcat(author) }}/{{ index() }}">{{ author }}</a> {% endfor %}</td>
|
<td>{% for author in work['authors'] %}<a class="work-info-link" href="{{ root() }}/authors/{{ urlcat(author) }}/{{ index() }}">{{ author }}</a> {% endfor %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if work['tags'] %}
|
{% if work['tags'] %}
|
||||||
<tr class="bubbles">
|
<tr>
|
||||||
<th>Tags</th>
|
<th>Tags</th>
|
||||||
<td>{% for tag in work['tags'] %}<a href="{{ root() }}/tags/{{ urlcat(tag) }}/{{ index() }}">{{ tag }}</a> {% endfor %}</td>
|
<td>{% for tag in work['tags'] %}<a class="work-info-link" href="{{ root() }}/tags/{{ urlcat(tag) }}/{{ index() }}">{{ tag }}</a> {% endfor %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if work['series'] %}
|
{% if work['series'] %}
|
||||||
<tr class="bubbles">
|
<tr>
|
||||||
<th>Series</th>
|
<th>Series</th>
|
||||||
<td><a href="{{ root() }}/series/{{ urlcat(work['series']) }}/{{ index() }}">{{ work['series'] }}</a></td>
|
<td><a class="work-info-link" href="{{ root() }}/series/{{ urlcat(work['series']) }}/{{ index() }}">{{ work['series'] }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<tr>
|
|
||||||
<th>Pages</th>
|
|
||||||
<td>{{ work['images'] | length }}</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
{% if work['description'] %}
|
{% if work['description'] %}
|
||||||
{{ work['description'] }}
|
{{ work['description'] }}
|
||||||
|
|
Loading…
Reference in a new issue