From e075e6141bf186f264b2fd8f4fe44275a0ab6e52 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 7 Dec 2018 18:24:56 +0300 Subject: [PATCH] json-viewfeed updates --- classes/feeds.php | 74 ++++++++++++++++--------- js/Feeds.js | 2 +- js/Headlines.js | 135 +++++++++++++++++++++++++++++----------------- 3 files changed, 136 insertions(+), 75 deletions(-) diff --git a/classes/feeds.php b/classes/feeds.php index aab770fc0..90add2297 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -234,8 +234,6 @@ class Feeds extends Handler_Protected { $headlines_count = 0; - $lnum = $offset; - $num_unread = 0; if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info); if (is_object($result)) { @@ -261,9 +259,8 @@ class Feeds extends Handler_Protected { $line['feed_id'] = 0; $line["feed_title"] = __("Archived articles"); } - $feed_id = $line["feed_id"]; - //$mouseover_attrs = "onmouseover='Article.mouseIn($id)' onmouseout='Article.mouseOut($id)'"; + $feed_id = $line["feed_id"]; $label_cache = $line["label_cache"]; $labels = false; @@ -292,18 +289,49 @@ class Feeds extends Handler_Protected { array_push($topmost_article_ids, $id); } - $class = ""; + if (!$line["feed_title"]) $line["feed_title"] = ""; - if ($line["unread"]) { - $class .= " Unread"; - ++$num_unread; - } + if (get_pref('COMBINED_DISPLAY_MODE')) { - $class .= $line["marked"] ? " marked" : ""; - //$marked_pic = "star"; + $line["buttons_left"] = ""; + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { + $line["buttons_left"] .= $p->hook_article_left_button($line); + } + + $line["buttons"] = ""; + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { + $line["buttons"] .= $p->hook_article_button($line); + } + + $line["content"] = sanitize($line["content"], + $line['hide_images'], false, $line["site_url"], $highlight_words, $line["id"]); + + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) { + $line = $p->hook_render_article_cdm($line); + } + + $line['content'] = rewrite_cached_urls($line['content']); + $line["content"] = htmlspecialchars($line["content"]); + + if ($line['note']) + $line['note'] = Article::format_article_note($id, $line['note']); + else + $line['note'] = ""; + + if (!get_pref("CDM_EXPANDED")) { + $line["cdm_excerpt"] = " + remove_circle"; + + if (get_pref('SHOW_CONTENT_PREVIEW')) { + $line["cdm_excerpt"] .= "" . $line["content_preview"] . ""; + } + } + + $line["enclosures"] = Article::format_article_enclosures($id, $line["always_display_enclosures"], + $line["content"], $line["hide_images"]); + } - //$class .= $line["published"] ? " published" : ""; - //$published_pic = "rss_feed"; $line["updated"] = make_local_datetime($line["updated"], false, false, false, true); $line['imported'] = T_sprintf("Imported at %s", @@ -314,11 +342,12 @@ class Feeds extends Handler_Protected { $line["score_pic"] = get_score_pic($score); $line["score_class"] = get_score_class($score); - //$entry_author = $line["author"]; + if ($line["tag_cache"]) + $tags = explode(",", $line["tag_cache"]); + else + $tags = false; - /* if ($entry_author) { - $entry_author = " — $entry_author"; - } */ + $line["tags_str"] = Article::format_tags_string($tags, $id); if (feeds::feedHasIcon($feed_id)) { $line['feed_icon'] = "\"\""; @@ -326,16 +355,14 @@ class Feeds extends Handler_Protected { $line['feed_icon'] = "rss_feed"; } - //$entry_site_url = $line["site_url"]; - - //setting feed headline background color, needs to change text color based on dark/light + //setting feed headline background color, needs to change text color based on dark/light $fav_color = $line['favicon_avg_color']; require_once "colors.php"; if ($fav_color && $fav_color != 'fail') { if (!isset($rgba_cache[$feed_id])) { - $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)); + $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)) . ", 0.3"; } $line['favicon_avg_color_rgba'] = $rgba_cache[$feed_id]; @@ -419,7 +446,7 @@ class Feeds extends Handler_Protected { $reply['content'] .= ""; $reply['content'] .= ""; - } else { // HL + } else { // CDM if ($line["tag_cache"]) $tags = explode(",", $line["tag_cache"]); @@ -636,7 +663,6 @@ class Feeds extends Handler_Protected { $reply['content'] .= $tmp_content; } // end html */ - ++$lnum; } } @@ -644,7 +670,7 @@ class Feeds extends Handler_Protected { if (!$headlines_count) { - if (!is_numeric($result)) { + if (is_object($result)) { switch ($view_mode) { case "unread": diff --git a/js/Feeds.js b/js/Feeds.js index 5f7765119..3d6bc713e 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -363,7 +363,7 @@ define(["dojo/_base/declare"], function (declare) { if (viewfeed_debug) { window.open("backend.php?" + dojo.objectToQuery( - Object.assign({debug: 1, csrf_token: App.getInitParam("csrf_token")}, query) + Object.assign({debug: 0, csrf_token: App.getInitParam("csrf_token")}, query) )); } diff --git a/js/Headlines.js b/js/Headlines.js index 31e72fa3d..5e0e7de81 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -242,64 +242,88 @@ define(["dojo/_base/declare"], function (declare) { renderHeadline: function (headlines, hl) { let row = null; + let row_class = ""; + + if (hl.marked) row_class += " marked"; + if (hl.published) row_class += " published"; + if (App.isCombinedMode()) { - row = `
-
-
- - star - rss_feed -
- - - - ${hl.title} - — ${hl.author} - - - - - - ${hl.updated} - -
- - ${hl.score_icon} - -

Sorry for hijacking this htread, but I have a similar issue.

-

I have a feed category with about 120 unread articles. I toggle headline grouping, but I am not sure if this matters or not.

-

I click on the category on the left pane, and start clicking “ctrl+down” to scroll to read the articles.
-At some point ( I tried to figure it out, but can say exactly after how many articles I read) the page won’t scroll down with “ctrl+down”, so I have to scroll with down key alone.

-

TT-rss says it’s refreshing the content (or something similar), but was it does, is marking as read a bunch of articles, that were supposed to be shown between the last one I actually read, and the first unread it shows, which should not really be the first unread.

-

Last time it happened, I had around 120 unread articles, I could scroll via ctrl+down untill 80 were unread, I scroled manually, and it jumped to 50 unread. The right pane is also refreshed, so I can not scroll up to go through the ones marked as unread.

-

I hope it is somewhat related to this thread, otherwise let me know and I can open a new one.

-

Please let me know if what I wrote is clear.

-

By the way I am running f6e287df110b2046643551aaae70917c61b061c9 on shared hosting, PHP 7 and Mysql.

`; + row_class += App.getInitParam("cdm_expanded") ? " expanded" : " expandable"; + + row = `
+ +
+
+ + star + rss_feed +
+ + + + ${hl.title} + ${hl.author} + ${hl.labels} + ${hl.cdm_excerpt ? hl.cdm_excerpt : ""} + + + + + ${hl.updated} + +
+ ${hl.score_pic} + + + ${hl.feed_icon} +
+ +
+ +
+
${hl.note}
+
+
+ ${hl.enclosures} +
+ +
+
`; } else { - row = `
- star + star rss_feed
- ${hl.feed_title} + ${hl.feed_title}
${hl.updated} @@ -356,8 +380,7 @@ At some point ( I tried to figure it out, but can say exactly after how many art $("headlines-frame").addClassName(App.isCombinedMode() ? "cdm" : "normal"); const headlines_count = reply['headlines-info']['count']; - //Feeds.infscroll_disabled = parseInt(headlines_count) != 30; - Feeds.infscroll_disabled = true; // TEMPORARY + Feeds.infscroll_disabled = parseInt(headlines_count) != 30; console.log('received', headlines_count, 'headlines, infscroll disabled=', Feeds.infscroll_disabled); @@ -371,10 +394,14 @@ At some point ( I tried to figure it out, but can say exactly after how many art reply['headlines']['toolbar'], {parseContent: true}); - $("headlines-frame").innerHTML = ''; + if (typeof reply['headlines']['content'] == 'string') { + $("headlines-frame").innerHTML = reply['headlines']['content']; + } else { + $("headlines-frame").innerHTML = ''; - for (let i = 0; i < reply['headlines']['content'].length; i++) { - this.renderHeadline(reply['headlines'], reply['headlines']['content'][i]); + for (let i = 0; i < reply['headlines']['content'].length; i++) { + this.renderHeadline(reply['headlines'], reply['headlines']['content'][i]); + } } /* let tmp = document.createElement("div"); @@ -421,7 +448,7 @@ At some point ( I tried to figure it out, but can say exactly after how many art if (hsp) c.domNode.removeChild(hsp); - let tmp = document.createElement("div"); + /* let tmp = document.createElement("div"); tmp.innerHTML = reply['headlines']['content']; dojo.parser.parse(tmp); @@ -433,6 +460,14 @@ At some point ( I tried to figure it out, but can say exactly after how many art this.loaded_article_ids.push(row.id); } + } */ + + if (typeof reply['headlines']['content'] == 'string') { + $("headlines-frame").innerHTML = reply['headlines']['content']; + } else { + for (let i = 0; i < reply['headlines']['content'].length; i++) { + this.renderHeadline(reply['headlines'], reply['headlines']['content'][i]); + } } if (!hsp) {