basic functionality pass 10
This commit is contained in:
parent
857a92708b
commit
331900c642
56
backend.php
56
backend.php
|
@ -11,10 +11,11 @@
|
||||||
pg_query("set client_encoding = 'utf-8'");
|
pg_query("set client_encoding = 'utf-8'");
|
||||||
|
|
||||||
$op = $_GET["op"];
|
$op = $_GET["op"];
|
||||||
|
$fetch = $_GET["fetch"];
|
||||||
|
|
||||||
if ($op == "feeds") {
|
if ($op == "feeds") {
|
||||||
|
|
||||||
update_all_feeds($link);
|
if ($fetch) update_all_feeds($link);
|
||||||
|
|
||||||
$result = pg_query("SELECT *,
|
$result = pg_query("SELECT *,
|
||||||
(SELECT count(id) FROM ttrss_entries
|
(SELECT count(id) FROM ttrss_entries
|
||||||
|
@ -53,7 +54,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
print "<tr><td class=\"footer\" colspan=\"3\">
|
print "<tr><td class=\"footer\" colspan=\"3\">
|
||||||
<a href=\"javascript:update_feed_list()\">Update all feeds</a></td></tr>";
|
<a href=\"javascript:update_feed_list(false,true)\">Update all feeds</a></td></tr>";
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
|
@ -201,9 +202,43 @@
|
||||||
|
|
||||||
if ($op == "pref-feeds") {
|
if ($op == "pref-feeds") {
|
||||||
|
|
||||||
|
$subop = $_GET["subop"];
|
||||||
|
|
||||||
|
if ($subop == "edit") {
|
||||||
|
print "<p>[Edit feed placeholder]</p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($subop == "remove") {
|
||||||
|
$ids = split(",", $_GET["ids"]);
|
||||||
|
|
||||||
|
foreach ($ids as $id) {
|
||||||
|
pg_query("BEGIN");
|
||||||
|
pg_query("DELETE FROM ttrss_entries WHERE feed_id = '$id'");
|
||||||
|
pg_query("DELETE FROM ttrss_feeds WHERE id = '$id'");
|
||||||
|
pg_query("COMMIT");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($subop == "add") {
|
||||||
|
$feed_link = pg_escape_string($_GET["link"]);
|
||||||
|
|
||||||
|
$result = pg_query(
|
||||||
|
"INSERT INTO ttrss_feeds (feed_url,title) VALUES ('$feed_link', '')");
|
||||||
|
|
||||||
|
$result = pg_query("SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'");
|
||||||
|
|
||||||
|
$feed_id = pg_fetch_result($result, 0, "id");
|
||||||
|
|
||||||
|
if ($feed_id) {
|
||||||
|
update_rss_feed($link, $feed_link, $feed_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$result = pg_query("SELECT * FROM ttrss_feeds ORDER by title");
|
$result = pg_query("SELECT * FROM ttrss_feeds ORDER by title");
|
||||||
|
|
||||||
print "<p><table width=\"100%\" class=\"prefFeedList\">";
|
print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">";
|
||||||
print "<tr class=\"title\">
|
print "<tr class=\"title\">
|
||||||
<td>Select</td><td>Title</td><td>Link</td><td>Last Updated</td></tr>";
|
<td>Select</td><td>Title</td><td>Link</td><td>Last Updated</td></tr>";
|
||||||
|
|
||||||
|
@ -212,13 +247,18 @@
|
||||||
while ($line = pg_fetch_assoc($result)) {
|
while ($line = pg_fetch_assoc($result)) {
|
||||||
|
|
||||||
$class = ($lnum % 2) ? "even" : "odd";
|
$class = ($lnum % 2) ? "even" : "odd";
|
||||||
|
|
||||||
print "<tr class=\"$class\">";
|
$feed_id = $line["id"];
|
||||||
|
|
||||||
|
print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">";
|
||||||
|
|
||||||
print "<td><input onclick='toggleSelectRow(this);'
|
print "<td><input onclick='toggleSelectRow(this);'
|
||||||
type=\"checkbox\" id=\"FROW-".$line["id"]."\"></td>";
|
type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
|
||||||
print "<td>" . $line["title"] . "</td>";
|
print "<td><a href=\"javascript:editFeed($feed_id);\">" .
|
||||||
print "<td>" . $line["feed_url"] . "</td>";
|
$line["title"] . "</td>";
|
||||||
|
print "<td><a href=\"javascript:editFeed($feed_id);\">" .
|
||||||
|
$line["feed_url"] . "</td>";
|
||||||
|
|
||||||
print "<td>" . $line["last_updated"] . "</td>";
|
print "<td>" . $line["last_updated"] . "</td>";
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
function update_all_feeds($link) {
|
function update_all_feeds($link) {
|
||||||
|
|
||||||
$result = pg_query($link, "SELECT feed_url,id FROM ttrss_feeds WHERE
|
$result = pg_query($link, "SELECT feed_url,id FROM ttrss_feeds WHERE
|
||||||
last_updated is null OR
|
last_updated is null OR title = '' OR
|
||||||
EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) > " .
|
EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) > " .
|
||||||
MIN_UPDATE_TIME);
|
MIN_UPDATE_TIME);
|
||||||
|
|
||||||
|
@ -19,6 +19,16 @@
|
||||||
$rss = fetch_rss($feed_url);
|
$rss = fetch_rss($feed_url);
|
||||||
|
|
||||||
if ($rss) {
|
if ($rss) {
|
||||||
|
|
||||||
|
$result = pg_query("SELECT title FROM ttrss_feeds WHERE id = '$feed'");
|
||||||
|
|
||||||
|
$registered_title = pg_fetch_result($result, 0, "title");
|
||||||
|
|
||||||
|
if (!$registered_title) {
|
||||||
|
|
||||||
|
$feed_title = $rss->channel["title"];
|
||||||
|
pg_query("UPDATE ttrss_feeds SET title = '$feed_title' WHERE id = '$feed'");
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($rss->items as $item) {
|
foreach ($rss->items as $item) {
|
||||||
|
|
||||||
|
@ -30,7 +40,9 @@
|
||||||
$entry_timestamp = $item["pubdate"];
|
$entry_timestamp = $item["pubdate"];
|
||||||
if (!$entry_timestamp) $entry_timestamp = $item["modified"];
|
if (!$entry_timestamp) $entry_timestamp = $item["modified"];
|
||||||
if (!$entry_timestamp) $entry_timestamp = $item["updated"];
|
if (!$entry_timestamp) $entry_timestamp = $item["updated"];
|
||||||
|
|
||||||
|
if (!$entry_timestamp) continue;
|
||||||
|
|
||||||
$entry_timestamp = strtotime($entry_timestamp);
|
$entry_timestamp = strtotime($entry_timestamp);
|
||||||
|
|
||||||
if (!$entry_timestamp) continue;
|
if (!$entry_timestamp) continue;
|
||||||
|
|
86
prefs.js
86
prefs.js
|
@ -24,33 +24,6 @@ if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
|
||||||
xmlhttp = new XMLHttpRequest();
|
xmlhttp = new XMLHttpRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
function param_escape(arg) {
|
|
||||||
if (typeof encodeURIComponent != 'undefined')
|
|
||||||
return encodeURIComponent(arg);
|
|
||||||
else
|
|
||||||
return escape(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function param_unescape(arg) {
|
|
||||||
if (typeof decodeURIComponent != 'undefined')
|
|
||||||
return decodeURIComponent(arg);
|
|
||||||
else
|
|
||||||
return unescape(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function notify(msg) {
|
|
||||||
|
|
||||||
var n = document.getElementById("notify");
|
|
||||||
|
|
||||||
n.innerHTML = msg;
|
|
||||||
|
|
||||||
if (msg.length == 0) {
|
|
||||||
n.style.display = "none";
|
|
||||||
} else {
|
|
||||||
n.style.display = "block";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function feedlist_callback() {
|
function feedlist_callback() {
|
||||||
var container = document.getElementById('feeds');
|
var container = document.getElementById('feeds');
|
||||||
|
@ -85,13 +58,62 @@ function toggleSelectRow(sender) {
|
||||||
|
|
||||||
function addFeed() {
|
function addFeed() {
|
||||||
|
|
||||||
var link = document.getElementById("fadd_link").value;
|
var link = document.getElementById("fadd_link");
|
||||||
var title = document.getElementById("fadd_title").value;
|
|
||||||
|
|
||||||
if (link.length == 0 || title.length == 0) {
|
if (link.length == 0) {
|
||||||
notify("Error: all fields must be filled in.");
|
notify("Missing feed URL.");
|
||||||
} else {
|
} else {
|
||||||
notify("addFeed : " + link + ", " + title);
|
notify("Adding feed...");
|
||||||
|
|
||||||
|
xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
|
||||||
|
param_escape(link.value), true);
|
||||||
|
xmlhttp.onreadystatechange=feedlist_callback;
|
||||||
|
xmlhttp.send(null);
|
||||||
|
|
||||||
|
link.value = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function editFeed(feed) {
|
||||||
|
|
||||||
|
notify("Editing feed...");
|
||||||
|
|
||||||
|
xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
|
||||||
|
param_escape(feed), true);
|
||||||
|
xmlhttp.onreadystatechange=feedlist_callback;
|
||||||
|
xmlhttp.send(null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function removeSelectedFeeds() {
|
||||||
|
|
||||||
|
var content = document.getElementById("prefFeedList");
|
||||||
|
|
||||||
|
var sel_rows = new Array();
|
||||||
|
|
||||||
|
for (i = 0; i < content.rows.length; i++) {
|
||||||
|
if (content.rows[i].className.match("Selected")) {
|
||||||
|
var row_id = content.rows[i].id.replace("FEEDR-", "");
|
||||||
|
sel_rows.push(row_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sel_rows.length > 0) {
|
||||||
|
|
||||||
|
notify("Removing selected feeds...");
|
||||||
|
|
||||||
|
xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
|
||||||
|
param_escape(sel_rows.toString()), true);
|
||||||
|
xmlhttp.onreadystatechange=feedlist_callback;
|
||||||
|
xmlhttp.send(null);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
notify("Please select some feeds first.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
19
prefs.php
19
prefs.php
|
@ -2,6 +2,7 @@
|
||||||
<head>
|
<head>
|
||||||
<title>Tiny Tiny RSS</title>
|
<title>Tiny Tiny RSS</title>
|
||||||
<link rel="stylesheet" href="tt-rss.css" type="text/css">
|
<link rel="stylesheet" href="tt-rss.css" type="text/css">
|
||||||
|
<script type="text/javascript" src="functions.js"></script>
|
||||||
<script type="text/javascript" src="prefs.js"></script>
|
<script type="text/javascript" src="prefs.js"></script>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
</head>
|
</head>
|
||||||
|
@ -23,27 +24,19 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tr>
|
</tr>
|
||||||
<td class="content" id="content" valign="top" colspan="2">
|
<td class="prefContent" valign="top" colspan="2">
|
||||||
<h2>Feed Configuration</h2>
|
<h2>Feed Configuration</h2>
|
||||||
|
|
||||||
<!-- <input type="submit" value="Add feed"> -->
|
|
||||||
|
|
||||||
<!-- <table class="prefAddFeed">
|
|
||||||
<tr><td>Title:</td><td><input id="fadd_title"></td></tr>
|
|
||||||
<tr><td>Link:</td><td><input id="fadd_link"></td></tr>
|
|
||||||
<tr><td colspan="2" align="right">
|
|
||||||
<a class="button" href="javascript:addFeed()">Add feed</a></td></tr>
|
|
||||||
</table> -->
|
|
||||||
|
|
||||||
<table class="prefAddFeed">
|
<table class="prefAddFeed">
|
||||||
<tr><td>Title:</td><td><input id="fadd_title"></td>
|
<td><input id="fadd_link"></td>
|
||||||
<td>Link:</td><td><input id="fadd_link"></td></tr>
|
<td colspan="4" align="right">
|
||||||
<tr><td colspan="4" align="right">
|
|
||||||
<a class="button" href="javascript:addFeed()">Add feed</a></td></tr>
|
<a class="button" href="javascript:addFeed()">Add feed</a></td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div id="feeds"> </div>
|
<div id="feeds"> </div>
|
||||||
|
|
||||||
|
<p><a class="button" href="javascript:removeSelectedFeeds()">Remove Selected</a>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
44
tt-rss.css
44
tt-rss.css
|
@ -32,22 +32,6 @@ a:hover {
|
||||||
color : #5050aa;
|
color : #5050aa;
|
||||||
}
|
}
|
||||||
|
|
||||||
a.button {
|
|
||||||
border : 1px solid #d0d0d0;
|
|
||||||
background-image : url("button.png");
|
|
||||||
background-position : top;
|
|
||||||
background-repeat : repeat-x;
|
|
||||||
background-color : white;
|
|
||||||
color : black;
|
|
||||||
padding : 2px 10px 2px 10px;
|
|
||||||
font-size : small;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.button:hover {
|
|
||||||
background : white;
|
|
||||||
text-decoration : none;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.feedOverview {
|
table.feedOverview {
|
||||||
margin : 5px;
|
margin : 5px;
|
||||||
border : 1px solid #c0c0c0;
|
border : 1px solid #c0c0c0;
|
||||||
|
@ -112,7 +96,7 @@ table.main td.toolbar {
|
||||||
font-weight : bold;
|
font-weight : bold;
|
||||||
border : 1px solid #c0c0c0;
|
border : 1px solid #c0c0c0;
|
||||||
font-size : small;
|
font-size : small;
|
||||||
display : block;
|
display : none;
|
||||||
background : white;
|
background : white;
|
||||||
-moz-border-radius : 5px;
|
-moz-border-radius : 5px;
|
||||||
padding : 3px 10px 3px 10px;
|
padding : 3px 10px 3px 10px;
|
||||||
|
@ -149,12 +133,18 @@ table.main td.headlines {
|
||||||
overflow : scroll;
|
overflow : scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.main td.prefContent {
|
||||||
|
padding : 10px;
|
||||||
|
border-width : 1px 0px 0px 0px;
|
||||||
|
border-color : #c0c0c0;
|
||||||
|
border-style : solid;
|
||||||
|
}
|
||||||
|
|
||||||
table.main td.content {
|
table.main td.content {
|
||||||
padding : 10px;
|
padding : 10px;
|
||||||
border-width : 1px 0px 0px 0px;
|
border-width : 1px 0px 0px 0px;
|
||||||
border-color : #c0c0c0;
|
border-color : #c0c0c0;
|
||||||
border-style : solid;
|
border-style : solid;
|
||||||
overflow : scroll;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
td.content a {
|
td.content a {
|
||||||
|
@ -240,3 +230,21 @@ table.prefFeedList tr.title td {
|
||||||
background-color : #c0c0c0;
|
background-color : #c0c0c0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.button {
|
||||||
|
border : 1px solid #d0d0d0;
|
||||||
|
background-image : url("button.png");
|
||||||
|
background-position : top;
|
||||||
|
background-repeat : repeat-x;
|
||||||
|
background-color : white;
|
||||||
|
color : black;
|
||||||
|
padding : 2px 10px 2px 10px;
|
||||||
|
font-size : small;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.button:hover {
|
||||||
|
background : white;
|
||||||
|
text-decoration : none;
|
||||||
|
color : black;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
37
tt-rss.js
37
tt-rss.js
|
@ -24,28 +24,6 @@ if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
|
||||||
xmlhttp = new XMLHttpRequest();
|
xmlhttp = new XMLHttpRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
function param_escape(arg) {
|
|
||||||
if (typeof encodeURIComponent != 'undefined')
|
|
||||||
return encodeURIComponent(arg);
|
|
||||||
else
|
|
||||||
return escape(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function param_unescape(arg) {
|
|
||||||
if (typeof decodeURIComponent != 'undefined')
|
|
||||||
return decodeURIComponent(arg);
|
|
||||||
else
|
|
||||||
return unescape(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function notify(msg) {
|
|
||||||
|
|
||||||
var n = document.getElementById("notify");
|
|
||||||
|
|
||||||
n.innerHTML = msg;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function feedlist_callback() {
|
function feedlist_callback() {
|
||||||
var container = document.getElementById('feeds');
|
var container = document.getElementById('feeds');
|
||||||
if (xmlhttp.readyState == 4) {
|
if (xmlhttp.readyState == 4) {
|
||||||
|
@ -90,13 +68,17 @@ function view_callback() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function update_feed_list(called_from_timer) {
|
function update_feed_list(called_from_timer, fetch) {
|
||||||
|
|
||||||
if (called_from_timer != true) {
|
if (called_from_timer != true) {
|
||||||
document.getElementById("feeds").innerHTML = "Updating feeds, please wait...";
|
document.getElementById("feeds").innerHTML = "Loading feeds, please wait...";
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlhttp.open("GET", "backend.php?op=feeds", true);
|
var query_str = "backend.php?op=feeds";
|
||||||
|
|
||||||
|
if (fetch) query_str = query_str + "&fetch=yes";
|
||||||
|
|
||||||
|
xmlhttp.open("GET", query_str, true);
|
||||||
xmlhttp.onreadystatechange=feedlist_callback;
|
xmlhttp.onreadystatechange=feedlist_callback;
|
||||||
xmlhttp.send(null);
|
xmlhttp.send(null);
|
||||||
|
|
||||||
|
@ -105,7 +87,7 @@ function update_feed_list(called_from_timer) {
|
||||||
|
|
||||||
function viewfeed(feed, skip, ext) {
|
function viewfeed(feed, skip, ext) {
|
||||||
|
|
||||||
notify("view-feed: " + feed);
|
// notify("view-feed: " + feed);
|
||||||
|
|
||||||
document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
|
document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
|
||||||
document.getElementById('content').innerHTML=' ';
|
document.getElementById('content').innerHTML=' ';
|
||||||
|
@ -164,8 +146,9 @@ function search(feed, sender) {
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
update_feed_list();
|
update_feed_list(false, false);
|
||||||
|
|
||||||
setTimeout("timeout()", 1800*1000);
|
setTimeout("timeout()", 1800*1000);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
15
tt-rss.php
15
tt-rss.php
|
@ -2,6 +2,7 @@
|
||||||
<head>
|
<head>
|
||||||
<title>Tiny Tiny RSS</title>
|
<title>Tiny Tiny RSS</title>
|
||||||
<link rel="stylesheet" href="tt-rss.css" type="text/css">
|
<link rel="stylesheet" href="tt-rss.css" type="text/css">
|
||||||
|
<script type="text/javascript" src="functions.js"></script>
|
||||||
<script type="text/javascript" src="tt-rss.js"></script>
|
<script type="text/javascript" src="tt-rss.js"></script>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
</head>
|
</head>
|
||||||
|
@ -15,12 +16,12 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<!-- <td class="toolbar" valign="middle" >
|
<td class="toolbar" colspan="2">
|
||||||
Search: <input name="q" onclick=\"javascript:search(this);\">
|
<table width="100%" cellspacing="0" cellpadding="0">
|
||||||
</td> -->
|
<td valign="middle"> <div id="notify"> </div></td>
|
||||||
<td class="toolbar" valign="middle" colspan="2">
|
<td class="toolbar" valign="middle" align="right">
|
||||||
<a href="prefs.php" class="button">Preferences</a>
|
<a href="prefs.php" class="button">Preferences</a></td>
|
||||||
<!-- <a class="button" href="javascript:refresh()">Refresh</a> -->
|
</tr></table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" id="notify" class="notify">
|
<td colspan="2" class="notify">
|
||||||
<a href="">Tiny-Tiny RSS</a> v0.1 © 2005 Andrew Dolgov
|
<a href="">Tiny-Tiny RSS</a> v0.1 © 2005 Andrew Dolgov
|
||||||
</td>
|
</td>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in New Issue