diff options
| author | Scott Ostler <scottbot9000@gmail.com> | 2010-06-22 17:57:01 -0400 |
|---|---|---|
| committer | Scott Ostler <scottbot9000@gmail.com> | 2010-06-22 17:57:01 -0400 |
| commit | 7db4f66dc4510ea11c0b0f09569d8477c9fac90f (patch) | |
| tree | 92ae52c26bdaddeca0c8833b99f585880cf05637 | |
| parent | 42b7ddecd5bc2825755934c04d1d29be68e3ccc5 (diff) | |
Added recent dumps to profile
| -rw-r--r-- | src/site.clj | 10 | ||||
| -rw-r--r-- | template/banner.st | 219 | ||||
| -rw-r--r-- | template/form_login.st | 28 | ||||
| -rw-r--r-- | template/profile.st | 138 | ||||
| -rw-r--r-- | template/search_script.st | 98 |
5 files changed, 239 insertions, 254 deletions
diff --git a/src/site.clj b/src/site.clj index 00729fc..347100a 100644 --- a/src/site.clj +++ b/src/site.clj @@ -419,7 +419,13 @@ FROM users u has-avatar (non-empty-string? (user-info :avatar)) dump-cnt (count-dumps-posted profile-nick) fav-from-cnt (count-dumps-user-faved profile-nick) - score (lookup-score profile-nick)] + score (lookup-score profile-nick) + raw-dumps (logger tags/fetch-dumps-by-nick + :nick profile-nick + :amount 5) + dumps (map tags/add-favorited-flag (take 5 raw-dumps) (repeat session)) + dumps (map tags/remove-tags-for-output dumps) + dumps (logger doall (map process-message-for-output dumps))] (do (.setAttribute st "is_home" is-home) (doseq [a [:nick :avatar :contact :bio]] @@ -430,6 +436,8 @@ FROM users u (.setAttribute st "score_ent" (score-to-entity score)) (.setAttribute st "dump_cnt" (comma-format dump-cnt)) (.setAttribute st "dumps_user_faved_cnt" (comma-format fav-from-cnt)) + (if (not (empty? dumps)) + (.setAttribute st "dumps" dumps)) (.setAttribute st "debug_log_items" (logger)) (.toString st))) (resp-error "NO_USER")))) diff --git a/template/banner.st b/template/banner.st index 88ac21f..f94971f 100644 --- a/template/banner.st +++ b/template/banner.st @@ -1,171 +1,74 @@ <div id="rapper7"> <div id="header7"> - <div id="logoicons"> - <div id="logo7"> - <div align="center"> - <img style="visibility:hidden;width:0px;height:0px;" border=0 width=0 height=0 /> -<a class="img_roll" href="http://dump.fm/"></a> - - - </div> - </div> - <div class="white"> - - <div id="bar7"> - <div style="float: left;"> - <div align="center"> - $if(user_nick)$ - - - <a href="http://dump.fm/log" ><img src="/static/img/log.gif"width="20px" height="20px">♣ Log</a> - <a href="http://dump.fm/$user_nick$">$if(user_avatar)$<img src="$user_avatar$" width="19px" height="19px" />$else$<img src="/static/img/profile.gif"width="22px" height="22px" />$endif$♥ Profile</a> - <a href="http://dump.fm/directory"><img src="/static/img/directory.gif"width="20px" height="20px" />♠ Directory</a> - <a href="http://dump.fm/$user_nick$/favorites">❤ Favs</a> - <a href="http://dump.fm/browser"><img src="/static/img/image_draw.gif"/>♦ Image Search</a> - - $else$ - - -<a href="/register" id="registerlink">The coolest way to share pictures. Click here to get started!</a> - - $endif$ - - </div> + <div id="logoicons"> + <div id="logo7"> + <div align="center"> + <img style="visibility:hidden;width:0px;height:0px;" border=0 width=0 height=0 /> + <a class="img_roll" href="http://dump.fm/"></a> + </div> + </div> + <div class="white"> + <div id="bar7"> + <div style="float: left;"> + <div align="center"> + $if(user_nick)$ + <a href="http://dump.fm/log"><img src="/static/img/log.gif"width="20px" height="20px">♣ Log</a> + <a href="http://dump.fm/$user_nick$"> + $if(user_avatar)$ + <img src="$user_avatar$" width="19px" height="19px" /> + $else$ + <img src="/static/img/profile.gif"width="22px" height="22px" /> + $endif$ + ♥ Profile</a> + <a href="http://dump.fm/directory"> + <img src="/static/img/directory.gif" width="20px" height="20px" />♠ Directory + </a> + <a href="http://dump.fm/$user_nick$/favorites">❤ Favs</a> + <a href="http://dump.fm/browser"><img src="/static/img/image_draw.gif"/>♦ Image Search</a> + $else$ + <a href="/register" id="registerlink">The coolest way to share pictures. Click here to get started!</a> + $endif$ + </div> </div> - </div> + </div> </div> </div> -$if(isadmin)$ -<div id="searchbox"> -<input type="text" name="search-query" id="search-query" value="search dump.fm" -onblur="this.className = ''; resume_key_commands(); if (this.value == '') { this.value = default_search_text; this.style.color = '#c0c8d3'; }" onfocus="suspend_key_commands(); if (this.value == default_search_text) { this.value = ''; this.style.color = '#5c7480'; }" style="color: rgb(192, 200, 211);" class=""/> -<a href=# onclick="hideItem(searchresults);"><div class="search_icon"></div></a> -</div> -$endif$ - + $if(isadmin)$ + <div id="searchbox"> + <input type="text" name="search-query" id="search-query" value="search dump.fm" + onblur="this.className = ''; resume_key_commands(); if (this.value == '') { this.value = default_search_text; this.style.color = '#c0c8d3'; }" + onfocus="suspend_key_commands(); if (this.value == default_search_text) { this.value = ''; this.style.color = '#5c7480'; }" + style="color: rgb(192, 200, 211);" class="" /> + <a href="#" onclick="hideItem(searchresults);"> + <div class="search_icon"></div></a> + </div> + $endif$ <div id="topic"></div> - <div id="dumplist"> - $if(user_nick)$ - - - want a room? <a href="mailto:info@dump.fm">contact us! - <a href="http://dump.fm/chat/vortex"> checkout the image vortex!! </a>$else$ Talk with pictures! - <a href="http://dump.fm/chat/vortex"> checkout the nifty dump fm image vortex! </a> $endif$ $if(isadmin)$ - <a href="http://news.dump.fm">- news</a> - <a href="http://gossip.dump.fm">gossip</a> - <a href="http://art.dump.fm">art</a> - <a href="http://gif.dump.fm">gif</a> - <a href="http://design.dump.fm">design</a> - <a href="http://fashion.dump.fm">fashion</a> - - + <div id="dumplist"> + $if(user_nick)$ + want a room? <a href="mailto:info@dump.fm">contact us! - <a href="http://dump.fm/chat/vortex"> checkout the image vortex!! </a>$else$ Talk with pictures! - <a href="http://dump.fm/chat/vortex"> checkout the nifty dump fm image vortex! </a> $endif$ $if(isadmin)$ + <a href="http://news.dump.fm">- news</a> - <a href="http://gossip.dump.fm">gossip</a> - <a href="http://art.dump.fm">art</a> - <a href="http://gif.dump.fm">gif</a> - <a href="http://design.dump.fm">design</a> - <a href="http://fashion.dump.fm">fashion</a> -<a href="http://vip.dump.fm/"> VIP PIMP DEN (<del>GIRLS</del> BOYS ARE COOL) </a> - $endif$ + $endif$ + </div> + $if(user_nick)$ + <div id="logout7" class="white"> + <div align="center"> + <a href="/logout">Logout</a> + </div> + $else$ + <div id="toplogin" class="white"> + $form_login()$ </div> -$if(user_nick)$ - <div id="logout7" class="white"> - <div align="center"> <a href="/logout"> Logout</a> </div>$else$ <div id="toplogin" class="white"> $form_login()$</div> $endif$ -<div id="searchresults"></div> - + $endif$ + <div id="searchresults"></div> </div> <div align="center"><br /></div> - </div> </div> -$if(isadmin)$ - <script> - var term = "" - var imagesPerPage = 25; - var images = [] - - function addScript(term){ - jQuery("#search-script").remove() - jQuery("head").append("<scr"+"ipt src='/cmd/ghettosearch/"+term+"' id='search-script'></sc"+"ript>") - } - - function setContent(x){ - jQuery("#searchresults").html(x) - } - - function setMessage(x){ - jQuery("#message").html(x) - } - - function searchError(error){ - setContent("") - setMessage(error) - } - - function renderPage(num){ - if (images.length > 0) - setMessage("page " + (num + 1)); - var contentString = '' - var start = num * imagesPerPage - var imageCounter = 0 - for(var i = start; i < images.length; i++){ - if(imageCounter > imagesPerPage) break; - contentString += '<a href="'+images[i]+'"target="_blank"><img src="'+images[i]+'"></a>' - imageCounter += 1 - } - contentString += '<br><br>' - if(num > 0) - contentString += '<a href="javascript:renderPage('+(num-1)+')"><h1>previous</h1></a> ' - if (images.length > start + imageCounter) - contentString += ' <a href="javascript:renderPage('+(num+1)+')"><h1>next</h1></a>' - setContent(contentString) - } - - function searchResult(results){ - images = [] - var alreadyGot = {} - if(results === null || results.length == 0) { - setContent("") - setMessage("no results found") - } else { - for(var r = 0; r<results.length; r++){ - var content = results[r]['content'] - if (content.substring(0,6) == "<safe>") continue; // skip html posts - var imageUrls = getImagesAsArray(content); - for (var i=0; i<imageUrls.length; i++){ - var imageUrl = imageUrls[i]; - if (imageUrl in alreadyGot) continue; - alreadyGot[imageUrl] = true - var validImage = true; - for(var t = 0; t<tokens.length; t++){ - if (imageUrl.toLowerCase().indexOf(tokens[t]) == -1) { - validImage = false; - break; - } - } - if (validImage) - images.push(imageUrl); - } - } - if (images.length == 0) { - setMessage("no results found") - } - renderPage(0) - } - } - - var tokens = [] - - function doSearch(){ - term = jQuery("#search-query").val().trim().toLowerCase() - var rawTokens = term.split(" ") - tokens = [] - for(var t = 0; t < rawTokens.length; t++) { - if (rawTokens[t].length > 2) - tokens.push(rawTokens[t]) - } - if (tokens.length == 0) { - setMessage("search query too small") - } else { - setMessage("searching for '"+tokens.join(" and ")+"'") - addScript(tokens.join("+")) - } - } - // only search every 800ms while someone is typing - function keyHandler(){ - if (keyHandler.timeout) clearTimeout(keyHandler.timeout); - keyHandler.timeout = setTimeout(doSearch, 800) - } - - jQuery("#search-query").keyup(keyHandler) - - </script> - $endif$
\ No newline at end of file +$if(isadmin)$ +<script> + $search_script()$ +</script> +$endif$ diff --git a/template/form_login.st b/template/form_login.st index 4d78b20..0ca2107 100644 --- a/template/form_login.st +++ b/template/form_login.st @@ -2,29 +2,19 @@ <div class="topnav"><a href="login" class="signin"><span>Sign in</span></a> </div> <fieldset id="signin_menu"> <form onsubmit="return false"> - </p> - </p> - </p><br> - </p> - - - <i></i> + <br> <input id="nickInput" name="nickInput" title="username" tabindex="4" type="text"> - </p> <p> - <input id="passwordInputLabel" name="passwordInputLabel" tabindex="5" type="text" class="invisible"> - <input id="passwordInput" name="passwordInput" title="password" tabindex="5" type="password"> + <input id="passwordInputLabel" name="passwordInputLabel" tabindex="5" type="text" class="invisible"> + <input id="passwordInput" name="passwordInput" title="password" tabindex="5" type="password"> </p> - - - <p class="remember"><br> -<input id="signin-submit" value="Sign in" tabindex="6" type="submit"> -<br><br> - <label> - <input type="checkbox" name="rememberme" id="remembermeInput" checked="checked"/> - Remember Me - </label> + <input id="signin-submit" value="Sign in" tabindex="6" type="submit"> + <br><br> + <label> + <input type="checkbox" name="rememberme" id="remembermeInput" checked="checked"/> + Remember Me + </label> </p> </form> </fieldset> diff --git a/template/profile.st b/template/profile.st index 5278e77..ea554ab 100644 --- a/template/profile.st +++ b/template/profile.st @@ -10,92 +10,78 @@ </script> </head> <body> - $if(avatar)$ - <div id="dashtotal"style="background-image:url($avatar$);opacity:0.1;width:100%;height:100%;z-index:-1"></div> - $else$ + $if(avatar)$ + <div id="dashtotal"style="background-image:url($avatar$);opacity:0.1;width:100%;height:100%;z-index:-1"></div> + $else$ <div id="dashtotal"style="background-image:url(http://dump.fm/static/img/thumbs/stripes.gif);width:100%;height:100%;z-index:-1"></div> $endif$ $banner()$ - - <div id="dashrapper"> - <div id="dashuserlist"> - $if(avatar)$ - <div id="dashavatar"> - <img id="dashavatarPic" src="$avatar$"/> </div> - $else$ - <img id="avatarPic" src="/static/img/noinfo.png"> - - $endif$ + + <div id="dashrapper"> + <div id="dashuserlist"> + $if(avatar)$ + <div id="dashavatar"> + <img id="dashavatarPic" src="$avatar$"/> + </div> + $else$ + <img id="avatarPic" src="/static/img/noinfo.png"> + + $endif$ - $if(isadmin)$ - <div id="dashadminmute"> - <a href="#" onclick="Admin.mute('$nick$'); return false">Mute $nick$!</a> - </div> - $endif$ + $if(isadmin)$ + <div id="dashadminmute"> + <a href="#" onclick="Admin.mute('$nick$'); return false">Mute $nick$!</a> + </div> + $endif$ - - - - $if(is_home)$ - <div id="avatar-editing" style="display: none"> - <input id="uploadp" value="Upload Icon" type="submit"> - <img id="spinner" src="/static/img/spinner.gif" style="display: none" /> - </div> - $endif$ - <div id="dashinfo"> - <h2> - $nick$$if(score_ent)$$score_ent$$endif$ </h2> - - <br> <h3>contact info</h3> - $if(contact)$ - <div id="contact" class="linkify">$contact$</div> - $else$ - <img id="contact" src="/static/img/noinfo.png"> - $endif$ + $if(is_home)$ + <div id="avatar-editing" style="display: none"> + <input id="uploadp" value="Upload Icon" type="submit"> + <img id="spinner" src="/static/img/spinner.gif" style="display: none" /> + </div> + $endif$ + <div id="dashinfo"> + <h2> + $nick$$if(score_ent)$$score_ent$$endif$ </h2> + + <br> <h3>contact info</h3> + $if(contact)$ + <div id="contact" class="linkify">$contact$</div> + $else$ + <img id="contact" src="/static/img/noinfo.png"> + $endif$ <br> - <h3>bio</h3> - $if(bio)$ - <div id="bio" class="linkify">$bio$</div> - $else$ - <img id="bio" src="/static/img/noinfo.png"> - $endif$ - -</div> - - - $if(is_home)$ - - <div id="edit-toggle"><a href="#">edit profile</a></div> - $endif$ -</div> - - <div id="middash"> - - - <h2><a href="http://dump.fm/$nick$/log">$dump_cnt$ dumps ➡</a></h2> - <hr> - + <h3>bio</h3> + $if(bio)$ + <div id="bio" class="linkify">$bio$</div> + $else$ + <img id="bio" src="/static/img/noinfo.png"> + $endif$ + </div> + $if(is_home)$ + + <div id="edit-toggle"><a href="#">edit profile</a></div> + $endif$ + </div> - </h8> - <h2><a href="http://dump.fm/$nick$/favorites">$dumps_user_faved_cnt$ dumps Faved ➡</a></h2> - <hr> - <h3> $if(score_ent)$ $score$ $else$ 0 $endif$ of $if(is_home)$ your $else$ $nick$'s$endif$ dumps Faved</h3> - </div> - <div id="dashpix" style="display:none;"> + <div id="middash"> + <h2><a href="http://dump.fm/$nick$/log">$dump_cnt$ dumps ➡</a></h2> + <hr> + <h2><a href="http://dump.fm/$nick$/favorites">$dumps_user_faved_cnt$ dumps Faved ➡</a></h2> + <hr> + <h3>$if(score_ent)$ $score$ $else$ 0 $endif$ of $if(is_home)$ your $else$ $nick$'s$endif$ dumps Faved</h3> + </div> + <div id="dashpix"> <div id="favstxt">$nick$'s most recent favs</div> - <img src="http://www.poppindots.com/Images/Quote_Glitter_Graphics/images/quote11.gif"> - <img src="http://polisat.com/Images/MotherEarthFlatNoMore-Gif-At377x480.gif"> - <img src="http://www.leconcombre.com/gifgallery/cuke/image/oiseaubleu1.gif"> - <img src="http://dump.fm/images/20100618/1276900577123-dumpfm-saywhaaa-webcam.jpg"> - </div> - </div> -</div></div></div> - <div id="footerc"> - $footer()$ - </div> + $dumps: { d | $log_dump(dump=d)$ }$ + </div> + </div> +<div id="footerc"> + $footer()$ +</div> - </body> +</body> </html> diff --git a/template/search_script.st b/template/search_script.st new file mode 100644 index 0000000..94461b3 --- /dev/null +++ b/template/search_script.st @@ -0,0 +1,98 @@ +var term = "" +var imagesPerPage = 25; +var images = [] +function addScript(term) { + jQuery("#search-script").remove() + jQuery("head").append("<scr"+"ipt src='/cmd/ghettosearch/"+term+"' id='search-script'></sc"+"ript>") +} + +function setContent(x){ + jQuery("#searchresults").html(x) +} + +function setMessage(x){ + jQuery("#message").html(x) +} + +function searchError(error){ + setContent("") + setMessage(error) +} + +function renderPage(num){ + if (images.length > 0) + setMessage("page " + (num + 1)); + var contentString = '' + var start = num * imagesPerPage + var imageCounter = 0 + for(var i = start; i < images.length; i++){ + if(imageCounter > imagesPerPage) break; + contentString += '<a href="'+images[i]+'"target="_blank"><img src="'+images[i]+'"></a>' + imageCounter += 1 + } + contentString += '<br><br>' + if(num > 0) + contentString += '<a href="javascript:renderPage('+(num-1)+')"><h1>previous</h1></a> ' + if (images.length > start + imageCounter) + contentString += ' <a href="javascript:renderPage('+(num+1)+')"><h1>next</h1></a>' + setContent(contentString) +} + +function searchResult(results){ + images = [] + var alreadyGot = {} + if(results === null || results.length == 0) { + setContent("") + setMessage("no results found") + } else { + for(var r = 0; r<results.length; r++){ + var content = results[r]['content'] + if (content.substring(0,6) == "<safe>") continue; // skip html posts + var imageUrls = getImagesAsArray(content); + for (var i=0; i<imageUrls.length; i++){ + var imageUrl = imageUrls[i]; + if (imageUrl in alreadyGot) continue; + alreadyGot[imageUrl] = true + var validImage = true; + for(var t = 0; t<tokens.length; t++){ + if (imageUrl.toLowerCase().indexOf(tokens[t]) == -1) { + validImage = false; + break; + } + } + if (validImage) + images.push(imageUrl); + } + } + if (images.length == 0) { + setMessage("no results found") + } + renderPage(0) + } +} + +var tokens = [] + +function doSearch(){ + term = jQuery("#search-query").val().trim().toLowerCase() + var rawTokens = term.split(" ") + tokens = [] + for(var t = 0; t < rawTokens.length; t++) { + if (rawTokens[t].length > 2) + tokens.push(rawTokens[t]) + } + if (tokens.length == 0) { + setMessage("search query too small") + } else { + setMessage("searching for '"+tokens.join(" and ")+"'") + addScript(tokens.join("+")) + } +} + +// only search every 800ms while someone is typing +function keyHandler(){ + if (keyHandler.timeout) clearTimeout(keyHandler.timeout); + keyHandler.timeout = setTimeout(doSearch, 800) +} + +jQuery("#search-query").keyup(keyHandler)
\ No newline at end of file |
