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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76fc57d42183dffca4cd97846cdf5874e3fd849d
4
- data.tar.gz: bbd6603a9c732670c0351b13edc29bdc05574735
3
+ metadata.gz: 8c0420e45b64eb7bb1249b9a715f37c8a75a6220
4
+ data.tar.gz: c62ac39fb65807afa30fd5c888ed3bce288aa9ca
5
5
  SHA512:
6
- metadata.gz: e5d6460310efd4822829c96890f1c9275f064957307e2b1d74dad16e96d3a50517673d2fa5021f19629af914e3decbc1ac8ee02de200cb0f72e4dad490bc8c45
7
- data.tar.gz: d0dd0779c0796010a7478050b2802e480693e35e730e771cb988ff171f2bbfc0e36d2d5aa4740b097cdfc29804a798cb3ad6c6dd709cbe2ba8355ff3a6a33743
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
@@ -7,6 +7,8 @@ module RogerThemes
7
7
  title: nil,
8
8
  type: "main",
9
9
  mains: nil,
10
+ shared_folders: nil,
11
+ shared_templates: true,
10
12
  assets: []
11
13
  }
12
14
 
@@ -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
- r = /\A\/#{Regexp.escape(RogerThemes.themes_path)}\/([^\/]+)\/theme\//
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
- if theme = path[r,1]
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 = @shared_folders.local_to_shared_path(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
- release.debug self, "Copying shared assets from #{options[:shared_folders]} for #{theme.name}"
33
- shared_folders = SharedFolders.new(options[:shared_folders])
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
- copy_templates_to_theme(template_files, release.project.html_path, main_theme.html_path)
68
- mockup(main_theme.html_path, { "MAIN_THEME" => main_theme })
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(sub_theme_html_path, { "MAIN_THEME" => main_theme, "SUB_THEME" => sub_theme })
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
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RogerThemes
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
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.6.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-04-20 00:00:00.000000000 Z
12
+ date: 2017-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: roger