Merge pull request #56 from finnlabs/feature/extended_wiki_tabs

Feature/extended wiki tabs
pull/41/head
Romano Licker 12 years ago
commit dbfecfae9c
  1. 43
      app/controllers/wiki_controller.rb
  2. 62
      app/controllers/wiki_menu_items_controller.rb
  3. 12
      app/helpers/application_helper.rb
  4. 1
      app/helpers/projects_helper.rb
  5. 11
      app/helpers/wiki_helper.rb
  6. 9
      app/models/enabled_module.rb
  7. 8
      app/models/wiki.rb
  8. 61
      app/models/wiki_menu_item.rb
  9. 36
      app/models/wiki_page.rb
  10. 19
      app/views/projects/settings/_wiki.rhtml
  11. 6
      app/views/wiki/index.html.erb
  12. 44
      app/views/wiki/new.html.erb
  13. 9
      app/views/wiki/show.rhtml
  14. 46
      app/views/wiki_menu_items/edit.rhtml
  15. 16
      config/locales/de.yml
  16. 15
      config/locales/en.yml
  17. 6
      config/routes.rb
  18. 16
      db/migrate/20120731135140_create_wiki_menu_items.rb
  19. 18
      db/migrate/20120809131659_create_wiki_menu_item_for_existing_wikis.rb
  20. 7
      lib/redmine.rb
  21. 18
      lib/redmine/menu_manager.rb
  22. 39
      lib/redmine/menu_manager/menu_helper.rb
  23. 44
      public/stylesheets/application.css

@ -34,11 +34,15 @@ class WikiController < ApplicationController
before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy] before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy]
verify :method => :post, :only => [:protect], :redirect_to => { :action => :show } verify :method => :post, :only => [:protect], :redirect_to => { :action => :show }
verify :method => :get, :only => [:new, :new_child], :render => {:nothing => true, :status => :method_not_allowed}
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed}
include AttachmentsHelper include AttachmentsHelper
# List of pages, sorted alphabetically and by parent (hierarchy) # List of pages, sorted alphabetically and by parent (hierarchy)
def index def index
@related_page = WikiPage.find_by_wiki_id_and_title(@wiki.id, params[:id])
load_pages_for_index load_pages_for_index
@pages_by_parent_id = @pages.group_by(&:parent_id) @pages_by_parent_id = @pages.group_by(&:parent_id)
end end
@ -49,6 +53,45 @@ class WikiController < ApplicationController
@pages_by_date = @pages.group_by {|p| p.updated_on.to_date} @pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
end end
def new
@page = WikiPage.new(:wiki => @wiki)
@page.content = WikiContent.new(:page => @page)
@content = @page.content_for_version(nil)
@content.text = initial_page_content(@page)
end
def new_child
find_existing_page
return if performed?
old_page = @page
new
@page.parent = old_page
render :action => 'new'
end
def create
new
@page.title = params[:page][:title]
@page.parent_id = params[:page][:parent_id]
@content.attributes = params[:content].slice(:comments, :text)
@content.author = User.current
if @page.save
attachments = Attachment.attach_files(@page, params[:attachments])
render_attachment_warning_if_needed(@page)
call_hook(:controller_wiki_edit_after_save, :params => params, :page => @page)
redirect_to :action => 'show', :project_id => @project, :id => @page.title
else
render :action => 'new'
end
end
# display a page (in editing mode if it doesn't exist) # display a page (in editing mode if it doesn't exist)
def show def show
page_title = params[:id] page_title = params[:id]

