From f52879fed516925a1cc026401671bcb083880e13 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 19 Jan 2015 15:46:15 +0300 Subject: trgm: add basic related stories dialog --- plugins/af_psql_trgm/init.php | 54 +++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 15 deletions(-) (limited to 'plugins/af_psql_trgm/init.php') diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index a451dce23..97187a602 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -33,11 +33,11 @@ class Af_Psql_Trgm extends Plugin { $host->add_hook($host::HOOK_PREFS_TAB, $this); $host->add_hook($host::HOOK_PREFS_EDIT_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"); } @@ -53,35 +53,59 @@ class Af_Psql_Trgm extends Plugin { print "

$title

"; $title = db_escape_string($title); - $result = db_query("SELECT id,title,updated - FROM ttrss_entries, ttrss_user_entries - WHERE owner_uid = $owner_uid AND - id = ref_id AND - id != $id AND - date_entered >= NOW() - INTERVAL '1 day' AND - SIMILARITY(title, '$title') >= 0.5 - LIMIT 30"); + $result = db_query("SELECT ttrss_entries.id AS id, + feed_id, + ttrss_entries.title AS title, + updated, link, + ttrss_feeds.title AS feed_title, + SIMILARITY(ttrss_entries.title, '$title') AS sm + FROM + 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 ""; - } */ + print "
"; + print ""; + print "
"; - /* function hook_article_button($line) { + + } + + function hook_article_button($line) { return ""; - } */ + } function hook_prefs_tab($args) { if ($args != "prefFeeds") return; -- cgit v1.2.3