From 7a62c03ebe5c36a47274d170ce8c39957cdf437c Mon Sep 17 00:00:00 2001 From: dumpfmprod Date: Tue, 10 Sep 2013 13:10:56 -0400 Subject: reveal favs on /log --- static/js/pichat2.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'static/js/pichat2.js') diff --git a/static/js/pichat2.js b/static/js/pichat2.js index ceeb397..5fd0de8 100644 --- a/static/js/pichat2.js +++ b/static/js/pichat2.js @@ -547,7 +547,6 @@ function dragTarget (target, callbacks) { } base.enter = function(e){ base.target.classList.add('over'); - console.log(e.target); if ('enter' in callbacks) { callbacks.enter(Drag.url); } @@ -985,6 +984,18 @@ function initLogThumb(selector, parentSelector) { } }) } + +function load_favs(){ + $(function(){ + $(".permalink").each(function(){ + var $div = $("
"); + $div.load(this.href + " .faver-list"); + $div.insertBefore($(this).parent()) + }) + }) +} + + // Messages -- cgit v1.2.3-70-g09d2 From 101c0be26573b6cc20a8542d378592fd0eec2ba5 Mon Sep 17 00:00:00 2001 From: dumpfmprod Date: Wed, 14 May 2014 12:02:39 -0400 Subject: scripts to fix redis when it crashes --- scripts/fix_fav_counts.py | 99 +++++++++++++++++++++++++++++++++++++++++++++++ scripts/sort_faves.sh | 20 ++++++++++ src/site.clj | 3 ++ static/css/dump.css | 10 +++++ static/js/pichat.js | 18 ++++++++- static/js/pichat2.js | 18 ++++++++- static/js/register.js | 8 ++-- static/js/src/fun.js | 10 +++++ static/js/src/messages.js | 4 +- static/js/src/util.js | 4 ++ static/super/index.html | 8 ++-- template/banner.st | 5 ++- template/fullscreen.st | 7 ++++ 13 files changed, 202 insertions(+), 12 deletions(-) create mode 100644 scripts/fix_fav_counts.py create mode 100755 scripts/sort_faves.sh (limited to 'static/js/pichat2.js') diff --git a/scripts/fix_fav_counts.py b/scripts/fix_fav_counts.py new file mode 100644 index 0000000..00e8d0f --- /dev/null +++ b/scripts/fix_fav_counts.py @@ -0,0 +1,99 @@ +""" + this needs python 3 due to py-postgresql... + + before running this command, please run the following SQL, which tallies the faves per post: + + COPY (SELECT messages.user_id, tags.message_id, COUNT(tags.message_id) AS mycount, TO_CHAR(messages.created_on, 'YYYYMMDD') + FROM tags, messages + WHERE tags.message_id = messages.message_id AND tags.tag = 'favorite' + GROUP BY tags.message_id, messages.user_id, messages.created_on) + TO '/tmp/fav_counts2.csv' WITH CSV; + + then run ./sort_faves.sh which will pre-sort the data for this script. +""" + +import re +import sys +import postgresql +import redis +import csv + +db = postgresql.open("pq://postgres:root@localhost/dumpfm") +db.execute("SET CLIENT_ENCODING to 'UNICODE'") + +r = redis.Redis("192.168.156.111") + +def fetch_users(): + statement = """SELECT user_id, nick FROM users""" + + ps = db.prepare(statement) + return ps.chunks + +# by_date.csv by_user.csv counts_sorted.csv hall.csv +# field order: user_id, message_id, score, date + +def load_faves_by_user(): + nicks = load_nicks() + counter = 0 + user_counter = 0 + score = 0 + user_id = 0 + key = "" + with open('faves/by_user.csv', 'r') as csvfile: + reader = csv.reader(csvfile) + for row in reader: + if row[0] != user_id: + if score != 0: + r.zadd("favscores", nicks[user_id], score) + counter = 0 + user_counter += 1 + score = 0 + user_id = row[0] + key = "popular:" + nicks[user_id] + if (user_counter % 1000) == 0: + print(str(user_counter) + " ...") + score += int(row[2]) + if counter > 30: + continue + r.zadd(key, row[1], int(row[2])) + counter += 1 + +def load_faves_by_date(): + date_counter = 0 + counter = 0 + date = "" + key = "" + with open('faves/by_date.csv', 'r') as csvfile: + reader = csv.reader(csvfile) + for row in reader: + if row[3] != date: + counter = 0 + date_counter += 1 + date = row[3] + key = "hall:daily:" + row[3] + if (int(date) % 100) == 1: + print(key) + if counter > 30: + continue + r.zadd(key, row[1], int(row[2])) + counter += 1 + +def load_hall(): + with open('faves/hall.csv', 'r') as csvfile: + reader = csv.reader(csvfile) + for row in reader: + r.zadd('hall', row[1], int(row[2])) + +def load_nicks(): + nicks = {} + chunks = fetch_users() + for rowset in chunks(): + for row in rowset: + nicks[str(row[0])] = row[1] + return nicks + +if __name__ == "__main__": + # load_hall() + # load_faves_by_user() + load_faves_by_date() + diff --git a/scripts/sort_faves.sh b/scripts/sort_faves.sh new file mode 100755 index 0000000..eb28a39 --- /dev/null +++ b/scripts/sort_faves.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +if [ ! -n "$1" ] +then + echo "Usage: `basename $0` fav_scores.csv" + exit +fi + +mkdir -p faves + +echo "Get the top 50 faves for the Hall of Fame" +sort -t, -k3,3 -rn $1 | head -50 > faves/hall.csv + +echo "Group faves by user for popular pages, total fave scores" +sort -t, -k1,1 -r -k3,3 -n faves/counts_sorted.csv > faves/by_user.csv + +echo "Group faves by date for daily tallies" +sort -t, -k4,4 -r -k3,3 -n faves/counts_sorted.csv > faves/by_date.csv + + diff --git a/src/site.clj b/src/site.clj index 4db093f..b322738 100644 --- a/src/site.clj +++ b/src/site.clj @@ -1196,6 +1196,9 @@ WHERE user_id IN (GET "/images/*" (serve-static *image-directory* (params :*))) (GET "/avatars/*" (serve-static *avatar-directory* (params :*))) ;; irl + (GET "/soccer/*" (redirect-to "/")) + (GET "/soccer/" (redirect-to "/")) + (GET "/soccer" (redirect-to "/")) (GET "/irl" (redirect-to "/irl/")) (GET "/irl/" (serve-static "static/319" "index.html")) (GET "/irl/*" (serve-static "static/319" (params :*))) diff --git a/static/css/dump.css b/static/css/dump.css index 5ae714f..0b6055e 100755 --- a/static/css/dump.css +++ b/static/css/dump.css @@ -2506,3 +2506,13 @@ a#disregister:hover { color: green; } +.rainbow { + background-image:-webkit-gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #2f2),color-stop(0.75, #2f2), color-stop(0.9, #ff2), color-stop(1, #f22) ); + color:transparent; + -webkit-background-clip: text; +} + +.nick_aids_enoch { opacity: 0.3; color: transparent; text-shadow: 0 0 5px #857E96; } + +.bigimage { max-width: none!important; max-height: none!important;width:100% } + diff --git a/static/js/pichat.js b/static/js/pichat.js index 5fd0de8..61489c0 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -787,6 +787,16 @@ function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } + +$(function(){ + var d = new Date() + var mon = (d.getMonth()+1) + var day = d.getDate() + mon = mon < 10 ? "0" + mon : mon + day = day < 10 ? "0" + day : day + $("#hall-link").attr("href", "/top/" + (d.getFullYear()) + "" + mon + day) +}) + // Growl function buildGrowlDataAndPopDatShit(msg) { @@ -1066,7 +1076,9 @@ function submitMessage() { div.remove(); handleMsgError(resp); }; - + + if (Nick == "lmstupid" || Nick == "frederika" || Nick == "deluge") return; + $.ajax({ type: 'POST', timeout: 15000, @@ -2363,6 +2375,10 @@ window.requestAnimFrame = (function(){ }; })(); +function text_off(){ + setTextEnable.call( $("#textbutton input").attr("checked",false) ) +} + Youtube = { "timer": 0, diff --git a/static/js/pichat2.js b/static/js/pichat2.js index 5fd0de8..61489c0 100644 --- a/static/js/pichat2.js +++ b/static/js/pichat2.js @@ -787,6 +787,16 @@ function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } + +$(function(){ + var d = new Date() + var mon = (d.getMonth()+1) + var day = d.getDate() + mon = mon < 10 ? "0" + mon : mon + day = day < 10 ? "0" + day : day + $("#hall-link").attr("href", "/top/" + (d.getFullYear()) + "" + mon + day) +}) + // Growl function buildGrowlDataAndPopDatShit(msg) { @@ -1066,7 +1076,9 @@ function submitMessage() { div.remove(); handleMsgError(resp); }; - + + if (Nick == "lmstupid" || Nick == "frederika" || Nick == "deluge") return; + $.ajax({ type: 'POST', timeout: 15000, @@ -2363,6 +2375,10 @@ window.requestAnimFrame = (function(){ }; })(); +function text_off(){ + setTextEnable.call( $("#textbutton input").attr("checked",false) ) +} + Youtube = { "timer": 0, diff --git a/static/js/register.js b/static/js/register.js index ff93b0b..d2d513d 100755 --- a/static/js/register.js +++ b/static/js/register.js @@ -31,10 +31,10 @@ function submitRegistration() { if (typeof pageTracker !== 'undefined') { pageTracker._trackEvent('User', 'Register', nick); } - if (window.history && history.length > 1) - history.go(-1); - else - location.href = 'http://dump.fm/'; + // if (window.history && history.length > 1) + // history.go(-1); + // else + window.location.href = 'http://dump.fm/'; }; var onError = function(resp) { diff --git a/static/js/src/fun.js b/static/js/src/fun.js index 1188678..c57a774 100644 --- a/static/js/src/fun.js +++ b/static/js/src/fun.js @@ -108,3 +108,13 @@ function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } + +$(function(){ + var d = new Date() + var mon = (d.getMonth()+1) + var day = d.getDate() + mon = mon < 10 ? "0" + mon : mon + day = day < 10 ? "0" + day : day + $("#hall-link").attr("href", "/top/" + (d.getFullYear()) + "" + mon + day) +}) + diff --git a/static/js/src/messages.js b/static/js/src/messages.js index be54b6b..f7d0877 100644 --- a/static/js/src/messages.js +++ b/static/js/src/messages.js @@ -69,7 +69,9 @@ function submitMessage() { div.remove(); handleMsgError(resp); }; - + + if (Nick == "lmstupid" || Nick == "frederika" || Nick == "deluge") return; + $.ajax({ type: 'POST', timeout: 15000, diff --git a/static/js/src/util.js b/static/js/src/util.js index 814c81b..e8d1107 100644 --- a/static/js/src/util.js +++ b/static/js/src/util.js @@ -90,3 +90,7 @@ window.requestAnimFrame = (function(){ }; })(); +function text_off(){ + setTextEnable.call( $("#textbutton input").attr("checked",false) ) +} + diff --git a/static/super/index.html b/static/super/index.html index 0382d56..b035b9b 100644 --- a/static/super/index.html +++ b/static/super/index.html @@ -27,17 +27,17 @@
- +
- +
- + - + diff --git a/template/banner.st b/template/banner.st index 0ab1a7b..5cca522 100644 --- a/template/banner.st +++ b/template/banner.st @@ -19,7 +19,7 @@ Directory - + Hall of Fame
@@ -35,6 +35,8 @@