-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- update to ttrss v21.03-ddfa39015 - php8 - fix hotkey action
- Loading branch information
Showing
2 changed files
with
83 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,49 @@ | ||
function shareArticleToYourls(id) { | ||
try { | ||
var query = "?op=pluginhandler&plugin=yourls&method=getInfo&id=" + encodeURIComponent(id); | ||
var d = new Date(); | ||
var ts = d.getTime(); | ||
|
||
new Ajax.Request("backend.php", { | ||
parameters: query, | ||
onSuccess: function(transport) { | ||
var ti = JSON.parse(transport.responseText); | ||
var share_url_query = "?signature=" + ti.yourlsapi + "&action=shorturl&format=simple&url=" + encodeURIComponent(ti.link) + "&title=" + encodeURIComponent(ti.title); | ||
dialog = new dijit.Dialog({ | ||
id: "YourlsShortLinkDlg"+ts, | ||
title: __("Youlrs Shortened URL"), | ||
style: "width: 200px", | ||
content: '<p align=center>' + ti.shorturl + '<br/><a target="_blank" href="https://twitter.com/share?_=' + ts + '&text=' + encodeURIComponent(ti.title) + '&url=' + encodeURIComponent(ti.shorturl) + '"><img src="/plugins.local/yourls/tweetshare.png"/></a><br/><a target="_blank" href="https://www.facebook.com/sharer.php?u=' + encodeURIComponent(ti.shorturl) + '"><img src="/plugins.local/yourls/fbshare.png" border=0/></a></p>', | ||
}); | ||
dialog.show(); | ||
} }); | ||
|
||
} catch (e) { | ||
exception_error("yourlsArticle", e); | ||
} | ||
try { | ||
Notify.progress("Saving to YOURLS …", true); | ||
xhr.json("backend.php", | ||
{ | ||
'op': 'pluginhandler', | ||
'plugin': 'yourls', | ||
'method': 'getInfo', | ||
'id': encodeURIComponent(id) | ||
}, | ||
(reply) => { | ||
if (reply.status) { | ||
if (reply.status=="200") { | ||
var d = new Date(); | ||
var ts = d.getTime(); | ||
|
||
dialog = new dijit.Dialog({ | ||
id: "YourlsShortLinkDlg"+ts, | ||
title: __("Youlrs Shortened URL"), | ||
style: "width: 200px", | ||
content: '<p align=center>' + reply.shorturl + '<br/><a target="_blank" href="https://twitter.com/share?_=' + ts + '&text=' + encodeURIComponent(reply.title) + '&url=' + encodeURIComponent(reply.shorturl) + '"><img src="/plugins.local/yourls/tweetshare.png"/></a><br/><a target="_blank" href="https://www.facebook.com/sharer.php?u=' + encodeURIComponent(reply.shorturl) + '"><img src="/plugins.local/yourls/fbshare.png" border=0/></a></p>', | ||
}); | ||
|
||
dialog.show(); | ||
Notify.info("Saved to YOURLS"); | ||
} else { | ||
Notify.error("<strong>Error: "+reply.status+" encountered while saving to YOURLS!</strong>", true); | ||
} | ||
} else { | ||
Notify.error("The YOURLS plugin needs to be configured. See the README for help", true); | ||
} | ||
}); | ||
} catch (e) { | ||
Notify.error("yourlsArticle", e); | ||
} | ||
} | ||
|
||
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { | ||
ready(function () { | ||
PluginHost.register(PluginHost.HOOK_INIT_COMPLETE, () => { | ||
App.hotkey_actions["send_to_yourls"] = function() { | ||
if (Article.getActive()) { | ||
shareArticleToYourls(Article.getActive()); | ||
return; | ||
} | ||
}; | ||
}); | ||
}); | ||
}); |