@ -0,0 +1,62 @@
class WikiMenuItemsController < ApplicationController
def edit
get_data_from_params(params)
end
def update
wiki_menu_setting = params[:wiki_menu_item][:setting]
parent_wiki_menu_item = params[:parent_wiki_menu_item]
get_data_from_params(params)
if wiki_menu_setting == 'no_item'
@wiki_menu_item.destroy unless @wiki_menu_item.nil?
else
@wiki_menu_item.wiki_id = @page.wiki.id
@wiki_menu_item.name = params[:wiki_menu_item][:name]
@wiki_menu_item.title = @page_title
if wiki_menu_setting == 'sub_item'
@wiki_menu_item.parent_id = parent_wiki_menu_item
elsif wiki_menu_setting == 'main_item'
@wiki_menu_item.parent_id = nil
if params[:wiki_menu_item][:new_wiki_page] == "1"
@wiki_menu_item.new_wiki_page = true
elsif params[:wiki_menu_item][:new_wiki_page] == "0"
@wiki_menu_item.new_wiki_page = false
end
if params[:wiki_menu_item][:index_page] == "1"
@wiki_menu_item.index_page = true
elsif params[:wiki_menu_item][:index_page] == "0"
@wiki_menu_item.index_page = false
end
end
end
if not @wiki_menu_item.errors.size >= 1 and (@wiki_menu_item.destroyed? or @wiki_menu_item.save)
flash[:notice] = l(:notice_successful_update)
redirect_back_or_default({ :action => 'edit', :id => @page_title })
else
respond_to do |format|
format.html { render :action => 'edit', :id => @page_title }
end
end
end
private
def get_data_from_params(params)
@project = Project.find(params[:project_id])
@page_title = params[:id]
@page = WikiPage.find_by_title_and_wiki_id(@page_title, @project.wiki.id)
@wiki_menu_item = WikiMenuItem.find_or_initialize_by_wiki_id_and_title(@page.wiki.id, @page_title)
@possible_parent_menu_items = WikiMenuItem.main_items(@page.wiki.id) - [@wiki_menu_item]
@possible_parent_menu_items.map! {|item| [item.name, item.id]}
end
end

@ -1107,6 +1107,16 @@ module ApplicationHelper
'contracts' 'contracts'
when params[:controller] == 'my' && params[:action] == 'account' when params[:controller] == 'my' && params[:action] == 'account'
'account' 'account'
when params[:controller] == 'wiki' && !@page.nil? &&
menu_item = @page.nearest_menu_item
if menu_item.is_sub_item?
menu_item.parent.item_class
else
menu_item.item_class
end
when params[:controller] == 'wiki' && related_page = params[:id]
related_page.dasherize
else else
params[:controller].dasherize params[:controller].dasherize
end end
@ -1130,7 +1140,7 @@ module ApplicationHelper
def accessibility_js_enabled? def accessibility_js_enabled?
!@accessibility_js_disabled !@accessibility_js_disabled
end end
# #
# Returns the footer text displayed in the layout file. # Returns the footer text displayed in the layout file.
# #

