Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added search through git-grep

  • Loading branch information...
commit 3fe21594034d22381cc5dbbfef0181b3949e2893 1 parent e7718c5
@schacon schacon authored
View
3  TODO
@@ -5,11 +5,12 @@
= CHACON IDEAS
* inter-branch links
- * remotes (add / fetch)
* tagging
+ * file attachments
* merge conflict resolution
* cherry-picked branches (read-tree/write-tree)
* git-less version (read-only)
+ * track which branched from which
* push?
* users (email/name/ip - use for commits)
View
7 git-wiki.rb
@@ -37,6 +37,7 @@ def touchfile
get('/_style.css') { header 'Content-Type' => 'text/css'; File.read(File.join(File.dirname(__FILE__), 'css', 'style.css')) }
get('/_code.css') { header 'Content-Type' => 'text/css'; File.read(File.join(File.dirname(__FILE__), 'css', "#{UV_THEME}.css")) }
get('/_app.js') { header 'Content-Type' => 'application/x-javascript'; File.read(File.join(File.dirname(__FILE__), 'javascripts', "application.js")) }
+get('/_search.png') { header 'Content-Type' => 'image/png'; File.read(File.join(File.dirname(__FILE__), 'images', "search.png")) }
get '/_list' do
@pages = $repo.log.first.gtree.children.map { |name, blob| Page.new(name) } rescue []
@@ -154,4 +155,10 @@ def touchfile
$repo.add_remote(params[:branch_name], params[:branch_url])
$repo.fetch(params[:branch_name])
redirect '/a/branches'
+end
+
+get '/a/search' do
+ @search = params[:search]
+ @grep = $repo.grep(@search)
+ show :search, 'Search Results'
end
View
BIN  images/search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2  views/branch_history.erb
@@ -4,7 +4,7 @@
<% @history.each do |commit| %>
<tr>
<td><code><%= commit.sha[0, 8] %></code></td>
- <td><%= commit.date %></td>
+ <td><small><%= commit.date %></small></td>
<td><%= commit.message %></td>
<td><%= commit.name %></td>
<% if commit != @history.first %>
View
3  views/layout.erb
@@ -8,6 +8,7 @@
</head>
<body>
<div id="container">
+ <form method="get" action="/a/search">
<ul class="nav_list" id="top_nav">
<li><strong><%= $repo.current_branch %></strong></li>
<li><a href="/" class="nav_link">home</a></li>
@@ -15,7 +16,9 @@
<li><a href="/a/history" class="nav_link">history</a></li>
<li><a href="/_list" class="nav_link">pages</a></li>
<li><a href="/a/tarball" class="nav_link">tarball</a></li>
+ <li><input name="search" size="15"> <input type="image" src="/_search.png"></li>
</ul>
+ </form>
<%= yield %>
<div id="footer">
powered by <a href="http://github.com/sr/git-wiki/network">git-wiki</a>
View
23 views/search.erb
@@ -0,0 +1,23 @@
+<% if @grep.empty? %>
+ <h1>No pages match</h1>
+<% else %>
+ <h1>All matches for '<%= @search %>'</h1>
+ <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 %></td>
+ <td><small><%= match %></small></td>
+ </tr>
+ <% end %>
+ </table></td>
+ </tr>
+ <% end %>
+ </table>
+<% end %>
Please sign in to comment.
Something went wrong with that request. Please try again.