documentation 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7e39ff3bcc5366866daf61e794d0518228e30ce
4
- data.tar.gz: abb69304cb427450f290c8a6bdf6c2b0847bd36d
3
+ metadata.gz: 433141945b7824e3d665bfebd107331726436a5d
4
+ data.tar.gz: e3bc88439fe3078420672eaac6c24ea0660b7647
5
5
  SHA512:
6
- metadata.gz: 50e61fcd321e0a0448b1474a1afae58a2baf323f9a82c84d823449d7e5f8da5e7371db22df417f553c3d6feb8156dac76b98af19eb0e3e42e859007e3343a328
7
- data.tar.gz: 920ddcc979efc4fbcaa757e42f63d9389383a31b773744e845743e8c47b0ae5f245a63d7c9b191caeb70ec0d19c5bc73659a3bf836a911b5ce001cb902576af1
6
+ metadata.gz: 7c06c717bfd028a476da511c35ff5ab02e1bc8a39c364b5f52a6f65f4ea3d479ab1d1ad77bd55922dd35c18ca06d5073960134a853ce374c4753fd5d5027b193
7
+ data.tar.gz: 8304f3ca71b250892113418cd248cc03881f87d84825d808c4a6a5dc974d2f0da04383ff8d5d7443eb47ac2b58a0eedaf0686b9883987a3a5a412653f8916cba
@@ -1,3 +1,3 @@
1
1
  module Documentation
2
- VERSION = '1.0.8'
2
+ VERSION = '1.0.9'
3
3
  end
@@ -42,17 +42,22 @@ module Documentation
42
42
  #
43
43
  # Return a default navigation tree for the given page
44
44
  #
45
- def documentation_navigation_tree_for(page)
46
- String.new.tap do |s|
47
- s << "<ul>"
45
+ def documentation_navigation_tree_for(page, options = {})
46
+ active_page_type = nil
47
+ items = String.new.tap do |s|
48
48
  if page.is_a?(::Documentation::Page)
49
- page.navigation.select { |p,c| documentation_authorizer.can_view_page?(p) }.each do |p, children|
49
+
50
+ pages = page.navigation.select { |p,c| documentation_authorizer.can_view_page?(p) }
51
+
52
+ pages.each do |p, children|
50
53
  s << "<li>"
51
54
  s << "<a #{page == p ? "class='active'" : ''} href='#{documentation_doc_root}/#{p.full_permalink}'>#{p.title}</a>"
55
+ active_page_type = :root if page == p
52
56
  unless children.empty?
53
57
  s << "<ul>"
54
58
  children.select { |c| documentation_authorizer.can_view_page?(c) }.each do |p|
55
59
  s << "<li><a #{page == p ? "class='active'" : ''} href='#{documentation_doc_root}/#{p.full_permalink}'>#{p.title}</a></li>"
60
+ active_page_type = :child if page == p
56
61
  end
57
62
  s << "</ul>"
58
63
  end
@@ -63,7 +68,25 @@ module Documentation
63
68
  s << "<li><a href='#{documentation_doc_root}/#{page.full_permalink}'>#{page.title}</a></li>"
64
69
  end
65
70
  end
66
- s << "</ul>"
71
+ end
72
+
73
+ String.new.tap do |output|
74
+ output << "<ul>"
75
+ if options[:include_back] && page.breadcrumb.size > 1
76
+ if active_page_type == :root && page.has_children?
77
+ back_page = page.breadcrumb[-2]
78
+ elsif active_page_type == :child && !page.has_children?
79
+ back_page = page.breadcrumb[-3]
80
+ else
81
+ back_page = nil
82
+ end
83
+
84
+ if back_page
85
+ output << "<li class='back'><a href='#{documentation_doc_root}/#{back_page.full_permalink}'>&larr; Back to #{back_page.title}</a></li>"
86
+ end
87
+ end
88
+ output << items
89
+ output << "</ul>"
67
90
  end.html_safe
68
91
  end
69
92
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: documentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails