summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/frontpage_msgs.txt16
-rw-r--r--src/site.clj21
-rw-r--r--template/frontpage.st14
3 files changed, 44 insertions, 7 deletions
diff --git a/docs/frontpage_msgs.txt b/docs/frontpage_msgs.txt
new file mode 100644
index 0000000..79e9553
--- /dev/null
+++ b/docs/frontpage_msgs.txt
@@ -0,0 +1,16 @@
+1020124
+960980
+675137
+653108
+1882023
+822990
+1245092
+805380
+2078006
+972195
+793027
+805450
+1353545
+970172
+1038771
+1129104
diff --git a/src/site.clj b/src/site.clj
index b6c8882..6668fc7 100644
--- a/src/site.clj
+++ b/src/site.clj
@@ -22,6 +22,7 @@
email
fame
message
+ jedis
utils
cookie-login
session-sweeper
@@ -200,6 +201,21 @@
(def earliest-daily-hall (parse-yyyymmdd-date "20100409"))
+(defn hall-score [msg-id]
+ (first (do-select ["select count(*) from tags where message_id = ?" msg-id])))
+
+(def frontpage-posts-path "docs/frontpage_msgs.txt")
+(def frontpage-posts-agent
+ (scheduled-agent (fn []
+ (try
+ (let [msg-ids (re-seq #"\w+"
+ (slurp frontpage-posts-path))
+ msgs (datalayer/fetch-messages-by-id (shuffle msg-ids))]
+ (for [m msgs]
+ (assoc m :score (hall-score (:message_id m)))))
+ (catch Exception e (println e) [])))
+ 12000
+ nil))
(defn front-page
([session] (front-page session (format-yyyymmdd (Date.))))
([session dt-str]
@@ -209,7 +225,9 @@
(.after cur-date today) (redirect-to "/")
:else (let [st (fetch-template "frontpage" session)
dumps (map process-message-for-output
- (fetch-redis-daily-hall cur-date 0 20 (:user_id session)))]
+ (if (:nick session)
+ (fetch-redis-daily-hall cur-date 0 20 (:user_id session))
+ (poll frontpage-posts-agent)))]
(.setAttribute st "dumps" dumps)
(if-not (.after next-date today)
(.setAttribute st "next_date" (format-yyyymmdd next-date)))
@@ -1393,6 +1411,7 @@ WHERE user_id IN
(def server (start-server (options :port)))
(start! active-mutes)
+(start! frontpage-posts-agent)
(start-user-flusher!)
(start-session-pruner!)
diff --git a/template/frontpage.st b/template/frontpage.st
index 22c47fe..22c780c 100644
--- a/template/frontpage.st
+++ b/template/frontpage.st
@@ -468,22 +468,23 @@ jQuery(window).load(function(){
<iframe src="$domain$/fullscreen" style="overflow:hidden;width:240px;height:200px;border:0px;"></iframe>
</div>
$else$
- Currently hot on <a href="$domain$/chat">dump.fm</a>
<div class="alttxt">
- <br>Join the conversation!<br><br>
+ dump.fm is a real-time image chat!<br><br>
+ check out our top dumps
+ <br><br>
<strong>
- <a href="$domain$/login" class="signin">sign in</a></strong> or <strong><a href="$domain$/register">register!</a>
+ <a href="$domain$/login" class="signin">sign in</a></strong> or <strong><a href="$domain$/register">register</a>
</strong>
</div>
$endif$
</div>
-
$if(dumps)$
$dumps: { dump | $hall_log_dump()$ }$
$endif$
</div>
-
+
+$if(user_nick)$
<div id="pgbuttons">
$if(prev_date)$
<a class="prev_date" href="$domain$/top/$prev_date$"><- $prev_date$</a>
@@ -493,12 +494,13 @@ jQuery(window).load(function(){
<a class="next_date" href="$domain$/top/$next_date$">$next_date$ -></a>
$endif$
</div>
+$endif$
<!--START FOOTER
$footer()$-->
<br><br><center>
<div id="footer">
-@2010 <a href="/">dump.fm</a>
+@2011 <a href="/">dump.fm</a>
<a href="$domain$/about_us" style="word-spacing: normal">About Us</a>
<a href="$domain$/help" style="word-spacing: normal">Help FAQ</a>
<a href="$domain$/terms">Terms</a>