@ -25,7 +25,6 @@ module ProjectsHelper
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}, {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural},
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural}, {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
{:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural}, {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
{:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
{:name => 'repository', :action => :manage_repository, :partial => 'projects/settings/repository', :label => :label_repository}, {:name => 'repository', :action => :manage_repository, :partial => 'projects/settings/repository', :label => :label_repository},
{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}, {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural},
{:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities} {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities}

@ -13,7 +13,6 @@
#++ #++
module WikiHelper module WikiHelper
def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0) def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0)
pages = pages.group_by(&:parent) unless pages.is_a?(Hash) pages = pages.group_by(&:parent) unless pages.is_a?(Hash)
s = '' s = ''
@ -29,4 +28,14 @@ module WikiHelper
end end
s s
end end
def breadcrumb_for_page(page, action = nil)
if action
related_pages = page.ancestors.reverse + [page]
breadcrumb_paths(*(related_pages.collect{|parent| link_to h(parent.breadcrumb_title), {:id => parent.title, :project_id => parent.project, :action => "show"}} + [action]))
else
related_pages = page.ancestors.reverse
breadcrumb_paths(*(related_pages.collect{|parent| link_to h(parent.breadcrumb_title), {:id => parent.title, :project_id => parent.project, :action => "show"}} + [h(page.breadcrumb_title)]))
end
end
end end

@ -30,7 +30,14 @@ class EnabledModule < ActiveRecord::Base
when 'wiki' when 'wiki'
# Create a wiki with a default start page # Create a wiki with a default start page
if project && project.wiki.nil? if project && project.wiki.nil?
Wiki.create(:project => project, :start_page => 'Wiki') wiki = Wiki.create(:project => project, :start_page => 'Wiki')
wiki_menu_item = WikiMenuItem.find_or_initialize_by_wiki_id_and_title(wiki.id, wiki.start_page)
wiki_menu_item.name = 'Wiki'
wiki_menu_item.new_wiki_page = true
wiki_menu_item.index_page = true
wiki_menu_item.save!
end end
end end
end end

@ -16,10 +16,18 @@ class Wiki < ActiveRecord::Base
include Redmine::SafeAttributes include Redmine::SafeAttributes
belongs_to :project belongs_to :project
has_many :pages, :class_name => 'WikiPage', :dependent => :destroy, :order => 'title' has_many :pages, :class_name => 'WikiPage', :dependent => :destroy, :order => 'title'
has_many :wiki_menu_items, :class_name => 'WikiMenuItem', :dependent => :delete_all, :order => 'name'
has_many :redirects, :class_name => 'WikiRedirect', :dependent => :delete_all has_many :redirects, :class_name => 'WikiRedirect', :dependent => :delete_all
acts_as_watchable acts_as_watchable
accepts_nested_attributes_for :wiki_menu_items,
:allow_destroy => true,
:reject_if => proc { |attr| attr['name'].blank? && attr['title'].blank? }
safe_attributes 'wiki_menu_items_attributes'
attr_protected :project_id attr_protected :project_id
validates_presence_of :start_page validates_presence_of :start_page

@ -0,0 +1,61 @@
class WikiMenuItem < ActiveRecord::Base
belongs_to :wiki
belongs_to :parent, :class_name => 'WikiMenuItem'
has_many :children, :class_name => 'WikiMenuItem', :dependent => :destroy, :foreign_key => :parent_id, :order => 'id ASC'
serialize :options, Hash
named_scope :main_items, lambda { |wiki_id|
{:conditions => {:wiki_id => wiki_id, :parent_id => nil}, :order => 'id ASC'}
}
attr_accessible :name, :title
validates_presence_of :title
validates_format_of :title, :with => /^[^,\.\/\?\;\|\:]*$/
validates_uniqueness_of :title, :scope => :wiki_id
validates_presence_of :name
def after_initialize
self.options ||= Hash.new
end
def item_class
title.dasherize
end
def setting
if new_record?
:no_item
elsif is_main_item?
:main_item
else
:sub_item
end
end
def new_wiki_page
!!options[:new_wiki_page]
end
def new_wiki_page=(value)
options[:new_wiki_page] = value
end
def index_page
!!options[:index_page]
end
def index_page=(value)
options[:index_page] = value
end
def is_main_item?
parent_id.nil?
end
def is_sub_item?
!parent_id.nil?
end
end

@ -47,12 +47,18 @@ class WikiPage < ActiveRecord::Base
# Wiki pages that are protected by default # Wiki pages that are protected by default
DEFAULT_PROTECTED_PAGES = %w(sidebar) DEFAULT_PROTECTED_PAGES = %w(sidebar)
after_destroy :delete_wiki_menu_item
def after_initialize def after_initialize
if new_record? && DEFAULT_PROTECTED_PAGES.include?(title.to_s.downcase) if new_record? && DEFAULT_PROTECTED_PAGES.include?(title.to_s.downcase)
self.protected = true self.protected = true
end end
end end
def delete_wiki_menu_item
self.menu_item.destroy if self.menu_item
end
def visible?(user=User.current) def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_wiki_pages, project) !user.nil? && user.allowed_to?(:view_wiki_pages, project)
end end
@ -76,6 +82,14 @@ class WikiPage < ActiveRecord::Base
wiki.redirects.find_all_by_title(title).each(&:destroy) wiki.redirects.find_all_by_title(title).each(&:destroy)
# Create a redirect to the new title # Create a redirect to the new title
wiki.redirects << WikiRedirect.new(:title => @previous_title, :redirects_to => title) unless redirect_existing_links == "0" wiki.redirects << WikiRedirect.new(:title => @previous_title, :redirects_to => title) unless redirect_existing_links == "0"
# Change title of dependent wiki menu item
dependent_item = WikiMenuItem.find_by_wiki_id_and_title(self.wiki.id, @previous_title)
if dependent_item
dependent_item.title = title
dependent_item.save!
end
@previous_title = nil @previous_title = nil
end end
end end
@ -158,6 +172,28 @@ class WikiPage < ActiveRecord::Base
self.parent = parent_page self.parent = parent_page
end end
def menu_item
WikiMenuItem.find_by_title_and_wiki_id(title, wiki_id)
end
def nearest_menu_item
if self.menu_item
self.menu_item
elsif self.parent
self.parent.nearest_menu_item
else
nil
end
end
def breadcrumb_title
if item = menu_item
item.name
else
pretty_title
end
end
protected protected
def validate def validate

@ -1,19 +0,0 @@
<% remote_form_for :wiki, @wiki,
:url => { :controller => 'wikis', :action => 'edit', :id => @project },
:builder => TabularFormBuilder,
:lang => current_language do |f| %>
<%= error_messages_for 'wiki' %>
<div class="box tabular">
<p><%= f.text_field :start_page, :size => 60, :required => true %><br />
<em><%= l(:text_unallowed_characters) %>: , . / ? ; : |</em></p>
</div>
<div class="contextual">
<%= link_to(l(:button_delete), {:controller => 'wikis', :action => 'destroy', :id => @project},
:class => 'icon icon-del') if @wiki && !@wiki.new_record? %>
</div>
<%= submit_tag((@wiki.nil? || @wiki.new_record?) ? l(:button_create) : l(:button_save)) %>
<% end %>

