diff options
| -rw-r--r-- | docs/frontpage_msgs.txt | 16 | ||||
| -rw-r--r-- | src/datalayer.clj | 20 | ||||
| -rw-r--r-- | src/email.clj | 6 | ||||
| -rw-r--r-- | src/site.clj | 24 | ||||
| -rwxr-xr-x | static/css/dump.css | 2 | ||||
| -rw-r--r-- | static/error/502.html | 3 | ||||
| -rwxr-xr-x | static/js/home.js | 2 | ||||
| -rw-r--r-- | template/frontpage.st | 14 | ||||
| -rw-r--r-- | template/hall_log_dump.st | 2 | ||||
| -rw-r--r-- | template/pogs.st | 1 |
10 files changed, 68 insertions, 22 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/datalayer.clj b/src/datalayer.clj index 12714d3..52d3b0a 100644 --- a/src/datalayer.clj +++ b/src/datalayer.clj @@ -146,14 +146,18 @@ WHERE u.nick = ANY(?)" (str "hall:daily:" (format-yyyymmdd date))) (defn fetch-redis-zset [key symbol offset num] - (for [t (with-jedis - #(.zrevrangeWithScores % - key - offset - (+ offset num 1))) - :when (> (int (.getScore t)) 0)] - {symbol (.getElement t) - :score (int (.getScore t))})) + (try + (for [t (with-jedis + #(.zrevrangeWithScores % + key + offset + (+ offset num 1))) + :when (> (int (.getScore t)) 0)] + {symbol (.getElement t) + :score (int (.getScore t))}) + (catch Exception e + (println (new java.util.Date) "jedis exception" e) + []))) (defn fetch-redis-daily-hall [date offset num user-id] (let [msg-ids (fetch-redis-zset (redis-daily-hall-key date) diff --git a/src/email.clj b/src/email.clj index d387624..3231b60 100644 --- a/src/email.clj +++ b/src/email.clj @@ -66,9 +66,7 @@ :text text :mime (classify-mimetype text))) -(def *admin-lists* {"dumpfmprod" ["opuscule@gmail.com" - "sbostler@gmail.com" - "theryderproject@gmail.com"] +(def *admin-lists* {"dumpfmprod" ["info@dump.fm"] "sostler" ["sbostler@gmail.com"]}) (defn get-admins [] @@ -93,4 +91,4 @@ body (format "Reason: %s" reason)] (dump-mail (get-admins) subject body))) -
\ No newline at end of file + diff --git a/src/site.clj b/src/site.clj index b6c8882..f386f2a 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,23 @@ (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 msg-ids)] + (for [m msgs] + (assoc m :score (hall-score (:message_id m))))) + (catch Exception e (println e) []))) + 3600 + nil)) +(def num-frontpage-dumps 20) + (defn front-page ([session] (front-page session (format-yyyymmdd (Date.)))) ([session dt-str] @@ -209,7 +227,10 @@ (.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)) + (take num-frontpage-dumps + (shuffle (poll frontpage-posts-agent)))))] (.setAttribute st "dumps" dumps) (if-not (.after next-date today) (.setAttribute st "next_date" (format-yyyymmdd next-date))) @@ -1393,6 +1414,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/static/css/dump.css b/static/css/dump.css index 6b40263..09dd59d 100755 --- a/static/css/dump.css +++ b/static/css/dump.css @@ -108,7 +108,7 @@ color:#000;font-family:verdana;background-color:#ffffff; font-family: Monaco, "C #dumplist{ top:0px:padding:0px; font-size:88%;text-transform:uppercase;text-decoration: none;margin-right:4%; -text-align:left;position:fixed;top:0px;left:18px;line-height:.7;overflow:hidden;height:10px; +text-align:left;position:fixed;top:41px;left:18px;line-height:.7;overflow:hidden;height:10px; /*margin-left:40%; border-bottom-left-radius:5px; -webkit-border-bottom-left-radius:5px; diff --git a/static/error/502.html b/static/error/502.html new file mode 100644 index 0000000..91e74d1 --- /dev/null +++ b/static/error/502.html @@ -0,0 +1,3 @@ +<html> + <body>502</body> +</html> diff --git a/static/js/home.js b/static/js/home.js index 736fc84..9bee6ba 100755 --- a/static/js/home.js +++ b/static/js/home.js @@ -150,7 +150,7 @@ function login() { var hash = hex_sha1(nick + '$' + password + '$dumpfm'); var onSuccess = function(json) { - location.href = location.href; + location.href = '/chat'; if (typeof pageTracker !== 'undefined') { pageTracker._setCustomVar(1, "logged-in", nick); } 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> diff --git a/template/hall_log_dump.st b/template/hall_log_dump.st index 4cd7ba7..d12fecb 100644 --- a/template/hall_log_dump.st +++ b/template/hall_log_dump.st @@ -3,5 +3,7 @@ $if(dump.score)$<span class="hallscore" onclick="Tag.animated_fav(this, '.hallscore', '60px', '40px')">$dump.score$</span>$endif$ <div class="content" data-category="posts">$dump.content$</div> <hr /> + $if(logged_in)$ $frontpage_share_buttons()$ + $endif$ </div> diff --git a/template/pogs.st b/template/pogs.st index 63bc29e..e2f0dbd 100644 --- a/template/pogs.st +++ b/template/pogs.st @@ -216,7 +216,6 @@ font-size:100%;} <img src="http://dump.fm/images/20100706/1278438862410-dumpfm-pixelfuck-Untitled-3.gif"> <img src="http://dump.fm/images/20100706/1278437086903-dumpfm-noisia-digipog-man-face-boring.gif"> <img src="http://dump.fm/images/20100706/1278436783573-dumpfm-noisia-digipog-hypothete-subpixel-favheart.gif"> -<img src="http://dump.fm/images/20100706/1278436627721-dumpfm-noisia-digipog-dr-dieter-daniels.gif"> <img src="http://dump.fm/images/20100706/1278436379077-dumpfm-noisia-digipog-pie-chart.gif"> <img src="http://dump.fm/images/20100706/1278436190174-dumpfm-noisia-digipog-blinking-green-alien-sharp-big-shrunk-what.gif"> <img src="http://dump.fm/images/20100706/1278442797918-dumpfm-ryder-hentipog.gif"> |
