odania 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +63 -21
  3. data/Guardfile +31 -0
  4. data/Rakefile +1 -0
  5. data/config/varnish_config.json +4 -2
  6. data/lib/odania/{plugin_config/models → config}/backend.rb +1 -1
  7. data/lib/odania/{plugin_config/models → config}/backend_group.rb +7 -2
  8. data/lib/odania/config/domain.rb +55 -0
  9. data/lib/odania/config/duplicates.rb +28 -0
  10. data/lib/odania/config/global_config.rb +154 -0
  11. data/lib/odania/config/internal.rb +48 -0
  12. data/lib/odania/config/layout.rb +35 -0
  13. data/lib/odania/config/page.rb +28 -0
  14. data/lib/odania/config/plugin_config.rb +51 -0
  15. data/lib/odania/config/style.rb +60 -0
  16. data/lib/odania/config/sub_domain.rb +125 -0
  17. data/lib/odania/config.rb +16 -0
  18. data/lib/odania/consul.rb +6 -2
  19. data/lib/odania/erb.rb +154 -0
  20. data/lib/odania/plugin.rb +12 -5
  21. data/lib/odania/plugin_config/{plugin_config.rb → base.rb} +26 -31
  22. data/lib/odania/varnish/generators/generate_backend_vcl.rb +12 -0
  23. data/lib/odania/varnish/generators/generate_site_vcl.rb +16 -0
  24. data/lib/odania/varnish/generators/generate_sites_vcl.rb +0 -4
  25. data/lib/odania/varnish.rb +11 -12
  26. data/lib/odania/version.rb +1 -1
  27. data/lib/odania.rb +7 -1
  28. data/odania.gemspec +3 -0
  29. data/spec/fixtures/global_config.json +142 -0
  30. data/spec/fixtures/plugin_config_1.json +93 -0
  31. data/spec/lib/odania/config/global_config_spec.rb +67 -0
  32. data/spec/lib/odania/config/plugin_config_spec.rb +28 -0
  33. data/spec/lib/odania/erb_spec.rb +16 -0
  34. data/spec/lib/odania/plugin_spec.rb +25 -0
  35. data/spec/lib/odania/varnish_spec.rb +37 -0
  36. data/spec/spec_helper.rb +15 -0
  37. data/spec/support/consul_mock.rb +116 -0
  38. data/tasks/odania.rake +1 -5
  39. data/templates/varnish/backend.vcl.erb +7 -1
  40. data/templates/varnish/catch_all.vcl.erb +1 -0
  41. data/templates/varnish/default.vcl.erb +1 -0
  42. data/templates/varnish/general.vcl.erb +29 -13
  43. data/templates/varnish/general_site.vcl.erb +33 -0
  44. data/templates/varnish/redirects.vcl.erb +1 -0
  45. data/templates/varnish/site.vcl.erb +18 -8
  46. data/templates/varnish/sites.vcl.erb +1 -1
  47. data/templates/varnish/websocker.vcl.erb +1 -0
  48. metadata +79 -19
  49. data/lib/odania/plugin_config/models/domain.rb +0 -38
  50. data/lib/odania/plugin_config/models/layout.rb +0 -31
  51. data/lib/odania/plugin_config/models/page.rb +0 -23
  52. data/lib/odania/plugin_config/models/redirect.rb +0 -20
  53. data/lib/odania/plugin_config/models/sub_domain.rb +0 -99
  54. data/lib/odania/template/asset.rb +0 -15
  55. data/lib/odania/template/config.rb +0 -15
  56. data/lib/odania/template/page.rb +0 -16
  57. data/lib/odania/template.rb +0 -8
  58. data/lib/odania/varnish/generators/generate_site_assets_vcl.rb +0 -27
  59. data/templates/varnish/site_assets.vcl.erb +0 -24
  60. /data/spec/{odania → lib}/odania_spec.rb +0 -0
