locomotivecms_wagon 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/generators/bootstrap/app/views/pages/index.liquid +10 -1
- data/generators/bootstrap/app/views/pages/index.liquid.haml +9 -1
- data/generators/bootstrap/public/stylesheets/fonts/awesome.css.scss +3 -0
- data/generators/bootstrap/public/{fonts → stylesheets/fonts}/font-awesome-ie7.min.css +0 -0
- data/generators/bootstrap/public/{fonts → stylesheets/fonts}/font-awesome.css +0 -9
- data/generators/foundation/app/views/pages/index.liquid +1 -0
- data/generators/foundation/app/views/pages/index.liquid.haml +3 -1
- data/lib/locomotive/wagon/liquid.rb +2 -0
- data/lib/locomotive/wagon/liquid/drops/content_types.rb +6 -3
- data/lib/locomotive/wagon/liquid/drops/page.rb +2 -2
- data/lib/locomotive/wagon/liquid/drops/site.rb +0 -2
- data/lib/locomotive/wagon/liquid/filters/misc.rb +4 -0
- data/lib/locomotive/wagon/liquid/filters/text.rb +0 -1
- data/lib/locomotive/wagon/liquid/scopeable.rb +32 -0
- data/lib/locomotive/wagon/liquid/tags/editable.rb +1 -0
- data/lib/locomotive/wagon/liquid/tags/editable/base.rb +5 -1
- data/lib/locomotive/wagon/liquid/tags/editable/short_text.rb +5 -0
- data/lib/locomotive/wagon/liquid/tags/editable/text.rb +15 -0
- data/lib/locomotive/wagon/liquid/tags/hybrid.rb +27 -0
- data/lib/locomotive/wagon/liquid/tags/link_to.rb +112 -0
- data/lib/locomotive/wagon/liquid/tags/nav.rb +192 -73
- data/lib/locomotive/wagon/misc/core_ext.rb +18 -0
- data/lib/locomotive/wagon/server.rb +3 -1
- data/lib/locomotive/wagon/server/dynamic_assets.rb +19 -12
- data/lib/locomotive/wagon/server/logging.rb +1 -1
- data/lib/locomotive/wagon/server/page.rb +1 -1
- data/lib/locomotive/wagon/version.rb +1 -1
- data/locomotivecms_wagon.gemspec +3 -1
- data/spec/fixtures/default/app/views/pages/about_us.liquid.haml +1 -0
- data/spec/fixtures/default/app/views/pages/about_us/john_doe.liquid.haml +2 -0
- data/spec/fixtures/default/app/views/pages/archives/news.liquid.haml +3 -0
- data/spec/fixtures/default/app/views/pages/events.liquid.haml +13 -0
- data/spec/fixtures/default/app/views/pages/music.liquid.haml +13 -1
- data/spec/fixtures/default/app/views/pages/songs/template.liquid.haml +1 -0
- data/spec/fixtures/default/app/views/pages/tags/nav_in_deep.liquid.haml +6 -0
- data/spec/fixtures/default/app/views/snippets/A_Complicated-one.liquid.haml +1 -0
- data/spec/integration/server/basic_spec.rb +16 -9
- data/spec/integration/server/liquid_spec.rb +48 -4
- metadata +96 -11
- checksums.yaml +0 -15
- data/generators/bootstrap/public/fonts/font-awesome.min.css +0 -34
- data/lib/locomotive/wagon/scopeable.rb +0 -28
data/Gemfile
CHANGED
@@ -11,6 +11,13 @@ published: true
|
|
11
11
|
<meta name="description" content="{{ site.meta_description }}">
|
12
12
|
<meta name="keywords" content="{{ site.meta_keywords }}">
|
13
13
|
|
14
|
+
<!-- Fonts -->
|
15
|
+
{{ 'fonts/awesome.css' | stylesheet_tag }}
|
16
|
+
{{ 'fonts/font-awesome.css' | stylesheet_tag }}
|
17
|
+
<!--[if IE 7]>
|
18
|
+
{{ 'fonts/font-awesome-ie7.min.css' | stylesheet_tag }}
|
19
|
+
<![endif]-->
|
20
|
+
|
14
21
|
<!-- Le styles -->
|
15
22
|
{{ 'bootstrap.css' | stylesheet_tag }}
|
16
23
|
{{ 'bootstrap-responsive.css' | stylesheet_tag }}
|
@@ -20,6 +27,8 @@ published: true
|
|
20
27
|
<!--[if lt IE 9]>
|
21
28
|
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
22
29
|
<![endif]-->
|
30
|
+
|
31
|
+
{% inline_editor %}
|
23
32
|
</head>
|
24
33
|
|
25
34
|
<body>
|
@@ -42,7 +51,7 @@ published: true
|
|
42
51
|
<div class="jumbotron">
|
43
52
|
<h1>Super awesome marketing speak!</h1>
|
44
53
|
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
|
45
|
-
<a class="btn btn-large btn-success" href="#">Sign up today</a>
|
54
|
+
<a class="btn btn-large btn-success icon-flag" href="#">Sign up today</a>
|
46
55
|
</div>
|
47
56
|
|
48
57
|
<hr>
|
@@ -13,6 +13,12 @@ published: true
|
|
13
13
|
%meta{:content => "{{ site.meta_description }}", :name => "description"}
|
14
14
|
%meta{:content => "{{ site.meta_keywords }}", :name => "keywords"}
|
15
15
|
|
16
|
+
/ Fonts
|
17
|
+
{{ 'fonts/awesome.css' | stylesheet_tag }}
|
18
|
+
{{ 'fonts/font-awesome.css' | stylesheet_tag }}
|
19
|
+
/[if IE 7]
|
20
|
+
{{ 'fonts/font-awesome-ie7.min.css' | stylesheet_tag }}
|
21
|
+
|
16
22
|
/ Le styles
|
17
23
|
{{ 'bootstrap.css' | stylesheet_tag }}
|
18
24
|
{{ 'bootstrap-responsive.css' | stylesheet_tag }}
|
@@ -21,6 +27,8 @@ published: true
|
|
21
27
|
/ HTML5 shim, for IE6-8 support of HTML5 elements
|
22
28
|
/[if lt IE 9]
|
23
29
|
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
30
|
+
|
31
|
+
{% inline_editor %}
|
24
32
|
%body
|
25
33
|
|
26
34
|
.container-narrow
|
@@ -40,7 +48,7 @@ published: true
|
|
40
48
|
.jumbotron
|
41
49
|
%h1 Super awesome marketing speak!
|
42
50
|
%p.lead Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
|
43
|
-
%a.btn.btn-large.btn-success{:href => "#"} Sign up today
|
51
|
+
%a.btn.icon-flag.btn-large.btn-success{:href => "#"} Sign up today
|
44
52
|
|
45
53
|
%hr
|
46
54
|
|
File without changes
|
@@ -20,15 +20,6 @@
|
|
20
20
|
Work: Lead Product Designer @ http://kyruus.com
|
21
21
|
|
22
22
|
*/
|
23
|
-
@font-face {
|
24
|
-
font-family: 'FontAwesome';
|
25
|
-
src: url('fontawesome-webfont.eot');
|
26
|
-
src: url('fontawesome-webfont.eot?#iefix') format('embedded-opentype'),
|
27
|
-
url('fontawesome-webfont.woff') format('woff'),
|
28
|
-
url('fontawesome-webfont.ttf') format('truetype');
|
29
|
-
font-weight: normal;
|
30
|
-
font-style: normal;
|
31
|
-
}
|
32
23
|
/* Font Awesome styles
|
33
24
|
------------------------------------------------------- */
|
34
25
|
/* includes sprites.less reset */
|
@@ -16,6 +16,8 @@ published: true
|
|
16
16
|
{{ 'foundation.css' | stylesheet_tag }}
|
17
17
|
|
18
18
|
{{ 'vendor/custom.modernizr.js' | javascript_tag }}
|
19
|
+
|
20
|
+
{% inline_editor %}
|
19
21
|
%body
|
20
22
|
.row
|
21
23
|
.large-12.columns
|
@@ -96,7 +98,7 @@ published: true
|
|
96
98
|
|
97
99
|
{{ 'foundation.min.js' | javascript_tag }}
|
98
100
|
|
99
|
-
|
101
|
+
|
100
102
|
/ {{ 'foundation/foundation.js' | javascript_tag }}
|
101
103
|
|
102
104
|
/ {{ 'foundation/foundation.alerts.js' | javascript_tag }}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'liquid'
|
2
2
|
require 'locomotive/mounter'
|
3
|
+
require 'locomotive/wagon/liquid/scopeable'
|
3
4
|
require 'locomotive/wagon/liquid/drops/base'
|
5
|
+
require 'locomotive/wagon/liquid/tags/hybrid'
|
4
6
|
|
5
7
|
%w{. drops tags filters}.each do |dir|
|
6
8
|
Dir[File.join(File.dirname(__FILE__), 'liquid', dir, '*.rb')].each { |lib| require lib }
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require "locomotive/wagon/scopeable"
|
2
|
-
|
3
1
|
module Locomotive
|
4
2
|
module Wagon
|
5
3
|
module Liquid
|
@@ -14,6 +12,7 @@ module Locomotive
|
|
14
12
|
end
|
15
13
|
|
16
14
|
class ProxyCollection < ::Liquid::Drop
|
15
|
+
|
17
16
|
include Scopeable
|
18
17
|
|
19
18
|
def initialize(content_type)
|
@@ -21,6 +20,10 @@ module Locomotive
|
|
21
20
|
@collection = nil
|
22
21
|
end
|
23
22
|
|
23
|
+
def all
|
24
|
+
self.collection
|
25
|
+
end
|
26
|
+
|
24
27
|
def first
|
25
28
|
self.collection.first
|
26
29
|
end
|
@@ -95,7 +98,7 @@ module Locomotive
|
|
95
98
|
|
96
99
|
def collection
|
97
100
|
return unless @collection.blank?
|
98
|
-
|
101
|
+
|
99
102
|
@collection = apply_scope(@content_type.entries)
|
100
103
|
end
|
101
104
|
end
|
@@ -5,7 +5,7 @@ module Locomotive
|
|
5
5
|
class Page < Base
|
6
6
|
|
7
7
|
delegate :title, :slug, :fullpath, :parent, :depth, :seo_title, :redirect_url, :meta_description, :meta_keywords,
|
8
|
-
:templatized?, :published?, :redirect?, :listed?, to: '_source'
|
8
|
+
:templatized?, :published?, :redirect?, :listed?, :handle, to: '_source'
|
9
9
|
|
10
10
|
def children
|
11
11
|
_children = _source.children || []
|
@@ -16,7 +16,7 @@ module Locomotive
|
|
16
16
|
def content_type
|
17
17
|
ProxyCollection.new(_source.content_type) if _source.content_type
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def breadcrumbs
|
21
21
|
# TODO
|
22
22
|
''
|
@@ -0,0 +1,32 @@
|
|
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
|
+
collection = []
|
11
|
+
|
12
|
+
conditions = @context['with_scope'].clone.delete_if { |k, _| %w(order_by per_page page).include?(k) }
|
13
|
+
|
14
|
+
entries.each do |content|
|
15
|
+
accepted = (conditions.map do |key, value|
|
16
|
+
case value
|
17
|
+
when TrueClass, FalseClass, String, Integer then content.send(key) == value
|
18
|
+
else
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end).all? # all conditions works ?
|
22
|
+
|
23
|
+
collection << content if accepted
|
24
|
+
end
|
25
|
+
collection
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'locomotive/wagon/liquid/tags/editable/base'
|
2
|
+
require 'locomotive/wagon/liquid/tags/editable/text'
|
2
3
|
require 'locomotive/wagon/liquid/tags/editable/short_text'
|
3
4
|
require 'locomotive/wagon/liquid/tags/editable/long_text'
|
4
5
|
require 'locomotive/wagon/liquid/tags/editable/file'
|
@@ -22,7 +22,7 @@ module Locomotive
|
|
22
22
|
def render(context)
|
23
23
|
current_page = context.registers[:page]
|
24
24
|
|
25
|
-
element = current_page.find_editable_element(
|
25
|
+
element = current_page.find_editable_element(self.current_block_name(context), @slug)
|
26
26
|
|
27
27
|
if element.present?
|
28
28
|
render_element(context, element)
|
@@ -37,6 +37,10 @@ module Locomotive
|
|
37
37
|
element.content
|
38
38
|
end
|
39
39
|
|
40
|
+
def current_block_name(context)
|
41
|
+
context['block'].try(:name)
|
42
|
+
end
|
43
|
+
|
40
44
|
end
|
41
45
|
|
42
46
|
end
|
@@ -5,6 +5,11 @@ module Locomotive
|
|
5
5
|
module Editable
|
6
6
|
class ShortText < Base
|
7
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
|
+
|
8
13
|
end
|
9
14
|
|
10
15
|
::Liquid::Template.register_tag('editable_short_text', ShortText)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Locomotive
|
2
|
+
module Wagon
|
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,112 @@
|
|
1
|
+
module Locomotive
|
2
|
+
module Wagon
|
3
|
+
module Liquid
|
4
|
+
module Tags
|
5
|
+
class LinkTo < Hybrid
|
6
|
+
|
7
|
+
Syntax = /(#{::Liquid::Expression}+)(#{::Liquid::TagAttributes}?)/
|
8
|
+
|
9
|
+
def initialize(tag_name, markup, tokens, context)
|
10
|
+
if markup =~ Syntax
|
11
|
+
@handle = $1
|
12
|
+
@options = {}
|
13
|
+
markup.scan(::Liquid::TagAttributes) do |key, value|
|
14
|
+
@options[key] = value
|
15
|
+
end
|
16
|
+
else
|
17
|
+
raise SyntaxError.new("Syntax Error in 'link_to' - Valid syntax: link_to page_handle, locale es (locale is optional)")
|
18
|
+
end
|
19
|
+
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def render(context)
|
24
|
+
if page = self.retrieve_page_from_handle(context)
|
25
|
+
label = self.label_from_page(page)
|
26
|
+
path = self.public_page_url(context, page)
|
27
|
+
|
28
|
+
if @render_as_block
|
29
|
+
context.scopes.last['target'] = page
|
30
|
+
label = super.html_safe
|
31
|
+
end
|
32
|
+
|
33
|
+
%{<a href="#{path}">#{label}</a>}
|
34
|
+
else
|
35
|
+
'' # no page found
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def retrieve_page_from_handle(context)
|
42
|
+
mounting_point = context.registers[:mounting_point]
|
43
|
+
|
44
|
+
context.scopes.reverse_each do |scope|
|
45
|
+
handle = scope[@handle] || @handle
|
46
|
+
|
47
|
+
page = case handle
|
48
|
+
when Locomotive::Mounter::Models::Page then handle
|
49
|
+
when String then fetch_page(mounting_point, handle)
|
50
|
+
when Liquid::Drops::ContentEntry then fetch_page(mounting_point, handle._source, true)
|
51
|
+
when Locomotive::Mounter::Models::ContentEntry then fetch_page(mounting_point, handle, true)
|
52
|
+
else
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
56
|
+
return page unless page.nil?
|
57
|
+
end
|
58
|
+
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
|
62
|
+
def fetch_page(mounting_point, handle, templatized = false)
|
63
|
+
::Locomotive::Mounter.with_locale(@options['locale']) do
|
64
|
+
if templatized
|
65
|
+
page = mounting_point.pages.values.find do |_page|
|
66
|
+
_page.templatized? &&
|
67
|
+
_page.content_type.slug == handle.content_type.slug &&
|
68
|
+
(@options['with'].nil? || _page.handle == @options['with'])
|
69
|
+
end
|
70
|
+
|
71
|
+
page.content_entry = handle if page
|
72
|
+
|
73
|
+
page
|
74
|
+
else
|
75
|
+
mounting_point.pages.values.find { |_page| _page.handle == handle }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def label_from_page(page)
|
81
|
+
::Locomotive::Mounter.with_locale(@options['locale']) do
|
82
|
+
if page.templatized?
|
83
|
+
page.content_entry._label
|
84
|
+
else
|
85
|
+
page.title
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def public_page_url(context, page)
|
91
|
+
mounting_point = context.registers[:mounting_point]
|
92
|
+
|
93
|
+
fullpath = ::Locomotive::Mounter.with_locale(@options['locale']) do
|
94
|
+
page.fullpath.clone
|
95
|
+
end
|
96
|
+
|
97
|
+
fullpath = "#{::I18n.locale}/#{fullpath}" if ::I18n.locale.to_s != mounting_point.default_locale.to_s
|
98
|
+
|
99
|
+
if page.templatized?
|
100
|
+
fullpath.gsub!(/(content_type_template|template)/, page.content_entry._slug)
|
101
|
+
end
|
102
|
+
|
103
|
+
File.join('/', fullpath)
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
::Liquid::Template.register_tag('link_to', LinkTo)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|