bullet_train-themes 1.0.23 → 1.0.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6ec7ac778169e393502c1149e3ef264ff92c8bd142ec3348a2fb986ea38b98b
4
- data.tar.gz: 7c11f42d705cd7a20efd93c0a1b59ce739319aea04770a1cd733fdb27589006c
3
+ metadata.gz: d4623fb873c292890f3bd1ec62a2897c7bd88870c46bd90f40af765a0b390cae
4
+ data.tar.gz: b18cb50bc536b5a48f210d0c0ff04a47244a7df494cb372e0ae7323aa3cbd7c3
5
5
  SHA512:
6
- metadata.gz: b1c5e71cb2161fedd8764c51926620c0ba0b156385e75901e00cba9db7a8aa63724e6ac3b1b815e70684dfcbe4206553b4e497c34926f8393fedcd7c17afa19f
7
- data.tar.gz: 9f731798611e2fcd61c206741fc7e881f3045c7ad6ce47ade05a8a2435fbeb071372fbc1cff178474443d552430edebd5b97b7ce1a51eb8a973035e9e188ea6a
6
+ metadata.gz: b9b7d7f10d640bd3819bcff57c04d1b7db16dd834ee8007fdaa32cab4a125bb404222ae9b8e9d97f85a0ecb0e8f65f39dacf6a51e50cce8b3c0ab614dd4789c0
7
+ data.tar.gz: ed14ca4bd4d3c531e0d73235164e7c41e2c9f8ce5fc9aff809ac07e08ddeb3c67416a8df24b9a0e70b3911c97c536b9c60e3b5e932f2786aba63f73720d95ac5
@@ -1,5 +1,7 @@
1
1
  <% object ||= current_attributes_object %>
2
2
  <% strategy ||= current_attributes_strategy || :none %>
3
3
  <% url ||= nil %>
4
+ <% options ||= {} %>
5
+ <% options[:height] ||= 200 %>
4
6
 
5
- <%= cloudinary_image_tag object.send(attribute), height: 200 %>
7
+ <%= cloudinary_image_tag object.send(attribute), options %>
@@ -4,7 +4,8 @@
4
4
 
5
5
  <% if object.send(attribute).any? %>
6
6
  <%= render 'shared/attributes/attribute', object: object, attribute: attribute, strategy: strategy, url: url do %>
7
- <%= object.send(attribute).map do |value| %>
7
+ <%# TODO: Multiple option partials return arrays with blank characters in them. Is this expected? %>
8
+ <%= object.send(attribute).reject(&:blank?).map do |value| %>
8
9
  <% t("#{object.class.name.underscore.pluralize}.fields.#{attribute}.options.#{value}") %>
9
10
  <% end.map(&:strip).to_sentence %>
10
11
  <% end %>
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module Themes
3
- VERSION = "1.0.23"
3
+ VERSION = "1.0.24"
4
4
  end
5
5
  end
@@ -32,12 +32,19 @@ module BulletTrain
32
32
  end
33
33
 
34
34
  def resolved_partial_path_for(lookup_context, path, locals)
35
- # TODO This caching should be disabled in development so new templates are taken into account without restarting the server.
35
+ # We disable partial path caching in development so new templates are taken into account without restarting the server.
36
+ partial_paths = {}
37
+
36
38
  BulletTrain::Themes.partial_paths.fetch(path) do
37
39
  if (theme_path = BulletTrain::Themes.theme_invocation_path_for(path))
38
40
  # TODO directory_order should probably come from the `Current` model.
39
41
  if (partial = lookup_context.find_all(theme_path, directory_order.map { "themes/#{_1}" }, true, locals.keys).first)
40
- BulletTrain::Themes.partial_paths[path] = partial.virtual_path.gsub("/_", "/")
42
+ resolved_partial = partial.virtual_path.gsub("/_", "/")
43
+ if Rails.env.development?
44
+ partial_paths[path] = resolved_partial
45
+ else
46
+ BulletTrain::Themes.partial_paths[path] = resolved_partial
47
+ end
41
48
  end
42
49
  end
43
50
  end
@@ -0,0 +1,41 @@
1
+ module BulletTrain
2
+ module Themes
3
+ module Application
4
+ def self.install_theme(theme_name)
5
+ unless theme_name == "light" || Dir.exist?("app/views/themes/#{theme_name}")
6
+ raise "We could not find '#{theme_name}'. Please eject Bullet Train's standard views to your main application first by using `rake bullet_train:themes:light:eject[custom_theme_name_here]`".red
7
+ end
8
+
9
+ # Grabs the current theme from
10
+ # def current_theme
11
+ # :theme_name
12
+ # end
13
+ current_theme_regexp = /(^ :)(.*)/
14
+ current_theme = nil
15
+
16
+ new_lines = []
17
+ [
18
+ "./app/helpers/application_helper.rb",
19
+ "./Procfile.dev",
20
+ "./package.json"
21
+ ].each do |file|
22
+ File.open(file, "r") do |f|
23
+ new_lines = f.readlines
24
+ new_lines = new_lines.map do |line|
25
+ # Make sure we get the current theme before trying to replace it in any of the files.
26
+ # We grab it from the first file in the array above.
27
+ current_theme = line.scan(current_theme_regexp).flatten.last if line.match?(current_theme_regexp)
28
+
29
+ line.gsub!(/#{current_theme}/, theme_name) unless current_theme.nil?
30
+ line
31
+ end
32
+ end
33
+
34
+ File.open(file, "w") do |f|
35
+ f.puts new_lines.join
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,4 +1,9 @@
1
- # desc "Explaining what the task does"
2
- # task :bullet_train_themes do
3
- # # Task goes here
4
- # end
1
+ require_relative "../application"
2
+
3
+ namespace :bullet_train do
4
+ namespace :themes do
5
+ task :install, [:theme_name] => :environment do |task, args|
6
+ BulletTrain::Themes::Application.install_theme(args[:theme_name])
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-themes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.23
4
+ version: 1.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-24 00:00:00.000000000 Z
11
+ date: 2022-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard
@@ -80,6 +80,7 @@ files:
80
80
  - lib/bullet_train/themes.rb
81
81
  - lib/bullet_train/themes/engine.rb
82
82
  - lib/bullet_train/themes/version.rb
83
+ - lib/tasks/application.rb
83
84
  - lib/tasks/bullet_train/themes_tasks.rake
84
85
  homepage: https://github.com/bullet-train-co/bullet_train-themes
85
86
  licenses: