Commit 94dcadd6 authored by Alex Braha Stoll's avatar Alex Braha Stoll

Add a breadcrumb at projects/wikis/show.html.haml

parent 84cc7c37
......@@ -17,6 +17,11 @@
@extend .top-area;
position: relative;
.wiki-breadcrumb {
border-bottom: 1px solid $white-normal;
padding: 11px 0;
}
.wiki-page-title {
margin: 0;
font-size: 22px;
......
module WikiHelper
# Produces a pure text breadcrumb for a given page.
#
# page_slug - The slug of a WikiPage object.
#
# Returns a String composed of the capitalized name of each directory and the
# capitalized name of the page itself.
def breadcrumb(page_slug)
page_slug.split('/').
map { |dir_or_page| dir_or_page.gsub(/-+/, ' ').capitalize }.
join(' / ')
end
end
......@@ -6,6 +6,9 @@
%button.btn.btn-default.sidebar-toggle.js-sidebar-wiki-toggle{ role: "button", type: "button" }
= icon('angle-double-left')
.wiki-breadcrumb
%span= breadcrumb(@page.slug)
.nav-text
%h2.wiki-page-title= @page.title.capitalize
%span.wiki-last-edit-by
......
require 'spec_helper'
describe WikiHelper do
describe '#breadcrumb' do
context 'when the page is at the root level' do
it 'returns the capitalized page name' do
slug = 'page-name'
expect(helper.breadcrumb(slug)).to eq('Page name')
end
end
context 'when the page is inside a directory' do
it 'returns the capitalized name of each directory and of the page itself' do
slug = 'dir_1/page-name'
expect(helper.breadcrumb(slug)).to eq('Dir_1 / Page name')
end
end
end
end
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