radiant-navigation_tags-extension 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,16 +10,23 @@ module NavigationTags
10
10
  <pre><code><r:nav [id="subnav"] [root=\"/products\"] [append_urls=\"/,/about-us/contact\"] [labels=\"/:Home,/about-us/contact:Contact us\"] [depth=\"2\"] [expand_all=\"true\"]/></code></pre>
11
11
  *Attributes:*
12
12
 
13
- root: defaults to "/", where to start building the navigation from, you can i.e. use "/products" to build a subnav
14
- append_urls: urls of pages to add to the end of the navigation ul seperated by a comma
15
- prepend_urls: urls of pages to add to the beginning of the navigation ul seperated by a comma
16
- ids_for_lis: defaults to false, enable this to give each li an id (it's slug prefixed with nav_)
17
- ids_for_links: defaults to false, enable this to give each link an id (it's slug prefixed with nav_)
18
-
19
- labels: defaults to nil, use to overwrite the link text for given pages, otherwise the breadcrumb is used.
20
- depth: defaults to 1, which means no sub-ul's, set to 2 or more for a nested list
21
- expand_all: defaults to false, enable this to have all li's create sub-ul's of their children, i.o. only the currently active li
22
- id, class,..: go as html attributes of the outer ul
13
+ *root*: defaults to "/", where to start building the navigation from, you can i.e. use "/products" to build a subnav
14
+
15
+ *append_urls*: urls of pages to add to the end of the navigation ul seperated by a comma. For external links, you can provide a label text after the link with a semicolon. E.g. append_urls="/,http://example.com;Other site"
16
+
17
+ *prepend_urls*: urls of pages to add to the beginning of the navigation ul seperated by a comma. For external links, you can provide a label text after the link with a semicolon. E.g. prepend_urls="/,http://example.com;Other site"
18
+
19
+ *ids_for_lis*: defaults to false, enable this to give each li an id (it's slug prefixed with nav_)
20
+
21
+ *ids_for_links*: defaults to false, enable this to give each link an id (it's slug prefixed with nav_)
22
+
23
+ *labels*: defaults to nil, use to overwrite the link text for given pages, otherwise the breadcrumb is used.
24
+
25
+ *depth*: defaults to 1, which means no sub-ul's, set to 2 or more for a nested list
26
+
27
+ *expand_all*: defaults to false, enable this to have all li's create sub-ul's of their children, i.o. only the currently active li
28
+
29
+ *id, class,..*: go as html attributes of the outer ul
23
30
  }
24
31
 
25
32
  tag "nav" do |tag|
@@ -45,6 +52,8 @@ module NavigationTags
45
52
  page = Page.find_by_path(url)
46
53
  if page.class_name != "FileNotFoundPage"
47
54
  lis << li_for_current_page_vs_navigation_item(tag.locals.page, page)
55
+ else
56
+ lis << li_for_external_link(url)
48
57
  end
49
58
  end
50
59
  end
@@ -58,6 +67,8 @@ module NavigationTags
58
67
  page = Page.find_by_path(url)
59
68
  if page.class_name != "FileNotFoundPage"
60
69
  lis << li_for_current_page_vs_navigation_item(tag.locals.page, page)
70
+ else
71
+ lis << li_for_external_link(url)
61
72
  end
62
73
  end
63
74
  end
@@ -121,11 +132,37 @@ module NavigationTags
121
132
  "<li#{li_attrs_for_current_page_vs_navigation_item(current_page, child_page)}>#{link_for_page(child_page)}</li>"
122
133
  end
123
134
 
135
+ def li_attrs_for_external_link link, label
136
+ classes = ["external"]
137
+ (classes << "first" && @first_set = true) unless @first_set
138
+ result = " class=\"#{classes.compact.join(" ")}\""
139
+ if @ids_for_lis
140
+ result << " id=\"nav_" + label.slugify + "\""
141
+ end
142
+ end
143
+
144
+ def li_for_external_link link
145
+ if @labels &&
146
+ matched_label = @labels.split(',').map{|l| l[0..6] == 'http://' ? l[7..-1] : l }.select{|l| l.split(':').first == link}.first.try(:split, ':').try(:last)
147
+ else
148
+ matched_label = link[0..6] == 'http://' ? link[7..-1] : link
149
+ end
150
+ "<li#{li_attrs_for_external_link(link, matched_label)}>#{external_link(link, matched_label)}</li>"
151
+ end
152
+
153
+ def external_link link, label
154
+ if @ids_for_links
155
+ "<a href=\"#{link}\" id=\"link_#{ label.slugify }\">#{label}</a>"
156
+ else
157
+ "<a href=\"#{link}\">#{label}</a>"
158
+ end
159
+ end
160
+
124
161
  def link_for_page page
125
162
  if @ids_for_links
126
- "<a href=\"#{page.url}\" id=\"#{("link_" + (page.slug == "/" ? 'home' : page.slug))}\">#{label_for_page(page)}</a>"
163
+ "<a href=\"#{page.path}\" id=\"#{("link_" + (page.slug == "/" ? 'home' : page.slug))}\">#{label_for_page(page)}</a>"
127
164
  else
128
- "<a href=\"#{page.url}\">#{label_for_page(page)}</a>"
165
+ "<a href=\"#{page.path}\">#{label_for_page(page)}</a>"
129
166
  end
130
167
  end
131
168
 
@@ -1,5 +1,5 @@
1
1
  module RadiantNavigationTagsExtension
2
- VERSION = '0.2.6'
2
+ VERSION = '0.2.7'
3
3
  AUTHORS = ['Benny Degezelle', 'Marty Haught', 'Ryan Heneise']
4
4
  EMAIL = 'benny@gorilla-webdesign.be'
5
5
  URL = "https://github.com/jomz/navigation_tags"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-navigation_tags-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 6
10
- version: 0.2.6
9
+ - 7
10
+ version: 0.2.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Benny Degezelle
@@ -17,8 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-12-08 00:00:00 +01:00
21
- default_executable:
20
+ date: 2012-05-05 00:00:00 Z
22
21
  dependencies: []
23
22
 
24
23
  description: Adds an r:nav radius tag to Radiant CMS. This tag helps you build css-able navigation menus with ease.
@@ -39,7 +38,6 @@ files:
39
38
  - radiant-navigations_tags-extension.gemspec
40
39
  - Rakefile
41
40
  - README
42
- has_rdoc: true
43
41
  homepage: https://github.com/jomz/navigation_tags
44
42
  licenses: []
45
43
 
@@ -69,9 +67,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
67
  requirements: []
70
68
 
71
69
  rubyforge_project:
72
- rubygems_version: 1.5.3
70
+ rubygems_version: 1.8.23
73
71
  signing_key:
74
72
  specification_version: 3
75
73
  summary: Makes building navigations much easier.
76
74
  test_files: []
77
75
 
76
+ has_rdoc: