Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

prettier search results page

  • Loading branch information...
commit 952375327cd420439ce22c44f688a6fbd0526116 1 parent 14d211c
@al3x authored
View
2  environment.rb
@@ -6,7 +6,7 @@
require_gem_with_feedback gem
end
-GIT_REPO = ARGV[0] || ENV['HOME'] + '/wiki'
+GIT_REPO = ENV['HOME'] + '/wiki'
HOMEPAGE = 'home'
unless File.exists?(GIT_REPO) && File.directory?(GIT_REPO)
View
5 git-wiki.rb
@@ -11,7 +11,6 @@
end
get '/:page' do
- @page_url = page_url
@page = Page.new(params[:page])
@page.tracked? ? show(:show, @page.name) : redirect('/e/' + @page.name)
end
@@ -137,8 +136,8 @@
show :search, 'Search Results'
end
-def page_url
- "#{request.env["rack.url_scheme"]}://#{request.env["HTTP_HOST"]}#{request.env["REQUEST_PATH"]}"
+def page_url(page)
+ "#{request.env["rack.url_scheme"]}://#{request.env["HTTP_HOST"]}/#{page}"
end
private
View
2  public/app.js
@@ -25,5 +25,5 @@ function distance_of_time_in_words(to, from) {
}
function clearField(field_id) {
- document.getElementById(field_id).value = "";
+ document.getElementById(field_id).value = "";
}
View
10 public/style.css
@@ -63,7 +63,6 @@ ul {
.content {
margin-left: 35%;
- margin-top: -.55em;
padding: 0 10px 2px 10px;
}
@@ -106,6 +105,15 @@ ul {
.right { text-align: right; }
+.search_result {
+ margin-bottom: 15px;
+}
+
+.search_result .match {
+ line-height: 1em;
+ margin-bottom: 15px;
+}
+
.submit {
font-size: large;
font-weight: bold;
View
3  views/list.erb
@@ -9,7 +9,8 @@
<li>
<strong><a href="/<%= page.name %>"><%= page.name %></a></strong> &mdash;
<a href="/e/<%= page.name %>">edit</a> &bull;
- <a href="/h/<%= page.name %>">history</a>
+ <a href="/h/<%= page.name %>">history</a> &bull;
+ <a href="javascript:var q; if (window.getSelection) q=window.getSelection(); else if (document.selection) q=document.selection.createRange().text; if (q != '') location.href='<%= page_url(page.name) %>/append?text='+encodeURIComponent(q+' (from &quot;'+document.title+'&quot;:'+location.href+')'); else location.href='<%= page_url(page.name) %>/append?text='+encodeURIComponent('&quot;'+document.title+'&quot;:'+location.href);">bookmarklet</a>
</li>
<% end %>
</ul>
View
33 views/search.erb
@@ -1,32 +1,29 @@
<% if @grep.empty? %>
<h1>No pages match</h1>
<% else %>
- <h1>All matches for '<%= @search %>'</h1>
+ <h1>Results for '<%= @search %>'</h1>
<% end %>
<div class="sub_nav">
- Details go here.
+ <div class="details">
+ <%= @grep.size %> pages contain match<br />
+ <%= @grep.map { |g| g[1].size }.inject { |acc, n| acc + n } %> results
+ </div>
</div>
<div class="content">
- <br/>
- <table width="100%">
<% @grep.each do |sha, arr_match| %>
- <% (sha, file) = sha.split(':') %>
- <tr>
- <td valign="top"><%= $repo.object(sha).name %></td>
- <td valign="top"><a href="/<%= file %>"><%= file %></a></td>
- <td><table>
- <% arr_match.each do |line, match| %>
- <tr>
- <td>line <%= line %></td>
- <td><%= match %></td>
- </tr>
- <% end %>
- </table></td>
- </tr>
+ <div class="search_result">
+ <% (sha, file) = sha.split(':') %>
+ <% arr_match.each do |line, match| %>
+ <div class="match">
+ <tt><%= match %></tt>
+ <br />
+ &mdash; <a href="/<%= file %>"><%= file %></a>, line <%= line %> (<%= $repo.object(sha).name %>)
+ </div>
+ <% end %>
+ </div>
<% end %>
- </table>
</div>
View
4 views/show.erb
@@ -40,9 +40,7 @@
document.write(time_ago_in_words(<%= @page.updated_at.for_time_ago_in_words %>) + ' ago');
</script>
<br />
- <%= $repo.current_branch %> branch
- <br />
- <a href="javascript:var q; if (window.getSelection) q=window.getSelection(); else if (document.selection) q=document.selection.createRange().text; if (q != '') location.href='<%= @page_url %>/append?text='+encodeURIComponent(q+' (from &quot;'+document.title+'&quot;:'+location.href+')'); else location.href='<%= @page_url %>/append?text='+encodeURIComponent('&quot;'+document.title+'&quot;:'+location.href);">append bookmarklet</a>
+ <%= $repo.current_branch %> branch
</div>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.