@ -1,3 +1,9 @@
<% if @related_page %>
<% breadcrumb_for_page(@related_page, l(:label_table_of_contents)) %>
<% else %>
<% breadcrumb_paths(l(:label_table_of_contents)) %>
<% end %>
<div class="contextual"> <div class="contextual">
<%= watcher_link(@wiki, User.current) %> <%= watcher_link(@wiki, User.current) %>
</div> </div>

@ -0,0 +1,44 @@
<h2>
<% if @page.parent %>
<% breadcrumb_for_page(@page.parent, l("create_new_page")) %>
<%= l("create_child_page_for", :title => @page.parent.pretty_title) %>
<% else %>
<% breadcrumb_paths(l("create_new_page")) %>
<%= l("create_new_page") %>
<% end %>
</h2>
<% form_for :content, @content, :url => wiki_create_path(:project_id => @project), :html => {:method => :post, :multipart => true, :id => 'wiki_form'} do |f| %>
<%= error_messages_for 'page' %>
<% fields_for :page, @page do |page_fields| %>
<%= page_fields.hidden_field :parent_id %>
<p><label><%= l(:field_title) %></label><br /><%= page_fields.text_field :title, :size => 120 %></p>
<% end %>
<p><%= f.text_area :text, :cols => 100, :rows => 25, :class => 'wiki-edit', :accesskey => accesskey(:edit) %></p>
<p><label><%= l(:field_comments) %></label><br /><%= f.text_field :comments, :size => 120 %></p>
<p><label><%=l(:label_attachment_plural)%></label><br /><%= render :partial => 'attachments/form' %></p>
<p><%= submit_tag l(:button_save) %>
<%= link_to_remote l(:label_preview),
{ :url => wiki_preview_path(:project_id => @project),
:method => :post,
:update => 'preview',
:with => "Form.serialize('wiki_form')",
:complete => "Element.scrollTo('preview')"
}, :accesskey => accesskey(:preview) %></p>
<%= wikitoolbar_for 'content_text' %>
<% end %>
<div id="preview" class="wiki"></div>
<% content_for :header_tags do %>
<%= stylesheet_link_tag 'scm' %>
<%= robot_exclusion_tag %>
<% end %>
<% html_title @page.pretty_title %>

@ -9,14 +9,21 @@
<% if @editable %> <% if @editable %>
<%= li_unless_nil(link_to_if_authorized(l(:button_lock), {:action => 'protect', :id => @page.title, :protected => 1}, :method => :post, :class => 'icon icon-lock')) if !@page.protected? %> <%= li_unless_nil(link_to_if_authorized(l(:button_lock), {:action => 'protect', :id => @page.title, :protected => 1}, :method => :post, :class => 'icon icon-lock')) if !@page.protected? %>
<%= li_unless_nil(link_to_if_authorized(l(:button_unlock), {:action => 'protect', :id => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock')) if @page.protected? %> <%= li_unless_nil(link_to_if_authorized(l(:button_unlock), {:action => 'protect', :id => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock')) if @page.protected? %>
<% if User.current.allowed_to? :edit_wiki_pages, @project %>
<% if @page %>
<%= content_tag(:li, link_to(l(:create_child_page), wiki_new_child_path(:id => @page.title, :project_id => @project), :class => 'icon icon-duplicate')) %>
<% end %>
<% end %>
<%= li_unless_nil(link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move')) if @content.version == @page.content.version %> <%= li_unless_nil(link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move')) if @content.version == @page.content.version %>
<%= li_unless_nil(link_to_if_authorized(l(:button_delete), {:action => 'destroy', :id => @page.title}, :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del')) %> <%= li_unless_nil(link_to_if_authorized(l(:button_delete), {:action => 'destroy', :id => @page.title}, :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del')) %>
<%= li_unless_nil(link_to_if_authorized(l(:button_rollback), {:action => 'edit', :id => @page.title, :version => @content.version }, :class => 'icon icon-cancel')) if @content.version < @page.content.version %> <%= li_unless_nil(link_to_if_authorized(l(:button_rollback), {:action => 'edit', :id => @page.title, :version => @content.version }, :class => 'icon icon-cancel')) if @content.version < @page.content.version %>
<% end %> <% end %>
<%= li_unless_nil(link_to_if_authorized(l(:label_history), {:action => 'history', :id => @page.title}, :class => 'icon icon-history')) %> <%= li_unless_nil(link_to_if_authorized(l(:label_history), {:action => 'history', :id => @page.title}, :class => 'icon icon-history')) %>
<%= li_unless_nil(link_to_if_authorized(l(:button_wiki_menu_entry), {:controller => 'wiki_menu_items', :action => 'edit', :project_id => @project.identifier, :id => @page.title}, :class => 'icon icon-edit')) %>
<% end %> <% end %>
<% breadcrumb_paths(*@page.ancestors.reverse.collect {|parent| link_to h(parent.pretty_title), {:id => parent.title, :project_id => parent.project}}) %> <% breadcrumb_paths(*(@page.ancestors.reverse.collect {|parent| link_to h(parent.breadcrumb_title), {:id => parent.title, :project_id => parent.project}} + [h(@page.breadcrumb_title)])) %>
<% if @content.version != @page.content.version %> <% if @content.version != @page.content.version %>
<p> <p>

