From: Andrew Dolgov Date: Thu, 21 Mar 2013 12:36:48 +0000 (+0400) Subject: add embed_original plugin X-Git-Tag: 1.7.5~48 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=a479f3efe7f5108a3ca41d39dfd490e9ca221973;p=tt-rss.git add embed_original plugin --- diff --git a/plugins/embed_original/button.png b/plugins/embed_original/button.png new file mode 100644 index 00000000..e861201d Binary files /dev/null and b/plugins/embed_original/button.png differ diff --git a/plugins/embed_original/init.css b/plugins/embed_original/init.css new file mode 100644 index 00000000..c2e2bb85 --- /dev/null +++ b/plugins/embed_original/init.css @@ -0,0 +1,13 @@ +div.cdmContentInner iframe.embeddedContent { + overflow : hidden; + width : 100%; + height : 300px; + border-width : 0px; +} + +div.postContent iframe.embeddedContent { + overflow : hidden; + width : 100%; + height : 100%; + border-width : 0px; +} diff --git a/plugins/embed_original/init.js b/plugins/embed_original/init.js new file mode 100644 index 00000000..c0ae6461 --- /dev/null +++ b/plugins/embed_original/init.js @@ -0,0 +1,69 @@ +function embedOriginalArticle(id) { + try { + var hasSandbox = "sandbox" in document.createElement("iframe"); + + if (!hasSandbox) { + alert(__("Sorry, your browser does not support sandboxed iframes.")); + return; + } + + var query = "op=pluginhandler&plugin=embed_original&method=getUrl&id=" + + param_escape(id); + + var c = false; + + if (isCdmMode()) { + c = $$("div#RROW-" + id + " div[class=cdmContentInner]")[0]; + } else if (id == getActiveArticleId()) { + c = $$("div[class=postContent]")[0]; + } + + if (c) { + var iframe = c.getElementsByClassName("embeddedContent")[0]; + + if (iframe) { + Element.show(c.firstChild); + c.removeChild(iframe); + + if (isCdmMode()) { + cdmScrollToArticleId(id, true); + } + + return; + } + } + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + var ti = JSON.parse(transport.responseText); + + if (ti) { + + var iframe = new Element("iframe", { + class: "embeddedContent", + src: ti.url, + sandbox: 'sandbox', + }); + + if (c) { + Element.hide(c.firstChild); + + if (c.firstChild.nextSibling) + c.insertBefore(iframe, c.firstChild.nextSibling); + else + c.appendChild(iframe); + + if (isCdmMode()) { + cdmScrollToArticleId(id, true); + } + } + } + + } }); + + + } catch (e) { + exception_error("embedOriginalArticle", e); + } +} diff --git a/plugins/embed_original/init.php b/plugins/embed_original/init.php new file mode 100644 index 00000000..b28b2f8e --- /dev/null +++ b/plugins/embed_original/init.php @@ -0,0 +1,56 @@ +link = $host->get_link(); + $this->host = $host; + + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); + } + + function about() { + return array(1.0, + "Try to display original article content inside tt-rss", + "fox"); + } + + function get_js() { + return file_get_contents(dirname(__FILE__) . "/init.js"); + } + + function get_css() { + return file_get_contents(dirname(__FILE__) . "/init.css"); + } + + function hook_article_button($line) { + $id = $line["id"]; + + $rv = ""; + + return $rv; + } + + function getUrl() { + $id = db_escape_string($_REQUEST['id']); + + $result = db_query($this->link, "SELECT link + FROM ttrss_entries, ttrss_user_entries + WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']); + + $url = ""; + + if (db_num_rows($result) != 0) { + $url = db_fetch_result($result, 0, "link"); + + } + + print json_encode(array("url" => $url, "id" => $id)); + } + +} +?>