Commit 85974948e778f5261cc24a2911bd652a91e950da
1 parent
b565cd19
Exists in
master
and in
4 other branches
Wiki: history
Showing
7 changed files
with
41 additions
and
4 deletions
Show diff stats
app/controllers/wikis_controller.rb
| ... | ... | @@ -4,7 +4,11 @@ class WikisController < ApplicationController |
| 4 | 4 | layout "project" |
| 5 | 5 | |
| 6 | 6 | def show |
| 7 | - @wiki = @project.wikis.where(:slug => params[:id]).order("created_at").last | |
| 7 | + if params[:old_page_id] | |
| 8 | + @wiki = @project.wikis.find(params[:old_page_id]) | |
| 9 | + else | |
| 10 | + @wiki = @project.wikis.where(:slug => params[:id]).order("created_at").last | |
| 11 | + end | |
| 8 | 12 | respond_to do |format| |
| 9 | 13 | if @wiki |
| 10 | 14 | format.html |
| ... | ... | @@ -22,6 +26,7 @@ class WikisController < ApplicationController |
| 22 | 26 | |
| 23 | 27 | def create |
| 24 | 28 | @wiki = @project.wikis.new(params[:wiki]) |
| 29 | + @wiki.user = current_user | |
| 25 | 30 | |
| 26 | 31 | respond_to do |format| |
| 27 | 32 | if @wiki.save |
| ... | ... | @@ -31,6 +36,10 @@ class WikisController < ApplicationController |
| 31 | 36 | end |
| 32 | 37 | end |
| 33 | 38 | end |
| 39 | + | |
| 40 | + def history | |
| 41 | + @wikis = @project.wikis.where(:slug => params[:id]).order("created_at") | |
| 42 | + end | |
| 34 | 43 | |
| 35 | 44 | def destroy |
| 36 | 45 | @wiki = @project.wikis.find(params[:id]) | ... | ... |
app/models/wiki.rb
| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | +%h2 Versions | |
| 2 | +%table | |
| 3 | + %thead | |
| 4 | + %tr | |
| 5 | + %th # | |
| 6 | + %th last edit | |
| 7 | + %th created by | |
| 8 | + %tbody | |
| 9 | + - @wikis.each_with_index do |wiki_page, i| | |
| 10 | + %tr | |
| 11 | + %td= i + 1 | |
| 12 | + %td= link_to wiki_page.created_at.to_s(:short), project_wiki_path(@project, wiki_page, :old_page_id => wiki_page.id) | |
| 13 | + %td= wiki_page.user.name | |
| 14 | + | ... | ... |
app/views/wikis/show.html.haml
config/routes.rb
| ... | ... | @@ -56,7 +56,11 @@ Gitlab::Application.routes.draw do |
| 56 | 56 | get "files" |
| 57 | 57 | end |
| 58 | 58 | |
| 59 | - resources :wikis, :only => [:show, :edit, :destroy, :create] | |
| 59 | + resources :wikis, :only => [:show, :edit, :destroy, :create] do | |
| 60 | + member do | |
| 61 | + get "history" | |
| 62 | + end | |
| 63 | + end | |
| 60 | 64 | |
| 61 | 65 | resource :repository do |
| 62 | 66 | member do | ... | ... |
db/schema.rb
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | # |
| 12 | 12 | # It's strongly recommended to check this file into your version control system. |
| 13 | 13 | |
| 14 | -ActiveRecord::Schema.define(:version => 20120219140810) do | |
| 14 | +ActiveRecord::Schema.define(:version => 20120219193300) do | |
| 15 | 15 | |
| 16 | 16 | create_table "issues", :force => true do |t| |
| 17 | 17 | t.string "title" |
| ... | ... | @@ -166,6 +166,7 @@ ActiveRecord::Schema.define(:version => 20120219140810) do |
| 166 | 166 | t.datetime "created_at", :null => false |
| 167 | 167 | t.datetime "updated_at", :null => false |
| 168 | 168 | t.string "slug" |
| 169 | + t.integer "user_id" | |
| 169 | 170 | end |
| 170 | 171 | |
| 171 | 172 | end | ... | ... |