roger_themes 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/roger_themes/manifest.rb +2 -0
- data/lib/roger_themes/middleware.rb +13 -5
- data/lib/roger_themes/processor.rb +12 -7
- data/lib/roger_themes/theme.rb +12 -1
- data/lib/roger_themes/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8c0420e45b64eb7bb1249b9a715f37c8a75a6220
|
|
4
|
+
data.tar.gz: c62ac39fb65807afa30fd5c888ed3bce288aa9ca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c46652f12dc3c238a624c8980b1d041d3e473095750bf03fecd233da66b283f4b20a8ca861e98814b07d688d1f78bb60b7e5d6ee974f59f0f98cfeb4448e8fd9
|
|
7
|
+
data.tar.gz: 800c20999641f4c6027c0987ddd6a7d5a382655069495d7f3d383fbb247f5243c1e299aedeac5c96b5ea93f9c0f53a8f676fd3c0321d0ea4bd0eda051dcef4c2
|
data/README.md
CHANGED
|
@@ -48,6 +48,11 @@ mockup.release do |r|
|
|
|
48
48
|
|
|
49
49
|
## Changelog
|
|
50
50
|
|
|
51
|
+
### v0.7.0
|
|
52
|
+
* Allow config of shard folders in manifest files
|
|
53
|
+
* Allow disabling of shared templates in manifest files
|
|
54
|
+
* Make sure all templates in a theme folder are processed with the theme env variables set.
|
|
55
|
+
|
|
51
56
|
### v0.6.0
|
|
52
57
|
* Attention! `env["SITE_THEME"]` has been renamed to `env["MAIN_THEME"]`. Also it will now return a `RogerThemes::Theme` object instead of a string. The old behaviour can be restored by replacing `env["SITE_THEME"]` with `env["MAIN_THEME"].name`
|
|
53
58
|
* Add compatibility for subthemes
|
|
@@ -13,7 +13,6 @@ module RogerThemes
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@options = defaults.update(options)
|
|
16
|
-
@shared_folders = SharedFolders.new(@options[:shared_folders])
|
|
17
16
|
end
|
|
18
17
|
|
|
19
18
|
def call(env)
|
|
@@ -21,27 +20,36 @@ module RogerThemes
|
|
|
21
20
|
themes_path = project.html_path + RogerThemes.themes_path
|
|
22
21
|
|
|
23
22
|
path = ::Rack::Utils.unescape(env["PATH_INFO"])
|
|
24
|
-
|
|
23
|
+
|
|
24
|
+
# Regexp to match the theme url
|
|
25
|
+
theme_url_regex = /\A\/#{Regexp.escape(RogerThemes.themes_path)}\/([^\/]+)\//
|
|
26
|
+
shared_url_regex = Regexp.new(theme_url_regex.to_s + "theme\/")
|
|
25
27
|
|
|
26
28
|
env["SUB_THEME"] = nil
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
# Set the theme ENV paramaters
|
|
31
|
+
if theme = path[theme_url_regex,1]
|
|
29
32
|
main_theme, sub_theme = theme.split(".", 2)
|
|
30
33
|
orig_path = env["PATH_INFO"].dup
|
|
31
34
|
env["MAIN_THEME"] = Theme.new(main_theme, themes_path)
|
|
32
35
|
env["SUB_THEME"] = Theme.new(sub_theme, themes_path) if sub_theme
|
|
33
|
-
env["PATH_INFO"].sub!(r,"")
|
|
34
36
|
else
|
|
35
37
|
# Set default theme
|
|
36
38
|
env["MAIN_THEME"] = Theme.new(@options[:default_theme], themes_path)
|
|
37
39
|
end
|
|
38
40
|
|
|
41
|
+
# See if we have to render shared paths on /THEMES_PATH/THEME_NAME/theme/*
|
|
42
|
+
if env["MAIN_THEME"].shared_templates && shared_url_regex.match(path)
|
|
43
|
+
env["PATH_INFO"].sub!(shared_url_regex,"")
|
|
44
|
+
end
|
|
45
|
+
|
|
39
46
|
ret = @app.call(env)
|
|
40
47
|
|
|
41
48
|
# Fallback for shared images
|
|
42
49
|
if ret[0] == 404
|
|
50
|
+
shared_folders = SharedFolders.new(env["MAIN_THEME"].shared_folders || @options[:shared_folders])
|
|
43
51
|
|
|
44
|
-
shared_path =
|
|
52
|
+
shared_path = shared_folders.local_to_shared_path(path)
|
|
45
53
|
|
|
46
54
|
if shared_path
|
|
47
55
|
# Store so we can restore later
|
|
@@ -19,7 +19,6 @@ module RogerThemes
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def copy_templates_to_theme(template_files, template_root, theme_path)
|
|
22
|
-
puts "--> #{template_root} - #{theme_path}"
|
|
23
22
|
mkdir_p theme_path
|
|
24
23
|
|
|
25
24
|
template_files.each do |file|
|
|
@@ -29,11 +28,15 @@ module RogerThemes
|
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
def copy_shared_to_theme(theme, theme_path)
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
shared_folder_paths = theme.shared_folders || options[:shared_folders]
|
|
32
|
+
return if shared_folder_paths.empty?
|
|
33
|
+
|
|
34
|
+
release.debug self, "Copying shared assets from #{shared_folder_paths} for #{theme.name}"
|
|
35
|
+
shared_folders = SharedFolders.new(shared_folder_paths)
|
|
34
36
|
|
|
35
37
|
shared_folders.folders.each do |source, target|
|
|
36
38
|
if File.directory? release.build_path + source.to_s
|
|
39
|
+
mkdir_p File.dirname(theme_path + target)
|
|
37
40
|
cp_r release.build_path + "#{source}/.", theme_path + target
|
|
38
41
|
end
|
|
39
42
|
end
|
|
@@ -61,11 +64,13 @@ module RogerThemes
|
|
|
61
64
|
template_files = Dir.glob(release.project.html_path + options[:template_glob]).map{ |f| f.sub(release.project.html_path.to_s + "/", "") }
|
|
62
65
|
template_files.reject!{|c| options[:excludes].detect{|e| e.match(c) } }
|
|
63
66
|
|
|
64
|
-
release.debug self, "Copying theme files #{template_files.inspect}"
|
|
65
67
|
|
|
66
68
|
main_themes.each do |main_theme|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
if main_theme.shared_templates
|
|
70
|
+
release.debug self, "Copying theme files #{template_files.inspect}"
|
|
71
|
+
copy_templates_to_theme(template_files, release.project.html_path, main_theme.html_path)
|
|
72
|
+
end
|
|
73
|
+
mockup(main_theme.path, { "MAIN_THEME" => main_theme })
|
|
69
74
|
copy_shared_to_theme(main_theme, main_theme.path)
|
|
70
75
|
|
|
71
76
|
# Copy sub theme to MAINTHEME.SUBTHEME
|
|
@@ -76,7 +81,7 @@ module RogerThemes
|
|
|
76
81
|
copy_templates_to_theme(template_files, release.project.html_path, sub_theme_html_path)
|
|
77
82
|
|
|
78
83
|
# Run mockup
|
|
79
|
-
mockup(
|
|
84
|
+
mockup(sub_theme.path_in_main(main_theme.name), { "MAIN_THEME" => main_theme, "SUB_THEME" => sub_theme })
|
|
80
85
|
end
|
|
81
86
|
end
|
|
82
87
|
|
data/lib/roger_themes/theme.rb
CHANGED
|
@@ -18,7 +18,6 @@ module RogerThemes
|
|
|
18
18
|
|
|
19
19
|
def self.sub_themes_for(main_theme_name, themes_path)
|
|
20
20
|
all(themes_path).select{|theme| theme.type == "sub" && theme.compatible_with_main?(main_theme_name) }
|
|
21
|
-
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
def self.main_themes(themes_path)
|
|
@@ -55,6 +54,18 @@ module RogerThemes
|
|
|
55
54
|
@assets = manifest[:assets].map {|asset_data| Asset.new(asset_data, self) }
|
|
56
55
|
end
|
|
57
56
|
|
|
57
|
+
# Wether or not we take the toplevel templates
|
|
58
|
+
# and render them as our own.
|
|
59
|
+
def shared_templates
|
|
60
|
+
manifest[:shared_templates]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Shared folders to use. Will default to the
|
|
64
|
+
# globally set shared folders if nil or false
|
|
65
|
+
def shared_folders
|
|
66
|
+
manifest[:shared_folders]
|
|
67
|
+
end
|
|
68
|
+
|
|
58
69
|
def sub_themes
|
|
59
70
|
self.class.sub_themes_for(name, @themes_path)
|
|
60
71
|
end
|
data/lib/roger_themes/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: roger_themes
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Edwin van der Graaf
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2017-
|
|
12
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: roger
|