diff --git a/classes/rpc.php b/classes/rpc.php index 2bec8c54..4e08c3dc 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -594,60 +594,6 @@ class RPC extends Handler_Protected { } } - function digestgetcontents() { - $article_id = db_escape_string($_REQUEST['article_id']); - - $result = db_query($this->link, "SELECT content,title,link,marked,published - FROM ttrss_entries, ttrss_user_entries - WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']); - - $content = sanitize($this->link, db_fetch_result($result, 0, "content")); - $title = strip_tags(db_fetch_result($result, 0, "title")); - $article_url = htmlspecialchars(db_fetch_result($result, 0, "link")); - $marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked")); - $published = sql_bool_to_bool(db_fetch_result($result, 0, "published")); - - print json_encode(array("article" => - array("id" => $article_id, "url" => $article_url, - "tags" => get_article_tags($this->link, $article_id), - "marked" => $marked, "published" => $published, - "title" => $title, "content" => $content))); - } - - function digestupdate() { - $feed_id = db_escape_string($_REQUEST['feed_id']); - $offset = db_escape_string($_REQUEST['offset']); - $seq = db_escape_string($_REQUEST['seq']); - - if (!$feed_id) $feed_id = -4; - if (!$offset) $offset = 0; - - $reply = array(); - - $reply['seq'] = $seq; - - $headlines = api_get_headlines($this->link, $feed_id, 30, $offset, - '', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0); - - $reply['headlines'] = array(); - $reply['headlines']['title'] = getFeedTitle($this->link, $feed_id); - $reply['headlines']['content'] = $headlines; - - print json_encode($reply); - } - - function digestinit() { - $tmp_feeds = api_get_feeds($this->link, -4, true, false, 0); - - $feeds = array(); - - foreach ($tmp_feeds as $f) { - if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f); - } - - print json_encode(array("feeds" => $feeds)); - } - function catchupFeed() { $feed_id = db_escape_string($_REQUEST['feed_id']); $is_cat = db_escape_string($_REQUEST['is_cat']) == "true"; diff --git a/index.php b/index.php index d958e2b8..b86cd0e6 100644 --- a/index.php +++ b/index.php @@ -18,9 +18,15 @@ $mobile = new Mobile_Detect(); + $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); + + if (!init_connection($link)) return; + + global $pluginhost; + if (!$_REQUEST['mobile']) { - if ($mobile->isTablet()) { - header('Location: digest.php'); + if ($mobile->isTablet() && $pluginhost->get_plugin("digest")) { + header('Location: backend.php?op=digest'); exit; } else if ($mobile->isMobile()) { header('Location: mobile/index.php'); @@ -28,9 +34,6 @@ } } - $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - - if (!init_connection($link)) return; login_sequence($link); @@ -208,8 +211,10 @@
+ get_plugin("digest")) { ?>
-
+ +
diff --git a/js/tt-rss.js b/js/tt-rss.js index fd02081b..348d6bbd 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -391,7 +391,7 @@ function quickMenuGo(opid) { } if (opid == "qmcDigest") { - window.location.href = "digest.php"; + window.location.href = "backend.php?op=digest"; return; } diff --git a/digest.css b/plugins/digest/digest.css similarity index 100% rename from digest.css rename to plugins/digest/digest.css diff --git a/js/digest.js b/plugins/digest/digest.js similarity index 98% rename from js/digest.js rename to plugins/digest/digest.js index 241328ab..522d3545 100644 --- a/js/digest.js +++ b/plugins/digest/digest.js @@ -169,7 +169,7 @@ function update(callback) { window.clearTimeout(_update_timeout); new Ajax.Request("backend.php", { - parameters: "?op=rpc&method=digestinit", + parameters: "?op=digest&method=digestinit", onComplete: function(transport) { fatal_error_check(transport); parse_feeds(transport); @@ -220,7 +220,7 @@ function view(article_id) { }, 500); new Ajax.Request("backend.php", { - parameters: "?op=rpc&method=digestgetcontents&article_id=" + + parameters: "?op=digest&method=digestgetcontents&article_id=" + article_id, onComplete: function(transport) { fatal_error_check(transport); @@ -312,7 +312,7 @@ function viewfeed(feed_id, offset, replace, no_effects, no_indicator, callback) if (!offset) $("headlines").scrollTop = 0; - var query = "backend.php?op=rpc&method=digestupdate&feed_id=" + + var query = "backend.php?op=digest&method=digestupdate&feed_id=" + param_escape(feed_id) + "&offset=" + offset + "&seq=" + _update_seq; @@ -647,7 +647,7 @@ function parse_headlines(transport, replace, no_effects) { function init_second_stage() { try { new Ajax.Request("backend.php", { - parameters: "backend.php?op=rpc&method=digestinit", + parameters: "backend.php?op=digest&method=digestinit", onComplete: function(transport) { parse_feeds(transport); Element.hide("overlay"); diff --git a/plugins/digest/digest.php b/plugins/digest/digest.php new file mode 100644 index 00000000..5535c322 --- /dev/null +++ b/plugins/digest/digest.php @@ -0,0 +1,100 @@ +link = $host->get_link(); + $this->host = $host; + + $host->add_handler("digest", "*", $this); + + //$host->add_handler("rpc", "digestinit", $this); + //$host->add_handler("rpc", "digestupdate", $this); + //$host->add_handler("rpc", "digestgetcontents", $this); + } + + function index() { + header("Content-type: text/html; charset=utf-8"); + + login_sequence($this->link); + + global $link; + $link = $this->link; + + require_once dirname(__FILE__) . "/digest_body.php"; + } + + /* function get_js() { + return file_get_contents(dirname(__FILE__) . "/digest.js"); + } */ + + function csrf_ignore($method) { + return in_array($method, array("index")); + } + + function before($method) { + return true; + } + + function after() { + + } + + function digestgetcontents() { + $article_id = db_escape_string($_REQUEST['article_id']); + + $result = db_query($this->link, "SELECT content,title,link,marked,published + FROM ttrss_entries, ttrss_user_entries + WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']); + + $content = sanitize($this->link, db_fetch_result($result, 0, "content")); + $title = strip_tags(db_fetch_result($result, 0, "title")); + $article_url = htmlspecialchars(db_fetch_result($result, 0, "link")); + $marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked")); + $published = sql_bool_to_bool(db_fetch_result($result, 0, "published")); + + print json_encode(array("article" => + array("id" => $article_id, "url" => $article_url, + "tags" => get_article_tags($this->link, $article_id), + "marked" => $marked, "published" => $published, + "title" => $title, "content" => $content))); + } + + function digestupdate() { + $feed_id = db_escape_string($_REQUEST['feed_id']); + $offset = db_escape_string($_REQUEST['offset']); + $seq = db_escape_string($_REQUEST['seq']); + + if (!$feed_id) $feed_id = -4; + if (!$offset) $offset = 0; + + $reply = array(); + + $reply['seq'] = $seq; + + $headlines = api_get_headlines($this->link, $feed_id, 30, $offset, + '', ($feed_id == -4), true, false, "unread", "updated DESC", 0, 0); + + $reply['headlines'] = array(); + $reply['headlines']['title'] = getFeedTitle($this->link, $feed_id); + $reply['headlines']['content'] = $headlines; + + print json_encode($reply); + } + + function digestinit() { + $tmp_feeds = api_get_feeds($this->link, -4, true, false, 0); + + $feeds = array(); + + foreach ($tmp_feeds as $f) { + if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f); + } + + print json_encode(array("feeds" => $feeds)); + } + +} +?> diff --git a/plugins/digest/digest.txt b/plugins/digest/digest.txt new file mode 100644 index 00000000..d94efa10 --- /dev/null +++ b/plugins/digest/digest.txt @@ -0,0 +1 @@ +Digest mode for tt-rss (tablet friendly UI) diff --git a/digest.php b/plugins/digest/digest_body.php similarity index 79% rename from digest.php rename to plugins/digest/digest_body.php index 7cc17418..c4f51d37 100644 --- a/digest.php +++ b/plugins/digest/digest_body.php @@ -1,25 +1,5 @@ - - require_once "functions.php"; - require_once "sessions.php"; - require_once "sanity_check.php"; - require_once "version.php"; - require_once "config.php"; - require_once "db-prefs.php"; - - $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - - login_sequence($link); - - $dt_add = time(); - - no_cache_incantation(); - - header('Content-Type: text/html; charset=utf-8'); - -?> @@ -28,7 +8,7 @@ Tiny Tiny RSS - + @@ -43,7 +23,7 @@ - +