Skip to content

Instantly share code, notes, and snippets.

@ohpauleez
Created June 28, 2012 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ohpauleez/3014768 to your computer and use it in GitHub Desktop.
Save ohpauleez/3014768 to your computer and use it in GitHub Desktop.
Quick service example
(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