Commit 57271da6126a2ccf84cf93e7a1833fcbcfcd36ab

Authored by Valery Sizov
1 parent 4c1b8558

Wiki: design fixed

app/controllers/wikis_controller.rb
1 class WikisController < ApplicationController 1 class WikisController < ApplicationController
2 before_filter :project 2 before_filter :project
  3 + before_filter :add_project_abilities
3 layout "project" 4 layout "project"
4 5
5 def show 6 def show
app/models/ability.rb
@@ -5,6 +5,7 @@ class Ability @@ -5,6 +5,7 @@ class Ability
5 when "Issue" then issue_abilities(object, subject) 5 when "Issue" then issue_abilities(object, subject)
6 when "Note" then note_abilities(object, subject) 6 when "Note" then note_abilities(object, subject)
7 when "Snippet" then snippet_abilities(object, subject) 7 when "Snippet" then snippet_abilities(object, subject)
  8 + when "Wiki" then wiki_abilities(object, subject)
8 else [] 9 else []
9 end 10 end
10 end 11 end
@@ -26,12 +27,14 @@ class Ability @@ -26,12 +27,14 @@ class Ability
26 :write_issue, 27 :write_issue,
27 :write_snippet, 28 :write_snippet,
28 :write_merge_request, 29 :write_merge_request,
29 - :write_note 30 + :write_note,
  31 + :write_wiki
30 ] if project.allow_write_for?(user) 32 ] if project.allow_write_for?(user)
31 33
32 rules << [ 34 rules << [
33 :modify_issue, 35 :modify_issue,
34 :modify_snippet, 36 :modify_snippet,
  37 + :modify_wiki,
35 :admin_project, 38 :admin_project,
36 :admin_issue, 39 :admin_issue,
37 :admin_snippet, 40 :admin_snippet,
@@ -48,7 +51,7 @@ class Ability @@ -48,7 +51,7 @@ class Ability
48 end 51 end
49 52
50 class << self 53 class << self
51 - [:issue, :note, :snippet, :merge_request].each do |name| 54 + [:issue, :note, :snippet, :merge_request, :wiki].each do |name|
52 define_method "#{name}_abilities" do |user, subject| 55 define_method "#{name}_abilities" do |user, subject|
53 if subject.author == user 56 if subject.author == user
54 [ 57 [
app/views/wikis/_form.html.haml
@@ -6,12 +6,13 @@ @@ -6,12 +6,13 @@
6 - @wiki.errors.full_messages.each do |msg| 6 - @wiki.errors.full_messages.each do |msg|
7 %li= msg 7 %li= msg
8 8
9 - .field 9 + .clearfix
10 = f.label :title 10 = f.label :title
11 - = f.text_field :title 11 + .input= f.text_field :title, :class => :xxlarge
12 = f.hidden_field :slug 12 = f.hidden_field :slug
13 - .field 13 + .clearfix
14 = f.label :content 14 = f.label :content
15 - = f.text_area :content 15 + .input= f.text_area :content, :class => :xxlarge
16 .actions 16 .actions
17 - = f.submit 'Save' 17 + = f.submit 'Save', :class => "primary btn"
  18 + = link_to "Cancel", project_wiki_path(@project, :index), :class => "btn"
app/views/wikis/edit.html.haml
1 %h1 Editing page 1 %h1 Editing page
2 2
3 = render 'form' 3 = render 'form'
4 -  
5 -= link_to 'Show', [@project, @wiki]  
app/views/wikis/show.html.haml
  1 +%h3
  2 + = @wiki.title
  3 + - if can? current_user, :write_wiki, @project
  4 + = link_to edit_project_wiki_path(@project, @wiki), :class => "right btn small" do
  5 + Edit
  6 +
1 %p#notice= notice 7 %p#notice= notice
2 8
3 -%h3= @wiki.title  
4 = @wiki.content 9 = @wiki.content
5 10
6 %br 11 %br
7 -= link_to 'Edit', edit_project_wiki_path(@project, @wiki)