@@ -0,0 +1,33 @@
1
+ vcl 4.0;
2
+ # generated varnish config: <%= ENVIRONMENT %>
3
+ # local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
4
+
5
+ sub vcl_recv {
6
+ std.log("pre varnish log info _general:" + req.http.host);
7
+
8
+ <% %w(direct dynamic).each do |type| %>
9
+ <% general_subdomain[type].each_pair do |url, page| %>
10
+ if (req.url ~ "^<%= prepare_url url %>") {
11
+ std.log("general page identified Page:'<%= url %>':" + req.url);
12
+
13
+ <% if 'direct'.eql? type %>
14
+ set req.backend_hint = <%= page.director %>.backend();
15
+ <% unless page.plugin_url.nil? %>set req.url = "<%= page.plugin_url %>";<% end %>
16
+ <% else %>
17
+ set req.backend_hint = core_backend_director.backend();
18
+ set req.url = "/template/page?req_url=" + req.url + "&req_host=" + req.http.host + "<%= template_url_for(domain, page) %>";
19
+ <% end %>
20
+
21
+ return (hash);
22
+ }
23
+ <% end %>
24
+ <% end %>
25
+
26
+ <% general_subdomain.get_redirects.each_pair do |src, target| %>
27
+ if (req.url ~ "<%= src %>") {
28
+ std.log("general redirect identified src:'<%= src %>':" + req.url);
29
+ set req.http.Location = "<%= target %>";
30
+ return (synth(750, "Permanently moved"));
31
+ }
32
+ <% end %>
33
+ }
@@ -1,5 +1,6 @@
1
1
  vcl 4.0;
2
2
  # generated varnish config: <%= ENVIRONMENT %>
3
+ # local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
3
4
 
