summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2010-11-25 12:58:29 +0300
committerAndrew Dolgov <[email protected]>2010-11-25 12:58:29 +0300
commitba7e88e5a59295ac3eed38ea627e9fa2a414b989 (patch)
tree64c5475fcb5734b5f0a1758355b4174e1992ebc4
parent411fe209d642f64ee1f856908e6c1b4507893fcf (diff)
add tweet button to digest, misc digest fixes; rework article tweeting to use ajax loading of needed info
-rw-r--r--backend.php5
-rw-r--r--digest.css14
-rw-r--r--digest.js42
-rw-r--r--digest.php17
-rw-r--r--functions.php21
-rw-r--r--modules/backend-rpc.php20
-rw-r--r--viewfeed.js23
7 files changed, 95 insertions, 47 deletions
diff --git a/backend.php b/backend.php
index c64ceaa97..410f89864 100644
--- a/backend.php
+++ b/backend.php
@@ -526,6 +526,10 @@
$print_exec_time = false;
break; // digestSend
+ case "loading":
+ print __("Loading, please wait...") . " " .
+ "<img src='images/indicator_tiny.gif'>";
+
case "getProfiles":
$login = db_escape_string($_REQUEST["login"]);
$password = db_escape_string($_REQUEST["password"]);
@@ -553,6 +557,7 @@
} // Select action according to $op value.
+
// We close the connection to database.
db_close($link);
?>
diff --git a/digest.css b/digest.css
index 2ed6aae93..a31680325 100644
--- a/digest.css
+++ b/digest.css
@@ -1,7 +1,7 @@
-body {
+body#ttrssDigest {
background : #f0f0f0;
color : black;
- font-family : sans-serif;
+ font-family : "Lucida Grande", Arial, sans-serif;
font-size : 12px;
}
@@ -298,3 +298,13 @@ a:hover {
#overlay img {
vertical-align : middle;
}
+
+div.fatalError button {
+ margin-top : 5px;
+}
+
+div.fatalError textarea {
+ width : 100%;
+ height : 100px;
+}
+
diff --git a/digest.js b/digest.js
index d282f4ee2..520c3d619 100644
--- a/digest.js
+++ b/digest.js
@@ -429,6 +429,7 @@ function add_headline_entry(article, feed, no_effects) {
"<div class='digest-check'>" +
mark_part +
publ_part +
+ "<img title='" + __("Share on Twitter") + "' onclick=\"tweet_article("+article.id+", true)\" src='images/art-tweet.png'>" +
"<img title='" + __("Mark as read") + "' onclick=\"view("+article.id+", true)\" src='images/digest_checkbox.png'>" +
"</div>" +
"<a target=\"_blank\" href=\""+article.link+"\""+
@@ -497,7 +498,7 @@ function parse_feeds(transport) {
var feeds = transport.responseXML.getElementsByTagName('feeds')[0];
if (feeds) {
- feeds = eval("(" + feeds.firstChild.nodeValue + ")");
+ feeds = JSON.parse(feeds.firstChild.nodeValue);
feeds.sort( function (a,b)
{
@@ -546,7 +547,7 @@ function parse_headlines(transport, replace, no_effects) {
var headlines_title = transport.responseXML.getElementsByTagName('headlines-title')[0];
if (headlines && headlines_title) {
- headlines = eval("(" + headlines.firstChild.nodeValue + ")");
+ headlines = JSON.parse(headlines.firstChild.nodeValue);
var title = headlines_title.firstChild.nodeValue;
@@ -578,13 +579,13 @@ function parse_headlines(transport, replace, no_effects) {
if (ids.length > 0) {
if (pr) {
$('headlines-content').appendChild(pr);
- if (!no_effects) new Effect.ScrollTo(inserted);
+ if (!no_effects && inserted) new Effect.ScrollTo(inserted);
} else {
$('headlines-content').innerHTML += "<li id='H-MORE-PROMPT'>" +
"<div class='body'>" +
- "<a href=\"javascript:catchup_visible_articles()\">" +
+ "<a href=\"#\" onclick=\"catchup_visible_articles()\">" +
__("Mark as read") + "</a> | " +
- "<a href=\"javascript:load_more()\">" +
+ "<a href=\"#\" onclick=\"load_more()\">" +
__("Load more...") + "</a>" +
"<img style=\"display : none\" "+
"id=\"H-LOADING-IMG\" src='images/indicator_tiny.gif'>" +
@@ -622,6 +623,7 @@ function init_second_stage() {
function init() {
try {
+ dojo.require("dijit.Dialog");
new Ajax.Request("backend.php", {
parameters: "?op=rpc&subop=sanityCheck",
@@ -793,3 +795,33 @@ function update_title(unread) {
}
}
+function tweet_article(id) {
+ try {
+
+ var query = "?op=rpc&subop=getTweetInfo&id=" + param_escape(id);
+
+ console.log(query);
+
+ var d = new Date();
+ var ts = d.getTime();
+
+ var w = window.open('backend.php?op=loading', 'ttrss_tweet',
+ "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
+
+ new Ajax.Request("backend.php", {
+ parameters: query,
+ onComplete: function(transport) {
+ var ti = JSON.parse(transport.responseText);
+
+ var share_url = "http://twitter.com/share?_=" + ts +
+ "&text=" + param_escape(ti.title) +
+ "&url=" + param_escape(ti.link);
+
+ w.location.href = share_url;
+
+ } });
+
+ } catch (e) {
+ exception_error("tweet_article", e);
+ }
+}
diff --git a/digest.php b/digest.php
index 184e2b362..913cd10ae 100644
--- a/digest.php
+++ b/digest.php
@@ -23,8 +23,9 @@
<html>
<head>
<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="infobox.css?<?php echo $dt_add ?>"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
@@ -37,6 +38,7 @@
<script type="text/javascript" src="lib/prototype.js"></script>
<script type="text/javascript" src="lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls"></script>
+ <script type="text/javascript" src="lib/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
<script type="text/javascript" charset="utf-8" src="localized_js.php?<?php echo $dt_add ?>"></script>
<script type="text/javascript" charset="utf-8" src="functions.js?<?php echo $dt_add ?>"></script>
@@ -48,7 +50,7 @@
});
</script>
</head>
-<body id="ttrssDigest">
+<body id="ttrssDigest" class="claro">
<div id="overlay" style="display : block">
<div id="overlay_inner">
<noscript>
@@ -63,17 +65,6 @@
</div>
</div>
- <div id="dialog_overlay" style="display : none"> </div>
-
- <div id="errorBoxShadow" style="display : none">
- <div id="errorBox">
- <div id="xebTitle"><?php echo __('Fatal Exception') ?></div><div id="xebContent">&nbsp;</div>
- <div id="xebBtn" align='center'>
- <button onclick="closeErrorBox()"><?php echo __('Close this window') ?></button>
- </div>
- </div>
- </div>
-
<div id="header">
<div class="links">
diff --git a/functions.php b/functions.php
index 888af5667..5f88c5552 100644
--- a/functions.php
+++ b/functions.php
@@ -4577,15 +4577,6 @@
print "<div id=\"PTITLE-$id\" style=\"display : none\">" .
truncate_string(strip_tags($line['title']), 15) . "</div>";
- $tweet_title = htmlspecialchars(
- truncate_string(strip_tags($line['title']), 100, '...'));
-
- $tweet_link = htmlspecialchars($line['link']);
-
- print "<span id=\"TWEETINFO-$id\" style=\"display : none\">";
- print json_encode(array("title" => $tweet_title, "link" => $tweet_link));
- print "</span>";
-
print "<div class=\"postReply\" id=\"POST-$id\">";
/* print "<div dojoType=\"dijit.Menu\" style=\"display: none;\"
@@ -5232,18 +5223,6 @@
print_article_enclosures($link, $id, $always_display_enclosures,
$article_content);
- $short_title = truncate_string(
- strip_tags($line['title']), 90);
-
- $tweet_title = htmlspecialchars(
- truncate_string(strip_tags($line['title']), 100, '...'));
-
- $tweet_link = htmlspecialchars($line['link']);
-
- print "<span id=\"TWEETINFO-$id\" style=\"display : none\">";
- print json_encode(array("title" => $tweet_title, "link" => $tweet_link));
- print "</span>";
-
print "</div>";
print "<div class=\"cdmFooter\">";
diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php
index e7c1f5721..e93571207 100644
--- a/modules/backend-rpc.php
+++ b/modules/backend-rpc.php
@@ -982,6 +982,26 @@
return;
}
+ if ($subop == "getTweetInfo") {
+ header("Content-Type: text/html");
+ $id = db_escape_string($_REQUEST['id']);
+
+ $result = db_query($link, "SELECT title, link
+ FROM ttrss_entries, ttrss_user_entries
+ WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
+
+ if (db_num_rows($result) != 0) {
+ $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')),
+ 100, '...');
+ $article_link = db_fetch_result($result, 0, 'link');
+ }
+
+ print json_encode(array("title" => $title, "link" => $article_link,
+ "id" => $id));
+
+ return;
+ }
+
print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>";
}
?>
diff --git a/viewfeed.js b/viewfeed.js
index 602dc7724..4344398e3 100644
--- a/viewfeed.js
+++ b/viewfeed.js
@@ -2305,17 +2305,28 @@ function initHeadlinesMenu() {
function tweetArticle(id) {
try {
+ var query = "?op=rpc&subop=getTweetInfo&id=" + param_escape(id);
+
+ console.log(query);
+
var d = new Date();
var ts = d.getTime();
- var ti = JSON.parse($("TWEETINFO-" + id).innerHTML);
+ var w = window.open('backend.php?op=loading', 'ttrss_tweet',
+ "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
- var share_url = "http://twitter.com/share?_=" + ts +
- "&text=" + param_escape(ti.title) +
- "&url=" + param_escape(ti.link);
+ new Ajax.Request("backend.php", {
+ parameters: query,
+ onComplete: function(transport) {
+ var ti = JSON.parse(transport.responseText);
- window.open(share_url, 'ttrss_tweet',
- "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
+ var share_url = "http://twitter.com/share?_=" + ts +
+ "&text=" + param_escape(ti.title) +
+ "&url=" + param_escape(ti.link);
+
+ w.location.href = share_url;
+
+ } });
} catch (e) {