Created
June 28, 2012 23:43
-
-
Save ohpauleez/3014768 to your computer and use it in GitHub Desktop.
Quick service example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns barker.client.search | |
(:require [clojure.string :as cstr] | |
[shoreleave.client.services.geo :as geo] | |
[shoreleave.client.remote :as remote]) | |
(:use [jayq.core :only [$ inner]])) | |
(defn query->map [search-query] | |
(let [[topic location] (map cstr/trim (cstr/split search-query #" near ")) | |
zip (when (re-find #"\d" location) location)] ;if we see an digit, we assume it's some kind of zip | |
{:raw-query search-query :topic topic :location location :zip zip})) | |
;; Here I'm using callbacks instead of hooking into the pubsub system | |
(defn clean-location [search-map search-map-fn] | |
(if-let [location (:location search-map)] | |
(geo/normalize-location location #(search-map-fn (merge search-map %))) | |
(search-map-fn search-map))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment