Commit a5625c74 authored by Alex Braha Stoll's avatar Alex Braha Stoll

Render wiki entries using a collection of WikiPage and WikiDirectory objects

parent 7bd68ae0
......@@ -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)
......
......@@ -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
......
- 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
%li
= wiki_directory.slug
%ul
= render wiki_directory.pages, context: context
- 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})
......
......@@ -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'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment