From bb53f8ac2ab52301b32fe65ddc10a32f6bc730e8 Mon Sep 17 00:00:00 2001 From: tkimia Date: Tue, 22 Apr 2014 17:42:57 -0400 Subject: prelim search --- app/controllers/search_controller.rb | 11 ++++++++++ app/views/common/_show_tournament.html.erb | 32 ++++++++++++++++++++++++++++ app/views/layouts/application.html.erb | 12 ++++++++--- app/views/search/go.html.erb | 6 ++++++ app/views/tournaments/index.html.erb | 34 +----------------------------- 5 files changed, 59 insertions(+), 36 deletions(-) create mode 100644 app/views/common/_show_tournament.html.erb create mode 100644 app/views/search/go.html.erb (limited to 'app') diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index ee61487..9da649d 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,2 +1,13 @@ class SearchController < ApplicationController + + def go + @query = params[:query] + + if (@query.nil?) return; + + @tournaments = Tournament.where("name LIKE '#{@query}'") + @players = User.where("name LIKE '#{@query}") + + end + end diff --git a/app/views/common/_show_tournament.html.erb b/app/views/common/_show_tournament.html.erb new file mode 100644 index 0000000..89d8f53 --- /dev/null +++ b/app/views/common/_show_tournament.html.erb @@ -0,0 +1,32 @@ +
+
<%= image_tag ('http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(target.hosts.first.email) + '?s=100&d=mm') %>
+
+ <%# "header" %> + <%= link_to(target) do %>

<%= target.name %>

<% end %> +
+
+ Hosted by: <%= target.hosts.first.name %> +
+
+

Players per team: <%= target.min_players_per_team %>

+

Players signed up: <%= target.players.count %>

+
+
+

<%= (target.randomized_teams)? "Teams are Random" : "Teams are Chosen" %>

+

Players signed up: <%= target.players.count %>

+
+
+
+
+ <% if signed_in? %> + <% if !target.players.include?(current_user) %> + <%= form_tag(tournament_path(target), method: "put") do %> + + <%= submit_tag("Join")%> + <% end %> + <% else %> +

You've signed up for this tournament!

+ <% end %> + <% end %> +
+
\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e6b5b25..fb5c1c5 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,15 +13,20 @@ BetterDragSort.makeListSortable(document.getElementById("boxes")); }; -
+
<% if notice %>

<%= notice %>

<% end %> diff --git a/app/views/search/go.html.erb b/app/views/search/go.html.erb new file mode 100644 index 0000000..12a76c8 --- /dev/null +++ b/app/views/search/go.html.erb @@ -0,0 +1,6 @@ +

Showing results for: <%= @query %>

+ + +<% if @tounaments.empty? and @players.empty %> +

No results found for "<%= @query %>"

+<% else %> \ No newline at end of file diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb index eef9577..129f3de 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -4,39 +4,7 @@ <% if @tournaments.length > 0 %> <%# Each tournament has a div for its listing %> <% @tournaments.each do |t| %> -
-
<%= image_tag 'http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(t.hosts.first.email) + '?s=100&d=mm' %>
-
- <%# "header" %> - <%= link_to(t) do %>

<%= t.name %>

<% end %> -
-
- Hosted by: <%= t.hosts.first.name %> -
-
-

Players per team: <%= t.min_players_per_team %>

-

Players signed up: <%= t.players.count %>

-
-
-

<%= (t.randomized_teams)? "Teams are Random" : "Teams are Chosen" %>

-

Players signed up: <%= t.players.count %>

-
-
-
-
- <% if signed_in? %> - <% if !t.players.include?(current_user) %> - <%= form_tag(tournament_path(t), method: "put") do %> - - <%= submit_tag("Join") - %> - <% end %> - <% else %> -

You've signed up for this tournament!

- <% end %> - <% end %> -
-
+ <%= render "common/show_tournament", :target => t %> <% end %> <% else %>

No tournaments going on right now... -- cgit v1.2.3-54-g00ecf