From 582ff3cf6e617ccb6d6164da7381db80a0183127 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 5 Jul 2016 11:01:36 +0300 Subject: af_redditimgur: make sure content_link is defined even if content dupcheck is disabled --- plugins/af_redditimgur/init.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 2e0748137..8243b94c4 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -301,8 +301,9 @@ class Af_RedditImgur extends Plugin { @$doc->loadHTML($article["content"]); $xpath = new DOMXPath($doc); + $content_link = $xpath->query("(//a[contains(., '[link]')])")->item(0); + if ($this->host->get($this, "enable_content_dupcheck")) { - $content_link = $xpath->query("(//a[contains(., '[link]')])")->item(0); if ($content_link) { $content_href = db_escape_string($content_link->getAttribute("href")); -- cgit v1.2.3-54-g00ecf From eb95d1bddf12c6bd11d2d3af5a524e1216ea2264 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 7 Jul 2016 09:04:38 +0300 Subject: af_redditimgur: handle i.reddituploads.com as pictures --- plugins/af_redditimgur/init.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 8243b94c4..f32578450 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -179,7 +179,9 @@ class Af_RedditImgur extends Plugin { $found = true; } - if (preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?$/i", $entry->getAttribute("href"))) { + if (preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?$/i", $entry->getAttribute("href")) || + mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== FALSE) { + _debug("Handling as a picture", $debug); $img = $doc->createElement('img'); -- cgit v1.2.3-54-g00ecf From 76ba1df76e9ce3733c990e1d953706b691ee7b14 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 26 Jul 2016 15:46:54 +0300 Subject: af_redditimgur: use browser UA for readability requests --- plugins/af_redditimgur/init.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index f32578450..1068ec548 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -349,24 +349,27 @@ class Af_RedditImgur extends Plugin { /* link may lead to a huge video file or whatever, we need to check content type before trying to parse it which p much requires curl */ + $useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"; + $ch = curl_init($content_link->getAttribute("href")); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir")); - curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); + curl_setopt($ch, CURLOPT_USERAGENT, $useragent_compat); @$result = curl_exec($ch); $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); if ($content_type && strpos($content_type, "text/html") !== FALSE) { - $tmp = fetch_file_contents($content_link->getAttribute("href")); + $tmp = fetch_file_contents(array("url" => $content_link->getAttribute("href"), + "useragent" => $useragent_compat)); //_debug("tmplen: " . mb_strlen($tmp)); - if ($tmp && mb_strlen($tmp) < 65535 * 4) { + if ($tmp && mb_strlen($tmp) < 1024 * 250) { $r = new Readability($tmp, $content_link->getAttribute("href")); -- cgit v1.2.3-54-g00ecf From a6fde6c99f7295f0a3fc3e97333158b10e714af5 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 26 Jul 2016 16:29:17 +0300 Subject: af_redditimgur: support video elements in imgur albums --- plugins/af_redditimgur/init.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'plugins') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 1068ec548..af58197cd 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -239,7 +239,7 @@ class Af_RedditImgur extends Plugin { //if ($debug) print_r($album_content); - $aentries = $axpath->query("(//div[@class='post-image']/img[@src] | //a[@class='zoom']/img[@src])"); + $aentries = $axpath->query("(//div[@class='post-image']/img[@src] | //a[@class='zoom']/img[@src] | //div[@class='video-elements']/source)"); $urls = []; foreach ($aentries as $aentry) { @@ -247,14 +247,27 @@ class Af_RedditImgur extends Plugin { $url = $aentry->getAttribute("src"); if (!in_array($url, $urls)) { - $img = $doc->createElement('img'); - $img->setAttribute("src", $url); - $entry->parentNode->insertBefore($doc->createElement('br'), $entry); - $br = $doc->createElement('br'); + if ($aentry->tagName == "img") { - $entry->parentNode->insertBefore($img, $entry); - $entry->parentNode->insertBefore($br, $entry); + $img = $doc->createElement('img'); + $img->setAttribute("src", $url); + $entry->parentNode->insertBefore($doc->createElement('br'), $entry); + + $br = $doc->createElement('br'); + + $entry->parentNode->insertBefore($img, $entry); + $entry->parentNode->insertBefore($br, $entry); + } else if ($aentry->tagName == "source") { + + if (strpos($url, "i.imgur.com") !== FALSE) + $poster_url = str_replace(".mp4", "h.jpg", $url); + else + $poster_url = ""; + + $this->handle_as_video($doc, $entry, $url, $poster_url); + + } array_push($urls, $url); -- cgit v1.2.3-54-g00ecf From d419aed5434cd425a0b9be3f65cd6c8c6f930d1a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 1 Aug 2016 08:26:11 +0300 Subject: trgm plugin: increase check distance to 3 days --- plugins/af_psql_trgm/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index 521db4b85..0de46b085 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -274,7 +274,7 @@ class Af_Psql_Trgm extends Plugin { $result = db_query("SELECT COUNT(id) AS nequal FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id AND - date_entered >= NOW() - interval '1 day' AND + date_entered >= NOW() - interval '3 days' AND title = '$title_escaped' AND guid != '$entry_guid' AND owner_uid = $owner_uid"); -- cgit v1.2.3-54-g00ecf From 90e45935bb5573a94afa369a789f45e923f7bc9f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 1 Aug 2016 16:20:14 +0300 Subject: af_redditimgur: try to guess images to embed using content-type --- plugins/af_redditimgur/init.php | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'plugins') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index af58197cd..7414656d5 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -180,7 +180,8 @@ class Af_RedditImgur extends Plugin { } if (preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?$/i", $entry->getAttribute("href")) || - mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== FALSE) { + mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== FALSE || + mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== FALSE) { _debug("Handling as a picture", $debug); @@ -364,16 +365,7 @@ class Af_RedditImgur extends Plugin { $useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"; - $ch = curl_init($content_link->getAttribute("href")); - curl_setopt($ch, CURLOPT_TIMEOUT, 5); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HEADER, true); - curl_setopt($ch, CURLOPT_NOBODY, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir")); - curl_setopt($ch, CURLOPT_USERAGENT, $useragent_compat); - - @$result = curl_exec($ch); - $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); + $content_type = $this->get_content_type($content_link->getAttribute("href"), $useragent_compat); if ($content_type && strpos($content_type, "text/html") !== FALSE) { @@ -483,5 +475,24 @@ class Af_RedditImgur extends Plugin { print $doc->saveHTML(); } + + private function get_content_type($url, $useragent = SELF_USER_AGENT) { + $content_type = false; + + if (function_exists("curl_init") && !defined("NO_CURL")) { + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_TIMEOUT, 5); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HEADER, true); + curl_setopt($ch, CURLOPT_NOBODY, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir")); + curl_setopt($ch, CURLOPT_USERAGENT, $useragent); + + @$result = curl_exec($ch); + $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); + } + + return $content_type; + } } ?> -- cgit v1.2.3-54-g00ecf From 8788698b0531573548dceb1c0db0d3fb2f4c2a0b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 1 Aug 2016 21:03:36 +0300 Subject: basic tweet embedding using oembed --- plugins/af_redditimgur/init.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 7414656d5..e283b8cec 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -29,7 +29,7 @@ class Af_RedditImgur extends Plugin { $enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck"); $enable_content_dupcheck_checked = $enable_content_dupcheck ? "checked" : ""; - + print "
"; print " + get_plugins() as $n => $p) { if (method_exists($p, "get_js")) { diff --git a/js/tt-rss.js b/js/tt-rss.js index 108b65a7f..776c5d02b 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -216,90 +216,94 @@ function genericSanityCheck() { function init() { try { - //dojo.registerModulePath("fox", "../../js/"); - - dojo.require("fox.FeedTree"); - - dojo.require("dijit.ColorPalette"); - dojo.require("dijit.Dialog"); - dojo.require("dijit.form.Button"); - dojo.require("dijit.form.CheckBox"); - dojo.require("dijit.form.DropDownButton"); - dojo.require("dijit.form.FilteringSelect"); - dojo.require("dijit.form.Form"); - dojo.require("dijit.form.RadioButton"); - dojo.require("dijit.form.Select"); - dojo.require("dijit.form.SimpleTextarea"); - dojo.require("dijit.form.TextBox"); - dojo.require("dijit.form.ComboBox"); - dojo.require("dijit.form.ValidationTextBox"); - dojo.require("dijit.InlineEditBox"); - dojo.require("dijit.layout.AccordionContainer"); - dojo.require("dijit.layout.BorderContainer"); - dojo.require("dijit.layout.ContentPane"); - dojo.require("dijit.layout.TabContainer"); - dojo.require("dijit.Menu"); - dojo.require("dijit.ProgressBar"); - dojo.require("dijit.ProgressBar"); - dojo.require("dijit.Toolbar"); - dojo.require("dijit.Tree"); - dojo.require("dijit.tree.dndSource"); - dojo.require("dojo.data.ItemFileWriteStore"); - - dojo.parser.parse(); - - if (!genericSanityCheck()) - return false; - - loading_set_progress(30); - - var a = document.createElement('audio'); - - var hasAudio = !!a.canPlayType; - var hasSandbox = "sandbox" in document.createElement("iframe"); - var hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, '')); - var clientTzOffset = new Date().getTimezoneOffset() * 60; - - new Ajax.Request("backend.php", { - parameters: {op: "rpc", method: "sanityCheck", hasAudio: hasAudio, - hasMp3: hasMp3, - clientTzOffset: clientTzOffset, - hasSandbox: hasSandbox}, - onComplete: function(transport) { + require(['dojo/_base/kernel', 'dojo/ready', 'dojo/parser', 'dojo/_base/loader'], function(dojo, ready, parser) { + + //dojo.registerModulePath("fox", "../../js/"); + + dojo.require("fox.FeedTree"); + + dojo.require("dijit.ColorPalette"); + dojo.require("dijit.Dialog"); + dojo.require("dijit.form.Button"); + dojo.require("dijit.form.ComboButton"); + dojo.require("dijit.form.CheckBox"); + dojo.require("dijit.form.DropDownButton"); + dojo.require("dijit.form.FilteringSelect"); + dojo.require("dijit.form.Form"); + dojo.require("dijit.form.RadioButton"); + dojo.require("dijit.form.Select"); + dojo.require("dijit.form.SimpleTextarea"); + dojo.require("dijit.form.TextBox"); + dojo.require("dijit.form.ComboBox"); + dojo.require("dijit.form.ValidationTextBox"); + dojo.require("dijit.InlineEditBox"); + dojo.require("dijit.layout.AccordionContainer"); + dojo.require("dijit.layout.BorderContainer"); + dojo.require("dijit.layout.ContentPane"); + dojo.require("dijit.layout.TabContainer"); + dojo.require("dijit.PopupMenuItem"); + dojo.require("dijit.Menu"); + dojo.require("dijit.ProgressBar"); + dojo.require("dijit.ProgressBar"); + dojo.require("dijit.Toolbar"); + dojo.require("dijit.Tree"); + dojo.require("dijit.tree.dndSource"); + dojo.require("dojo.data.ItemFileWriteStore"); + + dojo.parser.parse(); + + if (!genericSanityCheck()) + return false; + + loading_set_progress(30); + + var a = document.createElement('audio'); + + var hasAudio = !!a.canPlayType; + var hasSandbox = "sandbox" in document.createElement("iframe"); + var hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, '')); + var clientTzOffset = new Date().getTimezoneOffset() * 60; + + new Ajax.Request("backend.php", { + parameters: {op: "rpc", method: "sanityCheck", hasAudio: hasAudio, + hasMp3: hasMp3, + clientTzOffset: clientTzOffset, + hasSandbox: hasSandbox}, + onComplete: function(transport) { backend_sanity_check_callback(transport); } }); - hotkey_actions["next_feed"] = function() { + hotkey_actions["next_feed"] = function() { var rv = dijit.byId("feedTree").getNextFeed( - getActiveFeedId(), activeFeedIsCat()); + getActiveFeedId(), activeFeedIsCat()); if (rv) viewfeed({feed: rv[0], is_cat: rv[1], can_wait: true}) - }; - hotkey_actions["prev_feed"] = function() { + }; + hotkey_actions["prev_feed"] = function() { var rv = dijit.byId("feedTree").getPreviousFeed( - getActiveFeedId(), activeFeedIsCat()); + getActiveFeedId(), activeFeedIsCat()); if (rv) viewfeed({feed: rv[0], is_cat: rv[1], can_wait: true}) - }; - hotkey_actions["next_article"] = function() { + }; + hotkey_actions["next_article"] = function() { moveToPost('next'); - }; - hotkey_actions["prev_article"] = function() { + }; + hotkey_actions["prev_article"] = function() { moveToPost('prev'); - }; - hotkey_actions["next_article_noscroll"] = function() { + }; + hotkey_actions["next_article_noscroll"] = function() { moveToPost('next', true); - }; - hotkey_actions["prev_article_noscroll"] = function() { + }; + hotkey_actions["prev_article_noscroll"] = function() { moveToPost('prev', true); - }; - hotkey_actions["next_article_noexpand"] = function() { + }; + hotkey_actions["next_article_noexpand"] = function() { moveToPost('next', true, true); - }; - hotkey_actions["prev_article_noexpand"] = function() { + }; + hotkey_actions["prev_article_noexpand"] = function() { moveToPost('prev', true, true); - }; - hotkey_actions["collapse_article"] = function() { + }; + hotkey_actions["collapse_article"] = function() { var id = getActiveArticleId(); var elem = $("CICD-"+id); @@ -311,8 +315,8 @@ function init() { cdmExpandArticle(id); } } - }; - hotkey_actions["toggle_expand"] = function() { + }; + hotkey_actions["toggle_expand"] = function() { var id = getActiveArticleId(); var elem = $("CICD-"+id); @@ -324,48 +328,48 @@ function init() { cdmExpandArticle(id); } } - }; - hotkey_actions["search_dialog"] = function() { + }; + hotkey_actions["search_dialog"] = function() { search(); - }; - hotkey_actions["toggle_mark"] = function() { + }; + hotkey_actions["toggle_mark"] = function() { selectionToggleMarked(undefined, false, true); - }; - hotkey_actions["toggle_publ"] = function() { + }; + hotkey_actions["toggle_publ"] = function() { selectionTogglePublished(undefined, false, true); - }; - hotkey_actions["toggle_unread"] = function() { + }; + hotkey_actions["toggle_unread"] = function() { selectionToggleUnread(undefined, false, true); - }; - hotkey_actions["edit_tags"] = function() { + }; + hotkey_actions["edit_tags"] = function() { var id = getActiveArticleId(); if (id) { editArticleTags(id); }; } - hotkey_actions["open_in_new_window"] = function() { + hotkey_actions["open_in_new_window"] = function() { if (getActiveArticleId()) { openArticleInNewWindow(getActiveArticleId()); return; } - }; - hotkey_actions["catchup_below"] = function() { + }; + hotkey_actions["catchup_below"] = function() { catchupRelativeToArticle(1); - }; - hotkey_actions["catchup_above"] = function() { + }; + hotkey_actions["catchup_above"] = function() { catchupRelativeToArticle(0); - }; - hotkey_actions["article_scroll_down"] = function() { + }; + hotkey_actions["article_scroll_down"] = function() { var ctr = $("content_insert") ? $("content_insert") : $("headlines-frame"); scrollArticle(40); - }; - hotkey_actions["article_scroll_up"] = function() { + }; + hotkey_actions["article_scroll_up"] = function() { var ctr = $("content_insert") ? $("content_insert") : $("headlines-frame"); scrollArticle(-40); - }; - hotkey_actions["close_article"] = function() { + }; + hotkey_actions["close_article"] = function() { if (isCdmMode()) { if (!getInitParam("cdm_expanded")) { cdmCollapseArticle(false, getActiveArticleId()); @@ -373,8 +377,8 @@ function init() { } else { closeArticlePanel(); } - }; - hotkey_actions["email_article"] = function() { + }; + hotkey_actions["email_article"] = function() { if (typeof emailArticle != "undefined") { emailArticle(); } else if (typeof mailtoArticle != "undefined") { @@ -382,103 +386,103 @@ function init() { } else { alert(__("Please enable mail plugin first.")); } - }; - hotkey_actions["select_all"] = function() { + }; + hotkey_actions["select_all"] = function() { selectArticles('all'); - }; - hotkey_actions["select_unread"] = function() { + }; + hotkey_actions["select_unread"] = function() { selectArticles('unread'); - }; - hotkey_actions["select_marked"] = function() { + }; + hotkey_actions["select_marked"] = function() { selectArticles('marked'); - }; - hotkey_actions["select_published"] = function() { + }; + hotkey_actions["select_published"] = function() { selectArticles('published'); - }; - hotkey_actions["select_invert"] = function() { + }; + hotkey_actions["select_invert"] = function() { selectArticles('invert'); - }; - hotkey_actions["select_none"] = function() { + }; + hotkey_actions["select_none"] = function() { selectArticles('none'); - }; - hotkey_actions["feed_refresh"] = function() { + }; + hotkey_actions["feed_refresh"] = function() { if (getActiveFeedId() != undefined) { viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat()}); return; } - }; - hotkey_actions["feed_unhide_read"] = function() { + }; + hotkey_actions["feed_unhide_read"] = function() { toggleDispRead(); - }; - hotkey_actions["feed_subscribe"] = function() { + }; + hotkey_actions["feed_subscribe"] = function() { quickAddFeed(); - }; - hotkey_actions["feed_debug_update"] = function() { - if (!activeFeedIsCat() && parseInt(getActiveFeedId()) > 0) { - window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + getActiveFeedId() + - "&csrf_token=" + getInitParam("csrf_token")); - } else { - alert("You can't debug this kind of feed."); - } - }; + }; + hotkey_actions["feed_debug_update"] = function() { + if (!activeFeedIsCat() && parseInt(getActiveFeedId()) > 0) { + window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + getActiveFeedId() + + "&csrf_token=" + getInitParam("csrf_token")); + } else { + alert("You can't debug this kind of feed."); + } + }; - hotkey_actions["feed_debug_viewfeed"] = function() { - viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat(), viewfeed_debug: true}); - }; + hotkey_actions["feed_debug_viewfeed"] = function() { + viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat(), viewfeed_debug: true}); + }; - hotkey_actions["feed_edit"] = function() { + hotkey_actions["feed_edit"] = function() { if (activeFeedIsCat()) alert(__("You can't edit this kind of feed.")); else editFeed(getActiveFeedId()); - }; - hotkey_actions["feed_catchup"] = function() { + }; + hotkey_actions["feed_catchup"] = function() { if (getActiveFeedId() != undefined) { catchupCurrentFeed(); return; } - }; - hotkey_actions["feed_reverse"] = function() { + }; + hotkey_actions["feed_reverse"] = function() { reverseHeadlineOrder(); - }; - hotkey_actions["feed_toggle_vgroup"] = function() { - var query_str = "?op=rpc&method=togglepref&key=VFEED_GROUP_BY_FEED"; + }; + hotkey_actions["feed_toggle_vgroup"] = function() { + var query_str = "?op=rpc&method=togglepref&key=VFEED_GROUP_BY_FEED"; - new Ajax.Request("backend.php", { - parameters: query_str, - onComplete: function(transport) { - viewCurrentFeed(); - } }); + new Ajax.Request("backend.php", { + parameters: query_str, + onComplete: function(transport) { + viewCurrentFeed(); + } }); - }; - hotkey_actions["catchup_all"] = function() { + }; + hotkey_actions["catchup_all"] = function() { catchupAllFeeds(); - }; - hotkey_actions["cat_toggle_collapse"] = function() { + }; + hotkey_actions["cat_toggle_collapse"] = function() { if (activeFeedIsCat()) { dijit.byId("feedTree").collapseCat(getActiveFeedId()); return; } - }; - hotkey_actions["goto_all"] = function() { + }; + hotkey_actions["goto_all"] = function() { viewfeed({feed: -4}); - }; - hotkey_actions["goto_fresh"] = function() { + }; + hotkey_actions["goto_fresh"] = function() { viewfeed({feed: -3}); - }; - hotkey_actions["goto_marked"] = function() { + }; + hotkey_actions["goto_marked"] = function() { viewfeed({feed: -1}); - }; - hotkey_actions["goto_published"] = function() { + }; + hotkey_actions["goto_published"] = function() { viewfeed({feed: -2}); - }; - hotkey_actions["goto_tagcloud"] = function() { + }; + hotkey_actions["goto_tagcloud"] = function() { displayDlg(__("Tag cloud"), "printTagCloud"); - }; - hotkey_actions["goto_prefs"] = function() { + }; + hotkey_actions["goto_prefs"] = function() { gotoPreferences(); - }; - hotkey_actions["select_article_cursor"] = function() { + }; + hotkey_actions["select_article_cursor"] = function() { var id = getArticleUnderPointer(); if (id) { var row = $("RROW-" + id); @@ -494,25 +498,25 @@ function init() { } } } - }; - hotkey_actions["create_label"] = function() { + }; + hotkey_actions["create_label"] = function() { addLabel(); - }; - hotkey_actions["create_filter"] = function() { + }; + hotkey_actions["create_filter"] = function() { quickAddFilter(); - }; - hotkey_actions["collapse_sidebar"] = function() { + }; + hotkey_actions["collapse_sidebar"] = function() { collapse_feedlist(); - }; - hotkey_actions["toggle_embed_original"] = function() { + }; + hotkey_actions["toggle_embed_original"] = function() { if (typeof embedOriginalArticle != "undefined") { if (getActiveArticleId()) embedOriginalArticle(getActiveArticleId()); } else { alert(__("Please enable embed_original plugin first.")); } - }; - hotkey_actions["toggle_widescreen"] = function() { + }; + hotkey_actions["toggle_widescreen"] = function() { if (!isCdmMode()) { _widescreen_mode = !_widescreen_mode; @@ -524,11 +528,11 @@ function init() { } else { alert(__("Widescreen is not available in combined mode.")); } - }; - hotkey_actions["help_dialog"] = function() { + }; + hotkey_actions["help_dialog"] = function() { helpDialog("main"); - }; - hotkey_actions["toggle_combined_mode"] = function() { + }; + hotkey_actions["toggle_combined_mode"] = function() { notify_progress("Loading, please wait..."); var value = isCdmMode() ? "false" : "true"; @@ -538,14 +542,14 @@ function init() { parameters: query, onComplete: function(transport) { setInitParam("combined_display_mode", - !getInitParam("combined_display_mode")); + !getInitParam("combined_display_mode")); closeArticlePanel(); viewCurrentFeed(); - } }); - }; - hotkey_actions["toggle_cdm_expanded"] = function() { + } }); + }; + hotkey_actions["toggle_cdm_expanded"] = function() { notify_progress("Loading, please wait..."); var value = getInitParam("cdm_expanded") ? "false" : "true"; @@ -557,8 +561,9 @@ function init() { setInitParam("cdm_expanded", !getInitParam("cdm_expanded")); viewCurrentFeed(); } }); - }; + }; + }); } catch (e) { exception_error("init", e); @@ -568,7 +573,11 @@ function init() { function init_second_stage() { try { - dojo.addOnLoad(function() { + Event.observe(window, 'resize', function() { + dijit.byId("main").resize(); + }); + + //dojo.addOnLoad(function() { updateFeedList(); closeArticlePanel(); @@ -594,7 +603,7 @@ function init_second_stage() { } }); - }); + //}); delCookie("ttrss_test"); diff --git a/plugins/af_zz_noautoplay/init.js b/plugins/af_zz_noautoplay/init.js index 9b7bf0077..3cf3a381c 100644 --- a/plugins/af_zz_noautoplay/init.js +++ b/plugins/af_zz_noautoplay/init.js @@ -1,40 +1,43 @@ -dojo.addOnLoad(function() { - PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) { - if (row) { - console.log("af_zz_noautoplay!"); - console.log(row); - - var videos = row.getElementsByTagName("video"); - console.log(row.innerHTML); - - for (i = 0; i < videos.length; i++) { - - videos[i].removeAttribute("autoplay"); - videos[i].pause(); - videos[i].onclick = function() { - this.paused ? this.play() : this.pause(); +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { + dojo.addOnLoad(function () { + PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function (row) { + if (row) { + console.log("af_zz_noautoplay!"); + console.log(row); + + var videos = row.getElementsByTagName("video"); + console.log(row.innerHTML); + + for (i = 0; i < videos.length; i++) { + + videos[i].removeAttribute("autoplay"); + videos[i].pause(); + videos[i].onclick = function () { + this.paused ? this.play() : this.pause(); + } } } - } - return true; - }); + return true; + }); - PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED, function(row) { - if (row) { - var videos = row.getElementsByTagName("video"); + PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED, function (row) { + if (row) { + var videos = row.getElementsByTagName("video"); - for (i = 0; i < videos.length; i++) { - videos[i].removeAttribute("autoplay"); - videos[i].pause(); - videos[i].onclick = function() { - this.paused ? this.play() : this.pause(); + for (i = 0; i < videos.length; i++) { + videos[i].removeAttribute("autoplay"); + videos[i].pause(); + videos[i].onclick = function () { + this.paused ? this.play() : this.pause(); + } } + } - } + return true; + }); - return true; }); }); \ No newline at end of file diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index 5e9e84aec..899f8a54d 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -22,26 +22,30 @@ function expandSizeWrapper(id) { } -dojo.addOnLoad(function() { - PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) { - if (getInitParam('cdm_expanded')) { +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { - window.setTimeout(function() { - if (row) { - if (row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { - var content = row.select(".cdmContentInner")[0]; + dojo.addOnLoad(function() { + PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) { + if (getInitParam('cdm_expanded')) { - if (content) { - content.innerHTML = "
" + - content.innerHTML + "
"; + window.setTimeout(function() { + if (row) { + if (row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { + var content = row.select(".cdmContentInner")[0]; + if (content) { + content.innerHTML = "
" + + content.innerHTML + "
"; + + } } } - } - }, 150); - } + }, 150); + } - return true; + return true; + }); }); + }); -- cgit v1.2.3-54-g00ecf From f6d2787a8e139da6af412f87645402e0c193af01 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 10 Aug 2016 12:22:55 +0300 Subject: plugins: use require() to hook into dojo --- plugins/af_zz_noautoplay/init.js | 4 +--- plugins/no_title_counters/init.js | 10 ++++++---- plugins/no_url_hashes/init.js | 11 ++++++++--- plugins/shorten_expanded/init.js | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) (limited to 'plugins') diff --git a/plugins/af_zz_noautoplay/init.js b/plugins/af_zz_noautoplay/init.js index 3cf3a381c..45dfc55ab 100644 --- a/plugins/af_zz_noautoplay/init.js +++ b/plugins/af_zz_noautoplay/init.js @@ -1,5 +1,5 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { - dojo.addOnLoad(function () { + ready(function () { PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function (row) { if (row) { console.log("af_zz_noautoplay!"); @@ -37,7 +37,5 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { return true; }); - }); - }); \ No newline at end of file diff --git a/plugins/no_title_counters/init.js b/plugins/no_title_counters/init.js index 9c16856a2..06edfb3ba 100644 --- a/plugins/no_title_counters/init.js +++ b/plugins/no_title_counters/init.js @@ -1,5 +1,7 @@ -dojo.addOnLoad(function() { - updateTitle = function() { - document.title = "Tiny Tiny RSS"; - }; +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { + ready(function () { + updateTitle = function () { + document.title = "Tiny Tiny RSS"; + }; + }); }); diff --git a/plugins/no_url_hashes/init.js b/plugins/no_url_hashes/init.js index a437a1f3e..fc4596724 100644 --- a/plugins/no_url_hashes/init.js +++ b/plugins/no_url_hashes/init.js @@ -1,4 +1,9 @@ -dojo.addOnLoad(function() { - hash_set = function() { }; - hash_get = function() { }; +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { + ready(function () { + hash_set = function () { + }; + hash_get = function () { + }; + }); }); + diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index 899f8a54d..ffec6271d 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -24,7 +24,7 @@ function expandSizeWrapper(id) { require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { - dojo.addOnLoad(function() { + ready(function() { PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) { if (getInitParam('cdm_expanded')) { -- cgit v1.2.3-54-g00ecf From 1a322ff3dfb47a73f52f4076b9d73601999c573e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Aug 2016 18:14:22 +0300 Subject: import_export: better error message if upload failed --- include/functions2.php | 16 ++++++++++++++++ plugins/import_export/init.php | 43 +++++++++++++++++++++--------------------- 2 files changed, 38 insertions(+), 21 deletions(-) (limited to 'plugins') diff --git a/include/functions2.php b/include/functions2.php index dceea507e..7e1171b7d 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -2449,4 +2449,20 @@ return $tmp; } + + function get_upload_error_message($code) { + + $errors = array( + 0 => __('There is no error, the file uploaded with success'), + 1 => __('The uploaded file exceeds the upload_max_filesize directive in php.ini'), + 2 => __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'), + 3 => __('The uploaded file was only partially uploaded'), + 4 => __('No file was uploaded'), + 6 => __('Missing a temporary folder'), + 7 => __('Failed to write file to disk.'), + 8 => __('A PHP extension stopped the file upload.'), + ); + + return $errors[$code]; + } ?> diff --git a/plugins/import_export/init.php b/plugins/import_export/init.php index 7c628909f..491216e06 100644 --- a/plugins/import_export/init.php +++ b/plugins/import_export/init.php @@ -425,34 +425,35 @@ class Import_Export extends Plugin implements IHandler { print "
"; if ($_FILES['export_file']['error'] != 0) { - print_error(T_sprintf("Upload failed with error code %d", - $_FILES['export_file']['error'])); - return; - } + print_error(T_sprintf("Upload failed with error code %d (%s)", + $_FILES['export_file']['error'], + get_upload_error_message($_FILES['export_file']['error']))); + } else { - $tmp_file = false; + $tmp_file = false; - if (is_uploaded_file($_FILES['export_file']['tmp_name'])) { - $tmp_file = tempnam(CACHE_DIR . '/upload', 'export'); + if (is_uploaded_file($_FILES['export_file']['tmp_name'])) { + $tmp_file = tempnam(CACHE_DIR . '/upload', 'export'); - $result = move_uploaded_file($_FILES['export_file']['tmp_name'], - $tmp_file); + $result = move_uploaded_file($_FILES['export_file']['tmp_name'], + $tmp_file); - if (!$result) { - print_error(__("Unable to move uploaded file.")); + if (!$result) { + print_error(__("Unable to move uploaded file.")); + return; + } + } else { + print_error(__('Error: please upload OPML file.')); return; } - } else { - print_error(__('Error: please upload OPML file.')); - return; - } - if (is_file($tmp_file)) { - $this->perform_data_import($tmp_file, $_SESSION['uid']); - unlink($tmp_file); - } else { - print_error(__('No file uploaded.')); - return; + if (is_file($tmp_file)) { + $this->perform_data_import($tmp_file, $_SESSION['uid']); + unlink($tmp_file); + } else { + print_error(__('No file uploaded.')); + return; + } } print "