Skip to content

Commit

Permalink
fix title_fmt bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cdhigh committed Apr 28, 2024
1 parent 6f3a926 commit 3ec5c3d
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 14 deletions.
3 changes: 3 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ handlers:
- url: /images
static_dir: application/images

- url: /recipes
static_dir: application/recipes

- url: /.*
secure: always
redirect_http_response_code: 301
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,9 @@ def add_article_toc(self, parent, entries, feedIdx):
def build_meta(self, recipe1, onlyRecipe):
title = recipe1.short_title() if onlyRecipe else 'KindleEar'
pdate = recipe1.publication_date()
if recipe1.output_profile.periodical_date_in_title:
title += strftime(recipe1.timefmt, pdate)
timefmt = recipe1.timefmt.strip()
if timefmt and self.user.book_cfg('title_fmt'):
title = f'{title} {strftime(timefmt, pdate)}'
mi = MetaInformation(title, ['KindleEar'])
mi.publisher = 'KindleEar'
#修正Kindle固件5.9.x将作者显示为日期的BUG
Expand Down
3 changes: 2 additions & 1 deletion application/lib/calibre/web/feeds/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,8 @@ def publication_date(self):
Defaults to the moment of download. Must return a :class:`datetime.datetime`
object.
'''
return nowf()
#return nowf()
return self.user.local_time()

#现在这个函数已经不用,使用recipe_input.py里面的create_opf()
#通过Feed对象列表构建一个opf文件
Expand Down
3 changes: 2 additions & 1 deletion application/lib/calibre/web/fetch/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ def process_images(self, soup, baseurl):
self.fs.write(imgpath, data, 'wb')
tag['src'] = imgpath
except Exception:
traceback.print_exc()
#traceback.print_exc()
self.log.info(traceback.format_exc())
continue

#如果需要,纠正或规则化soup里面的图片地址,比如延迟加载等
Expand Down
2 changes: 2 additions & 0 deletions application/lib/recipe_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def GenerateRecipeSource(title, feeds, user, isfulltext=False, language=None, ma
isfulltext = 'True' if isfulltext else 'None'
language = language or user.book_cfg('language')
timefmt = user.book_cfg('time_fmt')
if timefmt and (user.book_cfg('title_fmt') == 'title_[time]'):
timefmt = f'[{timefmt}]'
cover_url = f"'{cover_url}'" if isinstance(cover_url, str) else cover_url
src = textwrap.dedent(f'''\
#!/usr/bin/env python3
Expand Down
6 changes: 3 additions & 3 deletions application/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@
{% endif -%}
{% endif -%}
<li class="pure-menu-item">
<a href="/setlocale/en"><img src="data:image/gif;base64,R0lGODlhEAALAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD//////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBmAABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNmZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZmzGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZAJmZM5mZZpmZmZmZzJmZ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AGZmM2ZmZmZmmWZmzGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZAJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwAM8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8Amf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+ZzP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///yH5BAEAABAALAAAAAAQAAsAAAhUAMcJ7CZwHMGDBg3mGvdr3MKGC3E5HCeRIb93DtMJXEiQo8Rl6XB1aygx4sSCCwcm5OjQpEuKEyuynLnSoMSbMWGWLJiwY0GEuV7uHLqxpk+fuQICADs=" alt="CN" /></a>
<a href="/setlocale/tr_TR"><img src="data:image/gif;base64,R0lGODlhEAALAMQAAOQKFPSOlOxCTOwyPPzW1OQaJPzu7OQSHOw6RPSipOxydOQOHOxaZPza3OQiLPz+/Ow+ROQKHPSSlOxKVOw2PPzW3OQeLPz29OQWJPSqtOw+TAAAAAAAAAAAAAAAAAAAACwAAAAAEAALAAAFPyAgilEEmOdorulIniW6DNiKtiJSGQHD2qnHZKVgkFAlwMORrFxwLiGpmAJGEASDxPi6sQaHqksFhJlvXfEqBAA7" alt="TR" /></a>
<a href="#" onclick="window.location.href='/setlocale/en?next=' + encodeURIComponent(window.location.href);"><img src="data:image/gif;base64,R0lGODlhEAALAPcAAAAAAIAAAACA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BMirLKFocMtv4BFnAhsy0CLFxH+w5cP38aHDv/kkgisEsmCFwVuXOkRX4wtMaq8jEmRokKEHXEm3GjsmLF1PX8G9UlUHTBjwNYdTWoMqVKk1PBFnSq1KlWSNbFiDQgAOw==" alt="EN" /></a>
<a href="#" onclick="window.location.href='/setlocale/zh?next=' + encodeURIComponent(window.location.href);"><img src="data:image/gif;base64,R0lGODlhEAALAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD//////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBmAABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNmZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZmzGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZAJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwAM8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8Amf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+ZzP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///yH5BAEAABAALAAAAAAQAAsAAAhUAMcJ7CZwHMGDBg3mGvdr3MKGC3E5HCeRIb93DtMJXEiQo8Rl6XB1aygx4sSCCwcm5OjQpEuKEyuynLnSoMSbMWGWLJiwY0GEuV7uHLqxpk+fuQICADs=" alt="CN" /></a>
<a href="#" onclick="window.location.href='/setlocale/tr_TR?next=' + encodeURIComponent(window.location.href);"><img src="data:image/gif;base64,R0lGODlhEAALAMQAAOQKFPSOlOxCTOwyPPzW1OQaJPzu7OQSHOw6RPSipOxydOQOHOxaZPza3OQiLPz+/Ow+ROQKHPSSlOxKVOw2PPzW3OQeLPz29OQWJPSqtOw+TAAAAAAAAAAAAAAAAAAAACwAAAAAEAALAAAFPyAgilEEmOdorulIniW6DNiKtiJSGQHD2qnHZKVgkFAlwMORrFxwLiGpmAJGEASDxPi6sQaHqksFhJlvXfEqBAA7" alt="TR" /></a>
<!--<a href="/setlocale/en"><img src="/static/us.gif" alt="EN" /></a>
<a href="/setlocale/zh"><img src="/static/cn.gif" alt="CN" /></a>
<a href="/setlocale/tr_tr"><img src="/static/tr.gif" alt="TR" /></a>-->
Expand Down
6 changes: 2 additions & 4 deletions application/templates/setting.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@
<select class="pure-u-1 pure-u-sm-1-2" name="title_fmt">
{% set title_fmt = user.book_cfg('title_fmt') %}
<option value="" {% if not title_fmt %}selected="selected"{% endif %}>{{_("Title Only")}}</option>
<option value="%Y-%m-%d" {% if title_fmt=='%Y-%m-%d' %}selected="selected"{% endif %}>{{_("Title")}} {{now.strftime("%Y-%m-%d")}}</option>
<option value="%m-%d" {% if title_fmt=='%m-%d' %}selected="selected"{% endif %}>{{_("Title")}} {{now.strftime("%m-%d")}}</option>
<option value="%b %d" {% if title_fmt=='%b %d' %}selected="selected"{% endif %}>{{_("Title")}} {{now.strftime("%b %d")}}</option>
<option value="%a, %b %d" {% if title_fmt=='%a, %b %d' %}selected="selected"{% endif %}>{{_("Title")}} {{now.strftime("%a, %b %d")}}</option>
<option value="title_time" {% if title_fmt=='title_time' %}selected="selected"{% endif %}>{{_("Title")}} {{_("Time")}}</option>
<option value="title_[time]" {% if title_fmt=='title_[time]' %}selected="selected"{% endif %}>{{_("Title")}} [{{_("Time")}}]</option>
</select>
</div>
{#<div class="pure-control-group">
Expand Down
3 changes: 2 additions & 1 deletion application/view/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ def SetLang(langCode):
if langCode not in supported_languages:
langCode = "en"
session['langCode'] = langCode
return redirect('/')
url = request.args.get('next', '/')
return redirect(url)

#Babel选择显示哪种语言的回调函数
def get_locale():
Expand Down
4 changes: 2 additions & 2 deletions application/work/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def WorkerImpl(userName: str, recipeId: list=None, reason='cron', log=None):

if not ro.language or ro.language == 'und':
ro.language = user.book_cfg('language')

ro.delivery_reason = reason
ro.extra_css = combine_css(ro.extra_css) #合并自定义css
ro.translator = bked.translator #设置网页翻译器信息
ro.translator = bked.translator.copy() #设置网页翻译器信息
ro.tts = bked.tts.copy() #文本转语音设置,需要中途修改tts内容

#如果需要登录网站
Expand Down
3 changes: 3 additions & 0 deletions worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ handlers:
- url: /images
static_dir: application/images

- url: /recipes
static_dir: application/recipes

- url: /.*
secure: always
redirect_http_response_code: 301
Expand Down

0 comments on commit 3ec5c3d

Please sign in to comment.