dugway 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/README.md +151 -0
- data/Rakefile +12 -0
- data/bin/dugway +7 -0
- data/dugway.gemspec +43 -0
- data/lib/dugway.rb +66 -0
- data/lib/dugway/application.rb +147 -0
- data/lib/dugway/cart.rb +144 -0
- data/lib/dugway/cli.rb +22 -0
- data/lib/dugway/cli/build.rb +56 -0
- data/lib/dugway/cli/create.rb +71 -0
- data/lib/dugway/cli/server.rb +37 -0
- data/lib/dugway/cli/templates/Gemfile.tt +2 -0
- data/lib/dugway/cli/templates/config.tt +24 -0
- data/lib/dugway/cli/templates/gitignore.tt +9 -0
- data/lib/dugway/cli/templates/source/cart.html +40 -0
- data/lib/dugway/cli/templates/source/checkout.html +33 -0
- data/lib/dugway/cli/templates/source/contact.html +37 -0
- data/lib/dugway/cli/templates/source/home.html +25 -0
- data/lib/dugway/cli/templates/source/images/badge.png +0 -0
- data/lib/dugway/cli/templates/source/javascripts/cart.js.coffee +7 -0
- data/lib/dugway/cli/templates/source/javascripts/product.js.coffee +7 -0
- data/lib/dugway/cli/templates/source/layout.html +101 -0
- data/lib/dugway/cli/templates/source/maintenance.html +20 -0
- data/lib/dugway/cli/templates/source/product.html +65 -0
- data/lib/dugway/cli/templates/source/products.html +25 -0
- data/lib/dugway/cli/templates/source/screenshot.jpg +0 -0
- data/lib/dugway/cli/templates/source/scripts.js +19 -0
- data/lib/dugway/cli/templates/source/settings.json +71 -0
- data/lib/dugway/cli/templates/source/styles.css +27 -0
- data/lib/dugway/cli/templates/source/stylesheets/cart.css.sass +38 -0
- data/lib/dugway/cli/templates/source/stylesheets/layout.css.sass +103 -0
- data/lib/dugway/cli/templates/source/stylesheets/product.css.sass +19 -0
- data/lib/dugway/cli/templates/source/stylesheets/products.css.sass +20 -0
- data/lib/dugway/cli/templates/source/stylesheets/vendor/normalize.css +396 -0
- data/lib/dugway/cli/templates/source/success.html +5 -0
- data/lib/dugway/controller.rb +148 -0
- data/lib/dugway/data/locales/cs.yml +26 -0
- data/lib/dugway/data/locales/da.yml +26 -0
- data/lib/dugway/data/locales/en-AU.yml +26 -0
- data/lib/dugway/data/locales/en-GB.yml +26 -0
- data/lib/dugway/data/locales/en-PH.yml +27 -0
- data/lib/dugway/data/locales/en-US.yml +26 -0
- data/lib/dugway/data/locales/es-MX.yml +26 -0
- data/lib/dugway/data/locales/eu.yml +26 -0
- data/lib/dugway/data/locales/gsw-CH.yml +26 -0
- data/lib/dugway/data/locales/hu.yml +26 -0
- data/lib/dugway/data/locales/il.yml +26 -0
- data/lib/dugway/data/locales/ja.yml +30 -0
- data/lib/dugway/data/locales/ms-MY.yml +26 -0
- data/lib/dugway/data/locales/nb.yml +22 -0
- data/lib/dugway/data/locales/pl.yml +27 -0
- data/lib/dugway/data/locales/pt-BR.yml +26 -0
- data/lib/dugway/data/locales/sv-SE.yml +26 -0
- data/lib/dugway/data/locales/th.yml +26 -0
- data/lib/dugway/data/locales/tr.yml +29 -0
- data/lib/dugway/data/locales/zh-TW.yml +30 -0
- data/lib/dugway/data/theme_fonts.yml +151 -0
- data/lib/dugway/extensions/time.rb +15 -0
- data/lib/dugway/liquid/drops/account_drop.rb +17 -0
- data/lib/dugway/liquid/drops/artist_drop.rb +9 -0
- data/lib/dugway/liquid/drops/artists_drop.rb +13 -0
- data/lib/dugway/liquid/drops/base_drop.rb +59 -0
- data/lib/dugway/liquid/drops/cart_drop.rb +13 -0
- data/lib/dugway/liquid/drops/cart_item_drop.rb +21 -0
- data/lib/dugway/liquid/drops/categories_drop.rb +13 -0
- data/lib/dugway/liquid/drops/category_drop.rb +9 -0
- data/lib/dugway/liquid/drops/contact_drop.rb +29 -0
- data/lib/dugway/liquid/drops/country_drop.rb +6 -0
- data/lib/dugway/liquid/drops/currency_drop.rb +6 -0
- data/lib/dugway/liquid/drops/image_drop.rb +6 -0
- data/lib/dugway/liquid/drops/page_drop.rb +13 -0
- data/lib/dugway/liquid/drops/pages_drop.rb +9 -0
- data/lib/dugway/liquid/drops/product_drop.rb +101 -0
- data/lib/dugway/liquid/drops/product_option_drop.rb +27 -0
- data/lib/dugway/liquid/drops/products_drop.rb +75 -0
- data/lib/dugway/liquid/drops/shipping_option_drop.rb +13 -0
- data/lib/dugway/liquid/drops/theme_drop.rb +23 -0
- data/lib/dugway/liquid/filters/comparison_filters.rb +48 -0
- data/lib/dugway/liquid/filters/core_filters.rb +138 -0
- data/lib/dugway/liquid/filters/default_pagination.rb +35 -0
- data/lib/dugway/liquid/filters/font_filters.rb +9 -0
- data/lib/dugway/liquid/filters/url_filters.rb +66 -0
- data/lib/dugway/liquid/filters/util_filters.rb +119 -0
- data/lib/dugway/liquid/tags/checkout_form.rb +9 -0
- data/lib/dugway/liquid/tags/get.rb +58 -0
- data/lib/dugway/liquid/tags/paginate.rb +129 -0
- data/lib/dugway/liquifier.rb +122 -0
- data/lib/dugway/logger.rb +16 -0
- data/lib/dugway/request.rb +36 -0
- data/lib/dugway/store.rb +166 -0
- data/lib/dugway/template.rb +44 -0
- data/lib/dugway/theme.rb +145 -0
- data/lib/dugway/theme_font.rb +68 -0
- data/lib/dugway/version.rb +3 -0
- data/spec/fixtures/store/page/about-us.js +1 -0
- data/spec/fixtures/store/products.js +1 -0
- data/spec/fixtures/store/store.js +1 -0
- data/spec/fixtures/theme/cart.html +33 -0
- data/spec/fixtures/theme/checkout.html +31 -0
- data/spec/fixtures/theme/contact.html +37 -0
- data/spec/fixtures/theme/home.html +38 -0
- data/spec/fixtures/theme/images/bc_badge.png +0 -0
- data/spec/fixtures/theme/javascripts/one.js +3 -0
- data/spec/fixtures/theme/javascripts/two.js.coffee +2 -0
- data/spec/fixtures/theme/layout.html +77 -0
- data/spec/fixtures/theme/maintenance.html +17 -0
- data/spec/fixtures/theme/product.html +73 -0
- data/spec/fixtures/theme/products.html +41 -0
- data/spec/fixtures/theme/screenshot.jpg +0 -0
- data/spec/fixtures/theme/scripts.js +2 -0
- data/spec/fixtures/theme/settings.json +55 -0
- data/spec/fixtures/theme/styles.css +4 -0
- data/spec/fixtures/theme/stylesheets/one.css +3 -0
- data/spec/fixtures/theme/stylesheets/two.css.sass +4 -0
- data/spec/fixtures/theme/success.html +5 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/units/dugway/request_spec.rb +206 -0
- data/spec/units/dugway/store_spec.rb +194 -0
- data/spec/units/dugway/template_spec.rb +145 -0
- data/spec/units/dugway/theme_font_spec.rb +136 -0
- data/spec/units/dugway_spec.rb +9 -0
- metadata +549 -0
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'rack/mount'
|
2
|
+
|
3
|
+
module Dugway
|
4
|
+
class Controller
|
5
|
+
PERMALINK_REGEX = %r{[a-z0-9\-_]+}
|
6
|
+
FORMAT_REGEX = %r{(\.(?<format>js))?}
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def routes
|
10
|
+
@routes ||= Rack::Mount::RouteSet.new
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def route(method, path, &block)
|
16
|
+
routes.add_route(Proc.new { |env|
|
17
|
+
@page = nil
|
18
|
+
@request = Request.new(env)
|
19
|
+
@response = Rack::Response.new
|
20
|
+
|
21
|
+
if request.html? && page.blank?
|
22
|
+
render_not_found
|
23
|
+
else
|
24
|
+
yield
|
25
|
+
end
|
26
|
+
}, {
|
27
|
+
:request_method => method,
|
28
|
+
:path_info => interpret_path(path)
|
29
|
+
})
|
30
|
+
|
31
|
+
routes.rehash
|
32
|
+
end
|
33
|
+
|
34
|
+
def interpret_path(path)
|
35
|
+
if path.is_a?(String)
|
36
|
+
case path
|
37
|
+
# category/artist/product
|
38
|
+
when %r{^/(\w+)/:(#{ PERMALINK_REGEX })\(\.js\)}
|
39
|
+
%r{^/#{ $1 }/(?<#{ $2 }>#{ PERMALINK_REGEX })#{ FORMAT_REGEX }$}
|
40
|
+
# products/cart
|
41
|
+
when %r{^/(\w+)\(\.js\)$}
|
42
|
+
%r{^/#{ $1 }#{ FORMAT_REGEX }$}
|
43
|
+
# custom pages
|
44
|
+
when %r{^/:(#{ PERMALINK_REGEX })}
|
45
|
+
%r{^/(?<#{ $1 }>#{ PERMALINK_REGEX })$}
|
46
|
+
# styles/scripts
|
47
|
+
when %r{^/(\w+)\.(js|css)}
|
48
|
+
%r{^/#{ $1 }\.(?<format>(js|css))$}
|
49
|
+
# everything else
|
50
|
+
else
|
51
|
+
%r{^#{ path }$}
|
52
|
+
end
|
53
|
+
else
|
54
|
+
path
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def get(path, &block)
|
59
|
+
route('GET', path, &block)
|
60
|
+
end
|
61
|
+
|
62
|
+
def post(path, &block)
|
63
|
+
route('POST', path, &block)
|
64
|
+
end
|
65
|
+
|
66
|
+
def any(path, &block)
|
67
|
+
get(path, &block)
|
68
|
+
post(path, &block)
|
69
|
+
end
|
70
|
+
|
71
|
+
def request
|
72
|
+
@request
|
73
|
+
end
|
74
|
+
|
75
|
+
def response
|
76
|
+
@response
|
77
|
+
end
|
78
|
+
|
79
|
+
def params
|
80
|
+
request.params
|
81
|
+
end
|
82
|
+
|
83
|
+
def store
|
84
|
+
Dugway.store
|
85
|
+
end
|
86
|
+
|
87
|
+
def cart
|
88
|
+
Dugway.cart
|
89
|
+
end
|
90
|
+
|
91
|
+
def page
|
92
|
+
@page ||= begin
|
93
|
+
if page = Dugway.store.page(request.page_permalink)
|
94
|
+
page['url'] = request.path
|
95
|
+
page['full_url'] = request.url
|
96
|
+
page['full_path'] = request.fullpath
|
97
|
+
page
|
98
|
+
else
|
99
|
+
nil
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def error(msg)
|
105
|
+
request.session[:errors] ||= []
|
106
|
+
request.session[:errors] << msg
|
107
|
+
end
|
108
|
+
|
109
|
+
def render_file(file_name, variables={})
|
110
|
+
if errors = request.session.delete(:errors)
|
111
|
+
variables.merge!(:errors => errors)
|
112
|
+
end
|
113
|
+
|
114
|
+
template = Template.new(file_name)
|
115
|
+
content = template.render(request, variables)
|
116
|
+
|
117
|
+
response.write(content)
|
118
|
+
response['Content-Type'] = template.content_type
|
119
|
+
response.finish
|
120
|
+
end
|
121
|
+
|
122
|
+
def render_page(variables={})
|
123
|
+
render_file("#{ page['permalink'] }.html", variables.update({ :page => page }))
|
124
|
+
end
|
125
|
+
|
126
|
+
def render_json(object)
|
127
|
+
response.write(object.to_json)
|
128
|
+
response['Content-Type'] = 'application/json'
|
129
|
+
response.finish
|
130
|
+
end
|
131
|
+
|
132
|
+
def render_not_found
|
133
|
+
response.write('Not Found')
|
134
|
+
response.status = 404
|
135
|
+
response.finish
|
136
|
+
end
|
137
|
+
|
138
|
+
def redirect_to(path)
|
139
|
+
response.redirect(path)
|
140
|
+
response.finish
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def call(env)
|
145
|
+
self.class.routes.call(env)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
cs:
|
2
|
+
number:
|
3
|
+
format:
|
4
|
+
separator: ","
|
5
|
+
delimiter: ""
|
6
|
+
precision: 2
|
7
|
+
significant: false
|
8
|
+
strip_insignificant_zeros: false
|
9
|
+
|
10
|
+
currency:
|
11
|
+
format:
|
12
|
+
format: "%n%u"
|
13
|
+
unit: "Kč"
|
14
|
+
separator: ","
|
15
|
+
delimiter: ""
|
16
|
+
precision: 2
|
17
|
+
significant: false
|
18
|
+
strip_insignificant_zeros: false
|
19
|
+
|
20
|
+
percentage:
|
21
|
+
format:
|
22
|
+
delimiter: ""
|
23
|
+
|
24
|
+
precision:
|
25
|
+
format:
|
26
|
+
delimiter: ""
|
@@ -0,0 +1,26 @@
|
|
1
|
+
da:
|
2
|
+
number:
|
3
|
+
format:
|
4
|
+
separator: ","
|
5
|
+
delimiter: "."
|
6
|
+
precision: 2
|
7
|
+
significant: false
|
8
|
+
strip_insignificant_zeros: false
|
9
|
+
|
10
|
+
currency:
|
11
|
+
format:
|
12
|
+
format: "%u%n"
|
13
|
+
unit: "kr"
|
14
|
+
separator: ","
|
15
|
+
delimiter: "."
|
16
|
+
precision: 2
|
17
|
+
significant: false
|
18
|
+
strip_insignificant_zeros: false
|
19
|
+
|
20
|
+
percentage:
|
21
|
+
format:
|
22
|
+
delimiter: ""
|
23
|
+
|
24
|
+
precision:
|
25
|
+
format:
|
26
|
+
delimiter: "."
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"en-AU":
|
2
|
+
number:
|
3
|
+
format:
|
4
|
+
separator: "."
|
5
|
+
delimiter: ","
|
6
|
+
precision: 2
|
7
|
+
significant: false
|
8
|
+
strip_insignificant_zeros: false
|
9
|
+
|
10
|
+
currency:
|
11
|
+
format:
|
12
|
+
format: "%u%n"
|
13
|
+
unit: "$"
|
14
|
+
separator: "."
|
15
|
+
delimiter: ","
|
16
|
+
precision: 2
|
17
|
+
significant: false
|
18
|
+
strip_insignificant_zeros: false
|
19
|
+
|
20
|
+
percentage:
|
21
|
+
format:
|
22
|
+
delimiter: ""
|
23
|
+
|
24
|
+
precision:
|
25
|
+
format:
|
26
|
+
delimiter: ","
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"en-GB":
|
2
|
+
number:
|
3
|
+
format:
|
4
|
+
separator: "."
|
5
|
+
delimiter: ","
|
6
|
+
precision: 2
|
7
|
+
significant: false
|
8
|
+
strip_insignificant_zeros: false
|
9
|
+
|
10
|
+
currency:
|
11
|
+
format:
|
12
|
+
format: "%u%n"
|
13
|
+
unit: "£"
|
14
|
+
separator: "."
|
15
|
+
delimiter: ","
|
16
|
+
precision: 2
|
17
|
+
significant: false
|
18
|
+
strip_insignificant_zeros: false
|
19
|
+
|
20
|
+
percentage:
|
21
|
+
format:
|
22
|
+
delimiter: ""
|
23
|
+
|
24
|
+
precision:
|
25
|
+
format:
|
26
|
+
delimiter: ","
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"en-PH":
|
2
|
+
number:
|
3
|
+
format:
|
4
|
+
separator: "."
|
5
|
+
delimiter: ","
|
6
|
+
precision: 2
|
7
|
+
significant: false
|
8
|
+
strip_insignificant_zeros: false
|
9
|
+
|
10
|
+
currency:
|
11
|
+
format:
|
12
|
+
format: "%u%n"
|
13
|
+
unit: "₱"
|
14
|
+
separator: "."
|
15
|
+
delimiter: ","
|
16
|
+
precision: 2
|
17
|
+
significant: false
|
18
|
+
strip_insignificant_zeros: false
|
19
|
+
|
20
|
+
percentage:
|
21
|
+
format:
|
22
|
+
delimiter: ""
|
23
|
+
|
24
|
+
precision:
|
25
|
+
format:
|
26
|
+
delimiter: ","
|
27
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"en-US":
|
2
|
+
number:
|
3
|
+
format:
|
4
|
+
separator: "."
|
5
|
+
delimiter: ","
|
6
|
+
precision: 2
|
7
|
+
significant: false
|
8
|
+
strip_insignificant_zeros: false
|
9
|
+
|
10
|
+
currency:
|
11
|
+
format:
|
12
|
+
format: "%u%n"
|
13
|
+
unit: "$"
|
14
|
+
separator: "."
|
15
|
+
delimiter: ","
|
16
|
+
precision: 2
|
17
|
+
significant: false
|
18
|
+
strip_insignificant_zeros: false
|
19
|
+
|
20
|
+
percentage:
|
21
|
+
format:
|
22
|
+
delimiter: ""
|
23
|
+
|
24
|
+
precision:
|
25
|
+
format:
|
26
|
+
delimiter: ","
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"es-MX":
|
2
|
+
number:
|
3
|
+
format:
|
4
|
+
delimiter: ","
|
5
|
+
precision: 2
|
6
|
+
significant: false
|
7
|
+
strip_insignificant_zeros: false
|
8
|
+
separator: "."
|
9
|
+
|
10
|
+
currency:
|
11
|
+
format:
|
12
|
+
format: "%u%n"
|
13
|
+
unit: "$"
|
14
|
+
separator: "."
|
15
|
+
delimiter: ","
|
16
|
+
precision: 2
|
17
|
+
significant: false
|
18
|
+
strip_insignificant_zeros: false
|
19
|
+
|
20
|
+
percentage:
|
21
|
+
format:
|
22
|
+
delimiter: ""
|
23
|
+
|
24
|
+
precision:
|
25
|
+
format:
|
26
|
+
delimiter: ","
|
@@ -0,0 +1,26 @@
|
|
1
|
+
eu:
|
2
|
+
number:
|
3
|
+
format:
|
4
|
+
separator: "."
|
5
|
+
delimiter: ","
|
6
|
+
precision: 2
|
7
|
+
significant: false
|
8
|
+
strip_insignificant_zeros: false
|
9
|
+
|
10
|
+
currency:
|
11
|
+
format:
|
12
|
+
format: "%u%n"
|
13
|
+
unit: "€"
|
14
|
+
separator: "."
|
15
|
+
delimiter: ","
|
16
|
+
precision: 2
|
17
|
+
significant: false
|
18
|
+
strip_insignificant_zeros: false
|
19
|
+
|
20
|
+
percentage:
|
21
|
+
format:
|
22
|
+
delimiter: ""
|
23
|
+
|
24
|
+
precision:
|
25
|
+
format:
|
26
|
+
delimiter: ","
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"gsw-CH":
|
2
|
+
number:
|
3
|
+
format:
|
4
|
+
precision: 2
|
5
|
+
separator: '.'
|
6
|
+
delimiter: ","
|
7
|
+
significant: false
|
8
|
+
strip_insignificant_zeros: false
|
9
|
+
|
10
|
+
currency:
|
11
|
+
format:
|
12
|
+
unit: 'SFr.'
|
13
|
+
format: '%u%n'
|
14
|
+
separator: '.'
|
15
|
+
delimiter: ","
|
16
|
+
precision: 2
|
17
|
+
significant: false
|
18
|
+
strip_insignificant_zeros: false
|
19
|
+
|
20
|
+
percentage:
|
21
|
+
format:
|
22
|
+
delimiter: "'"
|
23
|
+
|
24
|
+
precision:
|
25
|
+
format:
|
26
|
+
delimiter: ","
|
@@ -0,0 +1,26 @@
|
|
1
|
+
hu:
|
2
|
+
number:
|
3
|
+
format:
|
4
|
+
precision: 2
|
5
|
+
separator: ","
|
6
|
+
delimiter: ""
|
7
|
+
|
8
|
+
currency:
|
9
|
+
format:
|
10
|
+
unit: 'Ft'
|
11
|
+
precision: 0
|
12
|
+
format: '%n%u'
|
13
|
+
separator: ","
|
14
|
+
delimiter: ""
|
15
|
+
|
16
|
+
percentage:
|
17
|
+
format:
|
18
|
+
delimiter: ""
|
19
|
+
|
20
|
+
precision:
|
21
|
+
format:
|
22
|
+
delimiter: ""
|
23
|
+
|
24
|
+
paypal:
|
25
|
+
format:
|
26
|
+
precision: 0
|
@@ -0,0 +1,26 @@
|
|
1
|
+
il:
|
2
|
+
number:
|
3
|
+
format:
|
4
|
+
separator: "."
|
5
|
+
delimiter: ","
|
6
|
+
precision: 2
|
7
|
+
significant: false
|
8
|
+
strip_insignificant_zeros: false
|
9
|
+
|
10
|
+
currency:
|
11
|
+
format:
|
12
|
+
format: "%u%n"
|
13
|
+
unit: "₪"
|
14
|
+
separator: "."
|
15
|
+
delimiter: ","
|
16
|
+
precision: 2
|
17
|
+
significant: false
|
18
|
+
strip_insignificant_zeros: false
|
19
|
+
|
20
|
+
percentage:
|
21
|
+
format:
|
22
|
+
delimiter: ""
|
23
|
+
|
24
|
+
precision:
|
25
|
+
format:
|
26
|
+
delimiter: ","
|