##// END OF EJS Templates
Introduce virtual MenuNodes (#15880)....
Introduce virtual MenuNodes (#15880). They are characterized by having a blank url. they will only be rendered if the user is authorized to see at least one of its children. they render as links which do nothing when clicked. Patch by Jan Schulz-Hofen. git-svn-id: http://svn.redmine.org/redmine/trunk@15501 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r15033:7d6b3d344db8
r15119:53710d80fc88
Show More
wiki_controller.rb
387 lines | 12.3 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
Moved wiki page updated_on eager load to a scope and fixed timestamp titles on wiki page index (#7818)....
r4978 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
wiki branch merged into trunk...
r320 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704 #
Jean-Philippe Lang
wiki branch merged into trunk...
r320 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704 #
Jean-Philippe Lang
wiki branch merged into trunk...
r320 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Eric Davis
Refactor: Rename WikiController#page_index to #index...
r4176 # The WikiController follows the Rails REST controller pattern but with
# a few differences
#
# * index - shows a list of WikiPages grouped by page or date
# * new - not used
# * create - not used
# * show - will also show the form for creating a new wiki page
# * edit - used to edit an existing or new page
# * update - used to save a wiki page update to the database, including new pages
# * destroy - normal
#
# Other member and collection methods are also used
#
# TODO: still being worked on
Jean-Philippe Lang
wiki branch merged into trunk...
r320 class WikiController < ApplicationController
Jean-Philippe Lang
Contextual quick search (#3263)....
r2829 default_search_scope :wiki_pages
Jean-Philippe Lang
Merged 0.6 branch into trunk....
r663 before_filter :find_wiki, :authorize
Jean-Philippe Lang
Code cleanup....
r5302 before_filter :find_existing_or_new_page, :only => [:show, :edit, :update]
Jean-Philippe Lang
Ability to delete a version from a wiki page history (#10852)....
r10493 before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy, :destroy_version]
Jean-Philippe Lang
REST API for deleting wiki pages (#7082)....
r10528 accept_api_auth :index, :show, :update, :destroy
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748 before_filter :find_attachments, :only => [:preview]
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
Attachments can now be added to wiki pages (original patch by Pavol Murin). Only authorized users can add/delete attachments....
r538 helper :attachments
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704 include AttachmentsHelper
Jean-Philippe Lang
Ability to watch a wiki or a single wiki page (#413)....
r2666 helper :watchers
Toshi MARUYAMA
pdf: add a new feature to export wiki pdf (#401)...
r7621 include Redmine::Export::PDF
Eric Davis
Refactor: rename WikiController#index to #show, it's a single resource action...
r4152
Eric Davis
Refactor: Rename WikiController#page_index to #index...
r4176 # List of pages, sorted alphabetically and by parent (hierarchy)
def index
Jean-Philippe Lang
Moved wiki page updated_on eager load to a scope and fixed timestamp titles on wiki page index (#7818)....
r4978 load_pages_for_index
Jean-Philippe Lang
REST API for retrieving wiki pages (#7082)....
r10504
respond_to do |format|
format.html {
@pages_by_parent_id = @pages.group_by(&:parent_id)
}
format.api
end
Jean-Philippe Lang
Moved wiki page updated_on eager load to a scope and fixed timestamp titles on wiki page index (#7818)....
r4978 end
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
Moved wiki page updated_on eager load to a scope and fixed timestamp titles on wiki page index (#7818)....
r4978 # List of page, by last update
def date_index
load_pages_for_index
@pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
Eric Davis
Refactor: Rename WikiController#page_index to #index...
r4176 end
Jean-Philippe Lang
Adds "New wiki page" link to create a new wiki page (#5536)....
r14964 def new
@page = WikiPage.new(:wiki => @wiki, :title => params[:title])
unless User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
render_403
end
if request.post?
@page.validate
if @page.errors[:title].blank?
path = project_wiki_page_path(@project, @page.title)
respond_to do |format|
format.html { redirect_to path }
format.js { render :js => "window.location = #{path.to_json}" }
end
end
end
end
Jean-Philippe Lang
wiki branch merged into trunk...
r320 # display a page (in editing mode if it doesn't exist)
Eric Davis
Refactor: rename WikiController#index to #show, it's a single resource action...
r4152 def show
Jean-Philippe Lang
Fixed that viewing/editing a wiki page without WikiContent raises an error (#14986)....
r11990 if params[:version] && !User.current.allowed_to?(:view_wiki_edits, @project)
deny_access
return
end
@content = @page.content_for_version(params[:version])
if @content.nil?
Jean-Philippe Lang
REST API for retrieving wiki pages (#7082)....
r10504 if User.current.allowed_to?(:edit_wiki_pages, @project) && editable? && !api_request?
Jean-Philippe Lang
Fixed: a user not authorized to edit wiki pages gets the edit form if the page doesn't exist. He now gets a 404....
r812 edit
render :action => 'edit'
else
render_404
end
return
Jean-Philippe Lang
wiki branch merged into trunk...
r320 end
Jean-Philippe Lang
Adds a permission for exporting wiki pages....
r3257 if User.current.allowed_to?(:export_wiki_pages, @project)
Toshi MARUYAMA
pdf: add a new feature to export wiki pdf (#401)...
r7621 if params[:format] == 'pdf'
Jean-Philippe Lang
Adds support for macro and Redmine links in PDF export (#13051)....
r13562 send_file_headers! :type => 'application/pdf', :filename => "#{@page.title}.pdf"
Toshi MARUYAMA
pdf: add a new feature to export wiki pdf (#401)...
r7621 return
elsif params[:format] == 'html'
Jean-Philippe Lang
Adds a permission for exporting wiki pages....
r3257 export = render_to_string :action => 'export', :layout => false
send_data(export, :type => 'text/html', :filename => "#{@page.title}.html")
return
elsif params[:format] == 'txt'
send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt")
return
end
Jean-Philippe Lang
wiki branch merged into trunk...
r320 end
Jean-Philippe Lang
Adds a permission for exporting wiki pages....
r3257 @editable = editable?
Jean-Philippe Lang
Handle the case of a text formatter that doesn't support section edit (#2222)....
r7711 @sections_editable = @editable && User.current.allowed_to?(:edit_wiki_pages, @page.project) &&
Jean-Philippe Lang
Adds #current_version? method to wiki content....
r7852 @content.current_version? &&
Jean-Philippe Lang
Handle the case of a text formatter that doesn't support section edit (#2222)....
r7711 Redmine::WikiFormatting.supports_section_edit?
Jean-Philippe Lang
REST API for retrieving wiki pages (#7082)....
r10504 respond_to do |format|
format.html
format.api
end
Jean-Philippe Lang
wiki branch merged into trunk...
r320 end
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
wiki branch merged into trunk...
r320 # edit an existing page or a new one
def edit
Jean-Philippe Lang
Wiki page protection (#851, patch #1146 by Mateo Murphy with slight changes)....
r1400 return render_403 unless editable?
Jean-Philippe Lang
Option to set parent automatically for new wiki pages (#3108)....
r8135 if @page.new_record?
if params[:parent].present?
@page.parent = @page.wiki.find_page(params[:parent].to_s)
end
end
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
Added the ability to easily rollback to a previous version of a wiki page....
r421 @content = @page.content_for_version(params[:version])
Jean-Philippe Lang
Fixed that viewing/editing a wiki page without WikiContent raises an error (#14986)....
r11990 @content ||= WikiContent.new(:page => @page)
Jean-Philippe Lang
Makes wiki text formatter pluggable....
r1953 @content.text = initial_page_content(@page) if @content.text.blank?
Jean-Philippe Lang
wiki branch merged into trunk...
r320 # don't keep previous comment
Jean-Philippe Lang
Fixed: 10342 Creation of Schema in Oracle...
r476 @content.comments = nil
Eric Davis
Refactor: split WikiController#edit into #update...
r4158
# To prevent StaleObjectError exception when reverting to a previous version
Jean-Philippe Lang
Fixed that viewing/editing a wiki page without WikiContent raises an error (#14986)....
r11990 @content.version = @page.content.version if @page.content
Toshi MARUYAMA
remove trailing white-space from app/controllers/wiki_controller.rb...
r10063
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 @text = @content.text
Jean-Philippe Lang
Handle the case of a text formatter that doesn't support section edit (#2222)....
r7711 if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 @section = params[:section].to_i
@text, @section_hash = Redmine::WikiFormatting.formatter.new(@text).get_section(@section)
render_404 if @text.blank?
end
Eric Davis
Refactor: split WikiController#edit into #update...
r4158 end
# Creates a new page or updates an existing one
def update
return render_403 unless editable?
Jean-Philippe Lang
REST API for creating/updating wiki pages (#7082)....
r10505 was_new_page = @page.new_record?
Jean-Philippe Lang
Ability to edit a wiki page's parent on the edit page (#6449)....
r8667 @page.safe_attributes = params[:wiki_page]
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
Fixed that viewing/editing a wiki page without WikiContent raises an error (#14986)....
r11990 @content = @page.content || WikiContent.new(:page => @page)
Jean-Philippe Lang
REST API for creating/updating wiki pages (#7082)....
r10505 content_params = params[:content]
if content_params.nil? && params[:wiki_page].is_a?(Hash)
content_params = params[:wiki_page].slice(:text, :comments, :version)
end
content_params ||= {}
Eric Davis
Refactor: split WikiController#edit into #update...
r4158
Jean-Philippe Lang
REST API for creating/updating wiki pages (#7082)....
r10505 @content.comments = content_params[:comments]
@text = content_params[:text]
Jean-Philippe Lang
Handle the case of a text formatter that doesn't support section edit (#2222)....
r7711 if params[:section].present? && Redmine::WikiFormatting.supports_section_edit?
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 @section = params[:section].to_i
@section_hash = params[:section_hash]
Jean-Philippe Lang
Return to section anchor after wiki section edit (#15182)....
r12009 @content.text = Redmine::WikiFormatting.formatter.new(@content.text).update_section(@section, @text, @section_hash)
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 else
Jean-Philippe Lang
REST API for creating/updating wiki pages (#7082)....
r10505 @content.version = content_params[:version] if content_params[:version]
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 @content.text = @text
end
Eric Davis
Refactor: split WikiController#edit into #update...
r4158 @content.author = User.current
Jean-Philippe Lang
Code cleanup....
r10615
Jean-Philippe Lang
Fixed that viewing/editing a wiki page without WikiContent raises an error (#14986)....
r11990 if @page.save_with_content(@content)
Jean-Philippe Lang
Add support for attaching file to WIKI pages by REST API (#14830)....
r15033 attachments = Attachment.attach_files(@page, params[:attachments] || (params[:wiki_page] && params[:wiki_page][:uploads]))
Eric Davis
Refactor: split WikiController#edit into #update...
r4158 render_attachment_warning_if_needed(@page)
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
Jean-Philippe Lang
REST API for creating/updating wiki pages (#7082)....
r10505
respond_to do |format|
Jean-Philippe Lang
Return to section anchor after wiki section edit (#15182)....
r12009 format.html {
anchor = @section ? "section-#{@section}" : nil
redirect_to project_wiki_page_path(@project, @page.title, :anchor => anchor)
}
Jean-Philippe Lang
REST API for creating/updating wiki pages (#7082)....
r10505 format.api {
if was_new_page
Jean-Philippe Lang
Use named routes in controllers....
r10754 render :action => 'show', :status => :created, :location => project_wiki_page_path(@project, @page.title)
Jean-Philippe Lang
REST API for creating/updating wiki pages (#7082)....
r10505 else
render_api_ok
end
}
end
Jean-Philippe Lang
Fixed: Missing template wiki/update.erb error introduced in r4272 (#6987)....
r4315 else
Jean-Philippe Lang
REST API for creating/updating wiki pages (#7082)....
r10505 respond_to do |format|
format.html { render :action => 'edit' }
format.api { render_validation_errors(@content) }
end
Jean-Philippe Lang
wiki branch merged into trunk...
r320 end
Eric Davis
Refactor: split WikiController#edit into #update...
r4158
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 rescue ActiveRecord::StaleObjectError, Redmine::WikiFormatting::StaleSectionError
Jean-Philippe Lang
Optimistic locking added for wiki edits....
r542 # Optimistic locking exception
Jean-Philippe Lang
REST API for creating/updating wiki pages (#7082)....
r10505 respond_to do |format|
format.html {
flash.now[:error] = l(:notice_locking_conflict)
render :action => 'edit'
}
format.api { render_api_head :conflict }
end
Jean-Philippe Lang
wiki branch merged into trunk...
r320 end
Eric Davis
Refactor: split WikiController#edit into #update...
r4158
Jean-Philippe Lang
Added the ability to rename wiki pages (specific permission required)....
r709 # rename a page
def rename
Jean-Philippe Lang
Check that wiki page exists before processing (#2360)....
r2143 return render_403 unless editable?
Jean-Philippe Lang
Added the ability to rename wiki pages (specific permission required)....
r709 @page.redirect_existing_links = true
# used to display the *original* title if some AR validation errors occur
@original_title = @page.pretty_title
Jean-Philippe Lang
Move wiki page to other project (#5450)....
r13261 @page.safe_attributes = params[:wiki_page]
if request.post? && @page.save
Jean-Philippe Lang
Added the ability to rename wiki pages (specific permission required)....
r709 flash[:notice] = l(:notice_successful_update)
Jean-Philippe Lang
Move wiki page to other project (#5450)....
r13261 redirect_to project_wiki_page_path(@page.project, @page.title)
Jean-Philippe Lang
Added the ability to rename wiki pages (specific permission required)....
r709 end
end
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
Wiki page protection (#851, patch #1146 by Mateo Murphy with slight changes)....
r1400 def protect
Jean-Philippe Lang
Check that wiki page exists before processing (#2360)....
r2143 @page.update_attribute :protected, params[:protected]
Jean-Philippe Lang
Use named routes in controllers....
r10754 redirect_to project_wiki_page_path(@project, @page.title)
Jean-Philippe Lang
Wiki page protection (#851, patch #1146 by Mateo Murphy with slight changes)....
r1400 end
Jean-Philippe Lang
wiki branch merged into trunk...
r320 # show page history
def history
Jean-Philippe Lang
Added pagination on wiki page history....
r568 @version_count = @page.content.versions.count
Jean-Philippe Lang
Deprecation warnings (#12774)....
r10909 @version_pages = Paginator.new @version_count, per_page_option, params['page']
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704 # don't load text
Jean-Philippe Lang
Replaces find(:first/:all) calls....
r10704 @versions = @page.content.versions.
select("id, author_id, comments, updated_on, version").
reorder('version DESC').
Jean-Philippe Lang
Use #per_page instead of #items_per_page....
r11195 limit(@version_pages.per_page + 1).
Jean-Philippe Lang
Deprecation warnings (#12774)....
r10909 offset(@version_pages.offset).
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 to_a
Jean-Philippe Lang
Added pagination on wiki page history....
r568
render :layout => false if request.xhr?
Jean-Philippe Lang
wiki branch merged into trunk...
r320 end
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
Added wiki diff....
r580 def diff
@diff = @page.diff(params[:version], params[:version_from])
render_404 unless @diff
end
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
Added wiki annotate view. It's accessible for each version from the page history view. ...
r1007 def annotate
@annotate = @page.annotate(params[:version])
Jean-Philippe Lang
Check that wiki page exists before processing (#2360)....
r2143 render_404 unless @annotate
Jean-Philippe Lang
Added wiki annotate view. It's accessible for each version from the page history view. ...
r1007 end
Eric Davis
Refactor: convert WikiController#destroy to use HTTP DELETE...
r4181
Jean-Philippe Lang
Ask user what to do with child pages when deleting a parent wiki page (#3202)....
r2584 # Removes a wiki page and its history
# Children can be either set as root pages, removed or reassigned to another parent page
Jean-Philippe Lang
Added the ability to destroy wiki pages (content and its history are deleted from the database)....
r537 def destroy
Jean-Philippe Lang
Check that wiki page exists before processing (#2360)....
r2143 return render_403 unless editable?
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
Ask user what to do with child pages when deleting a parent wiki page (#3202)....
r2584 @descendants_count = @page.descendants.size
if @descendants_count > 0
case params[:todo]
when 'nullify'
# Nothing to do
when 'destroy'
# Removes all its descendants
@page.descendants.each(&:destroy)
when 'reassign'
# Reassign children to another parent page
reassign_to = @wiki.pages.find_by_id(params[:reassign_to_id].to_i)
return unless reassign_to
@page.children.each do |child|
child.update_attribute(:parent, reassign_to)
end
else
@reassignable_to = @wiki.pages - @page.self_and_descendants
Jean-Philippe Lang
REST API for deleting wiki pages (#7082)....
r10528 # display the destroy form if it's a user request
return unless api_request?
Jean-Philippe Lang
Ask user what to do with child pages when deleting a parent wiki page (#3202)....
r2584 end
end
Jean-Philippe Lang
Check that wiki page exists before processing (#2360)....
r2143 @page.destroy
Jean-Philippe Lang
REST API for deleting wiki pages (#7082)....
r10528 respond_to do |format|
Jean-Philippe Lang
Use named routes in controllers....
r10754 format.html { redirect_to project_wiki_index_path(@project) }
Jean-Philippe Lang
REST API for deleting wiki pages (#7082)....
r10528 format.api { render_api_ok }
end
Jean-Philippe Lang
Added the ability to destroy wiki pages (content and its history are deleted from the database)....
r537 end
Jean-Philippe Lang
wiki branch merged into trunk...
r320
Jean-Philippe Lang
Ability to delete a version from a wiki page history (#10852)....
r10493 def destroy_version
return render_403 unless editable?
Jean-Philippe Lang
Fixed that #destroy_version with invalid version destroys wiki page content (#21155)....
r14474 if content = @page.content.versions.find_by_version(params[:version])
content.destroy
redirect_to_referer_or history_project_wiki_page_path(@project, @page.title)
else
render_404
end
Jean-Philippe Lang
Ability to delete a version from a wiki page history (#10852)....
r10493 end
Jean-Philippe Lang
Adds export of all wiki pages to a PDF file (#3463)....
r8614 # Export wiki to a single pdf or html file
Eric Davis
Refactor: extract method in WikiController#special to create a new #export method...
r4137 def export
Toshi MARUYAMA
cleanup syntax of Relation#all at WikiController#export...
r12345 @pages = @wiki.pages.
order('title').
includes([:content, {:attachments => :author}]).
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 to_a
Jean-Philippe Lang
Adds export of all wiki pages to a PDF file (#3463)....
r8614 respond_to do |format|
format.html {
export = render_to_string :action => 'export_multiple', :layout => false
send_data(export, :type => 'text/html', :filename => "wiki.html")
}
format.pdf {
Jean-Philippe Lang
Adds support for macro and Redmine links in PDF export (#13051)....
r13562 send_file_headers! :type => 'application/pdf', :filename => "#{@project.identifier}.pdf"
Jean-Philippe Lang
Adds export of all wiki pages to a PDF file (#3463)....
r8614 }
Eric Davis
Refactor: extract method in WikiController#special to create a new #export method...
r4137 end
end
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
wiki branch merged into trunk...
r320 def preview
Eric Davis
Refactor: use :id instead of :page when linking to Wiki Pages...
r4182 page = @wiki.find_page(params[:id])
Jean-Philippe Lang
Fixed: error when previewing a new wiki page (#1292) introduced in r1415....
r1431 # page is nil when previewing a new page
return render_403 unless page.nil? || editable?(page)
Jean-Philippe Lang
Adds child_pages macro for wiki pages (#528)....
r1690 if page
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748 @attachments += page.attachments
Jean-Philippe Lang
Adds child_pages macro for wiki pages (#528)....
r1690 @previewed = page.content
end
Jean-Philippe Lang
wiki branch merged into trunk...
r320 @text = params[:content][:text]
Jean-Philippe Lang
Added preview on add/edit issue form....
r801 render :partial => 'common/preview'
Jean-Philippe Lang
wiki branch merged into trunk...
r320 end
Jean-Philippe Lang
Attachments can now be added to wiki pages (original patch by Pavol Murin). Only authorized users can add/delete attachments....
r538 def add_attachment
Jean-Philippe Lang
Wiki page protection (#851, patch #1146 by Mateo Murphy with slight changes)....
r1400 return render_403 unless editable?
Eric Davis
Refactor: Moved ApplicationController#attach_files to the Attachment model...
r3409 attachments = Attachment.attach_files(@page, params[:attachments])
Eric Davis
Refactor: Decouple failed attachments and the flash messages...
r3414 render_attachment_warning_if_needed(@page)
Eric Davis
Refactor: convert WikiController to a REST resource...
r4189 redirect_to :action => 'show', :id => @page.title, :project_id => @project
Jean-Philippe Lang
Attachments can now be added to wiki pages (original patch by Pavol Murin). Only authorized users can add/delete attachments....
r538 end
Jean-Philippe Lang
wiki branch merged into trunk...
r320 private
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
wiki branch merged into trunk...
r320 def find_wiki
Eric Davis
Refactor: change :id on WikiController to use :project_id...
r4151 @project = Project.find(params[:project_id])
Jean-Philippe Lang
wiki branch merged into trunk...
r320 @wiki = @project.wiki
Jean-Philippe Lang
A wiki page can now be attached to each version....
r561 render_404 unless @wiki
Jean-Philippe Lang
wiki branch merged into trunk...
r320 rescue ActiveRecord::RecordNotFound
render_404
end
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
Code cleanup....
r5302 # Finds the requested page or a new page if it doesn't exist
def find_existing_or_new_page
@page = @wiki.find_or_new_page(params[:id])
Jean-Philippe Lang
Do a redirect when accessing a renamed wiki page....
r5303 if @wiki.page_found_with_redirect?
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 redirect_to_page @page
Jean-Philippe Lang
Do a redirect when accessing a renamed wiki page....
r5303 end
Jean-Philippe Lang
Code cleanup....
r5302 end
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
Check that wiki page exists before processing (#2360)....
r2143 # Finds the requested page and returns a 404 error if it doesn't exist
def find_existing_page
Eric Davis
Refactor: use :id instead of :page when linking to Wiki Pages...
r4182 @page = @wiki.find_page(params[:id])
Jean-Philippe Lang
Do a redirect when accessing a renamed wiki page....
r5303 if @page.nil?
render_404
return
end
if @wiki.page_found_with_redirect?
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 redirect_to_page @page
Jean-Philippe Lang
Do a redirect when accessing a renamed wiki page....
r5303 end
Jean-Philippe Lang
Check that wiki page exists before processing (#2360)....
r2143 end
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 def redirect_to_page(page)
Jean-Philippe Lang
Move wiki page to other project (#5450)....
r13261 if page.project && page.project.visible?
redirect_to :action => action_name, :project_id => page.project, :id => page.title
else
render_404
end
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 end
Jean-Philippe Lang
Wiki page protection (#851, patch #1146 by Mateo Murphy with slight changes)....
r1400 # Returns true if the current user is allowed to edit the page, otherwise false
def editable?(page = @page)
page.editable_by?(User.current)
end
Jean-Philippe Lang
Makes wiki text formatter pluggable....
r1953
# Returns the default content of a new wiki page
def initial_page_content(page)
helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting)
extend helper unless self.instance_of?(helper)
helper.instance_method(:initial_page_content).bind(self).call(page)
end
Toshi MARUYAMA
remove trailing white-spaces from wiki controller source....
r5704
Jean-Philippe Lang
Moved wiki page updated_on eager load to a scope and fixed timestamp titles on wiki page index (#7818)....
r4978 def load_pages_for_index
Toshi MARUYAMA
code format cleanup WikiController...
r12343 @pages = @wiki.pages.with_updated_on.
reorder("#{WikiPage.table_name}.title").
includes(:wiki => :project).
includes(:parent).
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 to_a
Jean-Philippe Lang
Moved wiki page updated_on eager load to a scope and fixed timestamp titles on wiki page index (#7818)....
r4978 end
Jean-Philippe Lang
wiki branch merged into trunk...
r320 end