Commit 57271da6126a2ccf84cf93e7a1833fcbcfcd36ab

Authored by Valery Sizov
1 parent 4c1b8558

Wiki: design fixed

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