diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index 45a42400b2a12465344214a9a13a84d5c8849f41..116c854b1aee587d0c51f9f4b2bea31690b90be0 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -8,7 +8,7 @@ class Projects::WikisController < Projects::ApplicationController def pages @wiki_pages = Kaminari.paginate_array(@project_wiki.pages).page(params[:page]) - @wiki_directories = WikiPage.group_by_directory(@wiki_pages) + @wiki_entries = WikiPage.group_by_directory(@wiki_pages) end def show @@ -117,7 +117,7 @@ class Projects::WikisController < Projects::ApplicationController # Call #wiki to make sure the Wiki Repo is initialized @project_wiki.wiki - @sidebar_wiki_directories = WikiPage.group_by_directory(@project_wiki.pages.first(15)) + @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." redirect_to project_path(@project) diff --git a/app/views/projects/wikis/_sidebar.html.haml b/app/views/projects/wikis/_sidebar.html.haml index b7464180a0c1f0692cb37fed4d92df5ccf0ab3d2..e3fddfba68949a6a8be345f87774c7e985f9a0ce 100644 --- a/app/views/projects/wikis/_sidebar.html.haml +++ b/app/views/projects/wikis/_sidebar.html.haml @@ -12,15 +12,7 @@ .blocks-container .block.block-first %ul.wiki-pages - - @sidebar_wiki_directories.each do |wiki_directory, wiki_pages| - - if wiki_directory == '/' - = render 'sidebar_wiki_pages', wiki_pages: wiki_pages - - else - %li - = wiki_directory - %ul - = render 'sidebar_wiki_pages', wiki_pages: wiki_pages - + = render @sidebar_wiki_entries, context: 'sidebar' .block = link_to namespace_project_wikis_pages_path(@project.namespace, @project), class: 'btn btn-block' do diff --git a/app/views/projects/wikis/_sidebar_wiki_pages.html.haml b/app/views/projects/wikis/_sidebar_wiki_pages.html.haml deleted file mode 100644 index 65453a384d27bf15931406ff27066aa3f4cd0e4d..0000000000000000000000000000000000000000 --- a/app/views/projects/wikis/_sidebar_wiki_pages.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -- wiki_pages.each do |wiki_page| - %li{ class: params[:id] == wiki_page.slug ? 'active' : '' } - = link_to namespace_project_wiki_path(@project.namespace, @project, wiki_page) do - = wiki_page.title.capitalize diff --git a/app/views/projects/wikis/_wiki_directory.html.haml b/app/views/projects/wikis/_wiki_directory.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..0e5f32ed859e3f5f4f1919cb9007176139f2b4e7 --- /dev/null +++ b/app/views/projects/wikis/_wiki_directory.html.haml @@ -0,0 +1,4 @@ +%li + = wiki_directory.slug + %ul + = render wiki_directory.pages, context: context diff --git a/app/views/projects/wikis/_wiki_pages.html.haml b/app/views/projects/wikis/_wiki_page.html.haml similarity index 52% rename from app/views/projects/wikis/_wiki_pages.html.haml rename to app/views/projects/wikis/_wiki_page.html.haml index ac98599d96b41464c7ab50f32aa4ea69279094e8..cea27388a0dbfbbce21f0901c639e8cd281cc9ee 100644 --- a/app/views/projects/wikis/_wiki_pages.html.haml +++ b/app/views/projects/wikis/_wiki_page.html.haml @@ -1,4 +1,8 @@ -- wiki_pages.each do |wiki_page| +- if context == 'sidebar' + %li{ class: params[:id] == wiki_page.slug ? 'active' : '' } + = link_to namespace_project_wiki_path(@project.namespace, @project, wiki_page) do + = wiki_page.title.capitalize +- else %li = link_to wiki_page.title, namespace_project_wiki_path(@project.namespace, @project, wiki_page) %small (#{wiki_page.format}) diff --git a/app/views/projects/wikis/pages.html.haml b/app/views/projects/wikis/pages.html.haml index 28dd81e5c3f82f67f148d9f4218329a1d329db1b..5fba2b1a5ae31e5b548e0a8510affcdef16537f4 100644 --- a/app/views/projects/wikis/pages.html.haml +++ b/app/views/projects/wikis/pages.html.haml @@ -14,13 +14,6 @@ Clone repository %ul.wiki-pages-list.content-list - - @wiki_directories.each do |wiki_directory, wiki_pages| - - if wiki_directory == '/' - = render 'wiki_pages', wiki_pages: wiki_pages - - else - %li - = wiki_directory - %ul - = render 'wiki_pages', wiki_pages: wiki_pages + = render @wiki_entries, context: 'pages' = paginate @wiki_pages, theme: 'gitlab'