From bb2e003f9f3362fca15272f527a6f87543ec1a21 Mon Sep 17 00:00:00 2001 From: tim b Date: Thu, 24 Jun 2010 23:13:08 -0700 Subject: add fav to permalinks, link to conextual domain for local testing, longer fadeout on fav, cleanup some html --- src/site.clj | 10 ++++++---- src/tags.clj | 22 ++++++++++++++++++++++ src/utils.clj | 17 ++++++++++------- static/css/dump.css | 18 +++++++++++------- static/index.html | 1 - static/js/pichat.js | 9 ++++++++- static/js/register.js | 5 ----- template/banner.st | 14 +++++++------- template/chat.st | 12 +++++------- template/directory.st | 1 - template/fame.st | 1 - template/fame_dump.st | 2 ++ template/head.st | 15 ++++++++------- template/log.st | 1 - template/log_dump.st | 2 ++ template/nigga.st | 1 - template/profile.st | 1 - template/profile_dump.st | 2 ++ template/profilelog.st | 1 - template/share_buttons.st | 19 ++++++++++--------- template/single_message.st | 33 ++++++++++++++------------------- template/userlog.st | 1 - 22 files changed, 107 insertions(+), 81 deletions(-) diff --git a/src/site.clj b/src/site.clj index 0967431..fc2999f 100644 --- a/src/site.clj +++ b/src/site.clj @@ -17,7 +17,7 @@ admin compojure email - fame + fame utils cookie-login session-sweeper @@ -145,7 +145,7 @@ (first (do-select [query (maybe-parse-int m-id -1)])))) (defn fetch-public-message-by-id [m-id] - (let [msg (fetch-message-by-id m-id)] + (let [msg (tags/fetch-dump-by-id m-id)] (if (and msg (not (:admin_only msg))) msg))) @@ -570,8 +570,10 @@ FROM users u ; error if nick in url doesn't match the nick who posted the message from the id in url ; this prevents people from scraping all the content by incrementing the id in the url (if (= (user-info :user_id) (message :user_id)) - (let [st (fetch-template "single_message" session)] - (.setAttribute st "message" (process-message-for-output message)) + (let [st (fetch-template "single_message" session) + message (tags/add-favorited-flag message session) + message (tags/remove-tags-for-output message)] + (.setAttribute st "dump" (process-message-for-output message)) (.toString st)) (resp-error "NO_MESSAGE")) (resp-error "NO_MESSAGE")) diff --git a/src/tags.clj b/src/tags.clj index de0b476..b6642d3 100644 --- a/src/tags.clj +++ b/src/tags.clj @@ -86,6 +86,22 @@ WHERE EXISTS (defn explain-query [query] (str "EXPLAIN ANALYZE " query)) +(defn fetch-dump-by-message-id-query [] (str +" SELECT + m.content, m.message_id, m.created_on, m.user_id, + u.nick, u.avatar, + r.key, r.admin_only, + array_to_string(ARRAY(SELECT nick || ' ' || tag + FROM tags, users + WHERE message_id = m.message_id AND tags.user_id = users.user_id), ' ') as tags + FROM + messages m, + users u, + rooms r + WHERE m.user_id = u.user_id + AND r.room_id = m.room_id + AND m.message_id = ?")) + ;; OFFSET is very slow when it is large ;; so, a subquery could be used when offset is large ;; one other thing we could do is include message_id in 'next page' url (tumblr & reddit do that for example) @@ -186,6 +202,7 @@ WHERE EXISTS ;; todo: only return distinct dumps? sorted by tag.created_on? ;; tag intersections +;; timb: just realized this is implemented wrongly... looking up "foo+bar" will also match stuff tagged "foo" by two people (defnk fetch-dumps-by-tags-query [:image-only true :num-tags 1 :message-user-id false :tag-user-id false :with-tags true :include-vip false] (str " SELECT m.content, m.message_id, m.created_on, @@ -212,6 +229,11 @@ WHERE EXISTS (if include-vip "" "AND r.admin_only = false"))) +(defn fetch-dump-by-id [m-id] + (let [query (fetch-dump-by-message-id-query)] + (let [rows (do-select [query (maybe-parse-int m-id -1)])] + (first (map parse-tags-from-row-as-tag-map rows))))) + (defnk fetch-dumps-by-room [:room-id 1 :image-only true :amount *dumps-per-page* :offset 0] (let [query (fetch-dumps-by-room-query image-only)] (let [rows (do-select [query room-id amount offset])] diff --git a/src/utils.clj b/src/utils.clj index fbdefda..9008793 100755 --- a/src/utils.clj +++ b/src/utils.clj @@ -13,7 +13,8 @@ clojure.contrib.sql clojure.contrib.duck-streams clojure.contrib.str-utils - compojure)) + compojure + config)) (let [db-host "localhost" db-name "dumpfm" @@ -263,13 +264,15 @@ (try (let [st (.getInstanceOf template-group template)] (if (session :nick) - (doto st - (.setAttribute "user_email" (session :email)) - (.setAttribute "user_nick" (session :nick)) - (.setAttribute "user_avatar" (if (non-empty-string? (session :avatar)) + (doto st + (.setAttribute "user_email" (session :email)) + (.setAttribute "user_nick" (session :nick)) + (.setAttribute "user_avatar" (if (non-empty-string? (session :avatar)) (session :avatar) nil)) - (.setAttribute "isadmin" (session :is_admin))) - st)) + (.setAttribute "isadmin" (session :is_admin)) + (.setAttribute "domain" config/*server-url*)) + (doto st + (.setAttribute "domain" config/*server-url*)))) (catch Exception e nil))) (defn fetch-template-fragment [template] diff --git a/static/css/dump.css b/static/css/dump.css index c149794..6f519bc 100755 --- a/static/css/dump.css +++ b/static/css/dump.css @@ -425,7 +425,7 @@ a.msg-image-zoom img.zoom-icon:hover { } -div.content img:hover{background-color:white;} +/*div.content img:hover{background-color:white;}*/ .nick{background-color:white;margin-right:3px;} .msgDiv dump{background-color:white;} @@ -1425,10 +1425,18 @@ background-color:#fff; -moz-border-radius-bottomright:5px; } -#profiletxt img{ + + +.buttons .permalink img { width:16px; height:16px; } +/* don't show permalink button on permalink pages */ +body.permalink .buttons .permalink { + display: none; +} + + #pnav a { font-size: 30px; color:#000; @@ -1485,22 +1493,18 @@ color:000; .logged-dump img{ max-width:400px; - width: expression(this.width > 600 ? 600: true); max-height:400px; - height: expression(this.width > 600 ? 600: true); border:0px; z-index:4; } #messageList img { max-width:400px; - width: expression(this.width > 600 ? 600: true); max-height:400px; - height: expression(this.width > 600 ? 600: true); z-index:4; } .logged-dump { - background-color:#f0f9ff; + background-color:#fff; text-overflow: ellipsis-word; padding: 18px 18px 6px 18px; font-family: Arial, Helvetica, sans-serif; diff --git a/static/index.html b/static/index.html index a9044ee..62a4cf2 100644 --- a/static/index.html +++ b/static/index.html @@ -2,7 +2,6 @@ dump.fm - diff --git a/static/js/pichat.js b/static/js/pichat.js index 5f66ee2..7b60071 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -240,9 +240,16 @@ function removeFavAndHideBox() { function showFav(f) { $('#favbox').show(); - buildFav(f).appendTo('#favbox').fadeOut(5000, removeFavAndHideBox); + buildFav(f).appendTo('#favbox').animate( + {"opacity": 0}, + {"duration": 9000, + "easing": "easeInExpo", + "complete": removeFavAndHideBox + }) + } + function updateFavs(fs) { if (fs.length == 0) return; diff --git a/static/js/register.js b/static/js/register.js index ebdc095..35fcc8a 100755 --- a/static/js/register.js +++ b/static/js/register.js @@ -26,11 +26,6 @@ function submitRegistration() { return; } - if (password.length < 5) { - alert("Password must be at least 5 characters long."); - return; - } - var hash = hex_sha1(nick + '$' + password + '$dumpfm'); var onSuccess = function() { if (typeof pageTracker !== 'undefined') { diff --git a/template/banner.st b/template/banner.st index f94971f..f025fc6 100644 --- a/template/banner.st +++ b/template/banner.st @@ -4,7 +4,7 @@
- +
@@ -12,19 +12,19 @@
$if(user_nick)$ - ♣ Log - + ♣ Log + $if(user_avatar)$ $else$ $endif$ ♥ Profile - + ♠ Directory - ❤ Favs - ♦ Image Search + ❤ Favs + ♦ Image Search $else$ The coolest way to share pictures. Click here to get started! $endif$ @@ -46,7 +46,7 @@
$if(user_nick)$ - want a room? contact us! - checkout the image vortex!! $else$ Talk with pictures! - checkout the nifty dump fm image vortex! $endif$ $if(isadmin)$ + want a room? contact us! - checkout the image vortex!! $else$ Talk with pictures! - checkout the nifty dump fm image vortex! $endif$ $if(isadmin)$ - news - gossip - art - gif - design - fashion - VIP PIMP DEN (GIRLS BOYS ARE COOL) $endif$ diff --git a/template/chat.st b/template/chat.st index d9de62c..43a1f34 100644 --- a/template/chat.st +++ b/template/chat.st @@ -19,13 +19,11 @@ $head()$ $roomname$ dump.fm - - - - - + + + $if(user_nick)$ - + $endif$ diff --git a/template/fame.st b/template/fame.st index 0fa5b03..2cda789 100644 --- a/template/fame.st +++ b/template/fame.st @@ -2,7 +2,6 @@ dump.fm hall of fame $head()$ - diff --git a/template/fame_dump.st b/template/fame_dump.st index 8ebce02..05cc9fe 100644 --- a/template/fame_dump.st +++ b/template/fame_dump.st @@ -12,11 +12,13 @@ $else$ $endif$
   $dump.count$ +
$dump.content$

$share_buttons()$ diff --git a/template/head.st b/template/head.st index 3fd18c6..faca979 100644 --- a/template/head.st +++ b/template/head.st @@ -1,24 +1,25 @@ - + - + + + $if(!user_nick)$ - + $endif$ $if(isadmin)$ - - + $endif$ - +
$dump.content$

$share_buttons()$ diff --git a/template/nigga.st b/template/nigga.st index 68c85eb..e46e61b 100644 --- a/template/nigga.st +++ b/template/nigga.st @@ -2,7 +2,6 @@ $nick$'s dump.fm $head()$ - - + $banner()$ -
- -
-
- $if(message.avatar)$ -
+
+
+
+$if(dump.avatar)$ +
- +
- - $message.nick$ + $dump.nick$
- $endif$ +
+$endif$
-
-
- - $message.content$ +
$dump.content$

-
+$share_buttons()$
$footer()$ -
+
diff --git a/template/userlog.st b/template/userlog.st index e70ae41..d52efd6 100644 --- a/template/userlog.st +++ b/template/userlog.st @@ -2,7 +2,6 @@ $nick$'s dump.fm $head()$ - -- cgit v1.2.3-70-g09d2