summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-10-25 19:44:04 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-10-25 19:44:04 +0000
commit9e313087205721ed3c6239be7cde55598d29f9e6 (patch)
treec5ba4ab52453907afae728887b470f95008bbbdb /app/controllers
parentb2e035fa96e4c2b06dcd559850d11987ba96ee1c (diff)
downloadredmine-9e313087205721ed3c6239be7cde55598d29f9e6.tar.gz
redmine-9e313087205721ed3c6239be7cde55598d29f9e6.zip
REST API for retrieving wiki pages (#7082).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10716 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/wiki_controller.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 6e747ecda..e8f6ef35d 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -36,6 +36,7 @@ class WikiController < ApplicationController
before_filter :find_wiki, :authorize
before_filter :find_existing_or_new_page, :only => [:show, :edit, :update]
before_filter :find_existing_page, :only => [:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy, :destroy_version]
+ accept_api_auth :index, :show
helper :attachments
include AttachmentsHelper
@@ -45,7 +46,13 @@ class WikiController < ApplicationController
# List of pages, sorted alphabetically and by parent (hierarchy)
def index
load_pages_for_index
- @pages_by_parent_id = @pages.group_by(&:parent_id)
+
+ respond_to do |format|
+ format.html {
+ @pages_by_parent_id = @pages.group_by(&:parent_id)
+ }
+ format.api
+ end
end
# List of page, by last update
@@ -57,7 +64,7 @@ class WikiController < ApplicationController
# display a page (in editing mode if it doesn't exist)
def show
if @page.new_record?
- if User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
+ if User.current.allowed_to?(:edit_wiki_pages, @project) && editable? && !api_request?
edit
render :action => 'edit'
else
@@ -66,8 +73,7 @@ class WikiController < ApplicationController
return
end
if params[:version] && !User.current.allowed_to?(:view_wiki_edits, @project)
- # Redirects user to the current version if he's not allowed to view previous versions
- redirect_to :version => nil
+ deny_access
return
end
@content = @page.content_for_version(params[:version])
@@ -89,7 +95,10 @@ class WikiController < ApplicationController
@content.current_version? &&
Redmine::WikiFormatting.supports_section_edit?
- render :action => 'show'
+ respond_to do |format|
+ format.html
+ format.api
+ end
end
# edit an existing page or a new one
@@ -321,6 +330,6 @@ private
end
def load_pages_for_index
- @pages = @wiki.pages.with_updated_on.all(:order => 'title', :include => {:wiki => :project})
+ @pages = @wiki.pages.with_updated_on.order("#{WikiPage.table_name}.title").includes(:wiki => :project).includes(:parent).all
end
end