locomotivecms_steam 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.travis.yml +4 -0
  4. data/CHANGELOG.md +19 -0
  5. data/Gemfile +8 -0
  6. data/Gemfile.lock +188 -0
  7. data/LICENSE +20 -0
  8. data/README.md +36 -0
  9. data/Rakefile +17 -0
  10. data/bin/publish +28 -0
  11. data/config/locales/de.yml +157 -0
  12. data/config/locales/en.yml +189 -0
  13. data/config/locales/es.yml +133 -0
  14. data/config/locales/et.yml +154 -0
  15. data/config/locales/fr.yml +148 -0
  16. data/config/locales/it.yml +155 -0
  17. data/config/locales/nb.yml +191 -0
  18. data/config/locales/nl.yml +160 -0
  19. data/config/locales/pl.yml +203 -0
  20. data/config/locales/pt-BR.yml +139 -0
  21. data/config/locales/ru.yml +224 -0
  22. data/lib/locomotive/steam/core_ext.rb +5 -0
  23. data/lib/locomotive/steam/core_ext/array.rb +3 -0
  24. data/lib/locomotive/steam/core_ext/boolean/false.rb +3 -0
  25. data/lib/locomotive/steam/core_ext/boolean/true.rb +3 -0
  26. data/lib/locomotive/steam/core_ext/hash.rb +27 -0
  27. data/lib/locomotive/steam/core_ext/string.rb +8 -0
  28. data/lib/locomotive/steam/exceptions.rb +62 -0
  29. data/lib/locomotive/steam/initializers.rb +5 -0
  30. data/lib/locomotive/steam/initializers/i18n.rb +3 -0
  31. data/lib/locomotive/steam/initializers/markdown.rb +27 -0
  32. data/lib/locomotive/steam/initializers/will_paginate.rb +16 -0
  33. data/lib/locomotive/steam/liquid.rb +22 -0
  34. data/lib/locomotive/steam/liquid/drops/base.rb +46 -0
  35. data/lib/locomotive/steam/liquid/drops/content_entry.rb +48 -0
  36. data/lib/locomotive/steam/liquid/drops/content_types.rb +117 -0
  37. data/lib/locomotive/steam/liquid/drops/page.rb +28 -0
  38. data/lib/locomotive/steam/liquid/drops/session_proxy.rb +18 -0
  39. data/lib/locomotive/steam/liquid/drops/site.rb +26 -0
  40. data/lib/locomotive/steam/liquid/errors.rb +17 -0
  41. data/lib/locomotive/steam/liquid/filters/date.rb +136 -0
  42. data/lib/locomotive/steam/liquid/filters/html.rb +188 -0
  43. data/lib/locomotive/steam/liquid/filters/misc.rb +49 -0
  44. data/lib/locomotive/steam/liquid/filters/resize.rb +18 -0
  45. data/lib/locomotive/steam/liquid/filters/text.rb +55 -0
  46. data/lib/locomotive/steam/liquid/filters/translate.rb +28 -0
  47. data/lib/locomotive/steam/liquid/patches.rb +47 -0
  48. data/lib/locomotive/steam/liquid/scopeable.rb +149 -0
  49. data/lib/locomotive/steam/liquid/tags/consume.rb +97 -0
  50. data/lib/locomotive/steam/liquid/tags/csrf.rb +34 -0
  51. data/lib/locomotive/steam/liquid/tags/editable.rb +6 -0
  52. data/lib/locomotive/steam/liquid/tags/editable/base.rb +50 -0
  53. data/lib/locomotive/steam/liquid/tags/editable/control.rb +19 -0
  54. data/lib/locomotive/steam/liquid/tags/editable/file.rb +15 -0
  55. data/lib/locomotive/steam/liquid/tags/editable/long_text.rb +15 -0
  56. data/lib/locomotive/steam/liquid/tags/editable/short_text.rb +20 -0
  57. data/lib/locomotive/steam/liquid/tags/editable/text.rb +15 -0
  58. data/lib/locomotive/steam/liquid/tags/extends.rb +25 -0
  59. data/lib/locomotive/steam/liquid/tags/google_analytics.rb +28 -0
  60. data/lib/locomotive/steam/liquid/tags/hybrid.rb +27 -0
  61. data/lib/locomotive/steam/liquid/tags/inline_editor.rb +16 -0
  62. data/lib/locomotive/steam/liquid/tags/link_to.rb +56 -0
  63. data/lib/locomotive/steam/liquid/tags/locale_switcher.rb +106 -0
  64. data/lib/locomotive/steam/liquid/tags/nav.rb +287 -0
  65. data/lib/locomotive/steam/liquid/tags/paginate.rb +105 -0
  66. data/lib/locomotive/steam/liquid/tags/path_helper.rb +98 -0
  67. data/lib/locomotive/steam/liquid/tags/path_to.rb +36 -0
  68. data/lib/locomotive/steam/liquid/tags/seo.rb +74 -0
  69. data/lib/locomotive/steam/liquid/tags/session_assign.rb +41 -0
  70. data/lib/locomotive/steam/liquid/tags/snippet.rb +63 -0
  71. data/lib/locomotive/steam/liquid/tags/with_scope.rb +44 -0
  72. data/lib/locomotive/steam/listen.rb +64 -0
  73. data/lib/locomotive/steam/logger.rb +54 -0
  74. data/lib/locomotive/steam/monkey_patches.rb +5 -0
  75. data/lib/locomotive/steam/monkey_patches/better_errors.rb +70 -0
  76. data/lib/locomotive/steam/monkey_patches/dragonfly.rb +79 -0
  77. data/lib/locomotive/steam/monkey_patches/haml.rb +15 -0
  78. data/lib/locomotive/steam/monkey_patches/httparty.rb +46 -0
  79. data/lib/locomotive/steam/monkey_patches/mounter.rb +32 -0
  80. data/lib/locomotive/steam/server.rb +81 -0
  81. data/lib/locomotive/steam/server/dynamic_assets.rb +33 -0
  82. data/lib/locomotive/steam/server/entry_submission.rb +120 -0
  83. data/lib/locomotive/steam/server/favicon.rb +18 -0
  84. data/lib/locomotive/steam/server/locale.rb +42 -0
  85. data/lib/locomotive/steam/server/logging.rb +32 -0
  86. data/lib/locomotive/steam/server/middleware.rb +61 -0
  87. data/lib/locomotive/steam/server/page.rb +69 -0
  88. data/lib/locomotive/steam/server/path.rb +34 -0
  89. data/lib/locomotive/steam/server/renderer.rb +118 -0
  90. data/lib/locomotive/steam/server/templatized_page.rb +32 -0
  91. data/lib/locomotive/steam/server/timezone.rb +18 -0
  92. data/lib/locomotive/steam/standalone_server.rb +33 -0
  93. data/lib/locomotive/steam/version.rb +5 -0
  94. data/lib/steam.rb +4 -0
  95. data/locomotivecms_steam.gemspec +42 -0
  96. data/spec/fixtures/default/README +0 -0
  97. data/spec/fixtures/default/app/content_types/bands.yml +19 -0
  98. data/spec/fixtures/default/app/content_types/events.yml +25 -0
  99. data/spec/fixtures/default/app/content_types/messages.yml +17 -0
  100. data/spec/fixtures/default/app/content_types/songs.yml +25 -0
  101. data/spec/fixtures/default/app/content_types/updates.yml +33 -0
  102. data/spec/fixtures/default/app/views/pages/404.liquid.haml +10 -0
  103. data/spec/fixtures/default/app/views/pages/about_us.fr.liquid.haml +7 -0
  104. data/spec/fixtures/default/app/views/pages/about_us.liquid.haml +21 -0
  105. data/spec/fixtures/default/app/views/pages/about_us.nb.liquid.haml +4 -0
  106. data/spec/fixtures/default/app/views/pages/about_us/jane_doe.liquid.haml +4 -0
  107. data/spec/fixtures/default/app/views/pages/about_us/john_doe.fr.liquid.haml +5 -0
  108. data/spec/fixtures/default/app/views/pages/about_us/john_doe.liquid.haml +6 -0
  109. data/spec/fixtures/default/app/views/pages/all.liquid.haml +13 -0
  110. data/spec/fixtures/default/app/views/pages/archives/news.liquid.haml +10 -0
  111. data/spec/fixtures/default/app/views/pages/contact.liquid.haml +54 -0
  112. data/spec/fixtures/default/app/views/pages/contest.liquid.haml +18 -0
  113. data/spec/fixtures/default/app/views/pages/events.liquid.haml +42 -0
  114. data/spec/fixtures/default/app/views/pages/filtered.liquid.haml +10 -0
  115. data/spec/fixtures/default/app/views/pages/grunge_bands.liquid.haml +8 -0
  116. data/spec/fixtures/default/app/views/pages/index.fr.liquid.haml +3 -0
  117. data/spec/fixtures/default/app/views/pages/index.liquid.haml +100 -0
  118. data/spec/fixtures/default/app/views/pages/music.fr.liquid.haml +4 -0
  119. data/spec/fixtures/default/app/views/pages/music.liquid.haml +42 -0
  120. data/spec/fixtures/default/app/views/pages/songs/template.fr.liquid.haml +16 -0
  121. data/spec/fixtures/default/app/views/pages/songs/template.liquid.haml +18 -0
  122. data/spec/fixtures/default/app/views/pages/songs/template/band.liquid.haml +16 -0
  123. data/spec/fixtures/default/app/views/pages/store.fr.liquid.haml +5 -0
  124. data/spec/fixtures/default/app/views/pages/store.liquid +5 -0
  125. data/spec/fixtures/default/app/views/pages/tags/nav.liquid.haml +6 -0
  126. data/spec/fixtures/default/app/views/pages/tags/nav_in_deep.liquid.haml +6 -0
  127. data/spec/fixtures/default/app/views/pages/unlisted_pages.liquid.haml +9 -0
  128. data/spec/fixtures/default/app/views/snippets/A_Complicated-one.liquid.haml +1 -0
  129. data/spec/fixtures/default/app/views/snippets/footer.liquid.haml +6 -0
  130. data/spec/fixtures/default/app/views/snippets/header.liquid.haml +1 -0
  131. data/spec/fixtures/default/app/views/snippets/song.fr.liquid.haml +8 -0
  132. data/spec/fixtures/default/app/views/snippets/song.liquid +12 -0
  133. data/spec/fixtures/default/config/deploy.yml +12 -0
  134. data/spec/fixtures/default/config/deploy_example.yml +12 -0
  135. data/spec/fixtures/default/config/site.yml +15 -0
  136. data/spec/fixtures/default/config/translations.yml +3 -0
  137. data/spec/fixtures/default/data/bands.yml +10 -0
  138. data/spec/fixtures/default/data/events.yml +53 -0
  139. data/spec/fixtures/default/data/songs.yml +46 -0
  140. data/spec/fixtures/default/data/updates.yml +48 -0
  141. data/spec/fixtures/default/public/fonts/chunkfive-webfont.eot +0 -0
  142. data/spec/fixtures/default/public/fonts/chunkfive-webfont.svg +213 -0
  143. data/spec/fixtures/default/public/fonts/chunkfive-webfont.ttf +0 -0
  144. data/spec/fixtures/default/public/fonts/chunkfive-webfont.woff +0 -0
  145. data/spec/fixtures/default/public/fonts/chunkfive.css +8 -0
  146. data/spec/fixtures/default/public/fonts/chunkfive.otf +0 -0
  147. data/spec/fixtures/default/public/images/nav_on.png +0 -0
  148. data/spec/fixtures/default/public/images/photo_frame.png +0 -0
  149. data/spec/fixtures/default/public/images/sep.png +0 -0
  150. data/spec/fixtures/default/public/images/top.jpg +0 -0
  151. data/spec/fixtures/default/public/javascripts/application.js.coffee +2 -0
  152. data/spec/fixtures/default/public/javascripts/common.js +1 -0
  153. data/spec/fixtures/default/public/samples/asset_collections/cover.jpg +0 -0
  154. data/spec/fixtures/default/public/samples/photo.jpg +0 -0
  155. data/spec/fixtures/default/public/samples/photo_2.jpg +0 -0
  156. data/spec/fixtures/default/public/stylesheets/application.css +64 -0
  157. data/spec/fixtures/default/public/stylesheets/other/extra.css.less +8 -0
  158. data/spec/fixtures/default/public/stylesheets/other/style.css.scss +13 -0
  159. data/spec/fixtures/default/public/stylesheets/reboot.css +82 -0
  160. data/spec/integration/integration_helper.rb +15 -0
  161. data/spec/integration/server/basic_spec.rb +170 -0
  162. data/spec/integration/server/contact_form_spec.rb +111 -0
  163. data/spec/integration/server/liquid_spec.rb +91 -0
  164. data/spec/integration/server/with_scope_spec.rb +20 -0
  165. data/spec/locales/locales_spec.rb +22 -0
  166. data/spec/spec_helper.rb +21 -0
  167. data/spec/support.rb +4 -0
  168. data/spec/support/examples/locale_file.rb +14 -0
  169. data/spec/support/examples/matching_locale.rb +8 -0
  170. data/spec/support/helpers.rb +22 -0
  171. data/spec/support/matchers/hash.rb +5 -0
  172. metadata +564 -0
