From f17069960c852237ca0ee25fb677cf7061c13599 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 13 Jul 2015 22:01:29 +0300 Subject: [PATCH] roll back separate headline transport --- classes/feeds.php | 177 ++++++++++++++++++++++------------------------ js/viewfeed.js | 39 ++++------ 2 files changed, 100 insertions(+), 116 deletions(-) diff --git a/classes/feeds.php b/classes/feeds.php index f91a7925..1d106ea2 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -296,7 +296,7 @@ class Feeds extends Handler_Protected { } } - $reply['content'] = array(); + $reply['content'] = ''; if (!is_numeric($result) && $this->dbh->num_rows($result) > 0) { @@ -310,7 +310,6 @@ class Feeds extends Handler_Protected { $expand_cdm = get_pref('CDM_EXPANDED'); while ($line = $this->dbh->fetch_assoc($result)) { - $headline_row = ''; $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); @@ -466,65 +465,65 @@ class Feeds extends Handler_Protected { $mouseover_attrs = "onmouseover='postMouseIn(event, $id)' onmouseout='postMouseOut($id)'"; - $headline_row .= "
"; + $reply['content'] .= "
"; - $headline_row .= "
"; + $reply['content'] .= "
"; - $headline_row .= ""; - $headline_row .= "$marked_pic"; - $headline_row .= "$published_pic"; + $reply['content'] .= "$marked_pic"; + $reply['content'] .= "$published_pic"; - $headline_row .= "
"; + $reply['content'] .= "
"; - $headline_row .= "
"; - $headline_row .= "" . truncate_string($line["title"], 200); if (get_pref('SHOW_CONTENT_PREVIEW')) { - $headline_row .= "" . $line["content_preview"] . ""; + $reply['content'] .= "" . $line["content_preview"] . ""; } - $headline_row .= ""; + $reply['content'] .= ""; - $headline_row .= $labels_str; + $reply['content'] .= $labels_str; - $headline_row .= "
"; + $reply['content'] .= "
"; if (!$vfeed_group_enabled) { if (@$line["feed_title"]) { $rgba = @$rgba_cache[$feed_id]; - $headline_row .= "". + $reply['content'] .= "". truncate_string($line["feed_title"],30).""; } } - $headline_row .= ""; + $reply['content'] .= ""; - $headline_row .= "
$updated_fmt
+ $reply['content'] .= "
$updated_fmt
"; - $headline_row .= "
"; + $reply['content'] .= "
"; - $headline_row .= $score_pic; + $reply['content'] .= $score_pic; if ($line["feed_title"] && !$vfeed_group_enabled) { - $headline_row .= " $feed_icon_img"; } - $headline_row .= "
"; - $headline_row .= "
"; + $reply['content'] .= "
"; + $reply['content'] .= ""; } else { @@ -572,20 +571,20 @@ class Feeds extends Handler_Protected { $expanded_class = $expand_cdm ? "expanded" : "expandable"; - $headline_row .= "
"; - $headline_row .= "
"; - $headline_row .= "
"; + $reply['content'] .= "
"; + $reply['content'] .= "
"; - $headline_row .= ""; - $headline_row .= "$marked_pic"; - $headline_row .= "$published_pic"; + $reply['content'] .= "$marked_pic"; + $reply['content'] .= "$published_pic"; - $headline_row .= "
"; + $reply['content'] .= "
"; if ($highlight_words && count($highlight_words > 0)) { foreach ($highlight_words as $word) { @@ -594,7 +593,7 @@ class Feeds extends Handler_Protected { } } - $headline_row .= " $entry_author"; - $headline_row .= $labels_str; + $reply['content'] .= $labels_str; - $headline_row .= ""; + $reply['content'] .= ""; if (!$vfeed_group_enabled) { if (@$line["feed_title"]) { $rgba = @$rgba_cache[$feed_id]; - $headline_row .= "
+ $reply['content'] .= "
". truncate_string($line["feed_title"],30)." @@ -631,34 +630,34 @@ class Feeds extends Handler_Protected { } } - $headline_row .= " + $reply['content'] .= " $updated_fmt"; - $headline_row .= "
"; - $headline_row .= "$score_pic"; + $reply['content'] .= "
"; + $reply['content'] .= "$score_pic"; if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) { - $headline_row .= "$feed_icon_img"; } - $headline_row .= "
"; + $reply['content'] .= "
"; - $headline_row .= "
"; + $reply['content'] .= "
"; - $headline_row .= "
"; - $headline_row .= "
"; + $reply['content'] .= "
"; if ($line['note']) { - $headline_row .= format_article_note($id, $line['note']); + $reply['content'] .= format_article_note($id, $line['note']); } - $headline_row .= "
"; + $reply['content'] .= "
"; if (!$line['lang']) $line['lang'] = 'en'; - $headline_row .= "
"; + $reply['content'] .= "
"; if ($line["orig_feed_id"]) { @@ -667,54 +666,54 @@ class Feeds extends Handler_Protected { if ($this->dbh->num_rows($tmp_result) != 0) { - $headline_row .= "
"; - $headline_row .= __("Originally from:"); + $reply['content'] .= "
"; + $reply['content'] .= __("Originally from:"); - $headline_row .= " "; + $reply['content'] .= " "; $tmp_line = $this->dbh->fetch_assoc($tmp_result); - $headline_row .= "" . $tmp_line['title'] . ""; - $headline_row .= " "; + $reply['content'] .= " "; - $headline_row .= ""; - $headline_row .= ""; + $reply['content'] .= ""; + $reply['content'] .= ""; - $headline_row .= "
"; + $reply['content'] .= "
"; } } - $headline_row .= ""; + $reply['content'] .= ""; // if (!$expand_cdm) { - $headline_row .= ""; - $headline_row .= htmlspecialchars($line["content"]); - $headline_row .= ""; + $reply['content'] .= htmlspecialchars($line["content"]); + $reply['content'] .= ""; + $reply['content'] .= "
"; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { - $headline_row .= $p->hook_article_left_button($line); + $reply['content'] .= $p->hook_article_left_button($line); } $tags_str = format_tags_string($tags, $id); - $headline_row .= "Tags + $reply['content'] .= "Tags $tags_str (+)"; @@ -738,28 +737,26 @@ class Feeds extends Handler_Protected { } } - if ($entry_comments) $headline_row .= " ($entry_comments)"; + if ($entry_comments) $reply['content'] .= " ($entry_comments)"; - $headline_row .= "
"; + $reply['content'] .= "
"; -// $headline_row .= "$marked_pic"; -// $headline_row .= "$published_pic"; +// $reply['content'] .= "$marked_pic"; +// $reply['content'] .= "$published_pic"; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { - $headline_row .= $p->hook_article_button($line); + $reply['content'] .= $p->hook_article_button($line); } - $headline_row .= "
"; - $headline_row .= "
"; + $reply['content'] .= "
"; + $reply['content'] .= "
"; - $headline_row .= "
"; + $reply['content'] .= "
"; - $headline_row .= "
"; + $reply['content'] .= "
"; } - array_push($reply['content'], array("id" => (int)$line['id'], 'html' => $headline_row)); - ++$lnum; } @@ -787,9 +784,9 @@ class Feeds extends Handler_Protected { } if (!$offset && $message) { - $headline_row = "
$message"; + $reply['content'] = "
$message"; - $headline_row .= "

"; + $reply['content'] .= "

"; $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); @@ -797,7 +794,7 @@ class Feeds extends Handler_Protected { $last_updated = $this->dbh->fetch_result($result, 0, "last_updated"); $last_updated = make_local_datetime($last_updated, false); - $headline_row .= sprintf(__("Feeds last updated at %s"), $last_updated); + $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); $result = $this->dbh->query("SELECT COUNT(id) AS num_errors FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); @@ -805,14 +802,12 @@ class Feeds extends Handler_Protected { $num_errors = $this->dbh->fetch_result($result, 0, "num_errors"); if ($num_errors > 0) { - $headline_row .= "
"; - $headline_row .= "". + $reply['content'] .= "
"; + $reply['content'] .= "
". __('Some feeds have update errors (click for details)').""; } - $headline_row .= "

"; + $reply['content'] .= "

"; - //array_push($reply['content'], array("id" => 0, "kind" => "status_message", "html" => $headline_row)); - array_push($reply['content'], array("id" => 0, 'kind' => 'status_message', 'html' => $headline_row)); } } else if (is_numeric($result) && $result == -1) { $reply['first_id_changed'] = true; @@ -961,9 +956,9 @@ class Feeds extends Handler_Protected { $reply['headlines']['toolbar'] = ''; - $headline_row = "
".__('No feed selected.'); + $reply['headlines']['content'] = "
".__('No feed selected.'); - $headline_row .= "

"; + $reply['headlines']['content'] .= "

"; $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); @@ -971,7 +966,7 @@ class Feeds extends Handler_Protected { $last_updated = $this->dbh->fetch_result($result, 0, "last_updated"); $last_updated = make_local_datetime($last_updated, false); - $headline_row .= sprintf(__("Feeds last updated at %s"), $last_updated); + $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); $result = $this->dbh->query("SELECT COUNT(id) AS num_errors FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); @@ -979,13 +974,11 @@ class Feeds extends Handler_Protected { $num_errors = $this->dbh->fetch_result($result, 0, "num_errors"); if ($num_errors > 0) { - $headline_row .= "
"; - $headline_row .= "". + $reply['headlines']['content'] .= "
"; + $reply['headlines']['content'] .= "
". __('Some feeds have update errors (click for details)').""; } - $headline_row .= "

"; - - $reply['headlines']['content'] = array(array("kind" => "status_message", "html" => $headline_row)); + $reply['headlines']['content'] .= "

"; $reply['headlines-info'] = array("count" => 0, "vgroup_last_feed" => '', diff --git a/js/viewfeed.js b/js/viewfeed.js index 8254e86b..dff11556 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -90,21 +90,14 @@ function headlines_callback2(transport, offset, background, infscroll_req) { reply['headlines']['toolbar'], {parseContent: true}); - dijit.byId("headlines-frame").attr("content", ""); + dojo.html.set($("headlines-frame"), + reply['headlines']['content'], + {parseContent: true}); - var tmp = new Element("div"); - - reply['headlines']['content'].each(function(row) { - if (loaded_article_ids.indexOf(row.id) == -1) { - loaded_article_ids.push(row.id); - } - - tmp.innerHTML += row.html; + $$("#headlines-frame div[id*='RROW']").each(function(row) { + loaded_article_ids.push(row.id); }); - dojo.parser.parse(tmp); - dijit.byId("headlines-frame").attr("content", tmp.innerHTML); - var hsp = $("headlines-spacer"); if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"}); dijit.byId('headlines-frame').domNode.appendChild(hsp); @@ -135,26 +128,24 @@ function headlines_callback2(transport, offset, background, infscroll_req) { c.domNode.removeChild(hsp); var tmp = new Element("div"); - - reply['headlines']['content'].each(function(row) { - if (loaded_article_ids.indexOf(row.id) == -1 || row.kind == 'feed_title') { - loaded_article_ids.push(row.id); - - tmp.innerHTML += row.html; - - } - }); - + tmp.innerHTML = reply['headlines']['content']; dojo.parser.parse(tmp); while (tmp.hasChildNodes()) { - dijit.byId("headlines-frame").domNode.appendChild(tmp.removeChild(tmp.firstChild)); + var row = tmp.removeChild(tmp.firstChild); + + if (loaded_article_ids.indexOf(row.id) == -1 || row.hasClassName("cdmFeedTitle")) { + dijit.byId("headlines-frame").domNode.appendChild(row); + Element.hide(row); + new Effect.Appear(row, {duration:0.5}); + loaded_article_ids.push(row.id); + } } if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"}); c.domNode.appendChild(hsp); - if (reply['headlines']['content'].size() == 0) _infscroll_disable = true; + if (headlines_count < 30) _infscroll_disable = true; console.log("restore selected ids: " + ids); -- 2.39.5