locomotivecms_wagon 1.5.8 → 2.0.0.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/.rspec +0 -1
  4. data/Gemfile +17 -2
  5. data/README.md +2 -6
  6. data/Rakefile +3 -20
  7. data/lib/locomotive/wagon/cli.rb +34 -39
  8. data/lib/locomotive/wagon/commands/authenticate_command.rb +65 -0
  9. data/lib/locomotive/wagon/commands/concerns/api_concern.rb +57 -0
  10. data/lib/locomotive/wagon/commands/concerns/deploy_file_concern.rb +32 -0
  11. data/lib/locomotive/wagon/commands/concerns/instrumentation_concern.rb +16 -0
  12. data/lib/locomotive/wagon/commands/concerns/netrc_concern.rb +21 -0
  13. data/lib/locomotive/wagon/commands/concerns/steam_concern.rb +24 -0
  14. data/lib/locomotive/wagon/commands/generate_command.rb +29 -0
  15. data/lib/locomotive/wagon/commands/init_command.rb +19 -0
  16. data/lib/locomotive/wagon/commands/loggers/push_logger.rb +59 -0
  17. data/lib/locomotive/wagon/commands/push_command.rb +116 -0
  18. data/lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb +68 -0
  19. data/lib/locomotive/wagon/commands/push_sub_commands/push_content_assets_command.rb +54 -0
  20. data/lib/locomotive/wagon/commands/push_sub_commands/push_content_entries_command.rb +85 -0
  21. data/lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb +70 -0
  22. data/lib/locomotive/wagon/commands/push_sub_commands/push_pages_command.rb +71 -0
  23. data/lib/locomotive/wagon/commands/push_sub_commands/push_snippets_command.rb +23 -0
  24. data/lib/locomotive/wagon/commands/push_sub_commands/push_theme_assets_command.rb +70 -0
  25. data/lib/locomotive/wagon/commands/push_sub_commands/push_translations_command.rb +23 -0
  26. data/lib/locomotive/wagon/commands/serve_command.rb +131 -0
  27. data/lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb +20 -0
  28. data/lib/locomotive/wagon/decorators/concerns/to_hash_concern.rb +25 -0
  29. data/lib/locomotive/wagon/decorators/content_asset_decorator.rb +29 -0
  30. data/lib/locomotive/wagon/decorators/content_entry_decorator.rb +100 -0
  31. data/lib/locomotive/wagon/decorators/content_type_decorator.rb +78 -0
  32. data/lib/locomotive/wagon/decorators/content_type_field_decorator.rb +76 -0
  33. data/lib/locomotive/wagon/decorators/editable_element_decorator.rb +32 -0
  34. data/lib/locomotive/wagon/decorators/page_decorator.rb +81 -0
  35. data/lib/locomotive/wagon/decorators/site_decorator.rb +25 -0
  36. data/lib/locomotive/wagon/decorators/snippet_decorator.rb +29 -0
  37. data/lib/locomotive/wagon/decorators/theme_asset_decorator.rb +53 -0
  38. data/lib/locomotive/wagon/decorators/translation_decorator.rb +19 -0
  39. data/lib/locomotive/wagon/exceptions.rb +3 -55
  40. data/lib/locomotive/wagon/generators/site/unzip.rb +2 -2
  41. data/lib/locomotive/wagon/tools/deployment_connection.rb +120 -0
  42. data/lib/locomotive/wagon/tools/hosting_api.rb +117 -0
  43. data/lib/locomotive/wagon/tools/listen.rb +51 -0
  44. data/lib/locomotive/wagon/{misc → tools}/livereload.rb +5 -3
  45. data/lib/locomotive/wagon/{misc → tools}/tcp_port.rb +0 -0
  46. data/lib/locomotive/wagon/{misc → tools}/thor.rb +0 -0
  47. data/lib/locomotive/wagon/version.rb +1 -1
  48. data/lib/locomotive/wagon.rb +34 -162
  49. data/locomotivecms_wagon.gemspec +11 -24
  50. data/spec/fixtures/cassettes/authenticate.yml +425 -0
  51. data/spec/fixtures/cassettes/push.yml +34737 -0
  52. data/spec/fixtures/default/app/views/pages/events.liquid.haml +2 -1
  53. data/spec/fixtures/default/app/views/pages/index.liquid.haml +3 -2
  54. data/spec/fixtures/default/app/views/pages/layouts/simple.liquid.haml +1 -1
  55. data/spec/fixtures/default/app/views/snippets/footer.liquid.haml +1 -1
  56. data/spec/fixtures/default/app/views/snippets/song.liquid +3 -3
  57. data/spec/fixtures/default/config/site.yml +2 -4
  58. data/spec/fixtures/default/data/events.yml +3 -2
  59. data/spec/fixtures/default/data/songs.yml +1 -1
  60. data/spec/integration/cli_spec.rb +35 -12
  61. data/spec/integration/commands/authenticate_command_spec.rb +60 -0
  62. data/spec/integration/commands/push_command_spec.rb +55 -0
  63. data/spec/integration/generators/page_spec.rb +9 -9
  64. data/spec/integration/generators/relationship_spec.rb +6 -6
  65. data/spec/integration/integration_helper.rb +11 -11
  66. data/spec/integration/sites_spec.rb +48 -48
  67. data/spec/spec_helper.rb +3 -4
  68. data/spec/support/api_settings.rb +5 -0
  69. data/spec/support/helpers.rb +6 -19
  70. data/spec/support/pry.rb +4 -0
  71. data/spec/support/thor.rb +12 -0
  72. data/spec/support/vcr.rb +10 -0
  73. data/spec/unit/decorators/site_decorator_spec.rb +36 -0
  74. metadata +88 -309
  75. data/lib/locomotive/wagon/liquid/drops/base.rb +0 -49
  76. data/lib/locomotive/wagon/liquid/drops/content_entry.rb +0 -49
  77. data/lib/locomotive/wagon/liquid/drops/content_types.rb +0 -119
  78. data/lib/locomotive/wagon/liquid/drops/page.rb +0 -84
  79. data/lib/locomotive/wagon/liquid/drops/session_proxy.rb +0 -18
  80. data/lib/locomotive/wagon/liquid/drops/site.rb +0 -26
  81. data/lib/locomotive/wagon/liquid/errors.rb +0 -17
  82. data/lib/locomotive/wagon/liquid/filters/date.rb +0 -136
  83. data/lib/locomotive/wagon/liquid/filters/html.rb +0 -188
  84. data/lib/locomotive/wagon/liquid/filters/misc.rb +0 -49
  85. data/lib/locomotive/wagon/liquid/filters/resize.rb +0 -18
  86. data/lib/locomotive/wagon/liquid/filters/text.rb +0 -55
  87. data/lib/locomotive/wagon/liquid/filters/translate.rb +0 -28
  88. data/lib/locomotive/wagon/liquid/patches.rb +0 -47
  89. data/lib/locomotive/wagon/liquid/scopeable.rb +0 -151
  90. data/lib/locomotive/wagon/liquid/tags/consume.rb +0 -100
  91. data/lib/locomotive/wagon/liquid/tags/csrf.rb +0 -34
  92. data/lib/locomotive/wagon/liquid/tags/editable/base.rb +0 -50
  93. data/lib/locomotive/wagon/liquid/tags/editable/control.rb +0 -19
  94. data/lib/locomotive/wagon/liquid/tags/editable/file.rb +0 -15
  95. data/lib/locomotive/wagon/liquid/tags/editable/long_text.rb +0 -15
  96. data/lib/locomotive/wagon/liquid/tags/editable/short_text.rb +0 -20
  97. data/lib/locomotive/wagon/liquid/tags/editable/text.rb +0 -15
  98. data/lib/locomotive/wagon/liquid/tags/editable.rb +0 -6
  99. data/lib/locomotive/wagon/liquid/tags/extends.rb +0 -25
  100. data/lib/locomotive/wagon/liquid/tags/fetch_page.rb +0 -41
  101. data/lib/locomotive/wagon/liquid/tags/google_analytics.rb +0 -28
  102. data/lib/locomotive/wagon/liquid/tags/hybrid.rb +0 -27
  103. data/lib/locomotive/wagon/liquid/tags/inline_editor.rb +0 -16
  104. data/lib/locomotive/wagon/liquid/tags/link_to.rb +0 -56
  105. data/lib/locomotive/wagon/liquid/tags/locale_switcher.rb +0 -106
  106. data/lib/locomotive/wagon/liquid/tags/model_form.rb +0 -67
  107. data/lib/locomotive/wagon/liquid/tags/nav.rb +0 -287
  108. data/lib/locomotive/wagon/liquid/tags/paginate.rb +0 -105
  109. data/lib/locomotive/wagon/liquid/tags/path_helper.rb +0 -97
  110. data/lib/locomotive/wagon/liquid/tags/path_to.rb +0 -36
  111. data/lib/locomotive/wagon/liquid/tags/seo.rb +0 -74
  112. data/lib/locomotive/wagon/liquid/tags/session_assign.rb +0 -41
  113. data/lib/locomotive/wagon/liquid/tags/snippet.rb +0 -63
  114. data/lib/locomotive/wagon/liquid/tags/with_scope.rb +0 -48
  115. data/lib/locomotive/wagon/liquid.rb +0 -21
  116. data/lib/locomotive/wagon/listen.rb +0 -65
  117. data/lib/locomotive/wagon/logger.rb +0 -58
  118. data/lib/locomotive/wagon/misc/better_errors.rb +0 -70
  119. data/lib/locomotive/wagon/misc/core_ext.rb +0 -62
  120. data/lib/locomotive/wagon/misc/deployment_connection.rb +0 -120
  121. data/lib/locomotive/wagon/misc/dragonfly.rb +0 -78
  122. data/lib/locomotive/wagon/misc/haml.rb +0 -15
  123. data/lib/locomotive/wagon/misc/hosting_api.rb +0 -117
  124. data/lib/locomotive/wagon/misc/httparty.rb +0 -55
  125. data/lib/locomotive/wagon/misc/i18n.rb +0 -2
  126. data/lib/locomotive/wagon/misc/markdown.rb +0 -27
  127. data/lib/locomotive/wagon/misc/mounter.rb +0 -32
  128. data/lib/locomotive/wagon/misc/will_paginate.rb +0 -16
  129. data/lib/locomotive/wagon/misc.rb +0 -9
  130. data/lib/locomotive/wagon/server/dynamic_assets.rb +0 -33
  131. data/lib/locomotive/wagon/server/entry_submission.rb +0 -151
  132. data/lib/locomotive/wagon/server/favicon.rb +0 -17
  133. data/lib/locomotive/wagon/server/locale.rb +0 -42
  134. data/lib/locomotive/wagon/server/logging.rb +0 -32
  135. data/lib/locomotive/wagon/server/middleware.rb +0 -63
  136. data/lib/locomotive/wagon/server/page.rb +0 -67
  137. data/lib/locomotive/wagon/server/path.rb +0 -34
  138. data/lib/locomotive/wagon/server/renderer.rb +0 -118
  139. data/lib/locomotive/wagon/server/templatized_page.rb +0 -32
  140. data/lib/locomotive/wagon/server/timezone.rb +0 -18
  141. data/lib/locomotive/wagon/server.rb +0 -86
  142. data/lib/locomotive/wagon/standalone_server.rb +0 -28
  143. data/locales/de.yml +0 -157
  144. data/locales/en.yml +0 -189
  145. data/locales/es.yml +0 -133
  146. data/locales/et.yml +0 -154
  147. data/locales/fr.yml +0 -148
  148. data/locales/it.yml +0 -155
  149. data/locales/nb.yml +0 -191
  150. data/locales/nl.yml +0 -160
  151. data/locales/pl.yml +0 -203
  152. data/locales/pt-BR.yml +0 -139
  153. data/locales/ru.yml +0 -224
  154. data/spec/integration/server/basic_spec.rb +0 -169
  155. data/spec/integration/server/contact_form_spec.rb +0 -111
  156. data/spec/integration/server/liquid_spec.rb +0 -98
  157. data/spec/integration/server/new_contact_form_spec.rb +0 -67
  158. data/spec/integration/server/with_scope_spec.rb +0 -30
  159. data/spec/unit/locomotive/wagon/liquid/drops/page_spec.rb +0 -41
