summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-12-24 10:16:01 +0400
committerAndrew Dolgov <[email protected]>2012-12-24 10:16:01 +0400
commitac22075182f1d9b8dfd0c481e943d812e63f7789 (patch)
tree9cdde8d9d52624dd01c03493ed76a67ab97d42e6
parent68d539ceef3289ffb5d0d1007be0657e2a6bb49d (diff)
move digest to a separate plugin
-rw-r--r--classes/rpc.php54
-rw-r--r--index.php17
-rw-r--r--js/tt-rss.js2
-rw-r--r--plugins/digest/digest.css (renamed from digest.css)0
-rw-r--r--plugins/digest/digest.js (renamed from js/digest.js)8
-rw-r--r--plugins/digest/digest.php100
-rw-r--r--plugins/digest/digest.txt1
-rw-r--r--plugins/digest/digest_body.php (renamed from digest.php)26
-rw-r--r--plugins/digest/images/tile.png (renamed from images/tile.png)bin958 -> 958 bytes
9 files changed, 120 insertions, 88 deletions
diff --git a/classes/rpc.php b/classes/rpc.php
index 2bec8c54a..4e08c3dc7 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 d958e2b89..b86cd0e66 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 @@
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcCatchupAll')"><?php echo __('Mark as read') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcShowOnlyUnread')"><?php echo __('(Un)hide read feeds') ?></div>
<div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Other actions:') ?></div>
+ <?php if ($pluginhost->get_plugin("digest")) { ?>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcDigest')"><?php echo __('Switch to digest...') ?></div>
- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcTagCloud')"><?php echo __('Show tag cloud...') ?></div>
+ <?php } ?>
+ <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcTagCloud')"><?php echo __('Show tag cloud...') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcTagSelect')"><?php echo __('Select by tags...') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddLabel')"><?php echo __('Create label...') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFilter')"><?php echo __('Create filter...') ?></div>
diff --git a/js/tt-rss.js b/js/tt-rss.js
index fd02081bb..348d6bbd6 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
index 54568e3bc..54568e3bc 100644
--- a/digest.css
+++ b/plugins/digest/digest.css
diff --git a/js/digest.js b/plugins/digest/digest.js
index 241328ab2..522d35453 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 000000000..5535c3222
--- /dev/null
+++ b/plugins/digest/digest.php
@@ -0,0 +1,100 @@
+<?
+class Digest extends Plugin implements IHandler {
+
+ private $link;
+ private $host;
+
+ function __construct($host) {
+ $this->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 000000000..d94efa104
--- /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
index 7cc174185..c4f51d376 100644
--- a/digest.php
+++ b/plugins/digest/digest_body.php
@@ -1,25 +1,5 @@
-<?php
- set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
- get_include_path());
+<?php global $link; ?>
- 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');
-
-?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -28,7 +8,7 @@
<title>Tiny Tiny RSS</title>
<link rel="stylesheet" type="text/css" href="lib/dijit/themes/claro/claro.css"/>
- <link rel="stylesheet" type="text/css" href="digest.css?<?php echo $dt_add ?>"/>
+ <link rel="stylesheet" type="text/css" href="plugins/digest/digest.css?<?php echo $dt_add ?>"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
@@ -43,7 +23,7 @@
<script type="text/javascript" charset="utf-8" src="localized_js.php?<?php echo $dt_add ?>"></script>
<script type="text/javascript" charset="utf-8" src="errors.php?mode=js"></script>
<script type="text/javascript" charset="utf-8" src="js/functions.js?<?php echo $dt_add ?>"></script>
- <script type="text/javascript" src="js/digest.js"></script>
+ <script type="text/javascript" src="plugins/digest/digest.js"></script>
<script type="text/javascript">
Event.observe(window, 'load', function() {
diff --git a/images/tile.png b/plugins/digest/images/tile.png
index 72f2f4553..72f2f4553 100644
--- a/images/tile.png
+++ b/plugins/digest/images/tile.png
Binary files differ