Compare commits

...
This repository has been archived on 2025-08-18. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.

10 commits

Author SHA1 Message Date
Jeena
348725476b fixed urlify 2014-02-21 12:05:10 +01:00
Jeena
a70306da82 added keyboard shortcuts 2014-02-21 11:55:25 +01:00
Jeena
2d5e1f00e7 fixes after revert 2014-02-21 11:48:49 +01:00
Jeena
01cb207b65 some reverts 2014-02-21 11:35:58 +01:00
Jeena
5d3be078b4 merge 2014-02-21 11:21:49 +01:00
Jeena
92ad94c1d8 fixed css a bit and logout 2014-02-21 11:15:21 +01:00
Jeena
4dba0ea078 removed owncloud and ttrss 2014-02-21 11:02:50 +01:00
Jeena
5b252e56b3 removed owncloud and ttrss 2014-02-21 11:02:08 +01:00
Jeena
5a0950a8ee login only with pond now 2014-02-21 11:01:11 +01:00
Jeena
69c5c270ad first steps to indienotes 2014-02-06 21:10:00 +01:00
8 changed files with 64 additions and 466 deletions

View file

@ -165,6 +165,7 @@ canvas {
list-style-type: none;
margin: 0;
padding: 0;
word-wrap: break-word;
}
#list p {
@ -188,6 +189,7 @@ canvas {
#list li {
position: relative;
min-height: 3em;
}
.red #list li { border-bottom: 1px solid #c0392b; }
@ -199,7 +201,7 @@ canvas {
content: "";
position: absolute;
right: 7px;
top: 0.1em;
top: 0;
font-weight: 100;
font-size: 3em;
font-family: "Entypo";
@ -248,6 +250,7 @@ canvas {
font-weight: normal;
margin: 0;
padding: 0;
display: none;
}
#full .wrapper {
@ -278,9 +281,28 @@ canvas {
padding: 0;
}
#full article header p:nth-child(1) {
float: left;
}
#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;
padding-bottom: 3em;
font-size: 1.3em;
}
#full footer.bar {
margin: auto 0 0 0;
position: relative;
position: fixed;
height: 3.8em;
}

View file

@ -94,8 +94,8 @@
<article>
<header>
<p><span class="feed_title"></span> <span class="author"></span></p>
<h1><a class="title" href="" target="_blank"></a></h1>
<p><timedate class="date"></timedate></p>
<p><a class="link" href="" target="_blank"></a></p>
</header>
<div class="article"></div>
<div class="info swipe">

View file

@ -7,6 +7,20 @@ 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();
} else if(e.keyCode == 13) {
_this.openInBrowser();
} else if(e.keyCode == 82) {
_this.reload();
}
}
};
App.prototype.authenticate = function() {
@ -14,11 +28,11 @@ 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;
@ -182,8 +196,10 @@ App.prototype.populateList = function() {
html_str += "<li"+ (article.unread ? " class='unread'" : "") +">";
html_str += "<a href='#full-"+i+"'>";
html_str += "<p class='title'>" + article.feed_title + "</p>";
html_str += "<h2>" + article.title + "</h2>";
if(article.excerpt) html_str += "<p class='excerpt'>" + article.excerpt + "</p>";
var content = article.content.stripHTML();
if(content.replace(/^\s+|\s+$/g,'').length == 0) content = article.title;
html_str += "<h2>" + content + "</h2>";
//if(article.excerpt) html_str += "<p class='excerpt'>" + article.excerpt + "</p>";
html_str += "</a></li>";
}
@ -274,9 +290,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;
@ -284,7 +300,9 @@ App.prototype.showFull = function(article, slide_back) {
if(article.author && article.author.length > 0)
$(page_id + " .author").innerHTML = "&ndash; " + 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";
});
@ -325,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

View file

@ -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;

View file

@ -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();
}

View file

@ -193,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;
}

View file

@ -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));
}

View file

@ -63,5 +63,10 @@ String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
String.prototype.urlify = function() {
var exp = /[^\>](https?:\/\/[^\s\<]*)/ig;
return this.replace(exp," <a href='$1'>$1</a>");
}
if(!window.app) window.app = new App();