bullet_train-themes 1.0.22 → 1.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/theme_helper.rb +1 -1
- data/app/views/themes/base/attributes/_image.html.erb +3 -1
- data/app/views/themes/base/attributes/_options.html.erb +2 -1
- data/lib/bullet_train/themes/version.rb +1 -1
- data/lib/bullet_train/themes.rb +9 -2
- data/lib/tasks/application.rb +41 -0
- data/lib/tasks/bullet_train/themes_tasks.rake +9 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4623fb873c292890f3bd1ec62a2897c7bd88870c46bd90f40af765a0b390cae
|
4
|
+
data.tar.gz: b18cb50bc536b5a48f210d0c0ff04a47244a7df494cb372e0ae7323aa3cbd7c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9b7d7f10d640bd3819bcff57c04d1b7db16dd834ee8007fdaa32cab4a125bb404222ae9b8e9d97f85a0ecb0e8f65f39dacf6a51e50cce8b3c0ab614dd4789c0
|
7
|
+
data.tar.gz: ed14ca4bd4d3c531e0d73235164e7c41e2c9f8ce5fc9aff809ac07e08ddeb3c67416a8df24b9a0e70b3911c97c536b9c60e3b5e932f2786aba63f73720d95ac5
|
data/app/helpers/theme_helper.rb
CHANGED
@@ -36,7 +36,7 @@ end
|
|
36
36
|
|
37
37
|
module ThemeHelper
|
38
38
|
def current_theme_object
|
39
|
-
BulletTrain::Themes.
|
39
|
+
@current_theme_object ||= "BulletTrain::Themes::#{current_theme.to_s.classify}::Theme".constantize.new
|
40
40
|
end
|
41
41
|
|
42
42
|
def render(options = {}, locals = {}, &block)
|
@@ -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),
|
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
|
-
|
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 %>
|
data/lib/bullet_train/themes.rb
CHANGED
@@ -32,12 +32,19 @@ module BulletTrain
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def resolved_partial_path_for(lookup_context, path, locals)
|
35
|
-
#
|
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
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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.
|
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-
|
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:
|