diff options
author | Hiroyuki Sato <sathiroyuki@gmail.com> | 2017-07-23 21:26:02 +0900 |
---|---|---|
committer | Hiroyuki Sato <sathiroyuki@gmail.com> | 2017-07-23 21:26:02 +0900 |
commit | 9b25bbc45d4e6602452e230506601ff0ed8ba84a (patch) | |
tree | 95f7326e4162a325a5e7c7304c33f18194b52cbe /app/controllers/projects/wikis_controller.rb | |
parent | 839018d2d4e3e899b1fa06a43d093a0fdceced42 (diff) | |
parent | b92d5135d8522e1370636799d74b51f9a37d0b2f (diff) | |
download | gitlab-ce-9b25bbc45d4e6602452e230506601ff0ed8ba84a.tar.gz |
Merge branch 'master' into 1827-prevent-concurrent-editing-wiki
Conflicts:
app/controllers/projects/wikis_controller.rb
app/views/projects/wikis/edit.html.haml
spec/features/projects/wiki/user_updates_wiki_page_spec.rb
Diffstat (limited to 'app/controllers/projects/wikis_controller.rb')
-rw-r--r-- | app/controllers/projects/wikis_controller.rb | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index d27af79e003..968d880886c 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -1,5 +1,3 @@ -require 'project_wiki' - class Projects::WikisController < Projects::ApplicationController before_action :authorize_read_wiki! before_action :authorize_create_wiki!, only: [:edit, :create, :history] @@ -47,10 +45,11 @@ class Projects::WikisController < Projects::ApplicationController return render('empty') unless can?(current_user, :create_wiki, @project) @page = @project_wiki.find_page(params[:id]) + @page = WikiPages::UpdateService.new(@project, current_user, wiki_params).execute(@page) - if @page = WikiPages::UpdateService.new(@project, current_user, wiki_params).execute(@page) + if @page.valid? redirect_to( - namespace_project_wiki_path(@project.namespace, @project, @page), + project_wiki_path(@project, @page), notice: 'Wiki was successfully updated.' ) else @@ -66,7 +65,7 @@ class Projects::WikisController < Projects::ApplicationController if @page.persisted? redirect_to( - namespace_project_wiki_path(@project.namespace, @project, @page), + project_wiki_path(@project, @page), notice: 'Wiki was successfully updated.' ) else @@ -79,7 +78,7 @@ class Projects::WikisController < Projects::ApplicationController unless @page redirect_to( - namespace_project_wiki_path(@project.namespace, @project, :home), + project_wiki_path(@project, :home), notice: "Page not found" ) end @@ -89,29 +88,25 @@ class Projects::WikisController < Projects::ApplicationController @page = @project_wiki.find_page(params[:id]) WikiPages::DestroyService.new(@project, current_user).execute(@page) - redirect_to( - namespace_project_wiki_path(@project.namespace, @project, :home), - notice: "Page was successfully deleted" - ) + redirect_to project_wiki_path(@project, :home), + status: 302, + notice: "Page was successfully deleted" end - def preview_markdown - text = params[:text] + def git_access + end - ext = Gitlab::ReferenceExtractor.new(@project, current_user) - ext.analyze(text, author: current_user) + def preview_markdown + result = PreviewMarkdownService.new(@project, current_user, params).execute render json: { - body: view_context.markdown(text, pipeline: :wiki, project_wiki: @project_wiki, page_slug: params[:id]), + body: view_context.markdown(result[:text], pipeline: :wiki, project_wiki: @project_wiki, page_slug: params[:id]), references: { - users: ext.users.map(&:username) + users: result[:users] } } end - def git_access - end - private def load_project_wiki @@ -119,7 +114,6 @@ class Projects::WikisController < Projects::ApplicationController # Call #wiki to make sure the Wiki Repo is initialized @project_wiki.wiki - @sidebar_wiki_entries = WikiPage.group_by_directory(@project_wiki.pages.first(15)) rescue ProjectWiki::CouldNotCreateWikiError flash[:notice] = "Could not create Wiki Repository at this time. Please try again later." @@ -128,6 +122,6 @@ class Projects::WikisController < Projects::ApplicationController end def wiki_params - params[:wiki].slice(:title, :content, :format, :message, :last_commit_sha) + params.require(:wiki).permit(:title, :content, :format, :message, :last_commit_sha) end end |