diff options
author | Alex Braha Stoll <alexbrahastoll@gmail.com> | 2016-12-18 21:22:20 -0200 |
---|---|---|
committer | Alex Braha Stoll <alexbrahastoll@gmail.com> | 2016-12-31 16:55:50 -0200 |
commit | 5bbe6559917e1e64cdb047b6235715e2a7f002f2 (patch) | |
tree | 8ec5db6fa9527808826904aa5d32016a645e2b8d /app/models/wiki_page.rb | |
parent | 294acf1c5cd2aea353081059c60b3951a2cf7c77 (diff) | |
download | gitlab-ce-5bbe6559917e1e64cdb047b6235715e2a7f002f2.tar.gz |
Add component to show the full path of a wiki page when viewing its content
Diffstat (limited to 'app/models/wiki_page.rb')
-rw-r--r-- | app/models/wiki_page.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index aeacb6f8995..e970cfbfff8 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -88,6 +88,12 @@ class WikiPage end end + # The hierarchy of the directory this page is contained in. + def directory + dir = wiki.page_title_and_dir(slug).last + dir.present? ? dir : '/' + end + # The processed/formatted content of this page. def formatted_content @attributes[:formatted_content] ||= if @page @@ -100,6 +106,11 @@ class WikiPage @attributes[:format] || :markdown end + # The full path for this page, including its filename and extension. + def full_path + "/#{directory}/#{page.filename}".gsub(/\/+/, '/') + end + # The commit message for this page version. def message version.try(:message) |