add tweet button to digest, misc digest fixes; rework article tweeting to use ajax loading of needed info
This commit is contained in:
parent
411fe209d6
commit
ba7e88e5a5
|
@ -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);
|
||||
?>
|
||||
|
|
14
digest.css
14
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;
|
||||
}
|
||||
|
||||
|
|
42
digest.js
42
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);
|
||||
}
|
||||
}
|
||||
|
|
17
digest.php
17
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"> </div>
|
||||
<div id="xebBtn" align='center'>
|
||||
<button onclick="closeErrorBox()"><?php echo __('Close this window') ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="header">
|
||||
|
||||
<div class="links">
|
||||
|
|
|
@ -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\">";
|
||||
|
|
|
@ -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>";
|
||||
}
|
||||
?>
|
||||
|
|
25
viewfeed.js
25
viewfeed.js
|
@ -2305,18 +2305,29 @@ 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 share_url = "http://twitter.com/share?_=" + ts +
|
||||
"&text=" + param_escape(ti.title) +
|
||||
"&url=" + param_escape(ti.link);
|
||||
|
||||
window.open(share_url, 'ttrss_tweet',
|
||||
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("tweetArticle", e);
|
||||
|
|
Loading…
Reference in New Issue