@ -0,0 +1,46 @@
<%= error_messages_for "wiki_menu_item", :object => @wiki_menu_item %>
<% breadcrumb_paths(*@page.ancestors.reverse.collect {|parent| link_to h(parent.pretty_title), {:id => parent.title, :project_id => parent.project}}.push(@page.title)) %>
<h2><%= l(:wiki_menu_item_for, :title => @page_title) %></h2>
<% form_for :wiki_menu_item, @wiki_menu_item, :html => {:id => 'wiki_menu_item_form', :class => 'wiki_menu_item_form', :method => :put}, :url => wiki_menu_item_path(@project, @page_title) do |form| %>
<p class="name_of_item">
<%= form.label :name, l(:label_menu_item_name), {:id => 'name_of_item'} %>
<% if @wiki_menu_item.name.nil? %>
<%= form.text_field :name, :size => 20, :value => @page_title.gsub("_"," ") %>
<% else %>
<%= form.text_field :name, :size => 20 %>
<% end %>
</p>
</br>
<div style="clear: both;"></div>
<fieldset class="box" id="wiki_menu_item_setting"><legend><%=l(:wiki_menu_item_setting)%></legend>
<p>
<%= form.radio_button 'setting', :no_item %>
<%= form.label 'setting_no_item', l(:label_wiki_dont_show_menu_item) %>
</p>
<p class="main_item">
<%= form.radio_button 'setting', :main_item %>
<%= form.label 'setting_main_item', l(:label_wiki_show_menu_item) %>
</p>
<p class="wiki_menu_item_optional_links">
<%= form.check_box 'new_wiki_page' %>
<%= form.label 'new_wiki_page', l(:label_wiki_show_new_page_link) %>
</br>
<%= form.check_box 'index_page' %>
<%= form.label 'index_page', l(:label_wiki_show_index_page_link) %>
</p>
<p>
<% disabled = @possible_parent_menu_items.empty? %>
<%= form.radio_button 'setting', :sub_item, :disabled => disabled %>
<%= form.label 'setting_sub_item', l(:label_wiki_show_submenu_item), {:id => 'with-select'} %>
<%= select_tag "parent_wiki_menu_item", options_for_select(@possible_parent_menu_items), :disabled => disabled %>
</p>
</fieldset>
<p>
<%= submit_tag l(:button_save), :method => :post %>
<%= link_to l(:button_cancel), {:controller => 'wiki', :action => 'show', :project_id => @project, :id => @page_title} %>
</p>
<% end %>

