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 | 3 | class Projects::WikisController < Projects::ApplicationController |
2 | 4 | before_filter :authorize_read_wiki! |
3 | 5 | before_filter :authorize_write_wiki!, only: [:edit, :create, :history] |
4 | 6 | before_filter :authorize_admin_wiki!, only: :destroy |
5 | - before_filter :load_gollum_wiki | |
7 | + before_filter :load_project_wiki | |
6 | 8 | |
7 | 9 | def pages |
8 | - @wiki_pages = @gollum_wiki.pages | |
10 | + @wiki_pages = @project_wiki.pages | |
9 | 11 | end |
10 | 12 | |
11 | 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 | 17 | render 'show' |
16 | 18 | else |
17 | 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 | 23 | render 'edit' |
22 | 24 | end |
23 | 25 | end |
24 | 26 | |
25 | 27 | def edit |
26 | - @wiki = @gollum_wiki.find_page(params[:id]) | |
28 | + @page = @project_wiki.find_page(params[:id]) | |
27 | 29 | end |
28 | 30 | |
29 | 31 | def update |
30 | - @wiki = @gollum_wiki.find_page(params[:id]) | |
32 | + @page = @project_wiki.find_page(params[:id]) | |
31 | 33 | |
32 | 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 | 38 | else |
37 | 39 | render 'edit' |
38 | 40 | end |
39 | 41 | end |
40 | 42 | |
41 | 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 | 48 | else |
47 | 49 | render action: "edit" |
48 | 50 | end |
49 | 51 | end |
50 | 52 | |
51 | 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 | 59 | end |
56 | 60 | |
57 | 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 | 65 | redirect_to project_wiki_path(@project, :home), notice: "Page was successfully deleted" |
61 | 66 | end |
62 | 67 | |
... | ... | @@ -65,12 +70,12 @@ class Projects::WikisController < Projects::ApplicationController |
65 | 70 | |
66 | 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 | 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 | 79 | flash[:notice] = "Could not create Wiki Repository at this time. Please try again later." |
75 | 80 | redirect_to @project |
76 | 81 | return false |
... | ... | @@ -91,5 +96,4 @@ class Projects::WikisController < Projects::ApplicationController |
91 | 96 | def message |
92 | 97 | params[:wiki][:message] |
93 | 98 | end |
94 | - | |
95 | 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 | 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 | 5 | %ul |
6 | - - @wiki.errors.full_messages.each do |msg| | |
6 | + - @page.errors.full_messages.each do |msg| | |
7 | 7 | %li= msg |
8 | 8 | |
9 | - = f.hidden_field :title, value: @wiki.title | |
9 | + = f.hidden_field :title, value: @page.title | |
10 | 10 | .form-group |
11 | 11 | = f.label :format, class: 'control-label' |
12 | 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 | 15 | .row |
16 | 16 | .col-sm-2 |
... | ... | @@ -31,9 +31,9 @@ |
31 | 31 | .col-sm-10= f.text_field :message, class: 'form-control', rows: 18 |
32 | 32 | |
33 | 33 | .form-actions |
34 | - - if @wiki && @wiki.persisted? | |
34 | + - if @page && @page.persisted? | |
35 | 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 | 37 | - else |
38 | 38 | = f.submit 'Create page', class: "btn-create btn" |
39 | 39 | = link_to "Cancel", project_wiki_path(@project, :home), class: "btn btn-cancel" | ... | ... |
app/views/projects/wikis/_main_links.html.haml
1 | 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 | 4 | Page History |
5 | 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 | 7 | %i.icon-edit |
8 | 8 | Edit | ... | ... |
app/views/projects/wikis/edit.html.haml
... | ... | @@ -3,11 +3,11 @@ |
3 | 3 | = render 'main_links' |
4 | 4 | %h3.page-title |
5 | 5 | Editing - |
6 | - %span.light #{@wiki.title.titleize} | |
6 | + %span.light #{@page.title.titleize} | |
7 | 7 | %hr |
8 | 8 | = render 'form' |
9 | 9 | |
10 | 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 | 13 | Delete this page | ... | ... |
app/views/projects/wikis/git_access.html.haml
... | ... | @@ -3,10 +3,10 @@ |
3 | 3 | .col-sm-6 |
4 | 4 | %h3.page-title |
5 | 5 | Git access for |
6 | - %strong= @gollum_wiki.path_with_namespace | |
6 | + %strong= @project_wiki.path_with_namespace | |
7 | 7 | |
8 | 8 | .col-sm-6 |
9 | - = render "shared/clone_panel", project: @gollum_wiki | |
9 | + = render "shared/clone_panel", project: @project_wiki | |
10 | 10 | |
11 | 11 | .git-empty |
12 | 12 | %fieldset |
... | ... | @@ -18,8 +18,8 @@ |
18 | 18 | %legend Clone Your Wiki: |
19 | 19 | %pre.dark |
20 | 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 | 24 | %legend Start Gollum And Edit Locally: |
25 | 25 | %pre.dark | ... | ... |
app/views/projects/wikis/history.html.haml
1 | 1 | = render 'nav' |
2 | 2 | %h3.page-title |
3 | 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 | 6 | %table.table |
7 | 7 | %thead |
... | ... | @@ -12,11 +12,11 @@ |
12 | 12 | %th Last updated |
13 | 13 | %th Format |
14 | 14 | %tbody |
15 | - - @wiki.versions.each do |version| | |
15 | + - @page.versions.each do |version| | |
16 | 16 | - commit = version |
17 | 17 | %tr |
18 | 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 | 20 | = commit.short_id |
21 | 21 | %td |
22 | 22 | = commit_author_link(commit, avatar: true, size: 24) |
... | ... | @@ -26,4 +26,4 @@ |
26 | 26 | #{time_ago_with_tooltip(version.date)} |
27 | 27 | %td |
28 | 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 | 1 | = render 'nav' |
2 | 2 | %h3.page-title |
3 | - = @wiki.title.titleize | |
3 | + = @page.title.titleize | |
4 | 4 | = render 'main_links' |
5 | -- if @wiki.historical? | |
5 | +- if @page.historical? | |
6 | 6 | .warning_message |
7 | 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 | 10 | %hr |
11 | 11 | |
12 | 12 | .wiki-holder |
13 | 13 | .wiki |
14 | 14 | = preserve do |
15 | - = render_wiki_content(@wiki) | |
15 | + = render_wiki_content(@page) | |
16 | 16 | |
17 | 17 | %hr |
18 | 18 | |
19 | 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)} | ... | ... |