GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of al3x/git-wiki
Description: A wiki engine that uses a Git repository as its data store.
Homepage: http://atonie.org/2008/02/git-wiki
Clone URL: git://github.com/zmalltalker/git-wiki.git
prettier search results page
al3x (author)
Sat Mar 15 01:02:34 -0700 2008
commit  952375327cd420439ce22c44f688a6fbd0526116
tree    0a692a9f6d14a0c1b0a1d4ca2b66311c8ae3fcd1
parent  14d211cfcdcf1c171e2bd7b469c0649bcb68acec
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ require 'page'
0
   require_gem_with_feedback gem
0
 end
0
 
0
-GIT_REPO = ARGV[0] || ENV['HOME'] + '/wiki'
0
+GIT_REPO = ENV['HOME'] + '/wiki'
0
 HOMEPAGE = 'home'
0
 
0
 unless File.exists?(GIT_REPO) && File.directory?(GIT_REPO)
...
11
12
13
14
15
16
17
...
137
138
139
140
141
 
 
142
143
144
...
11
12
13
 
14
15
16
...
136
137
138
 
 
139
140
141
142
143
0
@@ -11,7 +11,6 @@ get '/a/list' do
0
 end
0
 
0
 get '/:page' do
0
- @page_url = page_url
0
   @page = Page.new(params[:page])
0
   @page.tracked? ? show(:show, @page.name) : redirect('/e/' + @page.name)
0
 end
0
@@ -137,8 +136,8 @@ get '/a/search' do
0
   show :search, 'Search Results'
0
 end
0
 
0
-def page_url
0
- "#{request.env["rack.url_scheme"]}://#{request.env["HTTP_HOST"]}#{request.env["REQUEST_PATH"]}"
0
+def page_url(page)
0
+ "#{request.env["rack.url_scheme"]}://#{request.env["HTTP_HOST"]}/#{page}"
0
 end
0
 
0
 private
...
25
26
27
28
 
29
30
...
25
26
27
 
28
29
30
0
@@ -25,5 +25,5 @@ function distance_of_time_in_words(to, from) {
0
 }
0
 
0
 function clearField(field_id) {
0
- document.getElementById(field_id).value = "";
0
+ document.getElementById(field_id).value = "";
0
 }
0
\ No newline at end of file
...
63
64
65
66
67
68
69
...
106
107
108
 
 
 
 
 
 
 
 
 
109
110
111
...
63
64
65
 
66
67
68
...
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
0
@@ -63,7 +63,6 @@ ul {
0
 
0
 .content {
0
   margin-left: 35%;
0
- margin-top: -.55em;
0
   padding: 0 10px 2px 10px;
0
 }
0
 
0
@@ -106,6 +105,15 @@ ul {
0
 
0
 .right { text-align: right; }
0
 
0
+.search_result {
0
+ margin-bottom: 15px;
0
+}
0
+
0
+.search_result .match {
0
+ line-height: 1em;
0
+ margin-bottom: 15px;
0
+}
0
+
0
 .submit {
0
   font-size: large;
0
   font-weight: bold;
...
9
10
11
12
 
 
13
14
15
...
9
10
11
 
12
13
14
15
16
0
@@ -9,7 +9,8 @@
0
         <li>
0
           <strong><a href="/<%= page.name %>"><%= page.name %></a></strong> &mdash;
0
           <a href="/e/<%= page.name %>">edit</a> &bull;
0
- <a href="/h/<%= page.name %>">history</a>
0
+ <a href="/h/<%= page.name %>">history</a> &bull;
0
+ <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>
0
         </li>
0
       <% end %>
0
     </ul>
...
1
2
3
4
 
5
6
7
8
 
 
 
 
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
 
 
 
 
 
 
 
 
 
28
29
30
31
32
...
1
2
3
 
4
5
6
7
 
8
9
10
11
12
13
14
 
 
15
 
 
 
 
 
 
 
 
 
 
 
 
 
16
17
18
19
20
21
22
23
24
25
26
 
27
28
29
0
@@ -1,32 +1,29 @@
0
 <% if @grep.empty? %>
0
   <h1>No pages match</h1>
0
 <% else %>
0
- <h1>All matches for '<%= @search %>'</h1>
0
+ <h1>Results for '<%= @search %>'</h1>
0
 <% end %>
0
 
0
 <div class="sub_nav">
0
- Details go here.
0
+ <div class="details">
0
+ <%= @grep.size %> pages contain match<br />
0
+ <%= @grep.map { |g| g[1].size }.inject { |acc, n| acc + n } %> results
0
+ </div>
0
 </div>
0
 
0
 <div class="content">
0
- <br/>
0
- <table width="100%">
0
   <% @grep.each do |sha, arr_match| %>
0
- <% (sha, file) = sha.split(':') %>
0
- <tr>
0
- <td valign="top"><%= $repo.object(sha).name %></td>
0
- <td valign="top"><a href="/<%= file %>"><%= file %></a></td>
0
- <td><table>
0
- <% arr_match.each do |line, match| %>
0
- <tr>
0
- <td>line <%= line %></td>
0
- <td><%= match %></td>
0
- </tr>
0
- <% end %>
0
- </table></td>
0
- </tr>
0
+ <div class="search_result">
0
+ <% (sha, file) = sha.split(':') %>
0
+ <% arr_match.each do |line, match| %>
0
+ <div class="match">
0
+ <tt><%= match %></tt>
0
+ <br />
0
+ &mdash; <a href="/<%= file %>"><%= file %></a>, line <%= line %> (<%= $repo.object(sha).name %>)
0
+ </div>
0
+ <% end %>
0
+ </div>
0
   <% end %>
0
- </table>
0
 </div>
0
 
0
 
...
40
41
42
43
44
45
 
46
47
48
...
40
41
42
 
 
 
43
44
45
46
0
@@ -40,9 +40,7 @@
0
       document.write(time_ago_in_words(<%= @page.updated_at.for_time_ago_in_words %>) + ' ago');
0
     </script>
0
     <br />
0
- <%= $repo.current_branch %> branch
0
- <br />
0
- <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>
0
+ <%= $repo.current_branch %> branch
0
   </div>
0
 </div>
0
 

Comments

    No one has commented yet.