@ -700,6 +700,21 @@ de:
label_wiki_edit_plural: Wiki-Bearbeitungen label_wiki_edit_plural: Wiki-Bearbeitungen
label_wiki_page: Wiki-Seite label_wiki_page: Wiki-Seite
label_wiki_page_plural: Wiki-Seiten label_wiki_page_plural: Wiki-Seiten
wiki_menu_item: "Menüpunkt"
wiki_menu_item_for: "Menüpunkt für die Wikiseite \"%{title}\""
label_wiki_dont_show_menu_item: Wikiseite nicht in der Projektnavigation anzeigen
label_wiki_show_menu_item: als Menüpunkt in der Projektnavigation anzeigen
label_wiki_show_submenu_item: "als Untermenüpunkt anzeigen von "
label_menu_item_name: Name des Menüpunktes
wiki_menu_item_setting: Sichtbarkeit
label_wiki_show_new_page_link: "'Neue Unterseite anlegen' Link als Untermenüpunkt anzeigen"
label_wiki_show_index_page_link: "'Inhaltsverzeichnis' Link als Untermenüpunkt anzeigen"
create_child_page: Neue Unterseite anlegen
create_child_page_for: "Neue Unterseite anlegen: \"%{title}\""
create_new_page: Neue Seite anlegen
label_index_by_title: Seiten nach Titel label_index_by_title: Seiten nach Titel
label_index_by_date: Seiten nach Datum label_index_by_date: Seiten nach Datum
label_current_version: Gegenwärtige Version label_current_version: Gegenwärtige Version
@ -891,6 +906,7 @@ de:
button_duplicate: Duplizieren button_duplicate: Duplizieren
button_show: Anzeigen button_show: Anzeigen
button_remove_widget: Infobox löschen button_remove_widget: Infobox löschen
button_wiki_menu_entry: Menüpunkt verwalten
status_active: aktiv status_active: aktiv
status_registered: angemeldet status_registered: angemeldet

@ -699,6 +699,20 @@ en:
label_wiki_edit_plural: Wiki edits label_wiki_edit_plural: Wiki edits
label_wiki_page: Wiki page label_wiki_page: Wiki page
label_wiki_page_plural: Wiki pages label_wiki_page_plural: Wiki pages
wiki_menu_item: "Menu item"
wiki_menu_item_for: "Menu item for wikipage \"%{title}\""
label_wiki_dont_show_menu_item: Do not show this wikipage in project navigation
label_wiki_show_menu_item: Show as menu item in project navigation
label_wiki_show_submenu_item: "Show as submenu item of "
label_menu_item_name: Name of menu item
wiki_menu_item_setting: Visibility
label_wiki_show_new_page_link: "Show submenu item 'Create new child page'"
label_wiki_show_index_page_link: "Show submenu item 'Table of Contents'"
create_child_page: Create new child page
create_child_page_for: "Create new child page: \"%{title}\""
create_new_page: Create new page
label_index_by_title: Index by title label_index_by_title: Index by title
label_index_by_date: Index by date label_index_by_date: Index by date
label_current_version: Current version label_current_version: Current version
@ -908,6 +922,7 @@ en:
button_duplicate: Duplicate button_duplicate: Duplicate
button_show: Show button_show: Show
button_remove_widget: Remove widget button_remove_widget: Remove widget
button_wiki_menu_entry: Configure menu item
status_active: active status_active: active
status_registered: registered status_registered: registered

@ -38,7 +38,13 @@ ActionController::Routing::Routes.draw do |map|
end end
map.resources :time_entries, :controller => 'timelog' map.resources :time_entries, :controller => 'timelog'
map.resource :wiki_menu_item, :path_prefix => "projects/:project_id/wiki/:id", :only => [:edit, :update]
map.wiki_new 'projects/:project_id/wiki/new', :controller => 'wiki', :action => 'new', :conditions => { :method => :get }
map.wiki_create 'projects/:project_id/wiki/new', :controller => 'wiki', :action => 'create', :conditions => { :method => :post }
map.wiki_preview 'projects/:project_id/wiki/preview', :controller => 'wiki', :action => 'preview', :conditions => { :method => :post }
map.wiki_new_child 'projects/:project_id/wiki/:id/new', :controller => 'wiki', :action => 'new_child', :conditions => { :method => :get }
map.wiki_page_toc 'projects/:project_id/wiki/:id/toc', :controller => 'wiki', :action => 'index', :conditions => { :method => :get }
map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get} map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post} map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}

@ -0,0 +1,16 @@
class CreateWikiMenuItems < ActiveRecord::Migration
def self.up
create_table :wiki_menu_items do |t|
t.column :name, :string
t.column :title, :string
t.column :parent_id, :integer
t.column :options, :text
t.belongs_to :wiki
end
end
def self.down
puts "You cannot safely undo this migration!"
end
end

@ -0,0 +1,18 @@
class CreateWikiMenuItemForExistingWikis < ActiveRecord::Migration
def self.up
Wiki.all.each do |wiki|
menu_item = WikiMenuItem.new
menu_item.name = wiki.start_page
menu_item.title = wiki.start_page
menu_item.wiki_id = wiki.id
menu_item.index_page = true
menu_item.new_wiki_page = true
menu_item.save!
end
end
def self.down
puts "You cannot safely undo this migration!"
end
end

