Skip to content

Commit

Permalink
Merge pull request cdhigh#556 from whtsky/bookmarklet
Browse files Browse the repository at this point in the history
Add Bookmarklet
  • Loading branch information
cdhigh authored Apr 13, 2019
2 parents ac3e1df + b6280a9 commit 74b2ab5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/View/Subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import datetime
from operator import attrgetter
import web
import urlparse

try:
import json
except ImportError:
Expand All @@ -20,6 +22,7 @@
from books import BookClasses, BookClass
from books.base import BaseComicBook
from books.comic import ComicBaseClasses
from config import *

class MySubscription(BaseHandler):
__url__ = "/my"
Expand All @@ -41,6 +44,7 @@ def GET(self, tips=None):
myfeeds=myfeeds,
comic_base_classes=ComicBaseClasses,
tips=tips,
subscribe_url=urlparse.urljoin(DOMAIN, self.__url__)
)

def POST(self): # 添加自定义RSS
Expand Down
Binary file modified i18n/zh-cn/LC_MESSAGES/lang.mo
Binary file not shown.
9 changes: 9 additions & 0 deletions i18n/zh-cn/LC_MESSAGES/lang.po
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ msgstr "未订阅"
msgid "Subscribe"
msgstr "订阅"

msgid "Bookmarklet"
msgstr "书签小应用"

msgid "Drag and drop this link to your bookmarks."
msgstr "将链接拖动到书签栏"

msgid "Add to KindleEar"
msgstr "在 KindleEar 中订阅"

msgid "No have book unsubscrebed"
msgstr "暂时没有未订阅的书籍"

Expand Down
20 changes: 20 additions & 0 deletions templates/my.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@
{% endif -%}
{% endfor -%}
</fieldset>
<fieldset id="bookmarklet" style="margin-top:10px;">
<legend>{{_("Bookmarklet")}}</legend>
<p>{{_("Drag and drop this link to your bookmarks.")}}</p>
<a class="actionButton"
href="javascript:location.href='{{subscribe_url}}?title_to_add='+encodeURIComponent(document.title)+'&url_to_add='+encodeURIComponent(window.location.href)">
{{_("Add to KindleEar")}}
</a>
</fieldset>
{% endblock -%}
{% block js -%}
<script type="text/javascript">
Expand All @@ -102,6 +110,18 @@
btnft.checked = !btnft.checked;
}

function fillAddForm() {
var urlParams = new URLSearchParams(window.location.search);
var title = urlParams.get('title_to_add');
var url = urlParams.get('url_to_add');
if (title || url) {
document.getElementById("title_to_add").value = title || "";
document.getElementById("url_to_add").value = url || "";
document.getElementById("title_to_add").scrollIntoView();
}
}
fillAddForm();

//点击了订阅内置书籍
function doSubscribe(obj, id_) {
var separate = document.getElementById("separate_" + id_).checked;
Expand Down

0 comments on commit 74b2ab5

Please sign in to comment.