diff options
author | Andrew Dolgov <[email protected]> | 2019-03-17 09:51:51 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2019-03-17 09:51:51 +0300 |
commit | fbb4bb0e575f602e9f9e6a4b06247d343eac89e5 (patch) | |
tree | 187d741d3d8f9438872aea77ea0c29a69606f346 |
initial
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | init.css | 9 | ||||
-rw-r--r-- | init.js | 12 | ||||
-rw-r--r-- | init.php | 46 |
4 files changed, 76 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..b913dbf --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +UI Gravatar +=========== + +Shows your globally recognized avatar in the overflow menu button of +main tt-rss UI. Needs your email address to be set in tt-rss preferences. + +Git clone to ``plugins.local/ui_gravatar``. + +See https://gravatar.com/ for more information. diff --git a/init.css b/init.css new file mode 100644 index 0000000..ff410d4 --- /dev/null +++ b/init.css @@ -0,0 +1,9 @@ +body.ttrss_main .action-chooser .action-button .dijitArrowButtonInner { + display : inline ! important; +} + +body.ttrss_main .action-chooser .userpic-gravatar { + width : 21px; + height : 21px; + border-radius: 50% 50%; +} @@ -0,0 +1,12 @@ +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { + ready(function() { + PluginHost.register(PluginHost.HOOK_INIT_COMPLETE, () => { + const btn = document.querySelector(".action-chooser .dijitButtonText"); + + if (btn) + btn.innerHTML = "<img referrerpolicy='no-referrer' class='userpic-gravatar' src=\"https://secure.gravatar.com/avatar/%GRAVATAR_HASH%?s=96\">"; + + return true; + }); + }); +}); diff --git a/init.php b/init.php new file mode 100644 index 0000000..c4f1b08 --- /dev/null +++ b/init.php @@ -0,0 +1,46 @@ +<?php +class UI_Gravatar extends Plugin { + private $host; + private $gravatar_hash = ""; + + function about() { + return array(1.0, + "Shows your globally recognized avatar (Gravatar) in the UI", + "fox"); + } + + function init($host) { + $this->host = $host; + + $sth = $this->pdo->prepare("SELECT email FROM ttrss_users WHERE id = ?"); + $sth->execute([$_SESSION['uid']]); + + if ($row = $sth->fetch()) { + $this->gravatar_hash = md5(trim($row['email'])); + } + + //$host->add_hook($host::HOOK_PREFS_TAB, $this); + } + + function get_js() { + if ($this->gravatar_hash) { + return str_replace("%GRAVATAR_HASH%", $this->gravatar_hash, + file_get_contents(__DIR__ . "/init.js")); + } else { + return ""; + } + } + + function get_css() { + if ($this->gravatar_hash) { + return file_get_contents(__DIR__ . "/init.css"); + } else { + return ""; + } + } + + function api_version() { + return 2; + } + +} |