diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-09-07 12:27:48 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-09-07 12:27:48 +0300 |
commit | 662cf2cef40b97b983b85abb7d68b8a81b170bc3 (patch) | |
tree | b3234b74551e0d5f57c4581dfeca225b0d39f8d5 /app | |
parent | b9df4998607c64b758af641339edd40254900ecc (diff) | |
parent | fbb891c8f3818b9aa17fadbb984ff7d33053c819 (diff) |
Merge branch 'fix-wiki-page-history' into 'master'
Fix broken Wiki Page History
This MR fixes the broken Page History on the Wiki pages. It turns out `WikiHelper` did not allow users to view different versions due to its omitting of query string parameters, which was necessary to specify different `version_id` parameters. Instead of this hacky approach, use manually-specified wildcard routes that match the ID field properly for slashes.
Closes #2104
Closes #1751
Closes #1592
Closes https://github.com/gitlabhq/gitlabhq/issues/9399
See merge request !1232
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/wikis_controller.rb | 1 | ||||
-rw-r--r-- | app/helpers/wiki_helper.rb | 24 | ||||
-rw-r--r-- | app/views/projects/wikis/_main_links.html.haml | 4 | ||||
-rw-r--r-- | app/views/projects/wikis/_nav.html.haml | 4 | ||||
-rw-r--r-- | app/views/projects/wikis/show.html.haml | 2 |
5 files changed, 5 insertions, 30 deletions
diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index 50512cb6dc3..51c26a6a465 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -5,7 +5,6 @@ class Projects::WikisController < Projects::ApplicationController before_action :authorize_create_wiki!, only: [:edit, :create, :history] before_action :authorize_admin_wiki!, only: :destroy before_action :load_project_wiki - include WikiHelper def pages @wiki_pages = Kaminari.paginate_array(@project_wiki.pages).page(params[:page]).per(PER_PAGE) diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb deleted file mode 100644 index f8a96516e61..00000000000 --- a/app/helpers/wiki_helper.rb +++ /dev/null @@ -1,24 +0,0 @@ -module WikiHelper - # Rails v4.1.9+ escapes all model IDs, converting slashes into %2F. The - # only way around this is to implement our own path generators. - def namespace_project_wiki_path(namespace, project, wiki_page, *args) - slug = - case wiki_page - when Symbol - wiki_page - when String - wiki_page - else - wiki_page.slug - end - namespace_project_path(namespace, project) + "/wikis/#{slug}" - end - - def edit_namespace_project_wiki_path(namespace, project, wiki_page, *args) - namespace_project_wiki_path(namespace, project, wiki_page) + '/edit' - end - - def history_namespace_project_wiki_path(namespace, project, wiki_page, *args) - namespace_project_wiki_path(namespace, project, wiki_page) + '/history' - end -end diff --git a/app/views/projects/wikis/_main_links.html.haml b/app/views/projects/wikis/_main_links.html.haml index 788bb8cf1e2..acc2c8b2f7f 100644 --- a/app/views/projects/wikis/_main_links.html.haml +++ b/app/views/projects/wikis/_main_links.html.haml @@ -1,8 +1,8 @@ %span.pull-right - if (@page && @page.persisted?) - = link_to history_namespace_project_wiki_path(@project.namespace, @project, @page), class: "btn btn-grouped" do + = link_to namespace_project_wiki_history_path(@project.namespace, @project, @page), class: "btn btn-grouped" do Page History - if can?(current_user, :create_wiki, @project) - = link_to edit_namespace_project_wiki_path(@project.namespace, @project, @page), class: "btn btn-grouped" do + = link_to namespace_project_wiki_edit_path(@project.namespace, @project, @page), class: "btn btn-grouped" do %i.fa.fa-pencil-square-o Edit diff --git a/app/views/projects/wikis/_nav.html.haml b/app/views/projects/wikis/_nav.html.haml index 804a1b52dbe..ec87c3c765a 100644 --- a/app/views/projects/wikis/_nav.html.haml +++ b/app/views/projects/wikis/_nav.html.haml @@ -3,10 +3,10 @@ = link_to 'Home', namespace_project_wiki_path(@project.namespace, @project, :home) = nav_link(path: 'wikis#pages') do - = link_to 'Pages', pages_namespace_project_wikis_path(@project.namespace, @project) + = link_to 'Pages', namespace_project_wiki_pages_path(@project.namespace, @project) = nav_link(path: 'wikis#git_access') do - = link_to git_access_namespace_project_wikis_path(@project.namespace, @project) do + = link_to namespace_project_wikis_git_access_path(@project.namespace, @project) do %i.fa.fa-download Git Access diff --git a/app/views/projects/wikis/show.html.haml b/app/views/projects/wikis/show.html.haml index 5c4dd7f91ae..90c4b83cf37 100644 --- a/app/views/projects/wikis/show.html.haml +++ b/app/views/projects/wikis/show.html.haml @@ -10,7 +10,7 @@ - if @page.historical? .warning_message This is an old version of this page. - You can view the #{link_to "most recent version", namespace_project_wiki_path(@project.namespace, @project, @page)} or browse the #{link_to "history", history_namespace_project_wiki_path(@project.namespace, @project, @page)}. + You can view the #{link_to "most recent version", namespace_project_wiki_path(@project.namespace, @project, @page)} or browse the #{link_to "history", namespace_project_wiki_history_path(@project.namespace, @project, @page)}. %hr |