Merge pull request #39 from Bonbadil/master
Add a publish button on article view for TTRSS.
This commit is contained in:
commit
7c63205d36
4 changed files with 70 additions and 2 deletions
|
@ -120,11 +120,14 @@ section > header h1 {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.reload, .all-read, #setstarred, #setunread {
|
.reload, .all-read, #setstarred, #setunread, #setpublished {
|
||||||
float: right;
|
float: right;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#setpublished { display: none;}
|
||||||
|
#setpublished.active { display: inline;}
|
||||||
|
|
||||||
.settings, .list {
|
.settings, .list {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<section id="full">
|
<section id="full">
|
||||||
<header class="bar">
|
<header class="bar">
|
||||||
<a class="button icon list" href="#list"></a>
|
<a class="button icon list" href="#list"></a>
|
||||||
|
<a id="setpublished" class="button icon" href="#published">☁</a>
|
||||||
<a id="setstarred" class="button icon" href="#starred">☆</a>
|
<a id="setstarred" class="button icon" href="#starred">☆</a>
|
||||||
<a id="setunread" class="button icon" href="#unread">✓</a>
|
<a id="setunread" class="button icon" href="#unread">✓</a>
|
||||||
<canvas width="40" height="40"></canvas>
|
<canvas width="40" height="40"></canvas>
|
||||||
|
|
26
js/App.js
26
js/App.js
|
@ -54,6 +54,8 @@ App.prototype.after_login = function(backend) {
|
||||||
_this.toggleCurrentUnread();
|
_this.toggleCurrentUnread();
|
||||||
} else if(url == "#starred") {
|
} else if(url == "#starred") {
|
||||||
_this.toggleStarred();
|
_this.toggleStarred();
|
||||||
|
} else if(url == "#published") {
|
||||||
|
_this.togglePublished();
|
||||||
} else if(url == "#logout") {
|
} else if(url == "#logout") {
|
||||||
_this.logout();
|
_this.logout();
|
||||||
} else if(url == "#reset-info") {
|
} else if(url == "#reset-info") {
|
||||||
|
@ -109,6 +111,7 @@ App.prototype.after_login = function(backend) {
|
||||||
this.backend = new Pond(this, localStorage.server_url, localStorage.session_id)
|
this.backend = new Pond(this, localStorage.server_url, localStorage.session_id)
|
||||||
} else {
|
} else {
|
||||||
this.backend = new TinyTinyRSS(this, localStorage.server_url, localStorage.session_id);
|
this.backend = new TinyTinyRSS(this, localStorage.server_url, localStorage.session_id);
|
||||||
|
$("#setpublished").addClass("active");
|
||||||
}
|
}
|
||||||
|
|
||||||
var numArticles = localStorage.numArticles;
|
var numArticles = localStorage.numArticles;
|
||||||
|
@ -346,6 +349,12 @@ App.prototype.showFull = function(article, slide_back) {
|
||||||
$("#setstarred").innerHTML = "☆";
|
$("#setstarred").innerHTML = "☆";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(article.published) {
|
||||||
|
$("#setpublished").innerHTML = "";
|
||||||
|
} else {
|
||||||
|
$("#setpublished").innerHTML = "☁";
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
App.prototype.showNext = function() {
|
App.prototype.showNext = function() {
|
||||||
|
@ -455,6 +464,23 @@ App.prototype.toggleStarred = function() {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
App.prototype.togglePublished = function() {
|
||||||
|
var article = this.unread_articles[this.currentIndex];
|
||||||
|
if(!article) return; // happens if we're not on a full article site
|
||||||
|
|
||||||
|
if(!article.published) {
|
||||||
|
article.published = true;
|
||||||
|
this.backend.setArticlePublished(article);
|
||||||
|
$("#setpublished").innerHTML = "";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
article.published = false;
|
||||||
|
this.backend.setArticleUnpublished(article);
|
||||||
|
$("#setpublished").innerHTML = "☁";
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
App.prototype.goToList = function() {
|
App.prototype.goToList = function() {
|
||||||
this.changeToPage("#list");
|
this.changeToPage("#list");
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@ TinyTinyRSS.prototype.onoffline = function() {
|
||||||
|
|
||||||
TinyTinyRSS.prototype.ononline = function() {
|
TinyTinyRSS.prototype.ononline = function() {
|
||||||
|
|
||||||
["read", "unread", "starred", "unstarred"].forEach(function(type) {
|
["read", "unread", "starred", "unstarred", "published", "unpublished"].forEach(function(type) {
|
||||||
var articles = localStorage[type + "_articles"];
|
var articles = localStorage[type + "_articles"];
|
||||||
if(articles) {
|
if(articles) {
|
||||||
var callback = function(ok) { if(ok) localStorage[type + "_articles"] = null }
|
var callback = function(ok) { if(ok) localStorage[type + "_articles"] = null }
|
||||||
|
@ -149,6 +149,44 @@ TinyTinyRSS.prototype.setArticleUnstarred = function(article, callback) {
|
||||||
this.setArticlesUnstarred([article], callback);
|
this.setArticlesUnstarred([article], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TinyTinyRSS.prototype.setArticlesPublished = function(articles, callback) {
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
article_ids: articles.map(function(o) { return o.id }).join(","),
|
||||||
|
mode: 1,
|
||||||
|
field: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
if (navigator.onLine) {
|
||||||
|
this.doOperation("updateArticle", options);
|
||||||
|
} else {
|
||||||
|
this.append("published_articles", articles);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TinyTinyRSS.prototype.setArticlePublished = function(article, callback) {
|
||||||
|
this.setArticlesPublished([article], callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
TinyTinyRSS.prototype.setArticlesUnpublished = function(articles, callback) {
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
article_ids: articles.map(function(o) { return o.id}).join(","),
|
||||||
|
mode: 0,
|
||||||
|
field: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
if (navigator.onLine) {
|
||||||
|
this.doOperation("updateArticle", options, callback);
|
||||||
|
} else {
|
||||||
|
this.append("unpublished_articles", articles);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TinyTinyRSS.prototype.setArticleUnpublished = function(article, callback) {
|
||||||
|
this.setArticlesUnpublished([article], callback);
|
||||||
|
};
|
||||||
|
|
||||||
TinyTinyRSS.prototype.append = function(key, array) {
|
TinyTinyRSS.prototype.append = function(key, array) {
|
||||||
var tmp = localStorage[key];
|
var tmp = localStorage[key];
|
||||||
|
|
||||||
|
|
Reference in a new issue