@ -128,12 +128,13 @@ Redmine::AccessControl.map do |map|
map.project_module :wiki do |map| map.project_module :wiki do |map|
map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
map.permission :manage_wiki_menu, {:wiki_menu_items => [:edit, :update]}, :require => :member
map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member
map.permission :view_wiki_pages, :wiki => [:index, :show, :special, :date_index] map.permission :view_wiki_pages, :wiki => [:index, :show, :special, :date_index]
map.permission :export_wiki_pages, :wiki => [:export] map.permission :export_wiki_pages, :wiki => [:export]
map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate]
map.permission :edit_wiki_pages, :wiki => [:edit, :update, :preview, :add_attachment] map.permission :edit_wiki_pages, :wiki => [:edit, :update, :preview, :add_attachment, :new, :new_child, :create]
map.permission :delete_wiki_pages_attachments, {} map.permission :delete_wiki_pages_attachments, {}
map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member
end end
@ -226,10 +227,6 @@ Redmine::MenuManager.map :project_menu do |menu|
menu.push :new_news, { :controller => 'news', :action => 'new' }, :param => :project_id, :caption => :label_news_new, :parent => :news, menu.push :new_news, { :controller => 'news', :action => 'new' }, :param => :project_id, :caption => :label_news_new, :parent => :news,
:if => Proc.new { |p| User.current.allowed_to?(:manage_news, p.project) } :if => Proc.new { |p| User.current.allowed_to?(:manage_news, p.project) }
menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural
menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id,
:if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
menu.push :wiki_index_by_title, {:action => 'index', :controller => 'wiki'}, :param => :project_id, :caption => :label_index_by_title, :parent => :wiki, :last => true
menu.push :wiki_index_by_date, {:action => 'date_index', :controller => 'wiki'}, :param => :project_id, :caption => :label_index_by_date, :parent => :wiki, :last => true
menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
:if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id

@ -24,11 +24,27 @@ module Redmine::MenuManager
end end
end end
def self.loose(menu_name, &menu_builder)
@temp_menu_builder_queues ||= {}
current_queue = @temp_menu_builder_queues[menu_name.to_sym] ||= []
if menu_builder
current_queue.push menu_builder
else
MapDeferrer.new current_queue
end
end
def self.items(menu_name) def self.items(menu_name)
items = {} items = {}
mapper = Mapper.new(menu_name.to_sym, items) mapper = Mapper.new(menu_name.to_sym, items)
@menu_builder_queues[menu_name.to_sym].each do |menu_builder| potential_items = @menu_builder_queues[menu_name.to_sym]
potential_items += @temp_menu_builder_queues[menu_name.to_sym] if @temp_menu_builder_queues and @temp_menu_builder_queues[menu_name.to_sym]
@temp_menu_builder_queues = {}
potential_items.each do |menu_builder|
menu_builder.call(mapper) menu_builder.call(mapper)
end end

@ -22,9 +22,35 @@ module Redmine::MenuManager::MenuHelper
# Renders the application main menu # Renders the application main menu
def render_main_menu(project) def render_main_menu(project)
build_wiki_menus(project) if project
render_menu((project && !project.new_record?) ? :project_menu : :application_menu, project) render_menu((project && !project.new_record?) ? :project_menu : :application_menu, project)
end end
def build_wiki_menus(project)
project_wiki = project.wiki
WikiMenuItem.main_items(project_wiki).each do |main_item|
Redmine::MenuManager.loose :project_menu do |menu|
menu.push "#{main_item.item_class}".to_sym,
{ :controller => 'wiki', :action => 'show', :id => h(main_item.title) },
:param => :project_id, :caption => main_item.name
menu.push :wiki_create_new_page, {:action=>"new_child", :controller=>"wiki", :id => h(main_item.title) },
:param => :project_id, :caption => :create_child_page,
:parent => "#{main_item.item_class}".to_sym if main_item.new_wiki_page and
WikiPage.find_by_wiki_id_and_title(project_wiki.id, main_item.title)
menu.push :table_of_contents, {:action => 'index', :controller => 'wiki', :id => h(main_item.title)}, :param => :project_id, :caption => :label_table_of_contents, :parent => "#{main_item.item_class}".to_sym if main_item.index_page
main_item.children.each do |child|
menu.push "#{child.item_class}".to_sym,
{ :controller => 'wiki', :action => 'show', :id => h(child.title) },
:param => :project_id, :caption => child.name, :parent => "#{main_item.item_class}".to_sym
end
end
end
end
def display_main_menu?(project) def display_main_menu?(project)
menu_name = project && !project.new_record? ? :project_menu : :application_menu menu_name = project && !project.new_record? ? :project_menu : :application_menu
Redmine::MenuManager.items(menu_name).size > 1 # 1 element is the root Redmine::MenuManager.items(menu_name).size > 1 # 1 element is the root
@ -158,7 +184,18 @@ module Redmine::MenuManager::MenuHelper
item.url item.url
end end
caption = item.caption(project) caption = item.caption(project)
return [caption, url, (current_menu_item == item.name)]
if @page and @page.instance_of?(WikiPage) and !@page.new_record? and current_menu_item == :wiki
menu_item = @page.nearest_menu_item
selected = node.name.to_sym == menu_item.title.dasherize.to_sym if menu_item
elsif current_menu_item == :wiki and related_page = params[:id]
selected = related_page.dasherize == item.name.to_s.dasherize
else
selected = current_menu_item == item.name
end
return [caption, url, selected]
end end
# Checks if a user is allowed to access the menu item by: # Checks if a user is allowed to access the menu item by:

@ -513,7 +513,7 @@ a.atom { background: url(../images/feed.png) no-repeat 1px 50%; padding: 2px 0px
div#tab-content-members .splitcontentleft, div#tab-content-memberships .splitcontentleft, div#tab-content-users .splitcontentleft { width: 64% } div#tab-content-members .splitcontentleft, div#tab-content-memberships .splitcontentleft, div#tab-content-users .splitcontentleft { width: 64% }
div#tab-content-members .splitcontentright, div#tab-content-memberships .splitcontentright, div#tab-content-users .splitcontentright { width: 34% } div#tab-content-members .splitcontentright, div#tab-content-memberships .splitcontentright, div#tab-content-users .splitcontentright { width: 34% }
div#tab-content-members fieldset, div#tab-content-memberships fieldset, div#tab-content-users fieldset { padding:1em; margin-bottom: 1em; } div#tab-content-members fieldset, div#tab-content-memberships fieldset, div#tab-content-users fieldset { padding:1em; margin-bottom: 1em; }
div#tab-content-info fieldset legend, div#tab-content-members fieldset legend, div#tab-content-memberships fieldset legend, div#tab-content-users fieldset legend { font-weight: bold; } div#tab-content-info fieldset legend, div#tab-content-members fieldset legend, div#tab-content-memberships fieldset legend, div#tab-content-users fieldset legend, fieldset#wiki_menu_item_setting { font-weight: bold; }
div#tab-content-members fieldset label, div#tab-content-memberships fieldset label, div#tab-content-users fieldset label { display: block; } div#tab-content-members fieldset label, div#tab-content-memberships fieldset label, div#tab-content-users fieldset label { display: block; }
div#tab-content-members fieldset div, div#tab-content-users fieldset div { max-height: 400px; overflow:auto; } div#tab-content-members fieldset div, div#tab-content-users fieldset div { max-height: 400px; overflow:auto; }
div#tab-content-members .user.status_registered, div#tab-content-members label.status_registered { filter: alpha(opacity=80); -khtml-opacity: 0.8; opacity: 0.8; -moz-opacity: 0.8; } div#tab-content-members .user.status_registered, div#tab-content-members label.status_registered { filter: alpha(opacity=80); -khtml-opacity: 0.8; opacity: 0.8; -moz-opacity: 0.8; }
@ -2971,3 +2971,45 @@ strong.related-issues-heading {
div.indent { div.indent {
padding-left: 10px; padding-left: 10px;
} }
form.wiki_menu_item_form p {
padding-left: 0px;
}
form.wiki_menu_item_form label {
display: inline-block;
margin-bottom: 10px;
margin-left: 0px;
width: auto;
font-weight: bold;
}
form.wiki_menu_item_form select#parent_wiki_menu_item {
margin-left: 7px;
margin-top: -1px;
}
form.wiki_menu_item_form label#name_of_item {
float: left;
padding-left: 3px;
margin-right: 4px;
line-height: 21px;
}
form.wiki_menu_item_form label#with-select {
margin-left: 0px;
}
form.wiki_menu_item_form select#parent_wiki_menu_item_wiki_page {
margin-bottom: 10px;
}
form.wiki_menu_item_form p input {
}
form.wiki_menu_item_form fieldset#wiki_menu_item_setting {
margin-top: 10px;
}
form.wiki_menu_item_form p.name_of_item {
padding-top: 10px;
}
form.wiki_menu_item_form p.main_item {
padding-bottom: 0px;
}
form.wiki_menu_item_form p.wiki_menu_item_optional_links {
margin-left: 10px;
padding-top: 0px;
}

Loading…
Cancel
Save