From 899f7fb8f57f01e388a46869ac0f55314b043a37 Mon Sep 17 00:00:00 2001 From: tim b Date: Thu, 10 Jun 2010 08:42:40 -0700 Subject: search for multiple tokens. fix case issues --- src/site.clj | 20 +++++++++++--------- template/search_files.st | 29 ++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/site.clj b/src/site.clj index 8596021..75980aa 100644 --- a/src/site.clj +++ b/src/site.clj @@ -795,22 +795,24 @@ FROM users u favs (reduce (fn [m fav] (assoc m (str (fav :message_id)) (fav :content))) {} raw-favs)] (str "RawFavs=" (json-str favs)))) -(defn ghetto-search-query [] +(defn ghetto-search-query [num-tokens] (str "select content from messages, rooms where messages.room_id=rooms.room_id - and content ilike ? and content like '%http://%' + and content ilike " (str-join " and content ilike " (take num-tokens (repeat "?"))) " + and content like '%http://%' and admin_only = 'f' order by message_id desc limit 250;")) -(def *ghetto-search-regex* #"^[A-Za-z0-9\-_]*$") +(def *ghetto-search-regex* #"^[A-Za-z0-9\-_.+]*$") -(defn json-ghetto-search [searchterm] - ( if (re-matches *ghetto-search-regex* searchterm) - (let [searchterm (str "%" searchterm "%") - query (ghetto-search-query) - rows (do-select [query searchterm])] +(defn json-ghetto-search [undecoded-url-searchterms] + ( if (re-matches *ghetto-search-regex* undecoded-url-searchterms) + (let [tokens (map url-decode (re-split #"\+" undecoded-url-searchterms)) + tokens (map #(str "%" %1 "%") tokens) + query (ghetto-search-query (count tokens)) + rows (do-select (vec (concat [query] tokens)))] (str "searchResult(" (json-str rows) ")")) (str "searchError('sorry, no fancy characters')"))) @@ -1020,7 +1022,7 @@ FROM users u (POST "/cancel-mute" (handle-cancel-mute! session params)) (GET "/profile-test/:t" (profile session "ryder" "0" (params :t))) - (GET "/cmd/ghettosearch/:searchterm" (json-ghetto-search (params :searchterm))) + (GET "/cmd/ghettosearch/:searchterm" (json-ghetto-search (undecoded-url-piece (request-url request) 2))) (GET "/search" (serve-template "search_files" session)) ;; Footer pages diff --git a/template/search_files.st b/template/search_files.st index f726364..d3deea5 100644 --- a/template/search_files.st +++ b/template/search_files.st @@ -9,7 +9,7 @@ -
search dumps:
+
search dumps:




@@ -72,8 +72,15 @@ var imageUrl = imageUrls[i]; if (imageUrl in alreadyGot) continue; alreadyGot[imageUrl] = true - if (imageUrl.indexOf(term) > -1) - images.push(imageUrl) + var validImage = true; + for(var t = 0; t 2) + tokens.push(rawTokens[t]) + } + if (tokens.length == 0) { setMessage("search query too small") } else { - setMessage("searching for '"+term+"'") - addScript(term) + setMessage("searching for '"+tokens.join(" and ")+"'") + addScript(tokens.join("+")) } } -- cgit v1.2.3-70-g09d2 From a5076000b758641d459a301b3d0155fdf4c3a76c Mon Sep 17 00:00:00 2001 From: dumpfmprod Date: Thu, 10 Jun 2010 15:20:01 -0400 Subject: sostler prod commit --- static/form_login/front.css | 2 +- static/registerr.html | 112 ++++++++++++++++++++++++++++++++++++++++++++ template/banner.st | 3 +- template/form_login.st | 2 +- template/profile.st | 2 +- template/tagged_dumps.st | 1 - 6 files changed, 117 insertions(+), 5 deletions(-) create mode 100644 static/registerr.html diff --git a/static/form_login/front.css b/static/form_login/front.css index 05d23ac..444c54b 100644 --- a/static/form_login/front.css +++ b/static/form_login/front.css @@ -118,7 +118,7 @@ filter: progid:DXImageTransform.Microsoft.dropShadow(color=#ccc, offX=3, offY=4, #signin_menu p a { color:#27B!important; } -#signin-submitform { +#signin-submit { display:inline-block; width:90px; height:35px; diff --git a/static/registerr.html b/static/registerr.html new file mode 100644 index 0000000..3111cf7 --- /dev/null +++ b/static/registerr.html @@ -0,0 +1,112 @@ + + + dump.fm + + + + + + + + + + + + + + +
+ + +
+
+
+Click here to Register! +
+
+preview dump.fm! +
+
+
+
+ dlkhjdfsgkhjgdhjklgsdfdgfjlhkdfg +
+ +
+ + +
+ +
+
Already a member?


+
+ +
+ + +
+
+ Lost password?
+
+
+
+ +
+ + +
+ +
+ + + + + diff --git a/template/banner.st b/template/banner.st index 3339fc2..ea7c826 100644 --- a/template/banner.st +++ b/template/banner.st @@ -33,6 +33,7 @@ a.img_roll:hover{ ♣ Log $if(user_avatar)$$else$$endif$♥ Profile ♠ Directory + ❤ Favs ♦ Image Search $else$ @@ -50,7 +51,7 @@ a.img_roll:hover{
-
dump.fm - let pictures do the talking $if(user_nick)$- my favorite pics - - justin bieber $endif$ $if(isadmin)$ +
dump.fm - let pictures do the talking $if(user_nick)$ - justin bieber $endif$ $if(isadmin)$ - news - gossip - art - gif - design - fashion diff --git a/template/form_login.st b/template/form_login.st index 33d240d..4d78b20 100644 --- a/template/form_login.st +++ b/template/form_login.st @@ -19,7 +19,7 @@


- +

diff --git a/template/tagged_dumps.st b/template/tagged_dumps.st index 4bc271d..f1fd4ad 100644 --- a/template/tagged_dumps.st +++ b/template/tagged_dumps.st @@ -21,7 +21,6 @@
-
$endif$ $page_title$

-- cgit v1.2.3-70-g09d2