initial for js templates

This commit is contained in:
Andrew Dolgov 2018-12-07 16:00:11 +03:00
parent a68b150601
commit 249c93a228
2 changed files with 128 additions and 37 deletions

View File

@ -230,7 +230,7 @@ class Feeds extends Handler_Protected {
} }
} }
$reply['content'] = ''; $reply['content'] = [];
$headlines_count = 0; $headlines_count = 0;
@ -240,32 +240,33 @@ class Feeds extends Handler_Protected {
if (is_object($result)) { if (is_object($result)) {
while ($line = $result->fetch()) { while ($line = $result->fetch(PDO::FETCH_ASSOC)) {
++$headlines_count; ++$headlines_count;
$line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); if (!get_pref('SHOW_CONTENT_PREVIEW')) {
$line["content_preview"] = null;
} else {
$line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
$line = $p->hook_query_headlines($line, 250, false); $line = $p->hook_query_headlines($line, 250, false);
} }
}
if (get_pref('SHOW_CONTENT_PREVIEW')) {
$content_preview = $line["content_preview"];
}
$id = $line["id"]; $id = $line["id"];
$feed_id = $line["feed_id"];
$label_cache = $line["label_cache"];
$labels = false;
// normalize archived feed // normalize archived feed
if ($feed_id === null) { if ($line['feed_id'] === null) {
$feed_id = 0; $line['feed_id'] = 0;
$line["feed_title"] = __("Archived articles"); $line["feed_title"] = __("Archived articles");
} }
$feed_id = $line["feed_id"];
$mouseover_attrs = "onmouseover='Article.mouseIn($id)' onmouseout='Article.mouseOut($id)'"; //$mouseover_attrs = "onmouseover='Article.mouseIn($id)' onmouseout='Article.mouseOut($id)'";
$label_cache = $line["label_cache"];
$labels = false;
if ($label_cache) { if ($label_cache) {
$label_cache = json_decode($label_cache, true); $label_cache = json_decode($label_cache, true);
@ -284,6 +285,9 @@ class Feeds extends Handler_Protected {
$labels_str .= Article::format_article_labels($labels); $labels_str .= Article::format_article_labels($labels);
$labels_str .= "</span>"; $labels_str .= "</span>";
$line["labels"] = $labels_str;
unset($line["label_cache"]);
if (count($topmost_article_ids) < 3) { if (count($topmost_article_ids) < 3) {
array_push($topmost_article_ids, $id); array_push($topmost_article_ids, $id);
} }
@ -296,35 +300,33 @@ class Feeds extends Handler_Protected {
} }
$class .= $line["marked"] ? " marked" : ""; $class .= $line["marked"] ? " marked" : "";
$marked_pic = "<i class=\"marked-pic marked-$id material-icons\" onclick='Headlines.toggleMark($id)'>star</i>"; //$marked_pic = "<i class=\"marked-pic marked-$id material-icons\" onclick='Headlines.toggleMark($id)'>star</i>";
$class .= $line["published"] ? " published" : ""; //$class .= $line["published"] ? " published" : "";
$published_pic = "<i class=\"pub-pic pub-$id material-icons\" onclick='Headlines.togglePub($id)'>rss_feed</i>"; //$published_pic = "<i class=\"pub-pic pub-$id material-icons\" onclick='Headlines.togglePub($id)'>rss_feed</i>";
$updated_fmt = make_local_datetime($line["updated"], false, false, false, true); $line["updated"] = make_local_datetime($line["updated"], false, false, false, true);
$date_entered_fmt = T_sprintf("Imported at %s", $line['imported'] = T_sprintf("Imported at %s",
make_local_datetime($line["date_entered"], false)); make_local_datetime($line["date_entered"], false));
$score = $line["score"]; $score = $line["score"];
$score_pic = "<i class='material-icons icon-score' title='$score' $line["score_pic"] = get_score_pic($score);
data-score='$score' onclick='Article.setScore($id, this)'>" . $line["score_class"] = get_score_class($score);
get_score_pic($score) . "</i>";
$score_class = get_score_class($score);
$entry_author = $line["author"]; //$entry_author = $line["author"];
if ($entry_author) { /* if ($entry_author) {
$entry_author = " &mdash; $entry_author"; $entry_author = " &mdash; $entry_author";
} } */
if (feeds::feedHasIcon($feed_id)) { if (feeds::feedHasIcon($feed_id)) {
$feed_icon_img = "<img class=\"icon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">"; $line['feed_icon'] = "<img class=\"icon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
} else { } else {
$feed_icon_img = "<i class='icon-no-feed material-icons'>rss_feed</i>"; $line['feed_icon'] = "<i class='icon-no-feed material-icons'>rss_feed</i>";
} }
$entry_site_url = $line["site_url"]; //$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']; $fav_color = $line['favicon_avg_color'];
@ -335,9 +337,13 @@ class Feeds extends Handler_Protected {
if (!isset($rgba_cache[$feed_id])) { if (!isset($rgba_cache[$feed_id])) {
$rgba_cache[$feed_id] = join(",", _color_unpack($fav_color)); $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color));
} }
$line['favicon_avg_color_rgba'] = $rgba_cache[$feed_id];
} }
if (!get_pref('COMBINED_DISPLAY_MODE')) { array_push($reply['content'], $line);
/* if (!get_pref('COMBINED_DISPLAY_MODE')) {
if ($vfeed_group_enabled) { if ($vfeed_group_enabled) {
if ($feed_id != $vgroup_last_feed) { if ($feed_id != $vgroup_last_feed) {
@ -413,7 +419,7 @@ class Feeds extends Handler_Protected {
$reply['content'] .= "</div>"; $reply['content'] .= "</div>";
$reply['content'] .= "</div>"; $reply['content'] .= "</div>";
} else { } else { // HL
if ($line["tag_cache"]) if ($line["tag_cache"])
$tags = explode(",", $line["tag_cache"]); $tags = explode(",", $line["tag_cache"]);
@ -628,7 +634,7 @@ class Feeds extends Handler_Protected {
} }
$reply['content'] .= $tmp_content; $reply['content'] .= $tmp_content;
} } // end html */
++$lnum; ++$lnum;
} }

View File

@ -239,6 +239,86 @@ define(["dojo/_base/declare"], function (declare) {
} }
} }
}, },
renderHeadline: function (headlines, hl) {
let row = null;
if (App.isCombinedMode()) {
row = `<div class="cdm expanded ${hl.score_class}" id="RROW-${hl.id}" data-article-id="${hl.id}" data-orig-feed-id="${hl.feed_id}"
onmouseover="Article.mouseIn(${hl.id})" onmouseout="Article.mouseOut(${hl.id})">
<div class="header">
<div class="left">
<input dojoType="dijit.form.CheckBox" type="checkbox" onclick="Headlines.onRowChecked(this)" class='rchk'>
<i class="marked-pic marked-8797658 material-icons" onclick="Headlines.toggleMark(8797658)">star</i>
<i class="pub-pic pub-8797658 material-icons" onclick="Headlines.togglePub(8797658)">rss_feed</i>
</div>
<span onclick="return Headlines.click(event, ${hl.id});" data-article-id="${hl.id}" class="titleWrap hlMenuAttach">
<a class="title" title="${hl.title}" target="_blank" rel="noopener noreferrer" href="${hl.link}">
${hl.title}</a>
<span class="author"> ${hl.author}</span>
<span class="HLLCTR-${hl.id}"></span>
</span>
<div class="feed">
<a href="#" style="background-color: rgba(${hl.favicon_avg_color_rgba} ,0.3)"
onclick="Feeds.open({feed:${hl.feed_id}})">${hl.feed_title}</a>
</div>
<span class="updated" title="${hl.imported}">${hl.updated}</span>
<div class="right">
<i class="material-icons icon-score" title="${hl.score}" data-score="${hl.score}" onclick="Article.setScore(${hl.id}, this)">${hl.score_icon}</i>
<span style="cursor : pointer" title="Tiny Tiny RSS '&quot;" onclick="Feeds.open({feed:3205})"><img class="icon" src="feed-icons/3205.ico" alt=""></span></div></div><div class="content" onclick="return Headlines.click(event, 8797658, true);"><div id="POSTNOTE-8797658"></div><div class="content-inner" lang="en"><p>Sorry for hijacking this htread, but I have a similar issue.</p>
<p>I have a feed category with about 120 unread articles. I toggle headline grouping, but I am not sure if this matters or not.</p>
<p>I click on the category on the left pane, and start clicking ctrl+down to scroll to read the articles.<br>
At some point ( I tried to figure it out, but can say exactly after how many articles I read) the page wont scroll down with ctrl+down, so I have to scroll with down key alone.</p>
<p>TT-rss says its 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.</p>
<p>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.</p>
<p>I hope it is somewhat related to this thread, otherwise let me know and I can open a new one.</p>
<p>Please let me know if what I wrote is clear.</p>
<p>By the way I am running f6e287df110b2046643551aaae70917c61b061c9 on shared hosting, PHP 7 and Mysql.</p></div><div class="intermediate"></div><div class="footer" onclick="event.stopPropagation()"><div class="left"><i class="material-icons">label_outline</i>
<span id="ATSTR-8797658">no tags</span>
<a title="Edit tags for this article" href="#" onclick="Article.editTags(8797658)">(+)</a></div><div class="right"><i style="cursor : pointer" class="material-icons" onclick="Plugins.Psql_Trgm.showRelated(8797658)" title="Show related articles">bookmark_outline</i><i class="material-icons" style="cursor : pointer" onclick="Plugins.Mail.send(8797658)" title="Forward by email">mail</i><i class="material-icons" onclick="Plugins.Note.edit(8797658)" style="cursor : pointer" title="Edit article note">note</i><i id="SHARE-IMG-6023086" class="material-icons icon-share " style="cursor : pointer" onclick="Plugins.Share.shareArticle(6023086)" title="Share by URL">link</i></div></div></div></div>`;
} else {
row = `<div class="hl ${hl.score_class}" data-orig-feed-id="${hl.feed_id}" data-article-id="${hl.id}" id="RROW-${hl.id}"
onmouseover="Article.mouseIn(${hl.id})" onmouseout="Article.mouseOut(${hl.id})">
<div class="left">
<input dojoType="dijit.form.CheckBox" type="checkbox" onclick="Headlines.onRowChecked(this)" class='rchk'>
<i class="marked-pic marked-8804827 material-icons" onclick="Headlines.toggleMark(${hl.id})">star</i>
<i class="pub-pic pub-${hl.id} material-icons" onclick="Headlines.togglePub(${hl.id})">rss_feed</i>
</div>
<div onclick="return Headlines.click(event, ${hl.id})" class="title">
<span data-article-id="${hl.id}" class="hl-content hlMenuAttach">
<a class="title" href="${hl.link}">${hl.title}
<span class="preview">${hl.content_preview}</span>
</a>
</span>
</div>
<span class="feed">
<a style="background : rgba(${hl.favicon_avg_color_rgba}, 0.3)" href="#" onclick="Feeds.open({feed:${hl.feed_id}})">${hl.feed_title}</a>
</span>
<div title="${hl.imported}">
<span class="updated">${hl.updated}</span>
</div>
<div class="right">
<i class="material-icons icon-score" title="${hl.score}" data-score="${hl.score}"
onclick="Article.setScore(${hl.id}, this)">${hl.score_pic}</i>
<span onclick="Feeds.open({feed:${hl.feed_id})" style="cursor : pointer" title="${hl.feed_title}">${hl.feed_icon}</span>
</div>
</div>
`;
}
const tmp = document.createElement("div");
tmp.innerHTML = row;
dojo.parser.parse(tmp);
$("headlines-frame").appendChild(tmp.firstChild);
},
onLoaded: function (transport, offset) { onLoaded: function (transport, offset) {
const reply = App.handleRpcJson(transport); const reply = App.handleRpcJson(transport);
@ -276,7 +356,8 @@ define(["dojo/_base/declare"], function (declare) {
$("headlines-frame").addClassName(App.isCombinedMode() ? "cdm" : "normal"); $("headlines-frame").addClassName(App.isCombinedMode() ? "cdm" : "normal");
const headlines_count = reply['headlines-info']['count']; const headlines_count = reply['headlines-info']['count'];
Feeds.infscroll_disabled = parseInt(headlines_count) != 30; //Feeds.infscroll_disabled = parseInt(headlines_count) != 30;
Feeds.infscroll_disabled = true; // TEMPORARY
console.log('received', headlines_count, 'headlines, infscroll disabled=', Feeds.infscroll_disabled); console.log('received', headlines_count, 'headlines, infscroll disabled=', Feeds.infscroll_disabled);
@ -292,7 +373,11 @@ define(["dojo/_base/declare"], function (declare) {
$("headlines-frame").innerHTML = ''; $("headlines-frame").innerHTML = '';
let tmp = document.createElement("div"); for (let i = 0; i < reply['headlines']['content'].length; i++) {
this.renderHeadline(reply['headlines'], reply['headlines']['content'][i]);
}
/* let tmp = document.createElement("div");
tmp.innerHTML = reply['headlines']['content']; tmp.innerHTML = reply['headlines']['content'];
dojo.parser.parse(tmp); dojo.parser.parse(tmp);
@ -304,7 +389,7 @@ define(["dojo/_base/declare"], function (declare) {
this.loaded_article_ids.push(row.id); this.loaded_article_ids.push(row.id);
} }
} } */
let hsp = $("headlines-spacer"); let hsp = $("headlines-spacer");