offline: store article labels
This commit is contained in:
parent
ed22888b0d
commit
c2726c9615
|
@ -560,6 +560,11 @@
|
||||||
print __("Special");
|
print __("Special");
|
||||||
print "]]></category>";
|
print "]]></category>";
|
||||||
|
|
||||||
|
print "<category id=\"-2\" collapsed=\"".
|
||||||
|
(int)$_COOKIE["ttrss_vf_lclps"]."\"><![CDATA[";
|
||||||
|
print __("Labels");
|
||||||
|
print "]]></category>";
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
while ($line = db_fetch_assoc($result)) {
|
||||||
print "<category
|
print "<category
|
||||||
id=\"".$line["id"]."\"
|
id=\"".$line["id"]."\"
|
||||||
|
@ -635,6 +640,8 @@
|
||||||
$line["marked"] = (int)sql_bool_to_bool($line["marked"]);
|
$line["marked"] = (int)sql_bool_to_bool($line["marked"]);
|
||||||
$line["unread"] = (int)sql_bool_to_bool($line["unread"]);
|
$line["unread"] = (int)sql_bool_to_bool($line["unread"]);
|
||||||
|
|
||||||
|
$line["labels"] = get_article_labels($link, $line["id"]);
|
||||||
|
|
||||||
// too slow :(
|
// too slow :(
|
||||||
// $line["tags"] = format_tags_string(
|
// $line["tags"] = format_tags_string(
|
||||||
// get_article_tags($link, $line["id"]), $line["id"]);
|
// get_article_tags($link, $line["id"]), $line["id"]);
|
||||||
|
|
89
offline.js
89
offline.js
|
@ -1,4 +1,4 @@
|
||||||
var SCHEMA_VERSION = 6;
|
var SCHEMA_VERSION = 7;
|
||||||
|
|
||||||
var offline_mode = false;
|
var offline_mode = false;
|
||||||
var store = false;
|
var store = false;
|
||||||
|
@ -422,16 +422,7 @@ function render_offline_feedlist() {
|
||||||
updateTitle();
|
updateTitle();
|
||||||
|
|
||||||
if (cats_enabled) {
|
if (cats_enabled) {
|
||||||
var rs = db.execute("SELECT collapsed FROM categories WHERE id = -1");
|
tmp += printCategoryHeader(-1, is_local_cat_collapsed(-1), false);
|
||||||
var cat_hidden = 0;
|
|
||||||
|
|
||||||
if (rs.isValidRow()) {
|
|
||||||
cat_hidden = rs.field(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
rs.close();
|
|
||||||
|
|
||||||
tmp += printCategoryHeader(-1, cat_hidden, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp += printFeedEntry(-4, __("All articles"), "feed", unread,
|
tmp += printFeedEntry(-4, __("All articles"), "feed", unread,
|
||||||
|
@ -448,6 +439,33 @@ function render_offline_feedlist() {
|
||||||
tmp += "<li><hr/></li>";
|
tmp += "<li><hr/></li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cats_enabled) {
|
||||||
|
tmp += printCategoryHeader(-2, is_local_cat_collapsed(-2), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
var rs = db.execute("SELECT id,caption "+
|
||||||
|
"FROM labels "+
|
||||||
|
"ORDER BY caption");
|
||||||
|
|
||||||
|
while (rs.isValidRow()) {
|
||||||
|
var id = -11 - parseInt(rs.field(0));
|
||||||
|
var caption = rs.field(1);
|
||||||
|
var unread = get_local_feed_unread(id);
|
||||||
|
|
||||||
|
tmp += printFeedEntry(id, caption, "feed", unread,
|
||||||
|
"images/label.png");
|
||||||
|
|
||||||
|
rs.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
|
||||||
|
if (cats_enabled) {
|
||||||
|
tmp += "</ul></li>";
|
||||||
|
} else {
|
||||||
|
tmp += "<li><hr/></li>";
|
||||||
|
}
|
||||||
|
|
||||||
/* var rs = db.execute("SELECT feeds.id,feeds.title,has_icon,COUNT(articles.id) "+
|
/* var rs = db.execute("SELECT feeds.id,feeds.title,has_icon,COUNT(articles.id) "+
|
||||||
"FROM feeds LEFT JOIN articles ON (feed_id = feeds.id) "+
|
"FROM feeds LEFT JOIN articles ON (feed_id = feeds.id) "+
|
||||||
"WHERE unread = 1 OR unread IS NULL GROUP BY feeds.id "+
|
"WHERE unread = 1 OR unread IS NULL GROUP BY feeds.id "+
|
||||||
|
@ -647,6 +665,8 @@ function offline_download_parse(stage, transport) {
|
||||||
var ts = Math.round(date.getTime() / 1000);
|
var ts = Math.round(date.getTime() / 1000);
|
||||||
|
|
||||||
db.execute("DELETE FROM articles WHERE id = ?", [a.id]);
|
db.execute("DELETE FROM articles WHERE id = ?", [a.id]);
|
||||||
|
db.execute("DELETE FROM article_labels WHERE id = ?", [a.id]);
|
||||||
|
|
||||||
db.execute("INSERT INTO articles "+
|
db.execute("INSERT INTO articles "+
|
||||||
"(id, feed_id, title, link, guid, updated, content, "+
|
"(id, feed_id, title, link, guid, updated, content, "+
|
||||||
"unread, marked, tags, added, comments) "+
|
"unread, marked, tags, added, comments) "+
|
||||||
|
@ -655,6 +675,12 @@ function offline_download_parse(stage, transport) {
|
||||||
a.content, a.unread, a.marked, a.tags, ts,
|
a.content, a.unread, a.marked, a.tags, ts,
|
||||||
a.comments]);
|
a.comments]);
|
||||||
|
|
||||||
|
if (a.labels.length > 0) {
|
||||||
|
for (var j = 0; j < a.labels.length; j++) {
|
||||||
|
label_local_add_article(a.id, a.labels[j][0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1014,3 +1040,44 @@ function printCategoryHeader(cat_id, hidden, can_browse) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_local_cat_collapsed(id) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
var rs = db.execute("SELECT collapsed FROM categories WHERE id = ?", [id]);
|
||||||
|
var cat_hidden = 0;
|
||||||
|
|
||||||
|
if (rs.isValidRow()) {
|
||||||
|
cat_hidden = rs.field(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
|
||||||
|
return cat_hidden == "1";
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("is_local_cat_collapsed", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function label_local_add_article(id, label_id) {
|
||||||
|
try {
|
||||||
|
debug("label_local_add_article " + id + " => " + label_id);
|
||||||
|
|
||||||
|
var rs = db.execute("SELECT COUNT(id) FROM article_labels WHERE "+
|
||||||
|
"id = ? AND label_id = ?", [id, label_id]);
|
||||||
|
var check = rs.field(0);
|
||||||
|
|
||||||
|
if (rs.isValidRow()) {
|
||||||
|
var check = rs.field(0);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
|
||||||
|
if (check == 0) {
|
||||||
|
db.execute("INSERT INTO article_labels (id, label_id) VALUES "+
|
||||||
|
"(?,?)", [id, label_id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("label_local_add_article", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue