bullet_train-themes 1.0.23 → 1.2.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
  SHA256:
3
- metadata.gz: d6ec7ac778169e393502c1149e3ef264ff92c8bd142ec3348a2fb986ea38b98b
4
- data.tar.gz: 7c11f42d705cd7a20efd93c0a1b59ce739319aea04770a1cd733fdb27589006c
3
+ metadata.gz: f0a8a68b456d834d2bb372fd3ae037d66379621a09f3b4f17b5c7be760470ab9
4
+ data.tar.gz: 39ca624a3df73105989dd12ed57fc87e76bcc8c1820913cf19e6aac0eccbb7e1
5
5
  SHA512:
6
- metadata.gz: b1c5e71cb2161fedd8764c51926620c0ba0b156385e75901e00cba9db7a8aa63724e6ac3b1b815e70684dfcbe4206553b4e497c34926f8393fedcd7c17afa19f
7
- data.tar.gz: 9f731798611e2fcd61c206741fc7e881f3045c7ad6ce47ade05a8a2435fbeb071372fbc1cff178474443d552430edebd5b97b7ce1a51eb8a973035e9e188ea6a
6
+ metadata.gz: e461584901f5e75902dbca0a434456128297383aff160e8a1bc4d0cdd78a2538053d8e54a4ad316337a7aaadd859ed11687199835352203987e25b835c9c497e
7
+ data.tar.gz: ef9f8a3ab9d210111cab82d87fa38d5662a530090412abce954381e4294ba4724fcb6b8fe67eefe62174108b5c9c5e9cb96436d9c6b0f99cc709a0dba6357e4f
@@ -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.2.0"
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.2.0
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-15 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: