]> git.wh0rd.org Git - tt-rss.git/commitdiff
finish initial work on scoring
authorAndrew Dolgov <fox@madoka.spb.ru>
Wed, 30 Apr 2008 08:10:59 +0000 (09:10 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Wed, 30 Apr 2008 08:10:59 +0000 (09:10 +0100)
functions.php
images/score_high.png [new file with mode: 0644]
images/score_neutral.png [new file with mode: 0644]
modules/backend-rpc.php
tt-rss.css
tt-rss.js

index bf0c55d3dccfed6bb30d39112517c1a0ebc6f4a6..2c073b46707643e684c47f0683fcc145a4ce527b 100644 (file)
                                                ttrss_entries,ttrss_user_entries,ttrss_feeds
                                        WHERE
                                        $group_limit_part
-                                       ttrss_feeds.hidden = false AND
+                                       ttrss_feeds.hidden = false AND 
+                                       score >= -500 AND
                                        ttrss_user_entries.feed_id = ttrss_feeds.id AND
                                        ttrss_user_entries.ref_id = ttrss_entries.id AND
                                        ttrss_user_entries.owner_uid = '$owner_uid' AND
                                        FROM
                                                ttrss_entries,ttrss_user_entries,ttrss_tags
                                        WHERE
-                                               ref_id = ttrss_entries.id AND
+                                               ref_id = ttrss_entries.id AND 
+                                               score >= -500 AND
                                                ttrss_user_entries.owner_uid = '$owner_uid' AND
                                                post_int_id = int_id AND tag_name = '$feed' AND
                                                $view_query_part
 
                                $score = $line["score"];
 
-                               if ($score < 100) $score_pic = "score_low
+                               if ($score > 100) { 
+                                       $score_pic = "score_high.png"; 
+                               } else { 
+                                       $score_pic = "score_neutral.png"; 
+                               }
+
+                               $score_title = __("(Click to change)");
+
+                               $score_pic = "<img src=\"images/$score_pic\" 
+                                       onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">";
 
                                $entry_author = $line["author"];
 
 #                                                              truncate_string($line["feed_title"],30)."</a>&nbsp;</td>";
 #                                      } else {                        
 
-                                       print "<td class='hlContent' valign='middle'>";
+
+                                       if ($score > 500) {
+                                               $hlc_suffix = "H";
+                                       } else if ($score < -100) {
+                                               $hlc_suffix = "L";
+                                       } else {
+                                               $hlc_suffix = "";
+                                       }
+
+                                       print "<td class='hlContent$hlc_suffix' valign='middle'>";
 
                                        print "<a href=\"javascript:view($id,$feed_id);\">" .
                                                $line["title"];
 #                                      }
                                        
                                        print "<td class=\"hlUpdated\"><nobr>$updated_fmt&nbsp;</nobr></td>";
-               
+
+                                       print "<td class='hlMarkedPic'>$score_pic</td>";
+       
                                        print "</tr>";
 
                                } else {
diff --git a/images/score_high.png b/images/score_high.png
new file mode 100644 (file)
index 0000000..fa19791
Binary files /dev/null and b/images/score_high.png differ
diff --git a/images/score_neutral.png b/images/score_neutral.png
new file mode 100644 (file)
index 0000000..b4cd7e2
Binary files /dev/null and b/images/score_neutral.png differ
index d7ebb594033a261d889a2a7fe423aad060796b1a..1bff702a7a410ed9d7a9dc19b3aa7055080afedb 100644 (file)
                        return;
                }
 
+               if ($subop == "setScore") {
+                       $id = db_escape_string($_REQUEST["id"]);
+                       $score = sprintf("%d", $_REQUEST["score"]);
+
+                       $result = db_query($link, "UPDATE ttrss_user_entries SET score = '$score'
+                               WHERE ref_id = '$id' AND owner_uid = ".$_SESSION["uid"]);
+
+                       print "<rpc-reply><message>Acknowledged.</message></rpc-reply>";
+
+                       return;
+
+               }
+
                print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>";
        }
 ?>
index 1cb36247f63a7d8b4df1412ba99d1611e93f0543..65c93175b24a2e7e3f21ae197ee0dd0887cdd147 100644 (file)
@@ -1759,3 +1759,12 @@ table.headlinesList tr.feedTitle td {
        margin-top : 10px; */
        padding-left : 5px;
 }
+
+td.hlContentH a, td.hlContentH span {
+       color : #00cc00;
+}
+
+td.hlContentL a, td.hlContentL span {
+       color : #909090;
+       text-decoration : line-through;
+}
index e165ec1c77360ca8b75593bd6336c1d4007ae059..d127e03d29a3c0cd99a3ea965c2c3cb3997a5af2 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -838,3 +838,22 @@ function viewLimitChanged() {
        cache_empty();
        return viewCurrentFeed(0, '')
 }
+
+function adjustArticleScore(id, score) {
+       try {
+
+               var pr = prompt(__("Assign score to article:"), score);
+
+               if (pr != undefined) {
+                       var query = "backend.php?op=rpc&subop=setScore&id=" + id + "&score=" + pr;
+
+                       new Ajax.Request(query, {
+                       onComplete: function(transport) {
+                                       viewCurrentFeed();
+                               } });
+
+               }
+       } catch (e) {
+               exception_error(e, "adjustArticleScore");
+       }
+}