summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Braha Stoll <alexbrahastoll@gmail.com>2016-12-27 01:44:03 -0200
committerAlex Braha Stoll <alexbrahastoll@gmail.com>2016-12-31 16:55:50 -0200
commit94dcadd62ac66cc5c52579ae9c288314bbca0c20 (patch)
tree2fe2ea2675ebaf2640a46f0fd8b6051af187514c
parent84cc7c3704cc0cc22a325572f35cd21d0e2a6cc7 (diff)
downloadgitlab-ce-94dcadd62ac66cc5c52579ae9c288314bbca0c20.tar.gz
Add a breadcrumb at projects/wikis/show.html.haml
-rw-r--r--app/assets/stylesheets/pages/wiki.scss5
-rw-r--r--app/helpers/wiki_helper.rb13
-rw-r--r--app/views/projects/wikis/show.html.haml3
-rw-r--r--spec/helpers/wiki_helper_spec.rb21
4 files changed, 42 insertions, 0 deletions
diff --git a/app/assets/stylesheets/pages/wiki.scss b/app/assets/stylesheets/pages/wiki.scss
index 369fb44d818..480cb2b9f0d 100644
--- a/app/assets/stylesheets/pages/wiki.scss
+++ b/app/assets/stylesheets/pages/wiki.scss
@@ -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;
diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb
new file mode 100644
index 00000000000..76ee632ab6d
--- /dev/null
+++ b/app/helpers/wiki_helper.rb
@@ -0,0 +1,13 @@
+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
diff --git a/app/views/projects/wikis/show.html.haml b/app/views/projects/wikis/show.html.haml
index 87b9ff6e415..3609461b721 100644
--- a/app/views/projects/wikis/show.html.haml
+++ b/app/views/projects/wikis/show.html.haml
@@ -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
diff --git a/spec/helpers/wiki_helper_spec.rb b/spec/helpers/wiki_helper_spec.rb
new file mode 100644
index 00000000000..92c6f27a867
--- /dev/null
+++ b/spec/helpers/wiki_helper_spec.rb
@@ -0,0 +1,21 @@
+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