trgm: add basic related stories dialog

master
Andrew Dolgov 10 years ago
parent 7ebb2daf91
commit f52879fed5

@ -341,6 +341,10 @@ div.prefHelp {
color : #555; color : #555;
} }
.small {
font-size : 11px;
}
#main-toolbar > * { #main-toolbar > * {
white-space : nowrap; white-space : nowrap;
display : table-cell; display : table-cell;

@ -3,11 +3,11 @@ function showTrgmRelated(id) {
var query = "backend.php?op=pluginhandler&plugin=af_psql_trgm&method=showrelated&param=" + param_escape(id); var query = "backend.php?op=pluginhandler&plugin=af_psql_trgm&method=showrelated&param=" + param_escape(id);
if (dijit.byId("editNoteDlg")) if (dijit.byId("trgmRelatedDlg"))
dijit.byId("editNoteDlg").destroyRecursive(); dijit.byId("trgmRelatedDlg").destroyRecursive();
dialog = new dijit.Dialog({ dialog = new dijit.Dialog({
id: "editNoteDlg", id: "trgmRelatedDlg",
title: __("Related articles"), title: __("Related articles"),
style: "width: 600px", style: "width: 600px",
execute: function() { execute: function() {

@ -33,11 +33,11 @@ class Af_Psql_Trgm extends Plugin {
$host->add_hook($host::HOOK_PREFS_TAB, $this); $host->add_hook($host::HOOK_PREFS_TAB, $this);
$host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this); $host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this);
$host->add_hook($host::HOOK_PREFS_SAVE_FEED, $this); $host->add_hook($host::HOOK_PREFS_SAVE_FEED, $this);
//$host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
} }
/* function get_js() { function get_js() {
return file_get_contents(__DIR__ . "/init.js"); return file_get_contents(__DIR__ . "/init.js");
} }
@ -53,35 +53,59 @@ class Af_Psql_Trgm extends Plugin {
print "<h2>$title</h2>"; print "<h2>$title</h2>";
$title = db_escape_string($title); $title = db_escape_string($title);
$result = db_query("SELECT id,title,updated $result = db_query("SELECT ttrss_entries.id AS id,
FROM ttrss_entries, ttrss_user_entries feed_id,
WHERE owner_uid = $owner_uid AND ttrss_entries.title AS title,
id = ref_id AND updated, link,
id != $id AND ttrss_feeds.title AS feed_title,
date_entered >= NOW() - INTERVAL '1 day' AND SIMILARITY(ttrss_entries.title, '$title') AS sm
SIMILARITY(title, '$title') >= 0.5 FROM
LIMIT 30"); ttrss_entries, ttrss_user_entries LEFT JOIN ttrss_feeds ON (ttrss_feeds.id = feed_id)
WHERE
ttrss_entries.id = ref_id AND
ttrss_user_entries.owner_uid = $owner_uid AND
ttrss_entries.id != $id AND
date_entered >= NOW() - INTERVAL '1 week'
ORDER BY
sm DESC, date_entered DESC
LIMIT 10");
print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">"; print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">";
while ($line = db_fetch_assoc($result)) { while ($line = db_fetch_assoc($result)) {
print "<li>"; print "<li>";
print "<div style='float : right'>" . smart_date_time($line["updated"]) print "<div class='insensitive small' style='margin-left : 20px; float : right'>" .
smart_date_time(strtotime($line["updated"]))
. "</div>"; . "</div>";
print $line["title"];
print "<img src='images/score_high.png' title='".sprintf("%.2f", $line['sm'])."'
style='vertical-align : middle'>";
$article_link = htmlspecialchars($line["link"]);
print " <a target=\"_blank\" href=\"$article_link\">".
$line["title"]."</a>";
print " (<a href=\"#\" onclick=\"viewfeed(".$line["feed_id"].")\">".
htmlspecialchars($line["feed_title"])."</a>)";
print "</li>"; print "</li>";
} }
print "</ul>"; print "</ul>";
} */ print "<div style='text-align : center'>";
print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('trgmRelatedDlg').hide()\">".__('Close this window')."</button>";
print "</div>";
/* function hook_article_button($line) {
}
function hook_article_button($line) {
return "<img src=\"plugins/af_psql_trgm/button.png\" return "<img src=\"plugins/af_psql_trgm/button.png\"
style=\"cursor : pointer\" style=\"cursor : pointer\" style=\"cursor : pointer\" style=\"cursor : pointer\"
onclick=\"showTrgmRelated(".$line["id"].")\" onclick=\"showTrgmRelated(".$line["id"].")\"
class='tagsPic' title='".__('Show related articles')."'>"; class='tagsPic' title='".__('Show related articles')."'>";
} */ }
function hook_prefs_tab($args) { function hook_prefs_tab($args) {
if ($args != "prefFeeds") return; if ($args != "prefFeeds") return;

Loading…
Cancel
Save