Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

search user names on search page as well

  • Loading branch information...
commit 90c5777e52e881b57905e1e0b6c83c85aff2eb3d 1 parent 2c77754
@leafo authored
Showing with 33 additions and 2 deletions.
  1. +8 −0 app.moon
  2. +12 −0 static/style.scss
  3. +13 −2 views/search.moon
View
8 app.moon
@@ -359,6 +359,14 @@ class MoonRocks extends lapis.Application
pcall ->
pager = Modules\search @params.q, manifests
@results = paginated_modules @, pager
+
+ import slugify from require "lapis.util"
+ user_query = slugify @params.q
+
+ if #user_query != 0
+ user_query = "%#{slugify @params.q}%"
+ pager = Users\paginated "where slug like ?", user_query
+ @user_results = pager\get_page!
else
@title = "Search"
View
12 static/style.scss
@@ -197,6 +197,18 @@ hr {
color: $sub_color;
}
+.user_list {
+ .user_row {
+ font-size: 16px;
+ margin: 10px 0;
+ background: white;
+ padding: 5px 10px;
+ border-radius: 2px;
+ border: 1px solid $border_color;
+ line-height: 1.5;
+ }
+}
+
.module_list {
.module_row {
margin: 10px 0;
View
15 views/search.moon
@@ -6,10 +6,13 @@ class Search extends require "widgets.base"
if @results
@render_search_results!
+ if @user_results and next @user_results
+ @render_user_results!
+
render_search_form: =>
form action: "", method: "get", class: "form", ->
div class: "row", ->
- label for: "search_input", "Module"
+ label for: "search_input", "Query"
input type: "text", name: "q", id: "search_input", value: @params.q, autofocus: "autofocus"
div class: "row", ->
@@ -20,7 +23,7 @@ class Search extends require "widgets.base"
input type: "submit", value: "Search"
render_search_results: =>
- h2 "Results"
+ h2 "Modules"
unless next @results
p class: "empty_message", "No results"
@@ -28,3 +31,11 @@ class Search extends require "widgets.base"
@render_modules @results
+ render_user_results: =>
+ h2 "Users"
+ div class: "user_list", ->
+ for user in *@user_results
+ div class: "user_row", ->
+ a href: @url_for("user_profile", user: user), user.username
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.