From 57271da6126a2ccf84cf93e7a1833fcbcfcd36ab Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Sun, 19 Feb 2012 19:47:49 +0200 Subject: Wiki: design fixed --- app/controllers/wikis_controller.rb | 1 + app/models/ability.rb | 7 +++++-- app/views/wikis/_form.html.haml | 11 ++++++----- app/views/wikis/edit.html.haml | 2 -- app/views/wikis/show.html.haml | 8 ++++++-- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb index 128e30c14c0..5d3f72a165e 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -1,5 +1,6 @@ class WikisController < ApplicationController before_filter :project + before_filter :add_project_abilities layout "project" def show diff --git a/app/models/ability.rb b/app/models/ability.rb index f31b510d8bd..42963f3ae4b 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -5,6 +5,7 @@ class Ability when "Issue" then issue_abilities(object, subject) when "Note" then note_abilities(object, subject) when "Snippet" then snippet_abilities(object, subject) + when "Wiki" then wiki_abilities(object, subject) else [] end end @@ -26,12 +27,14 @@ class Ability :write_issue, :write_snippet, :write_merge_request, - :write_note + :write_note, + :write_wiki ] if project.allow_write_for?(user) rules << [ :modify_issue, :modify_snippet, + :modify_wiki, :admin_project, :admin_issue, :admin_snippet, @@ -48,7 +51,7 @@ class Ability end class << self - [:issue, :note, :snippet, :merge_request].each do |name| + [:issue, :note, :snippet, :merge_request, :wiki].each do |name| define_method "#{name}_abilities" do |user, subject| if subject.author == user [ diff --git a/app/views/wikis/_form.html.haml b/app/views/wikis/_form.html.haml index 5c57c2b3179..f88e67bf427 100644 --- a/app/views/wikis/_form.html.haml +++ b/app/views/wikis/_form.html.haml @@ -6,12 +6,13 @@ - @wiki.errors.full_messages.each do |msg| %li= msg - .field + .clearfix = f.label :title - = f.text_field :title + .input= f.text_field :title, :class => :xxlarge = f.hidden_field :slug - .field + .clearfix = f.label :content - = f.text_area :content + .input= f.text_area :content, :class => :xxlarge .actions - = f.submit 'Save' + = f.submit 'Save', :class => "primary btn" + = link_to "Cancel", project_wiki_path(@project, :index), :class => "btn" diff --git a/app/views/wikis/edit.html.haml b/app/views/wikis/edit.html.haml index f83ff9e1d64..df3274b1ac7 100644 --- a/app/views/wikis/edit.html.haml +++ b/app/views/wikis/edit.html.haml @@ -1,5 +1,3 @@ %h1 Editing page = render 'form' - -= link_to 'Show', [@project, @wiki] diff --git a/app/views/wikis/show.html.haml b/app/views/wikis/show.html.haml index 1ea6743769d..0819c170d3d 100644 --- a/app/views/wikis/show.html.haml +++ b/app/views/wikis/show.html.haml @@ -1,7 +1,11 @@ +%h3 + = @wiki.title + - if can? current_user, :write_wiki, @project + = link_to edit_project_wiki_path(@project, @wiki), :class => "right btn small" do + Edit + %p#notice= notice -%h3= @wiki.title = @wiki.content %br -= link_to 'Edit', edit_project_wiki_path(@project, @wiki) -- cgit v1.2.1