Skip to content

Commit f89ec30

Browse files
committed
Fill the query input box with the current query.
1 parent b357243 commit f89ec30

File tree

10 files changed

+24
-24
lines changed

10 files changed

+24
-24
lines changed

src/clojars/web.clj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
(browse db account params)))
5858
(GET "/security" []
5959
(try-account
60-
(html-doc account "Security"
60+
(html-doc "Security" {:account account}
6161
(raw (slurp (io/resource "security.html"))))))
6262
session/routes
6363
(group/routes db)
@@ -71,8 +71,7 @@
7171
(ANY "*" _
7272
(try-account
7373
(not-found
74-
(html-doc account
75-
"Page not found"
74+
(html-doc "Page not found" {:account account}
7675
[:div.small-section
7776
[:h1 "Page not found"]
7877
[:p "Thundering typhoons! I think we lost it. Sorry!"]]))))))

src/clojars/web/browse.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
(let [project-count (count-all-projects db)
1212
total-pages (-> (/ project-count per-page) Math/ceil .intValue)
1313
projects (browse-projects db page per-page)]
14-
(html-doc account "All projects"
14+
(html-doc "All projects" {:account account}
1515
[:div.light-article.row
1616
[:h1 "All projects"]
1717
[:div.small-section

src/clojars/web/common.clj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
(defn typekit-js []
6262
[:script "try{Typekit.load();}catch(e){}"])
6363

64-
(defn html-doc [account title & body]
64+
(defn html-doc [title ctx & body]
6565
(html5
6666
[:head
6767
[:link {:type "application/opensearchdescription+xml"
@@ -98,9 +98,10 @@
9898
:id "search"
9999
:class "search"
100100
:placeholder "Search projects..."
101+
:value (:query ctx)
101102
:required true}]]]
102103
[:nav.main-navigation.col-md-6.col-sm-6.col-xs-12.col-lg-6
103-
(if account
104+
(if (:account ctx)
104105
(unordered-list
105106
[(link-to "/" "dashboard")
106107
(link-to "/profile" "profile")
@@ -111,7 +112,7 @@
111112
body
112113
footer]]))
113114

114-
(defn html-doc-with-large-header [account title & body]
115+
(defn html-doc-with-large-header [title ctx & body]
115116
(html5
116117
[:head
117118
[:link {:type "application/opensearchdescription+xml"
@@ -159,7 +160,7 @@
159160
[:h1
160161
(link-to "/" "Clojars")]]
161162
[:nav.main-navigation.col-md-6.col-sm-6.col-xs-12.col-lg-6
162-
(if account
163+
(if (:account ctx)
163164
(unordered-list
164165
[(link-to "/" "dashboard")
165166
(link-to "/profile" "profile")
@@ -181,6 +182,7 @@
181182
:name "q"
182183
:id "search"
183184
:placeholder "Search projects..."
185+
:value (:query ctx)
184186
:autofocus true
185187
:required true}]
186188
[:input {:id "search-button"

src/clojars/web/dashboard.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
(:jar_name jar-map))]]]))
2121

2222
(defn index-page [db stats account]
23-
(html-doc-with-large-header account nil
23+
(html-doc-with-large-header nil {:account account}
2424
[:article.row
2525
[:div.push-information.col-md-6.col-lg-6.col-sm-6.col-xs-12
2626
[:h3.push-header "Push with Leiningen"]
@@ -41,7 +41,7 @@
4141
[:ul.recent-jars-list.row (map #(recent-jar stats %) (recent-jars db))]))
4242

4343
(defn dashboard [db account]
44-
(html-doc account "Dashboard"
44+
(html-doc "Dashboard" {:account account}
4545
[:div.light-article.col-md-12.col-lg-12.col-xs-12.col-sm-12
4646
[:h1 (str "Dashboard (" account ")")]
4747
[:div.col-md-4.col-lg-4.col-sm-4.col-xs-12

src/clojars/web/error_page.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
[hiccup.element :refer [link-to]]))
55

66
(defn error-page-response [error-id]
7-
(-> (response (html-doc nil
8-
"Oops, we encountered an error"
7+
(-> (response (html-doc "Oops, we encountered an error" {}
98
[:div.small-section
109
[:h1 "Oops!"]
1110
[:p

src/clojars/web/group.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[clojars.web.safe-hiccup :refer [form-to]]))
88

99
(defn show-group [db account groupname membernames & errors]
10-
(html-doc account (str groupname " group")
10+
(html-doc (str groupname " group") {:account account}
1111
[:div.small-section.col-md-6.col-lg-6.col-sm-6.col-xs-12
1212
[:h1 (str groupname " group")]
1313
[:h2 "Projects"]

src/clojars/web/jar.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
(submit-button "Promote")))))))
8282

8383
(defn show-jar [db reporter stats account jar recent-versions count]
84-
(html-doc account (str (:jar_name jar) " " (:version jar))
84+
(html-doc (str (:jar_name jar) " " (:version jar)) {:account account}
8585
(let [pom-map (jar-to-pom-map reporter jar)]
8686
[:div.light-article.row
8787
[:div#jar-title.col-sm-9.col-lg-9.col-xs-12.col-md-9
@@ -182,7 +182,7 @@
182182
]])))
183183

184184
(defn show-versions [account jar versions]
185-
(html-doc account (str "all versions of "(jar-name jar))
185+
(html-doc account (str "all versions of "(jar-name jar)) {:account account}
186186
[:div.light-article
187187
[:h1 "all versions of "(jar-link jar)]
188188
[:div.versions

src/clojars/web/login.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[clojars.web.safe-hiccup :refer [form-to]]))
88

99
(defn login-form [login_failed username]
10-
(html-doc nil "Login"
10+
(html-doc "Login" {}
1111
[:div.small-section
1212
[:h1 "Login"]
1313
[:p.hint "Don't have an account? "

src/clojars/web/search.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
{:error (format "Invalid search syntax for query `%s`" query)}))))))
3232

3333
(defn html-search [search account query page]
34-
(html-doc account (str query " - search")
34+
(html-doc (str query " - search") {:account account :query query}
3535
[:div.light-article.row
3636
[:h1 "Search for '" query "'"]
3737
(try

src/clojars/web/user.clj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
[valip.predicates :as pred]))
1919

2020
(defn register-form [{:keys [errors email username pgp-key]}]
21-
(html-doc nil "Register"
21+
(html-doc "Register" {}
2222
[:div.small-section
2323
[:h1 "Register"]
2424
(error-list errors)
@@ -74,7 +74,7 @@
7474
(update-user-validations confirm)))
7575

7676
(defn profile-form [account user flash-msg & [errors]]
77-
(html-doc account "Profile"
77+
(html-doc "Profile" {:account account}
7878
[:div.small-section
7979
(flash flash-msg)
8080
[:h1 "Profile"]
@@ -105,7 +105,7 @@
105105
:flash "Profile updated.")))))
106106

107107
(defn show-user [db account user]
108-
(html-doc account (user :user)
108+
(html-doc (user :user) {:account account}
109109
[:div.light-article.row
110110
[:h1.col-md-12.col-sm-12.col-xs-12.col-lg-12
111111
(user :user)]
@@ -117,7 +117,7 @@
117117
(unordered-list (map group-link (find-groupnames db (user :user))))]]))
118118

119119
(defn forgot-password-form []
120-
(html-doc nil "Forgot password?"
120+
(html-doc "Forgot password?" {}
121121
[:div.small-section
122122
[:h1 "Forgot password?"]
123123
(form-to [:post "/forgot-password"]
@@ -140,13 +140,13 @@
140140
reset-password-url]
141141
(interpose "\n\n")
142142
(apply str)))))
143-
(html-doc nil "Forgot password?"
143+
(html-doc "Forgot password?" {}
144144
[:h1 "Forgot password?"]
145145
[:p "If your account was found, you should get an email with a link to reset your password soon."]))
146146

147147
(defn edit-password-form [db reset-code & [errors]]
148148
(if-let [user (db/find-user-by-password-reset-code db reset-code)]
149-
(html-doc nil "Reset your password"
149+
(html-doc "Reset your password" {}
150150
[:div.small-section
151151
[:h1 "Reset your password"]
152152
(error-list errors)
@@ -164,7 +164,7 @@
164164
:required true}
165165
:confirm)
166166
(submit-button "Update my password"))])
167-
(html-doc nil "Reset your password"
167+
(html-doc "Reset your password" {}
168168
[:h1 "Reset your password"]
169169
[:p "The reset code was not found. Please ask for a new code in the " [:a {:href "/forgot-password"} "forgot password"] " page"])))
170170

0 commit comments

Comments
 (0)