@@ -1,18 +0,0 @@
1
- module Locomotive
2
- module Wagon
3
- module Liquid
4
- module Filters
5
- module Resize
6
-
7
- def resize(input, resize_string)
8
- Locomotive::Wagon::Dragonfly.instance.resize_url(input, resize_string)
9
- end
10
-
11
- end
12
-
13
- ::Liquid::Template.register_filter(Resize)
14
-
15
- end
16
- end
17
- end
18
- end
@@ -1,55 +0,0 @@
1
- module Locomotive
2
- module Wagon
3
- module Liquid
4
- module Filters
5
- module Text
6
-
7
- # right justify and padd a string
8
- def rjust(input, integer, padstr = '')
9
- input.to_s.rjust(integer, padstr)
10
- end
11
-
12
- # left justify and padd a string
13
- def ljust(input, integer, padstr = '')
14
- input.to_s.ljust(integer, padstr)
15
- end
16
-
17
- def underscore(input)
18
- input.to_s.gsub(' ', '_').gsub('/', '_').underscore
19
- end
20
-
21
- def dasherize(input)
22
- input.to_s.gsub(' ', '-').gsub('/', '-').dasherize
23
- end
24
-
25
- # alias newline_to_br
26
- def multi_line(input)
27
- input.to_s.gsub("\n", '<br/>')
28
- end
29
-
30
- def concat(input, *args)
31
- result = input.to_s
32
- args.flatten.each { |a| result << a.to_s }
33
- result
34
- end
35
-
36
- def encode(input)
37
- Rack::Utils.escape(input)
38
- end
39
-
40
- def textile(input)
41
- ::RedCloth.new(input).to_html
42
- end
43
-
44
- def markdown(input)
45
- Locomotive::Wagon::Markdown.render(input)
46
- end
47
-
48
- end
49
-
50
- ::Liquid::Template.register_filter(Text)
51
-
52
- end
53
- end
54
- end
55
- end
@@ -1,28 +0,0 @@
1
- module Locomotive
2
- module Wagon
3
- module Liquid
4
- module Filters
5
- module Translate
6
-
7
- def translate(key, locale = nil, scope = nil)
8
- locale ||= I18n.locale.to_s
9
- if scope.blank?
10
- translation = @context.registers[:mounting_point].translations[key.to_s]
11
-
12
- if translation
13
- translation.get(locale) || translation.get(Locomotive::Mounter.locale.to_s)
14
- else
15
- "[unknown translation key: #{key}]"
16
- end
17
- else
18
- I18n.t(key, scope: scope.split('.'), locale: locale)
19
- end
20
- end
21
- end
22
-
23
- ::Liquid::Template.register_filter(Translate)
24
-
25
- end
26
- end
27
- end
28
- end
@@ -1,47 +0,0 @@
1
- module Liquid
2
-
3
- class Drop
4
-
5
- def mounting_point
6
- @context.registers[:mounting_point]
7
- end
8
-
9
- def site
10
- @context.registers[:site]
11
- end
12
-
13
- end
14
-
15
- class Template
16
-
17
- # creates a new <tt>Template</tt> object from liquid source code
18
- def parse_with_utf8(source, context = {})
19
- if RUBY_VERSION =~ /1\.9/
20
- source = source.force_encoding('UTF-8') if source.present?
21
- end
22
- self.parse_without_utf8(source, context)
23
- end
24
-
25
- alias_method_chain :parse, :utf8
26
-
27
- end
28
-
29
- module StandardFilters
30
-
31
- private
32
-
33
- def to_number(obj)
34
- case obj
35
- when Numeric
36
- obj
37
- when String
38
- (obj.strip =~ /^\d+\.\d+$/) ? obj.to_f : obj.to_i
39
- when DateTime, Date, Time
40
- obj.to_time.to_i
41
- else
42
- 0
43
- end
44
- end
45
- end
46
-
47
- end
@@ -1,151 +0,0 @@
1
- module Locomotive
2
- module Wagon
3
- module Liquid
4
- module Scopeable
5
-
6
- def apply_scope(entries)
7
- if @context['with_scope'].blank?
8
- entries
9
- else
10
- # extract the conditions
11
- _conditions = @context['with_scope'].clone.delete_if { |k, _| %w(order_by per_page page).include?(k) }
12
-
13
- # build the chains of conditions
14
- conditions = _conditions.map { |name, value| Condition.new(name, value) }
15
-
16
- Locomotive::Wagon::Logger.info "[with_scope] conditions: #{conditions.map(&:to_s).join(', ')}"
17
-
18
- # get only the entries matching ALL the conditions
19
- _entries = entries.find_all do |content|
20
- accepted = true
21
-
22
- conditions.each do |_condition|
23
- unless _condition.matches?(content)
24
- accepted = false
25
- break # no to go further
26
- end
27
- end
28
-
29
- accepted
30
- end
31
-
32
- self._apply_scope_order(_entries, @context['with_scope']['order_by'])
33
- end
34
- end
35
-
36
- def _apply_scope_order(entries, order_by)
37
- return entries if order_by.blank?
38
-
39
- name, direction = order_by.split(/[\s\.]/).map(&:to_sym)
40
-
41
- Locomotive::Wagon::Logger.info "[with_scope] order_by #{name} #{direction || 'asc'}"
42
-
43
- if direction == :asc || direction.nil?
44
- entries.sort { |a, b| a.send(name) <=> b.send(name) }
45
- else
46
- entries.sort { |a, b| b.send(name) <=> a.send(name) }
47
- end
48
- end
49
-
50
- class Condition
51
-
52
- OPERATORS = %w(all gt gte in lt lte ne nin size)
53
-
54
- attr_accessor :name, :operator, :right_operand
55
-
56
- def initialize(name, value)
57
- self.name, self.right_operand = name, value
58
-
59
- self.name = :_slug if %w(id _id).include?(name.to_s)
60
-
61
- self.process_right_operand
62
-
63
- # default value
64
- self.operator = :==
65
-
66
- self.decode_operator_based_on_name
67
- end
68
-
69
- def matches?(entry)
70
- value = self.get_value(entry)
71
-
72
- self.decode_operator_based_on_value(value)
73
-
74
- case self.operator
75
- when :== then value == self.right_operand
76
- when :ne then value != self.right_operand
77
- when :matches then self.right_operand =~ value
78
- when :gt then value > self.right_operand
79
- when :gte then value >= self.right_operand
80
- when :lt then value < self.right_operand
81
- when :lte then value <= self.right_operand
82
- when :size then value.size == self.right_operand
83
- when :all then [*self.right_operand].contains?(value)
84
- when :in, :nin
85
- _matches = if value.is_a?(Array)
86
- [*value].contains?([*self.right_operand])
87
- else
88
- [*self.right_operand].include?(value)
89
- end
90
- self.operator == :in ? _matches : !_matches
91
- else
92
- raise UnknownConditionInScope.new("#{self.operator} is unknown or not implemented.")
93
- end
94
- end
95
-
96
- def to_s
97
- "#{name} #{operator} #{self.right_operand.to_s}"
98
- end
99
-
100
- protected
101
-
102
- def get_value(entry)
103
- value = entry.send(self.name)
104
-
105
- if value.respond_to?(:_slug)
106
- # belongs_to
107
- value._slug
108
- elsif value.respond_to?(:map)
109
- # many_to_many or tags ?
110
- value.map { |v| v.respond_to?(:_slug) ? v._slug : v }
111
- else
112
- value
113
- end
114
- end
115
-
116
- def process_right_operand
117
- if self.right_operand.respond_to?(:_slug)
118
- # belongs_to
119
- self.right_operand = self.right_operand._slug
120
- elsif self.right_operand.respond_to?(:map) && self.right_operand.first.respond_to?(:_slug)
121
- # many_to_many
122
- self.right_operand = self.right_operand.map do |entry|
123
- entry.try(&:_slug)
124
- end
125
- end
126
- end
127
-
128
- def decode_operator_based_on_name
129
- if name =~ /^([a-z0-9_-]+)\.(#{OPERATORS.join('|')})$/
130
- self.name = $1.to_sym
131
- self.operator = $2.to_sym
132
- end
133
-
134
- if self.right_operand.is_a?(Regexp)
135
- self.operator = :matches
136
- end
137
- end
138
-
139
- def decode_operator_based_on_value(value)
140
- case value
141
- when Array
142
- self.operator = :in if self.operator == :==
143
- end
144
- end
145
-
146
- end
147
-
148
- end
149
- end
150
- end
151
- end
@@ -1,100 +0,0 @@
1
- module Locomotive
2
- module Wagon
3
- module Liquid
4
- module Tags
5
- # Consume web services as easy as pie directly in liquid !
6
- #
7
- # Usage:
8
- #
9
- # {% consume blog from 'http://nocoffee.tumblr.com/api/read.json?num=3', username: 'john', password: 'easy', format: 'json', expires_in: 3000 %}
10
- # {% for post in blog.posts %}
11
- # {{ post.title }}
12
- # {% endfor %}
13
- # {% endconsume %}
14
- #
15
- class Consume < ::Liquid::Block
16
-
17
- Syntax = /(#{::Liquid::VariableSignature}+)\s*from\s*(#{::Liquid::QuotedString}|#{::Liquid::VariableSignature}+)(.*)?/
18
-
19
- def initialize(tag_name, markup, tokens, options)
20
- if markup =~ Syntax
21
- @target = $1
22
-
23
- self.prepare_url($2)
24
- self.prepare_api_arguments($3)
25
- else
26
- raise ::Liquid::SyntaxError.new(options[:locale].t("errors.syntax.consume"), options[:line])
27
- end
28
-
29
- @local_cache_key = self.hash
30
-
31
- super
32
- end
33
-
34
- def render(context)
35
- self.set_api_options(context)
36
-
37
- if instance_variable_defined? :@variable_name
38
- @url = context[@variable_name]
39
- end
40
- render_all_without_cache(context)
41
- end
42
-
43
- protected
44
-
45
- def prepare_url(token)
46
- if token.match(::Liquid::QuotedString)
47
- @url = token.gsub(/['"]/, '')
48
- elsif token.match(::Liquid::VariableSignature)
49
- @variable_name = token
50
- else
51
- raise ::Liquid::SyntaxError.new("Syntax Error in 'consume' - Valid syntax: consume <var> from \"<url>\" [username: value, password: value]")
52
- end
53
- end
54
-
55
- def prepare_api_arguments(string)
56
- string = string.gsub(/^(\s*,)/, '').strip
57
- @api_arguments = Solid::Arguments.parse(string)
58
- end
59
-
60
- def set_api_options(context)
61
- @api_options = @api_arguments.interpolate(context).first || {}
62
- @expires_in = @api_options.delete(:expires_in) || 0
63
- end
64
-
65
- def cached_response
66
- @@local_cache ||= {}
67
- @@local_cache[@local_cache_key]
68
- end
69
-
70
- def cached_response=(response)
71
- @@local_cache ||= {}
72
- @@local_cache[@local_cache_key] = response
73
- end
74
-
75
- def render_all_without_cache(context)
76
- context.stack do
77
- begin
78
- context.scopes.last[@target.to_s] = Locomotive::Wagon::Httparty::Webservice.consume(@url, @api_options)
79
- self.cached_response = context.scopes.last[@target.to_s]
80
- rescue Timeout::Error
81
- context.scopes.last[@target.to_s] = self.cached_response
82
- rescue ::Liquid::Error => e
83
- raise e
84
- rescue => e
85
- liquid_e = ::Liquid::Error.new(e.message, line)
86
- liquid_e.set_backtrace(e.backtrace)
87
- raise liquid_e
88
- end
89
-
90
- render_all(@nodelist, context)
91
- end
92
- end
93
-
94
- end
95
-
96
- ::Liquid::Template.register_tag('consume', Consume)
97
- end
98
- end
99
- end
100
- end
@@ -1,34 +0,0 @@
1
- module Locomotive
2
- module Wagon
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
@@ -1,50 +0,0 @@
1
- module Locomotive
2
- module Wagon
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
@@ -1,19 +0,0 @@
1
- module Locomotive
2
- module Wagon
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
@@ -1,15 +0,0 @@
1
- module Locomotive
2
- module Wagon
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
@@ -1,15 +0,0 @@
1
- module Locomotive
2
- module Wagon
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
@@ -1,20 +0,0 @@
1
- module Locomotive
2
- module Wagon
3
- module Liquid
4
- module Tags
5
- module Editable
6
- class ShortText < Base
7
-
8
- def render(context)
9
- Locomotive::Wagon::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
@@ -1,15 +0,0 @@
1
- module Locomotive
2
- module Wagon
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
@@ -1,6 +0,0 @@
1
- require 'locomotive/wagon/liquid/tags/editable/base'
2
- require 'locomotive/wagon/liquid/tags/editable/text'
3
- require 'locomotive/wagon/liquid/tags/editable/short_text'
4
- require 'locomotive/wagon/liquid/tags/editable/long_text'
5
- require 'locomotive/wagon/liquid/tags/editable/file'
6
- require 'locomotive/wagon/liquid/tags/editable/control'
@@ -1,25 +0,0 @@
1
- module Locomotive
2
- module Wagon
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
@@ -1,41 +0,0 @@
1
- module Locomotive
2
- module Wagon
3
- module Liquid
4
- module Tags
5
-
6
- # Fetch a page from its handle and assign it to a liquid variable.
7
- #
8
- # Usage:
9
- #
10
- # {% fetch_page 'about_us' as a_page %}
11
- # <p>{{ a_page.title }}</p>
12
- #
13
- class FetchPage < ::Liquid::Tag
14
-
15
- Syntax = /(#{::Liquid::VariableSignature}+)\s+as\s+(#{::Liquid::VariableSignature}+)/
16
-
17
- def initialize(tag_name, markup, tokens, context)
18
- if markup =~ Syntax
19
- @handle = $1
20
- @var = $2
21
- else
22
- raise SyntaxError.new("Syntax Error in 'fetch_page' - Valid syntax: fetch_page page_handle as variable")
23
- end
24
-
25
- super
26
- end
27
-
28
- def render(context)
29
- mounting_point = context.registers[:mounting_point]
30
- context.scopes.last[@var] = mounting_point.pages.values.find { |_page| _page.handle == @handle }
31
- ''
32
- end
33
-
34
- end
35
-
36
- ::Liquid::Template.register_tag('fetch_page', FetchPage)
37
- end
38
-
39
- end
40
- end
41
- end
@@ -1,28 +0,0 @@
1
- module Locomotive
2
- module Wagon
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