]> git.wh0rd.org Git - tt-rss.git/commitdiff
add tweet button to digest, misc digest fixes; rework article tweeting to use ajax...
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 25 Nov 2010 09:58:29 +0000 (12:58 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 25 Nov 2010 09:58:29 +0000 (12:58 +0300)
backend.php
digest.css
digest.js
digest.php
functions.php
modules/backend-rpc.php
viewfeed.js

index c64ceaa977fef9b427f12311663e53d5dd331e34..410f89864350e80b3d3d4c9faf0ed91c3069ce00 100644 (file)
                        $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"]);
 
        } // Select action according to $op value.
 
+
        // We close the connection to database.
        db_close($link);
 ?>
index 2ed6aae93bb2d1d16d640187cecbc487524401cf..a316803252fd242f2f62af8ea90965c407a03c7a 100644 (file)
@@ -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;
+}
+
index d282f4ee2f89495472a32c4650daa58f6e421d5b..520c3d6194cea8c35f86f1a474575f8555a4c249 100644 (file)
--- 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);
+       }
+}
index 184e2b3626a62257b03f55b380fa51ce013bf8ff..913cd10aefad0a7804b67ab82e8de34c9e937aeb 100644 (file)
@@ -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>
                </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">
index 888af56672ea5d67dd8c23f4a8efc7f07123c14f..5f88c5552c765b4084205a8cca5c0bd8d7c43a92 100644 (file)
                        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;\" 
                                        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\">";
index e7c1f5721f881248c33aea6a3d6ecf3326232dea..e93571207c50423635a7b4303d7e84b21fbc9977 100644 (file)
                        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>";
        }
 ?>
index 602dc7724744954b7bb53c279c30b329fa646d21..4344398e3295bb839073d4def0201473e1af2791 100644 (file)
@@ -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) {