4
5
  sub vcl_recv {
5
6
  <% redirects.each_pair do |src, target| %>
@@ -3,6 +3,7 @@ is_first = true
3
3
  %>
4
4
  vcl 4.0;
5
5
  # generated varnish config: <%= ENVIRONMENT %>
6
+ # local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
6
7
 
7
8
  sub vcl_recv {
8
9
  std.log("pre varnish log info '<%= domain.name %>':" + req.http.host);
@@ -13,13 +14,22 @@ sub vcl_recv {
13
14
  <%= is_first ? '' : 'else ' %>if (req.http.host ~ "^<%= subdomain.name %>.<%= domain.name %>$") {
14
15
  std.log("subdomain identified '<%= subdomain.name %>.<%= domain.name %>':" + req.http.host + " url: " + req.url );
15
16
 
16
- <% subdomain.pages.each do |page| %>
17
- if (req.url ~ "^<%= page.url %>") {
18
- std.log("page identified '<%= subdomain.name %>.<%= domain.name %>' Page:'<%= page.url %>':" + req.url);
19
-
20
- set req.backend_hint = <%= page.director %>.backend();
21
- <% unless page.backend_url.nil? %>set req.url = "<%= page.backend_url %>";<% end %>
22
- }
17
+ <% %w(direct dynamic).each do |type| %>
18
+ <% subdomain[type].each_pair do |url, page| %>
19
+ if (req.url ~ "^<%= prepare_url url %>") {
20
+ std.log("page identified '<%= subdomain.name %>.<%= domain.name %>' Page:'<%= url %>':" + req.url);
21
+
22
+ <% if 'direct'.eql? type %>
23
+ set req.backend_hint = <%= page.director %>.backend();
24
+ <% unless page.plugin_url.nil? %>set req.url = "<%= page.plugin_url %>";<% end %>
25
+ <% else %>
26
+ set req.backend_hint = core_backend_director.backend();
27
+ set req.url = "/template/page?req_url=" + req.url + "&req_host=" + req.http.host + "<%= template_url_for(domain, page) %>";
28
+ <% end %>
29
+
30
+ return (hash);
31
+ }
32
+ <% end %>
23
33
  <% end %>
24
34
 
25
35
  <% subdomain.get_redirects.each_pair do |src, target| %>
@@ -34,7 +44,7 @@ sub vcl_recv {
34
44
  <% is_first = false %>
35
45
  <% end %>
36
46
 
37
- else {
47
+ <%= is_first ? '' : 'else' %> {
38
48
  # Redirect to default
39
49
  std.log("varnish log info 'redirect to default':" + req.url);
40
50
  set req.http.Location = "http://<%= default_subdomain_for(domain) %>.<%= domain.name %>" + req.url;
@@ -1,10 +1,10 @@
1
1
  vcl 4.0;
2
2
  # generated varnish config: <%= ENVIRONMENT %>
3
+ # local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
3
4
 
4
5
  # @see https://www.varnish-cache.org/lists/pipermail/varnish-misc/2011-January/005449.html
5
6
 
6
7
  # Sites
7
8
  <% domains.each_pair do |domain_name, domain| %>
8
9
  include "/etc/varnish/sites/<%= domain_name %>.vcl";
9
- include "/etc/varnish/sites/<%= domain_name %>_assets.vcl";
10
10
  <% end %>
@@ -1,5 +1,6 @@
1
1
  vcl 4.0;
2
2
  # generated varnish config: <%= ENVIRONMENT %>
3
+ # local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
3
4
  # https://www.varnish-cache.org/docs/4.0/users-guide/vcl-example-websockets.html
4
5
 
5
6
  sub vcl_pipe {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odania
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Petersen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-03 00:00:00.000000000 Z
11
+ date: 2016-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: diplomat
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +136,20 @@ dependencies:
108
136
  - - ">="
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: deep_merge
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
111
153
  description: Helper for the odania portal
112
154
  email:
113
155
  - mike@odania-it.de
@@ -118,6 +160,7 @@ files:
118
160
  - ".gitignore"
119
161
  - Gemfile
120
162
  - Gemfile.lock
163
+ - Guardfile
121
164
  - LICENSE.txt
122
165
  - README.md
123
166
  - Rakefile
@@ -128,42 +171,51 @@ files:
128
171
  - features/support/env.rb
129
172
  - features/varnish.feature
130
173
  - lib/odania.rb
174
+ - lib/odania/config.rb
175
+ - lib/odania/config/backend.rb
176
+ - lib/odania/config/backend_group.rb
177
+ - lib/odania/config/domain.rb
178
+ - lib/odania/config/duplicates.rb
179
+ - lib/odania/config/global_config.rb
180
+ - lib/odania/config/internal.rb
181
+ - lib/odania/config/layout.rb
182
+ - lib/odania/config/page.rb
183
+ - lib/odania/config/plugin_config.rb
184
+ - lib/odania/config/style.rb
185
+ - lib/odania/config/sub_domain.rb
131
186
  - lib/odania/consul.rb
187
+ - lib/odania/erb.rb
132
188
  - lib/odania/plugin.rb
133
- - lib/odania/plugin_config/models/backend.rb
134
- - lib/odania/plugin_config/models/backend_group.rb
135
- - lib/odania/plugin_config/models/domain.rb
136
- - lib/odania/plugin_config/models/layout.rb
137
- - lib/odania/plugin_config/models/page.rb
138
- - lib/odania/plugin_config/models/redirect.rb
139
- - lib/odania/plugin_config/models/sub_domain.rb
140
- - lib/odania/plugin_config/plugin_config.rb
141
- - lib/odania/template.rb
142
- - lib/odania/template/asset.rb
143
- - lib/odania/template/config.rb
144
- - lib/odania/template/page.rb
189
+ - lib/odania/plugin_config/base.rb
145
190
  - lib/odania/varnish.rb
146
191
  - lib/odania/varnish/generators/generate_backend_vcl.rb
147
192
  - lib/odania/varnish/generators/generate_catch_all_vcl.rb
148
193
  - lib/odania/varnish/generators/generate_default_vcl.rb
149
194
  - lib/odania/varnish/generators/generate_general_vcl.rb
150
195
  - lib/odania/varnish/generators/generate_redirects_vcl.rb
151
- - lib/odania/varnish/generators/generate_site_assets_vcl.rb
152
196
  - lib/odania/varnish/generators/generate_site_vcl.rb
153
197
  - lib/odania/varnish/generators/generate_sites_vcl.rb
154
198
  - lib/odania/version.rb
155
199
  - odania.gemspec
156
- - spec/odania/odania_spec.rb
200
+ - spec/fixtures/global_config.json
201
+ - spec/fixtures/plugin_config_1.json
202
+ - spec/lib/odania/config/global_config_spec.rb
203
+ - spec/lib/odania/config/plugin_config_spec.rb
204
+ - spec/lib/odania/erb_spec.rb
205
+ - spec/lib/odania/plugin_spec.rb
206
+ - spec/lib/odania/varnish_spec.rb
207
+ - spec/lib/odania_spec.rb
157
208
  - spec/spec_helper.rb
209
+ - spec/support/consul_mock.rb
158
210
  - tasks/odania.rake
159
211
  - tasks/rspec.rake
160
212
  - templates/varnish/backend.vcl.erb
161
213
  - templates/varnish/catch_all.vcl.erb
162
214
  - templates/varnish/default.vcl.erb
163
215
  - templates/varnish/general.vcl.erb
216
+ - templates/varnish/general_site.vcl.erb
164
217
  - templates/varnish/redirects.vcl.erb
165
218
  - templates/varnish/site.vcl.erb
166
- - templates/varnish/site_assets.vcl.erb
167
219
  - templates/varnish/sites.vcl.erb
168
220
  - templates/varnish/websocker.vcl.erb
169
221
  homepage: http://www.odania.com
@@ -186,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
238
  version: '0'
187
239
  requirements: []
188
240
  rubyforge_project:
189
- rubygems_version: 2.4.6
241
+ rubygems_version: 2.4.8
190
242
  signing_key:
191
243
  specification_version: 4
192
244
  summary: Helper for the odania portal
@@ -196,5 +248,13 @@ test_files:
196
248
  - features/step_definitions/varnish_steps.rb
197
249
  - features/support/env.rb
198
250
  - features/varnish.feature
199
- - spec/odania/odania_spec.rb
251
+ - spec/fixtures/global_config.json
252
+ - spec/fixtures/plugin_config_1.json
253
+ - spec/lib/odania/config/global_config_spec.rb
254
+ - spec/lib/odania/config/plugin_config_spec.rb
255
+ - spec/lib/odania/erb_spec.rb
256
+ - spec/lib/odania/plugin_spec.rb
257
+ - spec/lib/odania/varnish_spec.rb
258
+ - spec/lib/odania_spec.rb
200
259
  - spec/spec_helper.rb
260
+ - spec/support/consul_mock.rb
@@ -1,38 +0,0 @@
1
- module Odania
2
- module PluginConfig
3
- class Domain
4
- attr_accessor :name, :subdomains
5
-
6
- def initialize(name)
7
- self.name = name
8
- self.subdomains = Hash.new { |hash, key| hash[key] = SubDomain.new(key) }
9
- end
10
-
11
- def add_subdomain(subdomain_name)
12
- self.subdomains[subdomain_name]
13
- end
14
-
15
- def dump
16
- subdomain_data = {}
17
- subdomains.each_pair do |name, subdomain|
18
- subdomain_data[name] = subdomain.dump
19
- end
20
-
21
- {
22
- 'name' => name,
23
- 'subdomains' => subdomain_data
24
- }
25
- end
26
-
27
- def load(data)
28
- self.name = data['name']
29
-
30
- unless data['subdomains'].nil?
31
- data['subdomains'].each_pair do |name, data|
32
- self.subdomains[name].load(data)
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,31 +0,0 @@
1
- module Odania
2
- module PluginConfig
3
- class Layout
4
- attr_accessor :config
5
-
6
- def initialize
7
- @plugins = []
8
- end
9
-
10
- def set_config(config, plugin_name)
11
- result = true
12
- self.config = config
13
- result = false unless @plugins.empty?
14
- @plugins << plugin_name
15
- result
16
- end
17
-
18
- def plugins
19
- @plugins
20
- end
21
-
22
- def dump
23
- config
24
- end
25
-
26
- def load(data)
27
- self.config = data
28
- end
29
- end
30
- end
31
- end
@@ -1,23 +0,0 @@
1
- module Odania
2
- module PluginConfig
3
- class Page
4
- attr_accessor :group_name, :plugin_url
5
-
6
- def dump
7
- {
8
- 'group_name' => group_name,
9
- 'plugin_url' => plugin_url
10
- }
11
- end
12
-
13
- def load(data)
14
- self.group_name = data['group_name']
15
- self.plugin_url = data['plugin_url']
16
- end
17
-
18
- def director
19
- "#{Odania.varnish_sanitize(group_name)}_director"
20
- end
21
- end
22
- end
23
- end
@@ -1,20 +0,0 @@
1
- module Odania
2
- module PluginConfig
3
- class Redirect
4
- attr_accessor :src, :target, :plugins
5
-
6
- def initialize(src)
7
- self.src = src
8
- self.plugins = []
9
- end
10
-
11
- def add(target, plugin_name)
12
- self.target = target
13
- self.plugins << plugin_name
14
-
15
- return false if self.plugins.count > 1
16
- true
17
- end
18
- end
19
- end
20
- end
@@ -1,99 +0,0 @@
1
- module Odania
2
- module PluginConfig
3
- class SubDomain
4
- attr_accessor :name, :pages, :config, :assets, :from_plugin
5
-
6
- def initialize(name)
7
- self.name = name
8
- self.config = {}
9
- self.from_plugin = {:config => Hash.new { |hash, key| hash[key] = [] }}
10
- self.pages = Hash.new { |hash, key| hash[key] = Page.new }
11
- self.assets = Hash.new { |hash, key| hash[key] = Page.new }
12
- @plugins = {:page => Hash.new { |hash, key| hash[key] = [] }, :asset => Hash.new { |hash, key| hash[key] = [] }}
13
- end
14
-
15
- def set_config(config_data, group_name)
16
- errors = []
17
- config_data.each_pair do |key, val|
18
- from_plugin[:config][key] << group_name
19
- errors << {:type => :config, :plugins => from_plugin[:config][key], :key => key} unless config[key].nil?
20
- config[key] = val
21
- end
22
- errors
23
- end
24
-
25
- def add_page(web_url, group_name, plugin_url, plugin_name)
26
- result = true
27
- result = false unless self.assets.key? web_url
28
- self.pages[web_url].group_name = group_name
29
- self.pages[web_url].plugin_url = plugin_url
30
- @plugins[:page][web_url] << plugin_name
31
- result
32
- end
33
-
34
- def add_asset(web_url, group_name, plugin_url, plugin_name)
35
- result = true
36
- result = false unless self.assets.key? web_url
37
- self.assets[web_url].group_name = group_name
38
- self.assets[web_url].plugin_url = plugin_url
39
- @plugins[:asset][web_url] << plugin_name
40
- result
41
- end
42
-
43
- def get_redirects
44
- return {} if self.config.nil?
45
- return {} if self.config['redirects'].nil?
46
- self.config['redirects']
47
- end
48
-
49
- def plugins(type, key)
50
- @plugins[type][key]
51
- end
52
-
53
- def dump
54
- page_data = {}
55
- pages.each_pair do |web_url, page|
56
- page_data[web_url] = page.dump
57
- end
58
-
59
- asset_data = {}
60
- assets.each_pair do |web_url, page|
61
- asset_data[web_url] = page.dump
62
- end
63
-
64
- {
65
- 'name' => name,
66
- 'config' => config,
67
- 'pages' => page_data,
68
- 'assets' => asset_data
69
- }
70
- end
71
-
72
- def load(data)
73
- reset
74
- self.config = data['config']
75
-
76
- unless data['pages'].nil?
77
- data['pages'].each_pair do |name, data|
78
- self.pages[name].load(data)
79
- end
80
- end
81
-
82
- unless data['assets'].nil?
83
- data['assets'].each_pair do |name, data|
84
- self.assets[name].load(data)
85
- end
86
- end
87
- end
88
-
89
- private
90
-
91
- def reset
92
- self.from_plugin = {:config => Hash.new { |hash, key| hash[key] = [] }}
93
- self.pages = Hash.new { |hash, key| hash[key] = Page.new }
94
- self.assets = Hash.new { |hash, key| hash[key] = Page.new }
95
- @plugins = {:page => Hash.new { |hash, key| hash[key] = [] }, :asset => Hash.new { |hash, key| hash[key] = [] }}
96
- end
97
- end
98
- end
99
- end
@@ -1,15 +0,0 @@
1
- module Odania
2
- module Template
3
- class Asset
4
- attr_accessor :assets
5
-
6
- def initialize
7
- self.assets = Hash.new
8
- end
9
-
10
- def get(key)
11
- self.assets[key]
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Odania
2
- module Template
3
- class Config
4
- attr_accessor :config
5
-
6
- def initialize
7
- self.config = Hash.new
8
- end
9
-
10
- def get(key)
11
- self.config[key]
12
- end
13
- end
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- module Odania
2
- module Template
3
- class Page
4
- attr_accessor :pages
5
-
6
- def initialize
7
- self.pages = Hash.new
8
- end
9
-
10
- def get(key)
11
- "<esi:include src=\"/cgi-bin/date.cgi\"/>"
12
- self.pages[key]
13
- end
14
- end
15
- end
16
- end
@@ -1,8 +0,0 @@
1
- require_relative 'template/asset'
2
- require_relative 'template/config'
3
- require_relative 'template/page'
4
-
5
- module Odania
6
- module Template
7
- end
8
- end
@@ -1,27 +0,0 @@
1
- module Odania
2
- class GenerateSiteAssetsVcl
3
- attr_accessor :domain, :assets, :template
4
-
5
- def initialize(domain)
6
- self.domain = domain
7
- self.template = File.new("#{BASE_DIR}/templates/varnish/site_assets.vcl.erb").read
8
-
9
- self.assets = Hash.new { |hash, key| hash[key] = Odania::PluginConfig::SubDomain.new(key) }
10
- domain.subdomains.each_pair do |subdomain_name, subdomain|
11
- asset_domain = subdomain.config['asset_url'].nil? ? "#{subdomain.name}.#{domain.name}" : subdomain.config['asset_url']
12
-
13
- subdomain.assets.each_pair do |src, page|
14
- self.assets[asset_domain].assets[src] = page
15
- end
16
- end
17
- end
18
-
19
- def render
20
- Erubis::Eruby.new(self.template).result(binding)
21
- end
22
-
23
- def write(out_dir)
24
- File.write("#{out_dir}/sites/#{self.domain.name}_assets.vcl", self.render)
25
- end
26
- end
27
- end
@@ -1,24 +0,0 @@
1
- <%
2
- is_first = true
3
- %>
4
- vcl 4.0;
5
- # generated varnish config: <%= ENVIRONMENT %>
6
-
7
- sub vcl_recv {
8
- <% assets.each_pair do |asset_domain, subdomain| %>
9
- <%= is_first ? '' : 'else ' %>if (req.http.host ~ "^<%= asset_domain %>$") {
10
- std.log("subdomain identified assets '<%= asset_domain %>':" + req.http.host + " url: " + req.url );
11
-
12
- <% subdomain.assets.each_pair do |src, page| %>
13
- if (req.url ~ "^<%= src %>") {
14
- std.log("page identified assets '<%= asset_domain %>' Page:'<%= src %>':" + req.url);
15
-
16
- set req.backend_hint = <%= page.director %>.backend();
17
- <% unless page.plugin_url.nil? %>set req.url = "<%= page.plugin_url %>";<% end %>
18
- }
19
- <% end %>
20
-
21
- }
22
- <% is_first = false %>
23
- <% end %>
24
- }
File without changes