@@ -0,0 +1,34 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ module Csrf
6
+
7
+ class Param < ::Liquid::Tag
8
+
9
+ def render(context)
10
+ %{<input type="hidden" name="authenticity_token" value="helloworld" />}
11
+ end
12
+
13
+ end
14
+
15
+ class Meta < ::Liquid::Tag
16
+
17
+ def render(context)
18
+ %{
19
+ <meta name="csrf-param" content="authenticity_token" />
20
+ <meta name="csrf-token" content="helloworld" />
21
+ }
22
+ end
23
+
24
+ end
25
+
26
+ end
27
+
28
+ ::Liquid::Template.register_tag('csrf_param', Csrf::Param)
29
+ ::Liquid::Template.register_tag('csrf_meta', Csrf::Meta)
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,6 @@
1
+ require_relative 'editable/base'
2
+ require_relative 'editable/text'
3
+ require_relative 'editable/short_text'
4
+ require_relative 'editable/long_text'
5
+ require_relative 'editable/file'
6
+ require_relative 'editable/control'
@@ -0,0 +1,50 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ module Editable
6
+ class Base < ::Liquid::Block
7
+
8
+ Syntax = /(#{::Liquid::QuotedFragment})(\s*,\s*#{::Liquid::Expression}+)?/
9
+
10
+ def initialize(tag_name, markup, tokens, options)
11
+ if markup =~ Syntax
12
+ @slug = $1.gsub(/[\"\']/, '')
13
+ @_options = {}
14
+ markup.scan(::Liquid::TagAttributes) { |key, value| @_options[key.to_sym] = value.gsub(/^'/, '').gsub(/'$/, '') }
15
+ else
16
+ raise ::Liquid::SyntaxError.new(options[:locale].t("errors.syntax.#{tag_name}"), options[:line])
17
+ end
18
+
19
+ super
20
+ end
21
+
22
+ def render(context)
23
+ current_page = context.registers[:page]
24
+
25
+ element = current_page.find_editable_element(self.current_block_name(context), @slug)
26
+
27
+ if element.present?
28
+ render_element(context, element)
29
+ else
30
+ super
31
+ end
32
+ end
33
+
34
+ protected
35
+
36
+ def render_element(context, element)
37
+ element.content
38
+ end
39
+
40
+ def current_block_name(context)
41
+ context['block'].try(:name)
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,19 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ module Editable
6
+ class Control < Base
7
+
8
+ def render(context)
9
+ super
10
+ end
11
+
12
+ end
13
+
14
+ ::Liquid::Template.register_tag('editable_control', Control)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ module Editable
6
+ class File < Base
7
+
8
+ end
9
+
10
+ ::Liquid::Template.register_tag('editable_file', File)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ module Editable
6
+ class LongText < ShortText
7
+
8
+ end
9
+
10
+ ::Liquid::Template.register_tag('editable_long_text', LongText)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ module Editable
6
+ class ShortText < Base
7
+
8
+ def render(context)
9
+ Locomotive::Steam::Logger.warn " [#{self.current_block_name(context)}/#{@slug}] The editable_{short|long}_text tags are deprecated. Use editable_text instead.".colorize(:orange)
10
+ super(context)
11
+ end
12
+
13
+ end
14
+
15
+ ::Liquid::Template.register_tag('editable_short_text', ShortText)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ module Editable
6
+ class Text < Base
7
+
8
+ end
9
+
10
+ ::Liquid::Template.register_tag('editable_text', Text)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,25 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ class Extends < ::Liquid::Extends
6
+
7
+ def parse_parent_template
8
+ mounting_point = @options[:mounting_point]
9
+
10
+ page = if @template_name == 'parent'
11
+ @options[:page].parent
12
+ else
13
+ mounting_point.pages[@template_name]
14
+ end
15
+
16
+ ::Liquid::Template.parse(page.source, { mounting_point: mounting_point, page: page })
17
+ end
18
+
19
+ end
20
+
21
+ ::Liquid::Template.register_tag('extends', Extends)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,28 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ class GoogleAnalytics < ::Liquid::Tag
6
+
7
+ Syntax = /(#{::Liquid::Expression}+)?/
8
+
9
+ def initialize(tag_name, markup, tokens, options)
10
+ if markup =~ Syntax
11
+ @account_id = $1.gsub('\'', '')
12
+ else
13
+ raise ::Liquid::SyntaxError.new(options[:locale].t("errors.syntax.google_analytics"), options[:line])
14
+ end
15
+
16
+ super
17
+ end
18
+
19
+ def render(context)
20
+ "<!-- google analytics for #{@account_id} -->"
21
+ end
22
+ end
23
+
24
+ ::Liquid::Template.register_tag('google_analytics', GoogleAnalytics)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ class Hybrid < ::Liquid::Block
6
+ def parse(tokens)
7
+ nesting = 0
8
+ tokens.each do |token|
9
+ next unless token =~ IsTag
10
+ if token =~ FullToken
11
+ if nesting == 0 && $1 == block_delimiter
12
+ @render_as_block = true
13
+ super
14
+ return
15
+ elsif $1 == block_name
16
+ nesting += 1
17
+ elsif $1 == block_delimiter
18
+ nesting -= 1
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ class InlineEditor < ::Liquid::Tag
6
+
7
+ def render(context)
8
+ ''
9
+ end
10
+ end
11
+
12
+ ::Liquid::Template.register_tag('inline_editor', InlineEditor)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,56 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ class LinkTo < Hybrid
6
+
7
+ Syntax = /(#{::Liquid::Expression}+)(#{::Liquid::TagAttributes}?)/
8
+
9
+ include PathHelper
10
+
11
+ def initialize(tag_name, markup, tokens, options)
12
+ if markup =~ Syntax
13
+ @handle = $1
14
+ @_options = {}
15
+ markup.scan(::Liquid::TagAttributes) do |key, value|
16
+ @_options[key] = value
17
+ end
18
+ else
19
+ raise ::Liquid::SyntaxError.new(options[:locale].t("errors.syntax.link_to"), options[:line])
20
+ end
21
+
22
+ super
23
+ end
24
+
25
+ def render(context)
26
+ render_path(context) do |page, path|
27
+ label = label_from_page(page)
28
+
29
+ if @render_as_block
30
+ context.scopes.last['target'] = page
31
+ label = super.html_safe
32
+ end
33
+
34
+ %{<a href="#{path}">#{label}</a>}
35
+ end
36
+ end
37
+
38
+ protected
39
+
40
+ def label_from_page(page)
41
+ ::Locomotive::Mounter.with_locale(@_options['locale']) do
42
+ if page.templatized?
43
+ page.content_entry._label
44
+ else
45
+ page.title
46
+ end
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+ ::Liquid::Template.register_tag('link_to', LinkTo)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,106 @@
1
+ module Locomotive
2
+ module Steam
3
+ module Liquid
4
+ module Tags
5
+ # Display the links to change the locale of the current page
6
+ #
7
+ # Usage:
8
+ #
9
+ # {% locale_switcher %} => <div id="locale-switcher"><a href="/features" class="current en">Features</a><a href="/fr/fonctionnalites" class="fr">Fonctionnalités</a></div>
10
+ #
11
+ # {% locale_switcher label: locale, sep: ' - ' }
12
+ #
13
+ # options:
14
+ # - label: iso (de, fr, en, ...etc), locale (Deutsch, Français, English, ...etc), title (page title)
15
+ # - sep: piece of html code separating 2 locales
16
+ #
17
+ # notes:
18
+ # - "iso" is the default choice for label
19
+ # - " | " is the default separating code
20
+ #
21
+ class LocaleSwitcher < ::Liquid::Tag
22
+
23
+ Syntax = /(#{::Liquid::Expression}+)?/
24
+
25
+ def initialize(tag_name, markup, tokens, options)
26
+ @_options = { label: 'iso', sep: ' | ' }
27
+
28
+ if markup =~ Syntax
29
+ markup.scan(::Liquid::TagAttributes) { |key, value| @_options[key.to_sym] = value.gsub(/"|'/, '') }
30
+
31
+ @_options[:exclude] = Regexp.new(@_options[:exclude]) if @_options[:exclude]
32
+ else
33
+ raise ::Liquid::SyntaxError.new(options[:locale].t("errors.syntax.locale_switcher"), options[:line])
34
+ end
35
+
36
+ super
37
+ end
38
+
39
+ def render(context)
40
+ @site, @page = context.registers[:site], context.registers[:page]
41
+ @default_locale = context.registers[:mounting_point].default_locale
42
+
43
+ output = %(<div id="locale-switcher">)
44
+
45
+ output += @site.locales.collect do |locale|
46
+ Locomotive::Mounter.with_locale(locale) do
47
+ fullpath = localized_fullpath(locale)
48
+
49
+ if @page.templatized?
50
+ permalink = context['entry']._permalink
51
+
52
+ if permalink
53
+ fullpath.gsub!('*', permalink)
54
+ else
55
+ fullpath = '404'
56
+ end
57
+ end
58
+
59
+ css = link_class(locale, context['locale'])
60
+
61
+ %(<a href="/#{fullpath}" class="#{css}">#{link_label(locale)}</a>)
62
+ end
63
+ end.join(@_options[:sep])
64
+
65
+ output += %(</div>)
66
+ end
67
+
68
+ private
69
+
70
+ def link_class(locale, current_locale)
71
+ css = [locale]
72
+ css << 'current' if locale.to_s == current_locale.to_s
73
+ css.join(' ')
74
+ end
75
+
76
+ def link_label(locale)
77
+ case @_options[:label]
78
+ when 'iso' then locale
79
+ when 'locale' then I18n.t("locales.#{locale}")
80
+ when 'title' then @page.title # FIXME: this returns nil if the page has not been translated in the locale
81
+ else
82
+ locale
83
+ end
84
+ end
85
+
86
+ def localized_fullpath(locale)
87
+ return nil if @page.fullpath_translations.blank?
88
+
89
+ fullpath = @page.safe_fullpath || @page.fullpath_or_default
90
+
91
+ if locale.to_s == @default_locale.to_s # no need to specify the locale
92
+ @page.index? ? '' : fullpath
93
+ elsif @page.index? # avoid /en/index or /fr/index, prefer /en or /fr instead
94
+ locale
95
+ else
96
+ File.join(locale, fullpath)
97
+ end
98
+ end
99
+
100
+ end
101
+
102
+ ::Liquid::Template.register_tag('locale_switcher', LocaleSwitcher)
103
+ end
104
+ end
105
+ end
106
+ end