From 839757598bfa92da509ec52d696ed748d3c7b8d7 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 9 Aug 2012 07:34:29 +0300 Subject: [PATCH] Wiki pages page --- app/controllers/wikis_controller.rb | 4 ++++ app/views/wikis/history.html.haml | 4 +++- app/views/wikis/pages.html.haml | 18 ++++++++++++++++++ app/views/wikis/show.html.haml | 4 +++- config/routes.rb | 4 ++++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 app/views/wikis/pages.html.haml diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb index 1fa38034c66..993abcf8727 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -6,6 +6,10 @@ class WikisController < ApplicationController before_filter :authorize_admin_wiki!, :only => :destroy layout "project" + def pages + @wikis = @project.wikis.group(:slug).order("created_at") + end + def show if params[:old_page_id] @wiki = @project.wikis.find(params[:old_page_id]) diff --git a/app/views/wikis/history.html.haml b/app/views/wikis/history.html.haml index 2e46a90ef51..f82c681fcde 100644 --- a/app/views/wikis/history.html.haml +++ b/app/views/wikis/history.html.haml @@ -1,4 +1,6 @@ -%h3.page_title Versions +%h3.page_title + %span.cgray History for + = @wikis.last.title %br %table.admin-table %thead diff --git a/app/views/wikis/pages.html.haml b/app/views/wikis/pages.html.haml new file mode 100644 index 00000000000..c84621193d5 --- /dev/null +++ b/app/views/wikis/pages.html.haml @@ -0,0 +1,18 @@ +%h3.page_title All Pages +%br +%table.admin-table + %thead + %tr + %th Title + %th slug + %th created by + %tbody + - @wikis.each_with_index do |wiki_page, i| + %tr + %td + = link_to wiki_page.title, project_wiki_path(@project, wiki_page, :old_page_id => wiki_page.id) + (#{time_ago_in_words(wiki_page.created_at)} + ago) + %td= wiki_page.slug + %td= wiki_page.user.name + diff --git a/app/views/wikis/show.html.haml b/app/views/wikis/show.html.haml index 3e92275102c..579aeb41796 100644 --- a/app/views/wikis/show.html.haml +++ b/app/views/wikis/show.html.haml @@ -1,6 +1,8 @@ -%h3 +%h3.page_title = @wiki.title %span.right + = link_to pages_project_wikis_path(@project), :class => "btn small grouped" do + Pages - if can? current_user, :write_wiki, @project = link_to history_project_wiki_path(@project, @wiki), :class => "btn small grouped" do History diff --git a/config/routes.rb b/config/routes.rb index 11430baf30e..7ece304450d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -98,6 +98,10 @@ Gitlab::Application.routes.draw do end resources :wikis, :only => [:show, :edit, :destroy, :create] do + collection do + get :pages + end + member do get "history" end