Skip to content

Commit

Permalink
add custom rss delivery separated
Browse files Browse the repository at this point in the history
  • Loading branch information
cdhigh committed May 6, 2024
1 parent 3a4cba6 commit 3ecfa19
Show file tree
Hide file tree
Showing 12 changed files with 707 additions and 657 deletions.
4 changes: 1 addition & 3 deletions application/lib/ebook_tts/engines/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@ class EdgeTTSFree(TTSBase):
api_key_hint = ''
default_api_host = ''
default_timeout = 60
#https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-services-quotas-and-limits
request_interval = 10 #20 transactions per 60 seconds
#每段音频不能超过10分钟,对于中文,大约2000字,因为大约1500 word
request_interval = 20
max_len_per_request = 1000
languages = azuretts_languages
regions = {}
Expand Down
5 changes: 2 additions & 3 deletions application/static/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,8 @@ textarea {

@media only screen and (min-width: 768px) {
.my-rss .box-list .box,
.advwhitelist .box-list .box,
.advurlfilter .box-list .box {
padding-right: 6.3em;
.advwhitelist .box-list .box {
padding-right: 2em;
}

.box-list .box .cornerControls {
Expand Down
27 changes: 16 additions & 11 deletions application/static/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,8 @@ function AppendRecipeToLibrary(div, id) {
hamb_arg = [];
var fTpl = "{0}('{1}','{2}')";
if (id.startsWith("upload:")) { //增加汉堡按钮弹出菜单代码
var id_title = "'{0}','{1}')\"".format(id, title);
hamb_arg.push({klass: 'btn-A', title: i18n.delete, icon: 'icon-delete', act: fTpl.format('DeleteUploadRecipe', id, title)});
hamb_arg.push({klass: 'btn-E', title: i18n.share, icon: 'icon-share', act: fTpl.format('StartShareRss', id, title)});
hamb_arg.push({klass: 'btn-A', title: i18n.delete, icon: 'icon-delete', act: fTpl.format('DeleteUploadRecipe', id, title.replace("'", "\\\'"))});
hamb_arg.push({klass: 'btn-E', title: i18n.share, icon: 'icon-share', act: fTpl.format('StartShareRss', id, title.replace("'", "\\\'"))});
}
hamb_arg.push({klass: 'btn-B', title: i18n.viewSrc, icon: 'icon-source', act: "/viewsrc/" + id.replace(':', '__')});
hamb_arg.push({klass: 'btn-C', title: i18n.subscriSep, icon: 'icon-push', act: fTpl.format('SubscribeRecipe', id, '1')});
Expand Down Expand Up @@ -219,6 +218,9 @@ function PopulateMyCustomRss() {
if (isfulltext) {
row_str.push('<sup>{0}</sup>'.format(i18n.abbrEmb));
}
if (rss.separated) {
row_str.push('<sup>{0}</sup>'.format(i18n.abbrSep));
}
if (rss.tr_enable) {
row_str.push('<sup>{0}</sup>'.format(i18n.abbrTr));
}
Expand All @@ -239,9 +241,9 @@ function PopulateMyCustomRss() {
var fTplAll = "{0}(event,'{1}','{2}','{3}',{4})"; //id,title,url,isfulltext
hamb_arg.push({klass: 'btn-F', title: i18n.translator, icon: 'icon-translate', act: "/translator/" + id.replace(':', '__')});
hamb_arg.push({klass: 'btn-G', title: i18n.tts, icon: 'icon-tts', act: "/tts/" + id.replace(':', '__')});
hamb_arg.push({klass: 'btn-D', title: i18n.share, icon: 'icon-share', act: fTpl.format('StartShareRss', id, title)});
hamb_arg.push({klass: 'btn-D', title: i18n.share, icon: 'icon-share', act: fTpl.format('StartShareRss', id, title.replace("'", "\\\'"))});
hamb_arg.push({klass: 'btn-A', title: i18n.deleteCtrlNoConfirm, icon: 'icon-delete',
act: fTplAll.format('ShowDeleteCustomRssDialog', id, title, url, isfulltext)});
act: fTplAll.format('ShowDeleteCustomRssDialog', id, title.replace("'", "\\\'"), url, isfulltext)});
row_str.push(AddHamburgerButton(hamb_arg));
row_str.push('</div>');
//console.log(row_str.join(''));
Expand Down Expand Up @@ -295,11 +297,11 @@ function PopulateMySubscribed() {
hamb_arg.push({klass: 'btn-F', title: i18n.translator, icon: 'icon-translate', act: "/translator/" + recipe_id.replace(':', '__')});
hamb_arg.push({klass: 'btn-G', title: i18n.tts, icon: 'icon-tts', act: "/tts/" + recipe_id.replace(':', '__')});
if (recipe_id.startsWith("upload:")) { //只有自己上传的recipe才能分享,内置的不用分享
hamb_arg.push({klass: 'btn-D', title: i18n.share, icon: 'icon-share', act: fTpl.format('StartShareRss', recipe_id, title)});
hamb_arg.push({klass: 'btn-D', title: i18n.share, icon: 'icon-share', act: fTpl.format('StartShareRss', recipe_id, title.replace("'", "\\\'"))});
}
hamb_arg.push({klass: 'btn-B', title: i18n.viewSrc, icon: 'icon-source', act: "/viewsrc/" + recipe_id.replace(':', '__')});
hamb_arg.push({klass: 'btn-E', title: i18n.customizeDelivTime, icon: 'icon-schedule', act: fTpl.format('ScheduleRecipe', recipe_id, title)});
hamb_arg.push({klass: 'btn-A', title: i18n.unsubscribe, icon: 'icon-unsubscribe', act: fTpl.format('UnsubscribeRecipe', recipe_id, title)});
hamb_arg.push({klass: 'btn-E', title: i18n.customizeDelivTime, icon: 'icon-schedule', act: fTpl.format('ScheduleRecipe', recipe_id, title.replace("'", "\\\'"))});
hamb_arg.push({klass: 'btn-A', title: i18n.unsubscribe, icon: 'icon-unsubscribe', act: fTpl.format('UnsubscribeRecipe', recipe_id, title.replace("'", "\\\'"))});
row_str.push(AddHamburgerButton(hamb_arg));
row_str.push('</div>');
//console.log(row_str.join(''));
Expand Down Expand Up @@ -508,7 +510,6 @@ function DeleteCustomRss(rssid, title, url, isfulltext, reportInvalid) {
$('#url_to_add').val(url);
$('#isfulltext').prop('checked', isfulltext);
if (reportInvalid) { //报告源失效
console.log('report invalid');
$.post("/library/mgr/reportinvalid", {title: title, url: url, recipeId: ''});
}
} else if (data.status == i18n.loginRequired) {
Expand Down Expand Up @@ -542,6 +543,7 @@ function AddCustomRss() {
let title_to_add = $('#title_to_add');
let isfulltext = $('#isfulltext');
let url_to_add = $('#url_to_add');
let separated = $('#separated');
let title = title_to_add.val();
let url = url_to_add.val();
if ((title == '#removeall#') && !url) {
Expand All @@ -553,14 +555,17 @@ function AddCustomRss() {
}
}

$.post("/customrss/add", {title: title, url: url, fulltext: isfulltext.prop('checked')},
$.post("/customrss/add", {title: title, url: url, fulltext: isfulltext.prop('checked'),
separated: separated.prop('checked')},
function (data) {
if (data.status == "ok") {
my_custom_rss_list.unshift({title: data.title, url: data.url, 'id': data.id, isfulltext: data.isfulltext});
my_custom_rss_list.unshift({title: data.title, url: data.url, 'id': data.id,
isfulltext: data.isfulltext, separated: data.separated});
PopulateMyCustomRss();
title_to_add.val("");
url_to_add.val("");
isfulltext.prop('checked', false);
separated.prop('checked', false);
} else if (data.status == i18n.loginRequired) {
window.location.href = '/login';
} else {
Expand Down
25 changes: 12 additions & 13 deletions application/static/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ function CreatePageContent(category, page) {

hamb_arg = [];
//汉堡按钮弹出菜单代码
var dbId = '';
if ((typeof item.r != 'undefined') && item.r) { //item.r 用来保存服务器上的数据库ID
dbId = ",'" + item.r + "'";
}
var repAct = "ReportInvalid('" + item.t + "','" + item.u + "'" + dbId + ")";
var subsAct = "SubscribeSharedFeed('" + item.t + "','" + item.u + "','" + item.f + "'" + dbId + ")";
var dbId = item.r || '';
let title = item.t.replace("'", "\\\'");
var repAct = "ReportInvalid('`{0}','{1}','{2}')".format(title, item.u, dbId);
var subsAct = "SubscribeSharedFeed('{0}','{1}','{2}','{3}',{4})";
hamb_arg.push({klass: 'btn-A', title: i18n.invalidReport, icon: 'icon-offcloud', act: repAct});
hamb_arg.push({klass: 'btn-D', title: i18n.subscribe, icon: 'icon-subscribe', act: subsAct});

hamb_arg.push({klass: 'btn-C', title: i18n.subscriSep, icon: 'icon-push', act:
subsAct.format(title, item.u, item.f, dbId, 1)});
hamb_arg.push({klass: 'btn-D', title: i18n.subscribe, icon: 'icon-subscribe', act:
subsAct.format(title, item.u, item.f, dbId, 0)});
rssStr.push(AddHamburgerButton(hamb_arg)); //AddHamburgerButton()在base.js里
rssStr.push('</div>');
}
Expand Down Expand Up @@ -309,15 +309,14 @@ function DoSearchInShared() {
}

//订阅一个共享自定义RSS或Recipe
function SubscribeSharedFeed(title, feedurl, isfulltext, dbId) {
if ((typeof dbId == 'undefined') || !dbId) {
dbId = '';
}
function SubscribeSharedFeed(title, feedurl, isfulltext, dbId, separated) {
dbId = dbId || '';

$.ajax({
url: "/customrss/add",
type: "POST",
data: {title: title, fulltext: isfulltext, url: feedurl, fromsharedlibrary: 'true', 'recipeId': dbId},
data: {'title': title, 'fulltext': isfulltext, 'url': feedurl, fromsharedlibrary: 'true',
'recipeId': dbId, 'separated': separated},
success: function (resp, textStatus, xhr) {
if (resp.status == "ok") {
$('.additional-btns').stop(true).hide();
Expand Down
30 changes: 15 additions & 15 deletions application/templates/my.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
<div class="main">
<legend><h3>{{_("Custom RSS")}}</legend>
<div class="box-list">
<div class="book box pure-form pure-form-aligned">
<div class="pure-control-group titleRow pure-g">
<div class="pure-u-3-5 pure-u-sm-3-4 pure-u-md-5-6">
<div class="book box pure-form pure-form-aligned" style="padding-right:1em;">
<div class="pure-control-group titleRow pure-g" style="font-size:1em;font-weight:normal;">
<div class="pure-u-3-5 pure-u-sm-2-3 pure-u-md-2-3">
<input type="text" name="rss_title" id="title_to_add" class="pure-u-23-24 pure-input-rounded" placeholder="{{ _('Title')}}"
{% if title_to_add %}value="{{title_to_add}}"{% endif %}/>
</div>
<div class="pure-u-2-5 pure-u-sm-1-4 pure-u-md-1-6">
<div>
<label style="white-space:nowrap;">
<input type="checkbox" name="fulltext" id="isfulltext" {% if isfulltext %}checked="checked"{% endif %}/>
{{_("Content embedded")}}
</label>
</div>
<div class="pure-u-2-5 pure-u-sm-1-3 pure-u-md-1-3" style="text-align:right;">
<label style="width:auto;white-space:nowrap;margin-right:20px;">
<input type="checkbox" name="fulltext" id="isfulltext" {% if isfulltext %}checked="checked"{% endif %}/>
{{_("Content embedded")}}
</label>
<label style="width:auto;white-space:nowrap;">
<input type="checkbox" name="separated" id="separated" style="margin-left:10px;" />
{{_("Deliver Separately")}}
</label>
</div>
</div>
<div class="summaryRow">
<input type="text" name="url" id="url_to_add" class="pure-input-1 pure-input-rounded" placeholder="URL"
<div class="summaryRow" style="white-space:nowrap;">
<input type="text" name="url" id="url_to_add" class="pure-input-3-4 pure-input-rounded" placeholder="URL"
{% if url_to_add %}value="{{url_to_add}}"{% endif %}/>
</div>
<div class="cornerControls">
<button onclick="AddCustomRss();return false;" class="actionButton add">{{_("Add")}}</button>
<button onclick="AddCustomRss();return false;" class="actionButton add pure-input-1-4" style="margin-left:10px;">{{_("Add")}}</button>
</div>
{% if tips -%}
<div class="notice-box">{{tips|safe}}</div>
Expand Down
Loading

0 comments on commit 3ecfa19

Please sign in to comment.