Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added change history for pages, and cleaned up a few things.

  • Loading branch information...
commit 3e099d05b6d51a265e522d16226fdf82e77aa144 1 parent d1ef023
@notahat authored
View
1  README.rdoc
@@ -13,6 +13,7 @@ is simply a git repository containing a *.markdown file for each page.
== To do
+- Delete pages
- Add user support so we can put a wiki on a server and have commits happen as different users
- View the change log for a single page
- View previous revisions of a page
View
4 app/models/page.rb
@@ -45,4 +45,8 @@ def new_record?
def path
"#{@project.path}/#{@name}.markdown"
end
+
+ def log
+ @project.git.gblob(path).log
+ end
end
View
2  app/views/layouts/application.html.erb
@@ -3,7 +3,7 @@
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
- <title>giki: <%=h @title %></title>
+ <title>Giki: <%=h @title %></title>
<%= stylesheet_link_tag 'application' %>
<%= javascript_include_tag :defaults %>
View
11 app/views/pages/index.html.erb
@@ -22,22 +22,21 @@
<script>$('page_name').focus()</script>
-<% if @pages.length > 0 %>
+<% unless @pages.length == 0 %>
<table>
<thead>
<tr>
- <th></th>
+ <th>Message</th>
<th>Date</th>
<th>Author</th>
- <th>Message</th>
</thead>
<tbody>
<% @project.git.log.each do |commit| %>
<tr>
- <td><%=h commit.sha %></td>
- <td><%=h commit.date %></td>
- <td><%=h commit.author.name %></td>
<td><%=h commit.message %></td>
+ <td><%= time_ago_in_words(commit.date) %> ago</td>
+ <td><%=h commit.author.name %></td>
+ <td><%=h commit.sha %></td>
</tr>
<% end %>
</tbody>
View
21 app/views/pages/show.html.erb
@@ -14,3 +14,24 @@
<% end %>
<%= markdown(@page.body) %>
+
+<% unless @page.new_record? %>
+ <table>
+ <thead>
+ <tr>
+ <th>Message</th>
+ <th>Date</th>
+ <th>Author</th>
+ </thead>
+ <tbody>
+ <% @page.log.each do |commit| %>
+ <tr>
+ <td><%=h commit.message %></td>
+ <td><%= time_ago_in_words(commit.date) %> ago</td>
+ <td><%=h commit.author.name %></td>
+ <td><%=h commit.sha %></td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+<% end %>
View
43 config/routes.rb
@@ -1,47 +1,6 @@
ActionController::Routing::Routes.draw do |map|
- # The priority is based upon order of creation: first created -> highest priority.
-
map.resources :projects do |project|
project.resources :pages, :new => { :new => :any }
end
-
- map.root :controller => "projects"
-
- # Sample of regular route:
- # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
- # Keep in mind you can assign values other than :controller and :action
-
- # Sample of named route:
- # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
- # This route can be invoked with purchase_url(:id => product.id)
-
- # Sample resource route (maps HTTP verbs to controller actions automatically):
- # map.resources :products
-
- # Sample resource route with options:
- # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
-
- # Sample resource route with sub-resources:
- # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
-
- # Sample resource route with more complex sub-resources
- # map.resources :products do |products|
- # products.resources :comments
- # products.resources :sales, :collection => { :recent => :get }
- # end
-
- # Sample resource route within a namespace:
- # map.namespace :admin do |admin|
- # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
- # admin.resources :products
- # end
-
- # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
- # map.root :controller => "welcome"
-
- # See how all your routes lay out with "rake routes"
-
- # Install the default routes as the lowest priority.
- map.connect ':controller/:action/:id'
- map.connect ':controller/:action/:id.:format'
+ map.root :projects
end
Please sign in to comment.
Something went wrong with that request. Please try again.