Commit b27c42be870f55667eaa8a7152aa9e70e4e32a29
1 parent
9a02e27b
Exists in
spb-stable
and in
3 other branches
Rename wiki variables
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
7 changed files
with
53 additions
and
49 deletions
Show diff stats
app/controllers/projects/wikis_controller.rb
| 1 | +require 'project_wiki' | ||
| 2 | + | ||
| 1 | class Projects::WikisController < Projects::ApplicationController | 3 | class Projects::WikisController < Projects::ApplicationController |
| 2 | before_filter :authorize_read_wiki! | 4 | before_filter :authorize_read_wiki! |
| 3 | before_filter :authorize_write_wiki!, only: [:edit, :create, :history] | 5 | before_filter :authorize_write_wiki!, only: [:edit, :create, :history] |
| 4 | before_filter :authorize_admin_wiki!, only: :destroy | 6 | before_filter :authorize_admin_wiki!, only: :destroy |
| 5 | - before_filter :load_gollum_wiki | 7 | + before_filter :load_project_wiki |
| 6 | 8 | ||
| 7 | def pages | 9 | def pages |
| 8 | - @wiki_pages = @gollum_wiki.pages | 10 | + @wiki_pages = @project_wiki.pages |
| 9 | end | 11 | end |
| 10 | 12 | ||
| 11 | def show | 13 | def show |
| 12 | - @wiki = @gollum_wiki.find_page(params[:id], params[:version_id]) | 14 | + @page = @project_wiki.find_page(params[:id], params[:version_id]) |
| 13 | 15 | ||
| 14 | - if @wiki | 16 | + if @page |
| 15 | render 'show' | 17 | render 'show' |
| 16 | else | 18 | else |
| 17 | return render('empty') unless can?(current_user, :write_wiki, @project) | 19 | return render('empty') unless can?(current_user, :write_wiki, @project) |
| 18 | - @wiki = WikiPage.new(@gollum_wiki) | ||
| 19 | - @wiki.title = params[:id] | 20 | + @page = WikiPage.new(@project_wiki) |
| 21 | + @page.title = params[:id] | ||
| 20 | 22 | ||
| 21 | render 'edit' | 23 | render 'edit' |
| 22 | end | 24 | end |
| 23 | end | 25 | end |
| 24 | 26 | ||
| 25 | def edit | 27 | def edit |
| 26 | - @wiki = @gollum_wiki.find_page(params[:id]) | 28 | + @page = @project_wiki.find_page(params[:id]) |
| 27 | end | 29 | end |
| 28 | 30 | ||
| 29 | def update | 31 | def update |
| 30 | - @wiki = @gollum_wiki.find_page(params[:id]) | 32 | + @page = @project_wiki.find_page(params[:id]) |
| 31 | 33 | ||
| 32 | return render('empty') unless can?(current_user, :write_wiki, @project) | 34 | return render('empty') unless can?(current_user, :write_wiki, @project) |
| 33 | 35 | ||
| 34 | - if @wiki.update(content, format, message) | ||
| 35 | - redirect_to [@project, @wiki], notice: 'Wiki was successfully updated.' | 36 | + if @page.update(content, format, message) |
| 37 | + redirect_to [@project, @page], notice: 'Wiki was successfully updated.' | ||
| 36 | else | 38 | else |
| 37 | render 'edit' | 39 | render 'edit' |
| 38 | end | 40 | end |
| 39 | end | 41 | end |
| 40 | 42 | ||
| 41 | def create | 43 | def create |
| 42 | - @wiki = WikiPage.new(@gollum_wiki) | 44 | + @page = WikiPage.new(@project_wiki) |
| 43 | 45 | ||
| 44 | - if @wiki.create(wiki_params) | ||
| 45 | - redirect_to project_wiki_path(@project, @wiki), notice: 'Wiki was successfully updated.' | 46 | + if @page.create(wiki_params) |
| 47 | + redirect_to project_wiki_path(@project, @page), notice: 'Wiki was successfully updated.' | ||
| 46 | else | 48 | else |
| 47 | render action: "edit" | 49 | render action: "edit" |
| 48 | end | 50 | end |
| 49 | end | 51 | end |
| 50 | 52 | ||
| 51 | def history | 53 | def history |
| 52 | - @wiki = @gollum_wiki.find_page(params[:id]) | 54 | + @page = @project_wiki.find_page(params[:id]) |
| 53 | 55 | ||
| 54 | - redirect_to(project_wiki_path(@project, :home), notice: "Page not found") unless @wiki | 56 | + unless @page |
| 57 | + redirect_to(project_wiki_path(@project, :home), notice: "Page not found") | ||
| 58 | + end | ||
| 55 | end | 59 | end |
| 56 | 60 | ||
| 57 | def destroy | 61 | def destroy |
| 58 | - @wiki = @gollum_wiki.find_page(params[:id]) | ||
| 59 | - @wiki.delete if @wiki | 62 | + @page = @project_wiki.find_page(params[:id]) |
| 63 | + @page.delete if @page | ||
| 64 | + | ||
| 60 | redirect_to project_wiki_path(@project, :home), notice: "Page was successfully deleted" | 65 | redirect_to project_wiki_path(@project, :home), notice: "Page was successfully deleted" |
| 61 | end | 66 | end |
| 62 | 67 | ||
| @@ -65,12 +70,12 @@ class Projects::WikisController < Projects::ApplicationController | @@ -65,12 +70,12 @@ class Projects::WikisController < Projects::ApplicationController | ||
| 65 | 70 | ||
| 66 | private | 71 | private |
| 67 | 72 | ||
| 68 | - def load_gollum_wiki | ||
| 69 | - @gollum_wiki = GollumWiki.new(@project, current_user) | 73 | + def load_project_wiki |
| 74 | + @project_wiki = ProjectWiki.new(@project, current_user) | ||
| 70 | 75 | ||
| 71 | # Call #wiki to make sure the Wiki Repo is initialized | 76 | # Call #wiki to make sure the Wiki Repo is initialized |
| 72 | - @gollum_wiki.wiki | ||
| 73 | - rescue GollumWiki::CouldNotCreateWikiError => ex | 77 | + @project_wiki.wiki |
| 78 | + rescue ProjectWiki::CouldNotCreateWikiError => ex | ||
| 74 | flash[:notice] = "Could not create Wiki Repository at this time. Please try again later." | 79 | flash[:notice] = "Could not create Wiki Repository at this time. Please try again later." |
| 75 | redirect_to @project | 80 | redirect_to @project |
| 76 | return false | 81 | return false |
| @@ -91,5 +96,4 @@ class Projects::WikisController < Projects::ApplicationController | @@ -91,5 +96,4 @@ class Projects::WikisController < Projects::ApplicationController | ||
| 91 | def message | 96 | def message |
| 92 | params[:wiki][:message] | 97 | params[:wiki][:message] |
| 93 | end | 98 | end |
| 94 | - | ||
| 95 | end | 99 | end |
app/views/projects/wikis/_form.html.haml
| 1 | -= form_for [@project, @wiki], method: @wiki.persisted? ? :put : :post, html: { class: 'form-horizontal' } do |f| | ||
| 2 | - -if @wiki.errors.any? | 1 | += form_for [@project, @page], method: @page.persisted? ? :put : :post, html: { class: 'form-horizontal' } do |f| |
| 2 | + -if @page.errors.any? | ||
| 3 | #error_explanation | 3 | #error_explanation |
| 4 | - %h2= "#{pluralize(@wiki.errors.count, "error")} prohibited this wiki from being saved:" | 4 | + %h2= "#{pluralize(@page.errors.count, "error")} prohibited this wiki from being saved:" |
| 5 | %ul | 5 | %ul |
| 6 | - - @wiki.errors.full_messages.each do |msg| | 6 | + - @page.errors.full_messages.each do |msg| |
| 7 | %li= msg | 7 | %li= msg |
| 8 | 8 | ||
| 9 | - = f.hidden_field :title, value: @wiki.title | 9 | + = f.hidden_field :title, value: @page.title |
| 10 | .form-group | 10 | .form-group |
| 11 | = f.label :format, class: 'control-label' | 11 | = f.label :format, class: 'control-label' |
| 12 | .col-sm-10 | 12 | .col-sm-10 |
| 13 | - = f.select :format, options_for_select(GollumWiki::MARKUPS, {selected: @wiki.format}), {}, class: "form-control" | 13 | + = f.select :format, options_for_select(ProjectWiki::MARKUPS, {selected: @page.format}), {}, class: "form-control" |
| 14 | 14 | ||
| 15 | .row | 15 | .row |
| 16 | .col-sm-2 | 16 | .col-sm-2 |
| @@ -31,9 +31,9 @@ | @@ -31,9 +31,9 @@ | ||
| 31 | .col-sm-10= f.text_field :message, class: 'form-control', rows: 18 | 31 | .col-sm-10= f.text_field :message, class: 'form-control', rows: 18 |
| 32 | 32 | ||
| 33 | .form-actions | 33 | .form-actions |
| 34 | - - if @wiki && @wiki.persisted? | 34 | + - if @page && @page.persisted? |
| 35 | = f.submit 'Save changes', class: "btn-save btn" | 35 | = f.submit 'Save changes', class: "btn-save btn" |
| 36 | - = link_to "Cancel", project_wiki_path(@project, @wiki), class: "btn btn-cancel" | 36 | + = link_to "Cancel", project_wiki_path(@project, @page), class: "btn btn-cancel" |
| 37 | - else | 37 | - else |
| 38 | = f.submit 'Create page', class: "btn-create btn" | 38 | = f.submit 'Create page', class: "btn-create btn" |
| 39 | = link_to "Cancel", project_wiki_path(@project, :home), class: "btn btn-cancel" | 39 | = link_to "Cancel", project_wiki_path(@project, :home), class: "btn btn-cancel" |
app/views/projects/wikis/_main_links.html.haml
| 1 | %span.pull-right | 1 | %span.pull-right |
| 2 | - - if (@wiki && @wiki.persisted?) | ||
| 3 | - = link_to history_project_wiki_path(@project, @wiki), class: "btn btn-grouped" do | 2 | + - if (@page && @page.persisted?) |
| 3 | + = link_to history_project_wiki_path(@project, @page), class: "btn btn-grouped" do | ||
| 4 | Page History | 4 | Page History |
| 5 | - if can?(current_user, :write_wiki, @project) | 5 | - if can?(current_user, :write_wiki, @project) |
| 6 | - = link_to edit_project_wiki_path(@project, @wiki), class: "btn btn-grouped" do | 6 | + = link_to edit_project_wiki_path(@project, @page), class: "btn btn-grouped" do |
| 7 | %i.icon-edit | 7 | %i.icon-edit |
| 8 | Edit | 8 | Edit |
app/views/projects/wikis/edit.html.haml
| @@ -3,11 +3,11 @@ | @@ -3,11 +3,11 @@ | ||
| 3 | = render 'main_links' | 3 | = render 'main_links' |
| 4 | %h3.page-title | 4 | %h3.page-title |
| 5 | Editing - | 5 | Editing - |
| 6 | - %span.light #{@wiki.title.titleize} | 6 | + %span.light #{@page.title.titleize} |
| 7 | %hr | 7 | %hr |
| 8 | = render 'form' | 8 | = render 'form' |
| 9 | 9 | ||
| 10 | .pull-right | 10 | .pull-right |
| 11 | - - if @wiki.persisted? && can?(current_user, :admin_wiki, @project) | ||
| 12 | - = link_to project_wiki_path(@project, @wiki), data: { confirm: "Are you sure you want to delete this page?"}, method: :delete, class: "btn btn-small btn-remove" do | 11 | + - if @page.persisted? && can?(current_user, :admin_wiki, @project) |
| 12 | + = link_to project_wiki_path(@project, @page), data: { confirm: "Are you sure you want to delete this page?"}, method: :delete, class: "btn btn-small btn-remove" do | ||
| 13 | Delete this page | 13 | Delete this page |
app/views/projects/wikis/git_access.html.haml
| @@ -3,10 +3,10 @@ | @@ -3,10 +3,10 @@ | ||
| 3 | .col-sm-6 | 3 | .col-sm-6 |
| 4 | %h3.page-title | 4 | %h3.page-title |
| 5 | Git access for | 5 | Git access for |
| 6 | - %strong= @gollum_wiki.path_with_namespace | 6 | + %strong= @project_wiki.path_with_namespace |
| 7 | 7 | ||
| 8 | .col-sm-6 | 8 | .col-sm-6 |
| 9 | - = render "shared/clone_panel", project: @gollum_wiki | 9 | + = render "shared/clone_panel", project: @project_wiki |
| 10 | 10 | ||
| 11 | .git-empty | 11 | .git-empty |
| 12 | %fieldset | 12 | %fieldset |
| @@ -18,8 +18,8 @@ | @@ -18,8 +18,8 @@ | ||
| 18 | %legend Clone Your Wiki: | 18 | %legend Clone Your Wiki: |
| 19 | %pre.dark | 19 | %pre.dark |
| 20 | :preserve | 20 | :preserve |
| 21 | - git clone #{ content_tag(:span, default_url_to_repo(@gollum_wiki), class: 'clone')} | ||
| 22 | - cd #{@gollum_wiki.path} | 21 | + git clone #{ content_tag(:span, default_url_to_repo(@project_wiki), class: 'clone')} |
| 22 | + cd #{@project_wiki.path} | ||
| 23 | 23 | ||
| 24 | %legend Start Gollum And Edit Locally: | 24 | %legend Start Gollum And Edit Locally: |
| 25 | %pre.dark | 25 | %pre.dark |
app/views/projects/wikis/history.html.haml
| 1 | = render 'nav' | 1 | = render 'nav' |
| 2 | %h3.page-title | 2 | %h3.page-title |
| 3 | %span.light History for | 3 | %span.light History for |
| 4 | - = link_to @wiki.title.titleize, project_wiki_path(@project, @wiki) | 4 | + = link_to @page.title.titleize, project_wiki_path(@project, @page) |
| 5 | 5 | ||
| 6 | %table.table | 6 | %table.table |
| 7 | %thead | 7 | %thead |
| @@ -12,11 +12,11 @@ | @@ -12,11 +12,11 @@ | ||
| 12 | %th Last updated | 12 | %th Last updated |
| 13 | %th Format | 13 | %th Format |
| 14 | %tbody | 14 | %tbody |
| 15 | - - @wiki.versions.each do |version| | 15 | + - @page.versions.each do |version| |
| 16 | - commit = version | 16 | - commit = version |
| 17 | %tr | 17 | %tr |
| 18 | %td | 18 | %td |
| 19 | - = link_to project_wiki_path(@project, @wiki, version_id: commit.id) do | 19 | + = link_to project_wiki_path(@project, @page, version_id: commit.id) do |
| 20 | = commit.short_id | 20 | = commit.short_id |
| 21 | %td | 21 | %td |
| 22 | = commit_author_link(commit, avatar: true, size: 24) | 22 | = commit_author_link(commit, avatar: true, size: 24) |
| @@ -26,4 +26,4 @@ | @@ -26,4 +26,4 @@ | ||
| 26 | #{time_ago_with_tooltip(version.date)} | 26 | #{time_ago_with_tooltip(version.date)} |
| 27 | %td | 27 | %td |
| 28 | %strong | 28 | %strong |
| 29 | - = @wiki.page.wiki.page(@wiki.page.name, commit.id).try(:format) | 29 | + = @page.page.wiki.page(@page.page.name, commit.id).try(:format) |
app/views/projects/wikis/show.html.haml
| 1 | = render 'nav' | 1 | = render 'nav' |
| 2 | %h3.page-title | 2 | %h3.page-title |
| 3 | - = @wiki.title.titleize | 3 | + = @page.title.titleize |
| 4 | = render 'main_links' | 4 | = render 'main_links' |
| 5 | -- if @wiki.historical? | 5 | +- if @page.historical? |
| 6 | .warning_message | 6 | .warning_message |
| 7 | This is an old version of this page. | 7 | This is an old version of this page. |
| 8 | - You can view the #{link_to "most recent version", project_wiki_path(@project, @wiki)} or browse the #{link_to "history", history_project_wiki_path(@project, @wiki)}. | 8 | + You can view the #{link_to "most recent version", project_wiki_path(@project, @page)} or browse the #{link_to "history", history_project_wiki_path(@project, @page)}. |
| 9 | 9 | ||
| 10 | %hr | 10 | %hr |
| 11 | 11 | ||
| 12 | .wiki-holder | 12 | .wiki-holder |
| 13 | .wiki | 13 | .wiki |
| 14 | = preserve do | 14 | = preserve do |
| 15 | - = render_wiki_content(@wiki) | 15 | + = render_wiki_content(@page) |
| 16 | 16 | ||
| 17 | %hr | 17 | %hr |
| 18 | 18 | ||
| 19 | .wiki-last-edit-by | 19 | .wiki-last-edit-by |
| 20 | - Last edited by #{commit_author_link(@wiki.commit, avatar: true, size: 16)} #{time_ago_with_tooltip(@wiki.commit.created_at)} | 20 | + Last edited by #{commit_author_link(@page.commit, avatar: true, size: 16)} #{time_ago_with_tooltip(@page.commit.created_at)} |