From 69c5c270ad145a5f860a29fe0c11d2464a550e33 Mon Sep 17 00:00:00 2001 From: Jeena Date: Thu, 6 Feb 2014 21:10:00 +0100 Subject: [PATCH 1/9] first steps to indienotes --- css/screen.css | 18 +++++++++++++++++- js/App.js | 6 ++++-- js/Pond.js | 4 +++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/css/screen.css b/css/screen.css index 7c14659..d1b2fe4 100644 --- a/css/screen.css +++ b/css/screen.css @@ -188,6 +188,7 @@ canvas { #list li { position: relative; + min-height: 3em; } .red #list li { border-bottom: 1px solid #c0392b; } @@ -199,7 +200,7 @@ canvas { content: ""; position: absolute; right: 7px; - top: 0.1em; + top: 0; font-weight: 100; font-size: 3em; font-family: "Entypo"; @@ -248,6 +249,7 @@ canvas { font-weight: normal; margin: 0; padding: 0; + display: none; } #full .wrapper { @@ -278,6 +280,20 @@ canvas { padding: 0; } +#full article header p:nth-child(1) { + float: left; +} + +#full article header p:nth-child(3) { + float: right; +} + +#full .article { + clear: both; + padding-top: 1em; + font-size: 1.3em; +} + #full footer.bar { margin: auto 0 0 0; position: relative; diff --git a/js/App.js b/js/App.js index c874b84..bbcc0dd 100644 --- a/js/App.js +++ b/js/App.js @@ -182,8 +182,10 @@ App.prototype.populateList = function() { html_str += ""; html_str += ""; html_str += "

" + article.feed_title + "

"; - html_str += "

" + article.title + "

"; - if(article.excerpt) html_str += "

" + article.excerpt + "

"; + var content = article.content.stripHTML(); + if(content.replace(/^\s+|\s+$/g,'').length == 0) content = article.title; + html_str += "

" + content + "

"; + //if(article.excerpt) html_str += "

" + article.excerpt + "

"; html_str += "
"; } diff --git a/js/Pond.js b/js/Pond.js index 501494c..cdea2b0 100644 --- a/js/Pond.js +++ b/js/Pond.js @@ -76,7 +76,7 @@ Pond.prototype.reload = function(callback) { Pond.prototype.getUnreadFeeds = function(callback, skip) { var options = { - status: "unread", + status: "all", limit: 100 }; @@ -134,6 +134,8 @@ Pond.prototype.normalizeArticle = function(article) { var timestamp = new Date(article.published_at).getTime() / 1000; + console.log(article.read) + return { id: article.id, guid_hash: article.url + article.id, From 5a0950a8ee59d049a6a40e76055631cd1701afc6 Mon Sep 17 00:00:00 2001 From: Jeena Date: Fri, 21 Feb 2014 11:01:11 +0100 Subject: [PATCH 2/9] login only with pond now --- css/screen.css | 7 ++++++- index.html | 7 ------- js/App.js | 26 +++++++++++++++++++++----- js/Login.js | 20 +++----------------- js/Pond.js | 10 ++++------ js/application.js | 5 +++++ 6 files changed, 39 insertions(+), 36 deletions(-) diff --git a/css/screen.css b/css/screen.css index d1b2fe4..6fbf34a 100644 --- a/css/screen.css +++ b/css/screen.css @@ -165,6 +165,7 @@ canvas { list-style-type: none; margin: 0; padding: 0; + word-wrap: break-word; } #list p { @@ -284,10 +285,14 @@ canvas { float: left; } -#full article header p:nth-child(3) { +#full article header p:nth-child(2) { float: right; } +#full article header p:nth-child(3) { + clear: both; +} + #full .article { clear: both; padding-top: 1em; diff --git a/index.html b/index.html index feaa4f4..9686112 100644 --- a/index.html +++ b/index.html @@ -64,14 +64,7 @@ -

- - - -

- - diff --git a/js/App.js b/js/App.js index bbcc0dd..b577d17 100644 --- a/js/App.js +++ b/js/App.js @@ -7,6 +7,16 @@ function App() { if(!color) color = "red"; this.setColor(color); this.fontChange(); + + var _this = this; + + window.onkeydown = function(e) { + if(e.keyCode == 39) { + _this.showNext(); + } else if(e.keyCode == 37) { + _this.showPrevious(); + } + } }; App.prototype.authenticate = function() { @@ -15,10 +25,13 @@ App.prototype.authenticate = function() { App.prototype.after_login = function(backend) { + /* var request = window.navigator.mozApps.getSelf(); request.onsuccess = function() { - $("#version").innerHTML = request.result.manifest.version; - } + if(request.result) { + $("#version").innerHTML = request.result.manifest.version; + } + }*/ var _this = this; @@ -276,8 +289,8 @@ App.prototype.showFull = function(article, slide_back) { $(page_id + " .date").innerHTML = (new Date(parseInt(article.updated, 10) * 1000)).toLocaleString(); - var title = $(page_id + " .title"); - title.innerHTML = article.title; + var title = $(page_id + " .link"); + title.innerHTML = article.link; title.href = article.link; $(page_id + " .feed_title").innerHTML = article.feed_title; @@ -286,7 +299,10 @@ App.prototype.showFull = function(article, slide_back) { if(article.author && article.author.length > 0) $(page_id + " .author").innerHTML = "– " + article.author; - $(page_id + " .article").innerHTML = article.content; + + var content = article.content + if(content.replace(/^\s+|\s+$/g,'').length == 0) content = article.title; + $(page_id + " .article").innerHTML = content.urlify(); $$(page_id + " .article a").forEach(function(o, i) { o.target = "_blank"; }); diff --git a/js/Login.js b/js/Login.js index 72a9490..bc05ba8 100644 --- a/js/Login.js +++ b/js/Login.js @@ -17,19 +17,6 @@ Login.prototype.is_logged_in = function() { Login.prototype.log_in = function() { this.app.changeToPage("#login"); - $("#login form").backend.forEach(function(o, i) { - o.addEventListener("change", function(e) { - if(e.target.checked) { - if(e.target.value == "OwnCloud") { - $("#url").placeholder = "http://example.com/owncloud/"; - } else if(e.target.value == "Pond") { - $("#url").placeholder = "http://example.com/pond/"; - } else { - $("#url").placeholder = "http://example.com/tt-rss/"; - } - } - }); - }); $("#login form").addEventListener('submit', this.authenticate.bind(this)); }; @@ -38,11 +25,10 @@ Login.prototype.authenticate = function(e) { e.preventDefault(); e.stopPropagation(); - var backend = "TinyTinyRSS"; - if($("#login form").backend[1].checked) backend = "OwnCloud"; - else if($("#login form").backend[2].checked) backend = "Pond"; + var backend = "Pond"; - var server_url = $("#url").value; + var server_url = window.location.href.split("#")[0].replace(/\/FeedMonkey\//, ''); + console.log(server_url) var user = $("#un").value; var password = $("#pw").value; diff --git a/js/Pond.js b/js/Pond.js index cdea2b0..5991620 100644 --- a/js/Pond.js +++ b/js/Pond.js @@ -46,7 +46,7 @@ Pond.prototype.doOperation = function(method, operation, new_options, callback) body = a.join("&"); } - var xhr = new XMLHttpRequest({mozSystem: true}); + var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if(xhr.readyState == 4) { if(xhr.status == 200) { @@ -76,7 +76,7 @@ Pond.prototype.reload = function(callback) { Pond.prototype.getUnreadFeeds = function(callback, skip) { var options = { - status: "all", + status: "unread", limit: 100 }; @@ -134,8 +134,6 @@ Pond.prototype.normalizeArticle = function(article) { var timestamp = new Date(article.published_at).getTime() / 1000; - console.log(article.read) - return { id: article.id, guid_hash: article.url + article.id, @@ -195,7 +193,7 @@ Pond.prototype.setArticleUnstarred = function(articles, callback) { } Pond.prototype.logOut = function() { - this.doOperation("auth/sessions/" + this.session_token ); + this.doOperation("DELETE", "auth/sessions/" + this.session_token ); localStorage.feeds = null; } @@ -209,7 +207,7 @@ Pond.login = function(server_url, user, password, callback) { var password_hash = md5(user + ':' + password) var options = "username=" + user.toLowerCase() + "&" + "password=" + password_hash; - var xhr = new XMLHttpRequest({mozSystem: true}); + var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if(xhr.readyState == 4) { if(xhr.status == 201) { diff --git a/js/application.js b/js/application.js index 5e38312..e20c39b 100644 --- a/js/application.js +++ b/js/application.js @@ -63,5 +63,10 @@ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } +String.prototype.urlify = function() { + var exp = /^\>(\b(http):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; + return this.replace(exp,"$1"); +} + if(!window.app) window.app = new App(); From 5b252e56b3d2485673c024a21d03da9940f9cb05 Mon Sep 17 00:00:00 2001 From: Jeena Date: Fri, 21 Feb 2014 11:02:08 +0100 Subject: [PATCH 3/9] removed owncloud and ttrss --- js/OwnCloud.js | 254 ---------------------------------------------- js/TinyTinyRSS.js | 183 --------------------------------- 2 files changed, 437 deletions(-) delete mode 100644 js/OwnCloud.js delete mode 100644 js/TinyTinyRSS.js diff --git a/js/OwnCloud.js b/js/OwnCloud.js deleted file mode 100644 index 15776f1..0000000 --- a/js/OwnCloud.js +++ /dev/null @@ -1,254 +0,0 @@ -function OwnCloud(app, server_url, user_pass_btoa) { - this.app = app; - this.server_url = server_url; - this.session_id = user_pass_btoa; - this.feeds = {}; - var feeds = localStorage.feeds; - if(feeds) this.feeds = JSON.parse(feeds); - - window.addEventListener("offline", this.onoffline.bind(this)); - window.addEventListener("online", this.ononline.bind(this)); -} - -OwnCloud.prototype.onoffline = function() { - // Do nothing -}; - -OwnCloud.prototype.ononline = function() { - - ["read", "unread", "starred", "unstarred"].forEach(function(type) { - var articles = localStorage[type + "_articles"]; - if(articles) { - var callback = function(ok) { if(ok) localStorage[type + "_articles"] = null } - this.call("setArticles" + type.capitalize(), [JSON.parse(articles), callback]); - } - }); -}; - -OwnCloud.prototype.doOperation = function(method, operation, new_options, callback) { - if(!navigator.onLine) { - callback(null); - return; - } - - var url = this.server_url + "/index.php/apps/news/api/v1-2/" + operation; - var options = {}; - - for (var key in new_options) { - options[key] = new_options[key]; - } - - if(method == "GET" || method == "HEAD") { - var a = []; - for(var key in options) { - a.push(key + "=" + options[key]); - } - url += "?" + a.join("&"); - } - - var xhr = new XMLHttpRequest({mozSystem: true}); - xhr.onreadystatechange = function() { - if(xhr.readyState == 4) { - if(xhr.status == 200) { - if(callback) - callback(JSON.parse(xhr.responseText)); - } else { - if(xhr.status != 0) alert("error: " + xhr.status + " " + xhr.statusText); - if(callback) callback(null); - } - } - } - xhr.open(method, url, true); - xhr.withCredentials = true; - xhr.setRequestHeader('Authorization', 'Basic ' + this.session_id); - var body = JSON.stringify(options); - xhr.send(body); -} - -OwnCloud.prototype.reload = function(callback) { - var _this = this; - this.getFeeds(function() { _this.getUnreadFeeds(callback); }); -}; - -OwnCloud.prototype.getUnreadFeeds = function(callback, skip) { - if(skip) { - skip = skip[skip.length - 1].id; - } - - var options = { - batchSize: 700, - offset: skip || 0, - type: 3, - id: 0, - getRead: false - }; - - var _this = this; - this.doOperation("GET", "items", options, function(data) { - - var items = data.items; - - function isFeedAvailable(o) { - return !!_this.feeds[o.feedId]; - } - - if(items.every(isFeedAvailable)) { - callback(items.map(_this.normalize_article, _this)); - } else { - _this.getFeeds(function() { - callback(items.map(_this.normalize_article, _this)); - }); - } - }); -}; - - -OwnCloud.prototype.toString = function() { - return "OwnCloud" -}; - -OwnCloud.prototype.getFeeds = function(callback) { - var _this = this; - this.doOperation("GET", "feeds", {}, function(data) { - - _this.feeds = {}; - for (var i = 0; i < data.feeds.length; i++) { - var feed = data.feeds[i]; - _this.feeds[feed.id] = feed; - } - - localStorage.feeds = JSON.stringify(_this.feeds); - callback(); - }); -}; - -OwnCloud.prototype.setArticlesRead = function(articles, callback) { - - var options = { - items: articles.map(function(o) { return o.id; }), - }; - - if (navigator.onLine) { - this.doOperation("PUT", "items/read/multiple", options, callback); - } else { - this.append("read_articles", articles); - } -} - -OwnCloud.prototype.setArticleRead = function(article, callback) { - this.setArticlesRead([article], callback); -} - -OwnCloud.prototype.setArticlesUnread = function(articles, callback) { - - var options = { - items: articles.map(function(o) { return o.id; }), - }; - - if (navigator.onLine) this.doOperation("PUT", "items/unread/multiple", options, callback); - else { - this.append("unread_articles", articles); - } -}; - -OwnCloud.prototype.setArticleUnread = function(article, callback) { - this.setArticlesUnread([article], callback); -} - -OwnCloud.prototype.setArticlesStarred = function(articles, callback) { - - var options = { - items: articles.map(function(o) { return { feedId: o.feed_id, guidHash: o.guid_hash }; }) - }; - - if (navigator.onLine) { - this.doOperation("PUT", "items/star/multiple", options, callback); - } else { - this.append("starred_articles", articles); - } -}; - -OwnCloud.prototype.setArticleStarred = function(article, callback) { - this.setArticlesStarred([article], callback); -} - -OwnCloud.prototype.setArticlesUnstarred = function(articles, callback) { - - var options = { - items: articles.map(function(o) { return { feedId: o.feed_id, guidHash: o.guid_hash }; }) - }; - - if (navigator.onLine) { - this.doOperation("PUT", "items/unstar/multiple", options, callback); - } else { - this.append("unstarred_articles", articles); - } -}; - -OwnCloud.prototype.setArticleUnstarred = function(articles, callback) { - this.setArticlesUnstarred([articles], callback); -} - -OwnCloud.prototype.normalize_article = function(article) { - var feed = this.feeds[article.feedId]; - var feed_title = ""; - if(feed) { - feed_title = feed.title; - } - - return { - id: article.id, - guid_hash: article.guidHash, - title: article.title, - content: article.body, - feed_title: feed_title, - feed_id: article.feedId, - excerpt: article.body.stripHTML().substring(0, 100), - updated: article.pubDate, - link: article.link, - marked: article.starred, - unread: article.unread - } -}; - -OwnCloud.prototype.logOut = function() { - this.doOperation("logout"); - localStorage.feeds = null; -}; - -OwnCloud.prototype.getFeedFor = function(o) { - return this.feeds[o.feedId]; -}; - -OwnCloud.prototype.append = function(key, array) { - - var tmp = localStorage[key]; - - if (typeof tmp !== "undefined") tmp = JSON.parse(tmp); - else tmp = []; - - tmp.concat(options.items); - localStorage[key] = JSON.stringify(tmp); -}; - -OwnCloud.login = function(server_url, user, password, callback) { - - var url = server_url + "/index.php/apps/news/api/v1-2/version"; - - var xhr = new XMLHttpRequest({mozSystem: true}); - xhr.onreadystatechange = function() { - if(xhr.readyState == 4) { - if(xhr.status == 200) { - callback(JSON.parse(xhr.responseText)) - } else { - alert("error: " + xhr.status + " " + xhr.statusText) - } - } - } - - xhr.open("GET", url, true); - xhr.withCredentials = true; - var auth = btoa(user + ':' + password); - xhr.setRequestHeader('Authorization', 'Basic ' + auth); - xhr.send(); -} diff --git a/js/TinyTinyRSS.js b/js/TinyTinyRSS.js deleted file mode 100644 index 4479f49..0000000 --- a/js/TinyTinyRSS.js +++ /dev/null @@ -1,183 +0,0 @@ -function TinyTinyRSS(app, server_url, session_id) { - this.app = app; - this.server_url = server_url; - this.session_id = session_id; - - window.addEventListener("offline", this.onoffline.bind(this)); - window.addEventListener("online", this.ononline.bind(this)); -} - -TinyTinyRSS.prototype.onoffline = function() { - // Do nothing -}; - -TinyTinyRSS.prototype.ononline = function() { - - ["read", "unread", "starred", "unstarred"].forEach(function(type) { - var articles = localStorage[type + "_articles"]; - if(articles) { - var callback = function(ok) { if(ok) localStorage[type + "_articles"] = null } - this.call("setArticles" + type.capitalize(), [JSON.parse(articles), callback]); - } - }); -}; - -TinyTinyRSS.prototype.doOperation = function(operation, new_options, callback) { - if(!navigator.onLine) { - callback(null); - return; - } - - var url = this.server_url + "/api/"; - var options = { - sid: this.session_id, - op: operation - }; - - for (var key in new_options) { - options[key] = new_options[key]; - } - - var xhr = new XMLHttpRequest({mozSystem: true}); - xhr.onreadystatechange = function() { - if(xhr.readyState == 4) { - if(xhr.status == 200) { - if(callback) - callback(JSON.parse(xhr.responseText).content); - } else { - if(xhr.status != 0) alert("error: " + xhr.status + " " + xhr.statusText); - if(callback) callback(null); - } - } - } - xhr.open("POST", url, true); - xhr.send(JSON.stringify(options)); -} - -TinyTinyRSS.prototype.reload = function(callback) { - this.getUnreadFeeds(callback, []); -}; - -TinyTinyRSS.prototype.getUnreadFeeds = function(callback, skip) { - skip = skip.length; - var options = { - show_excerpt: false, - view_mode: "unread", - show_content: true, - feed_id: -4, - skip: skip || 0 - }; - - this.doOperation("getHeadlines", options, callback); -} - -TinyTinyRSS.prototype.setArticlesRead = function(articles, callback) { - - var options = { - article_ids: articles.map(function(o) { return o.id }).join(","), - mode: 0, - field: 2 - }; - - if (navigator.onLine) { - this.doOperation("updateArticle", options, callback); - } else { - this.append("read_articles", articles); - } -}; - -TinyTinyRSS.prototype.setArticleRead = function(article, callback) { - this.setArticlesRead([article], callback); -}; - - -TinyTinyRSS.prototype.setArticlesUnread = function(articles, callback) { - - var options = { - article_ids: articles.map(function(o) { return o.id }).join(","), - mode: 1, - field: 2 - }; - - if (navigator.onLine) { - this.doOperation("updateArticle", options, callback); - } else { - this.append("unread_articles", articles); - } -}; - -TinyTinyRSS.prototype.setArticleUnread = function(article, callback) { - this.setArticlesUnread([article], callback); -}; - -TinyTinyRSS.prototype.setArticlesStarred = function(articles, callback) { - - var options = { - article_ids: articles.map(function(o) { return o.id }).join(","), - mode: 1, - field: 0 - }; - - if (navigator.onLine) { - this.doOperation("updateArticle", options); - } else { - this.append("starred_articles", articles); - } -}; - -TinyTinyRSS.prototype.setArticleStarred = function(article, callback) { - this.setArticlesStarred([article], callback); -}; - -TinyTinyRSS.prototype.setArticlesUnstarred = function(articles, callback) { - - var options = { - article_ids: articles.map(function(o) { return o.id}).join(","), - mode: 0, - field: 0 - }; - - if (navigator.onLine) { - this.doOperation("updateArticle", options, callback); - } else { - this.append("unstarred_articles", articles); - } -}; - -TinyTinyRSS.prototype.setArticleUnstarred = function(article, callback) { - this.setArticlesUnstarred([article], callback); -}; - -TinyTinyRSS.prototype.append = function(key, array) { - - var tmp = localStorage[key]; - - if (typeof tmp !== "undefined") tmp = JSON.parse(tmp); - else tmp = []; - - tmp.concat(options.items); - localStorage[key] = JSON.stringify(tmp); -}; - -TinyTinyRSS.prototype.logOut = function() { - this.doOperation("logout"); -}; - -TinyTinyRSS.login = function(server_url, user, password, callback) { - - var url = server_url + "/api/"; - var options = {op: "login", user: user, password: password}; - - var xhr = new XMLHttpRequest({mozSystem: true}); - xhr.onreadystatechange = function() { - if(xhr.readyState == 4) { - if(xhr.status == 200) { - callback(JSON.parse(xhr.responseText).content) - } else { - alert("error: " + xhr.status + " " + xhr.statusText) - } - } - } - xhr.open("POST", url, true); - xhr.send(JSON.stringify(options)); -} From 4dba0ea07847000584f778b9f5516b0d3934eff9 Mon Sep 17 00:00:00 2001 From: Jeena Date: Fri, 21 Feb 2014 11:02:50 +0100 Subject: [PATCH 4/9] removed owncloud and ttrss --- index.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/index.html b/index.html index 9686112..d851058 100644 --- a/index.html +++ b/index.html @@ -10,8 +10,6 @@ - - From 92ad94c1d8a173772b66ebaaefef26985c9a4966 Mon Sep 17 00:00:00 2001 From: Jeena Date: Fri, 21 Feb 2014 11:15:21 +0100 Subject: [PATCH 5/9] fixed css a bit and logout --- css/screen.css | 4 +++- js/App.js | 3 ++- js/Pond.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/css/screen.css b/css/screen.css index d1b2fe4..3c995bf 100644 --- a/css/screen.css +++ b/css/screen.css @@ -291,12 +291,14 @@ canvas { #full .article { clear: both; padding-top: 1em; + padding-bottom: 2.8em; font-size: 1.3em; } #full footer.bar { + bottom: 0; margin: auto 0 0 0; - position: relative; + position: fixed; height: 3.8em; } diff --git a/js/App.js b/js/App.js index bbcc0dd..6354c4e 100644 --- a/js/App.js +++ b/js/App.js @@ -14,11 +14,12 @@ App.prototype.authenticate = function() { }; App.prototype.after_login = function(backend) { - + /* var request = window.navigator.mozApps.getSelf(); request.onsuccess = function() { $("#version").innerHTML = request.result.manifest.version; } + */ var _this = this; diff --git a/js/Pond.js b/js/Pond.js index cdea2b0..8765ce2 100644 --- a/js/Pond.js +++ b/js/Pond.js @@ -195,7 +195,7 @@ Pond.prototype.setArticleUnstarred = function(articles, callback) { } Pond.prototype.logOut = function() { - this.doOperation("auth/sessions/" + this.session_token ); + this.doOperation("DELETE", "auth/sessions/" + this.session_token ); localStorage.feeds = null; } From 01cb207b6562aa82faeb042bdc58101da6bc1335 Mon Sep 17 00:00:00 2001 From: Jeena Date: Fri, 21 Feb 2014 11:35:58 +0100 Subject: [PATCH 6/9] some reverts --- css/screen.css | 10 ++-------- index.html | 9 +++++++++ js/App.js | 24 ++++-------------------- js/Pond.js | 8 +++++--- 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/css/screen.css b/css/screen.css index b5116bd..46bcd45 100644 --- a/css/screen.css +++ b/css/screen.css @@ -165,7 +165,6 @@ canvas { list-style-type: none; margin: 0; padding: 0; - word-wrap: break-word; } #list p { @@ -285,23 +284,18 @@ canvas { float: left; } -#full article header p:nth-child(2) { - float: right; -} - #full article header p:nth-child(3) { - clear: both; + float: right; } #full .article { clear: both; padding-top: 1em; - padding-bottom: 2.8em; + padding-bottom: 3em; font-size: 1.3em; } #full footer.bar { - bottom: 0; margin: auto 0 0 0; position: fixed; height: 3.8em; diff --git a/index.html b/index.html index d851058..feaa4f4 100644 --- a/index.html +++ b/index.html @@ -10,6 +10,8 @@ + + @@ -62,7 +64,14 @@

+

+ + + +

+ + diff --git a/js/App.js b/js/App.js index 5b51703..be5ebe6 100644 --- a/js/App.js +++ b/js/App.js @@ -7,16 +7,6 @@ function App() { if(!color) color = "red"; this.setColor(color); this.fontChange(); - - var _this = this; - - window.onkeydown = function(e) { - if(e.keyCode == 39) { - _this.showNext(); - } else if(e.keyCode == 37) { - _this.showPrevious(); - } - } }; App.prototype.authenticate = function() { @@ -27,12 +17,9 @@ App.prototype.after_login = function(backend) { /* var request = window.navigator.mozApps.getSelf(); request.onsuccess = function() { - if(request.result) { - $("#version").innerHTML = request.result.manifest.version; - } + $("#version").innerHTML = request.result.manifest.version; }*/ - var _this = this; window.onhashchange = function(e) { @@ -289,8 +276,8 @@ App.prototype.showFull = function(article, slide_back) { $(page_id + " .date").innerHTML = (new Date(parseInt(article.updated, 10) * 1000)).toLocaleString(); - var title = $(page_id + " .link"); - title.innerHTML = article.link; + var title = $(page_id + " .title"); + title.innerHTML = article.title; title.href = article.link; $(page_id + " .feed_title").innerHTML = article.feed_title; @@ -299,10 +286,7 @@ App.prototype.showFull = function(article, slide_back) { if(article.author && article.author.length > 0) $(page_id + " .author").innerHTML = "– " + article.author; - - var content = article.content - if(content.replace(/^\s+|\s+$/g,'').length == 0) content = article.title; - $(page_id + " .article").innerHTML = content.urlify(); + $(page_id + " .article").innerHTML = article.content; $$(page_id + " .article a").forEach(function(o, i) { o.target = "_blank"; }); diff --git a/js/Pond.js b/js/Pond.js index 5991620..8765ce2 100644 --- a/js/Pond.js +++ b/js/Pond.js @@ -46,7 +46,7 @@ Pond.prototype.doOperation = function(method, operation, new_options, callback) body = a.join("&"); } - var xhr = new XMLHttpRequest(); + var xhr = new XMLHttpRequest({mozSystem: true}); xhr.onreadystatechange = function() { if(xhr.readyState == 4) { if(xhr.status == 200) { @@ -76,7 +76,7 @@ Pond.prototype.reload = function(callback) { Pond.prototype.getUnreadFeeds = function(callback, skip) { var options = { - status: "unread", + status: "all", limit: 100 }; @@ -134,6 +134,8 @@ Pond.prototype.normalizeArticle = function(article) { var timestamp = new Date(article.published_at).getTime() / 1000; + console.log(article.read) + return { id: article.id, guid_hash: article.url + article.id, @@ -207,7 +209,7 @@ Pond.login = function(server_url, user, password, callback) { var password_hash = md5(user + ':' + password) var options = "username=" + user.toLowerCase() + "&" + "password=" + password_hash; - var xhr = new XMLHttpRequest(); + var xhr = new XMLHttpRequest({mozSystem: true}); xhr.onreadystatechange = function() { if(xhr.readyState == 4) { if(xhr.status == 201) { From 2d5e1f00e7d51f2c019c4811736c8c75b7721f39 Mon Sep 17 00:00:00 2001 From: Jeena Date: Fri, 21 Feb 2014 11:48:49 +0100 Subject: [PATCH 7/9] fixes after revert --- css/screen.css | 7 ++++++- index.html | 2 +- js/App.js | 20 ++++++++++++++++---- js/Pond.js | 4 +--- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/css/screen.css b/css/screen.css index 46bcd45..cd9a860 100644 --- a/css/screen.css +++ b/css/screen.css @@ -165,6 +165,7 @@ canvas { list-style-type: none; margin: 0; padding: 0; + word-wrap: break-word; } #list p { @@ -284,10 +285,14 @@ canvas { float: left; } -#full article header p:nth-child(3) { +#full article header p:nth-child(2) { float: right; } +#full article header p:nth-child(3) { + clear: both; +} + #full .article { clear: both; padding-top: 1em; diff --git a/index.html b/index.html index feaa4f4..ff6889e 100644 --- a/index.html +++ b/index.html @@ -94,8 +94,8 @@

-

+

diff --git a/js/App.js b/js/App.js index be5ebe6..593ba29 100644 --- a/js/App.js +++ b/js/App.js @@ -7,6 +7,16 @@ function App() { if(!color) color = "red"; this.setColor(color); this.fontChange(); + + var _this = this; + + window.onkeydown = function(e) { + if(e.keyCode == 39) { + _this.showNext(); + } else if(e.keyCode == 37) { + _this.showPrevious(); + } + } }; App.prototype.authenticate = function() { @@ -276,9 +286,9 @@ App.prototype.showFull = function(article, slide_back) { $(page_id + " .date").innerHTML = (new Date(parseInt(article.updated, 10) * 1000)).toLocaleString(); - var title = $(page_id + " .title"); - title.innerHTML = article.title; - title.href = article.link; + var link = $(page_id + " .link"); + link.innerHTML = article.link; + link.href = article.link; $(page_id + " .feed_title").innerHTML = article.feed_title; @@ -286,7 +296,9 @@ App.prototype.showFull = function(article, slide_back) { if(article.author && article.author.length > 0) $(page_id + " .author").innerHTML = "– " + article.author; - $(page_id + " .article").innerHTML = article.content; + var content = article.content; + if(content.replace(/^\s+|\s+$/g,'').length == 0) content = article.title; + $(page_id + " .article").innerHTML = content; $$(page_id + " .article a").forEach(function(o, i) { o.target = "_blank"; }); diff --git a/js/Pond.js b/js/Pond.js index 8765ce2..1c424a6 100644 --- a/js/Pond.js +++ b/js/Pond.js @@ -76,7 +76,7 @@ Pond.prototype.reload = function(callback) { Pond.prototype.getUnreadFeeds = function(callback, skip) { var options = { - status: "all", + status: "unread", limit: 100 }; @@ -134,8 +134,6 @@ Pond.prototype.normalizeArticle = function(article) { var timestamp = new Date(article.published_at).getTime() / 1000; - console.log(article.read) - return { id: article.id, guid_hash: article.url + article.id, From a70306da82626b9f8cdc2c632fbd06c8a7610f00 Mon Sep 17 00:00:00 2001 From: Jeena Date: Fri, 21 Feb 2014 11:55:25 +0100 Subject: [PATCH 8/9] added keyboard shortcuts --- js/App.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/App.js b/js/App.js index 593ba29..d2cb11e 100644 --- a/js/App.js +++ b/js/App.js @@ -15,6 +15,10 @@ function App() { _this.showNext(); } else if(e.keyCode == 37) { _this.showPrevious(); + } else if(e.keyCode == 13) { + _this.openInBrowser(); + } else if(e.keyCode == 82) { + _this.reload(); } } }; @@ -298,7 +302,7 @@ App.prototype.showFull = function(article, slide_back) { var content = article.content; if(content.replace(/^\s+|\s+$/g,'').length == 0) content = article.title; - $(page_id + " .article").innerHTML = content; + $(page_id + " .article").innerHTML = content.urlify(); $$(page_id + " .article a").forEach(function(o, i) { o.target = "_blank"; }); @@ -339,6 +343,10 @@ App.prototype.showPrevious = function() { } }; +App.prototype.openInBrowser = function() { + $("#full .link").click(); +}; + App.prototype.setCurrentRead = function() { var article = this.unread_articles[this.currentIndex]; if(!article) return; // happens if we're not on a full article site From 348725476bfbb052cf01ac8629d231c359a6f71d Mon Sep 17 00:00:00 2001 From: Jeena Date: Fri, 21 Feb 2014 12:05:10 +0100 Subject: [PATCH 9/9] fixed urlify --- js/application.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/application.js b/js/application.js index e20c39b..ebacb08 100644 --- a/js/application.js +++ b/js/application.js @@ -64,8 +64,8 @@ String.prototype.capitalize = function() { } String.prototype.urlify = function() { - var exp = /^\>(\b(http):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; - return this.replace(exp,"$1"); + var exp = /[^\>](https?:\/\/[^\s\<]*)/ig; + return this.replace(exp," $1"); } if(!window.app) window.app = new App();