publishedOPML: use client dialog

This commit is contained in:
Andrew Dolgov 2021-02-11 21:42:38 +03:00
parent 848bc57f29
commit 1a680d4eae
4 changed files with 85 additions and 62 deletions

View File

@ -35,32 +35,6 @@ class Dlg extends Handler_Protected {
//return; //return;
} }
function pubOPMLUrl() {
$url_path = Opml::opml_publish_url();
print "<header>" . __("Your Public OPML URL is:") . "</header>";
print "<section>";
print "<div class='panel text-center'>";
print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
print "</div>";
print "</section>";
print "<footer class='text-center'>";
print "<button dojoType='dijit.form.Button' onclick=\"return Helpers.OPML.changeKey()\">".
__('Generate new URL')."</button> ";
print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.closeInfoBox()\">".
__('Close this window')."</button>";
print "</footer>";
//return;
}
function explainError() { function explainError() {
print "<div class=\"errorExplained\">"; print "<div class=\"errorExplained\">";
@ -191,17 +165,4 @@ class Dlg extends Handler_Protected {
//return; //return;
} }
function defaultPasswordWarning() {
print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication)."));
print "<footer class='text-center'>";
print "<button dojoType='dijit.form.Button' class='alt-primary'
onclick=\"document.location.href = 'prefs.php'\">".
__('Open Preferences')."</button> ";
print "<button dojoType='dijit.form.Button'
onclick=\"return dijit.byId('defaultPasswordDlg').hide();\">".
__('Close this window')."</button>";
print "</footer>";
}
} }

View File

@ -1379,7 +1379,7 @@ class Pref_Feeds extends Handler_Protected {
" " . " " .
__("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") . "</p>"; __("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") . "</p>";
print "<button dojoType='dijit.form.Button' class='alt-primary' onclick=\"return App.displayDlg('".__("Public OPML URL")."','pubOPMLUrl')\">". print "<button dojoType='dijit.form.Button' class='alt-primary' onclick=\"return CommonDialogs.publishedOPML()\">".
__('Display published OPML URL')."</button> "; __('Display published OPML URL')."</button> ";
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefFeedsOPML"); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefFeedsOPML");
@ -1706,13 +1706,17 @@ class Pref_Feeds extends Handler_Protected {
} }
} }
function getOPMLKey() {
print json_encode(["link" => OPML::opml_publish_url()]);
}
function regenOPMLKey() { function regenOPMLKey() {
$this->update_feed_access_key('OPML:Publish', $this->update_feed_access_key('OPML:Publish',
false, $_SESSION["uid"]); false, $_SESSION["uid"]);
$new_link = Opml::opml_publish_url(); $new_link = OPML::opml_publish_url();
print json_encode(array("link" => $new_link)); print json_encode(["link" => $new_link]);
} }
function regenFeedKey() { function regenFeedKey() {

View File

@ -359,5 +359,54 @@ const CommonDialogs = {
}); });
} }
return false; return false;
},
publishedOPML: function() {
Notify.progress("Loading, please wait...", true);
xhrJson("backend.php", {op: "pref-feeds", method: "getOPMLKey"}, (reply) => {
try {
if (dijit.byId("publicOPMLDlg"))
dijit.byId("publicOPMLDlg").destroyRecursive();
const dialog = new dijit.Dialog({
title: "Public OPML URL",
id: 'publicOPMLDlg',
style: "width: 600px",
onCancel: function () {
return true;
},
onExecute: function () {
return true;
},
onClose: function () {
return true;
},
content: `
<header>${__("Your Public OPML URL is:")}</header>
<section>
<div class='panel text-center'>
<a id='pub_opml_url' href='$url_path' target='_blank'>${reply.link}</a>
</div>
</section>
<footer class='text-center'>
<button dojoType='dijit.form.Button' onclick="return Helpers.OPML.changeKey()">
${__('Generate new URL')}
</button>
<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>
${__('Close this window')}
</button>
</footer>
`
});
dialog.show();
Notify.close();
} catch (e) {
this.Error.report(e);
} }
});
},
}; };

View File

@ -226,10 +226,20 @@ const Feeds = {
if (dijit.byId("defaultPasswordDlg")) if (dijit.byId("defaultPasswordDlg"))
dijit.byId("defaultPasswordDlg").destroyRecursive(); dijit.byId("defaultPasswordDlg").destroyRecursive();
xhrPost("backend.php", {op: 'dlg', method: 'defaultpasswordwarning'}, (transport) => {
const dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
title: __("Your password is at default value"), title: __("Your password is at default value"),
content: transport.responseText, content: `<div class='alert alert-error'>
${__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication).")}
</div>
<footer class='text-center'>
<button dojoType='dijit.form.Button' class='alt-primary' onclick="document.location.href = 'prefs.php'">
${__('Open Preferences')}
</button>
<button dojoType='dijit.form.Button' onclick="return dijit.byId('defaultPasswordDlg').hide()">
${__('Close this window')}
</button>
</footer>`,
id: 'defaultPasswordDlg', id: 'defaultPasswordDlg',
style: "width: 600px", style: "width: 600px",
onCancel: function () { onCancel: function () {
@ -244,7 +254,6 @@ const Feeds = {
}); });
dialog.show(); dialog.show();
});
} }
if (dijit.byId("safeModeDlg")) if (dijit.byId("safeModeDlg"))
@ -258,7 +267,7 @@ const Feeds = {
${__('Tiny Tiny RSS is running in safe mode. All themes and plugins are disabled. You will need to log out and back in to disable it.')} ${__('Tiny Tiny RSS is running in safe mode. All themes and plugins are disabled. You will need to log out and back in to disable it.')}
</div> </div>
<footer class='text-center'> <footer class='text-center'>
<button dojoType='dijit.form.Button' type='submit'> <button dojoType='dijit.form.Button' type='submit' class='alt-primary'>
${__('Close this window')} ${__('Close this window')}
</button> </button>
</footer> </footer>