lookbook 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/app/assets/lookbook/css/themes/blue.css +1 -1
- data/app/assets/lookbook/css/themes/green.css +66 -0
- data/app/assets/lookbook/css/themes/indigo.css +1 -1
- data/app/assets/lookbook/css/themes/rose.css +66 -0
- data/app/assets/lookbook/css/themes/zinc.css +1 -1
- data/app/components/lookbook/base_component.rb +2 -2
- data/app/components/lookbook/code/component.rb +2 -2
- data/app/components/lookbook/header/component.html.erb +1 -1
- data/app/components/lookbook/inspector_panel/component.rb +1 -1
- data/app/components/lookbook/nav/component.rb +8 -15
- data/app/components/lookbook/nav/directory/component.html.erb +26 -0
- data/app/components/lookbook/nav/directory/component.rb +4 -0
- data/app/components/lookbook/nav/{item → entity}/component.html.erb +5 -7
- data/app/components/lookbook/nav/entity/component.rb +49 -0
- data/app/components/lookbook/nav/item/component.css +15 -0
- data/app/components/lookbook/nav/item/component.js +4 -0
- data/app/components/lookbook/nav/item/component.rb +13 -56
- data/app/components/lookbook/tag_component.rb +1 -1
- data/app/components/lookbook/viewport/component.rb +1 -1
- data/app/controllers/concerns/lookbook/targetable_concern.rb +13 -38
- data/app/controllers/lookbook/application_controller.rb +9 -7
- data/app/controllers/lookbook/page_controller.rb +2 -2
- data/app/controllers/lookbook/pages_controller.rb +9 -15
- data/app/helpers/lookbook/application_helper.rb +2 -2
- data/app/helpers/lookbook/page_helper.rb +7 -4
- data/app/views/layouts/lookbook/application.html.erb +3 -4
- data/app/views/layouts/lookbook/page.html.erb +2 -2
- data/app/views/layouts/lookbook/shell.html.erb +2 -2
- data/app/views/layouts/lookbook/skeleton.html.erb +7 -7
- data/app/views/lookbook/index.html.erb +3 -3
- data/app/views/lookbook/inspector/panels/_params.html.erb +2 -2
- data/config/languages.yml +41 -0
- data/config/panels.yml +1 -1
- data/config/tags.yml +4 -0
- data/lib/lookbook/engine.rb +65 -43
- data/lib/lookbook/entities/collections/component_collection.rb +4 -0
- data/lib/lookbook/entities/collections/concerns/hierarchical_collection.rb +27 -0
- data/lib/lookbook/entities/collections/entity_collection.rb +66 -0
- data/lib/lookbook/entities/collections/page_collection.rb +30 -0
- data/lib/lookbook/entities/collections/preview_collection.rb +35 -0
- data/lib/lookbook/entities/collections/preview_example_collection.rb +9 -0
- data/lib/lookbook/entities/component.rb +31 -0
- data/lib/lookbook/entities/concerns/annotatable.rb +58 -0
- data/lib/lookbook/entities/concerns/inspectable.rb +44 -0
- data/lib/lookbook/entities/concerns/locatable.rb +73 -0
- data/lib/lookbook/entities/concerns/navigable.rb +27 -0
- data/lib/lookbook/entities/entity.rb +48 -0
- data/lib/lookbook/entities/page.rb +80 -0
- data/lib/lookbook/entities/page_section.rb +43 -0
- data/lib/lookbook/entities/preview.rb +87 -0
- data/lib/lookbook/entities/preview_example.rb +91 -0
- data/lib/lookbook/entities/preview_group.rb +48 -0
- data/lib/lookbook/file_watcher.rb +1 -1
- data/lib/lookbook/lang.rb +12 -35
- data/lib/lookbook/param.rb +2 -2
- data/lib/lookbook/preview_parser.rb +1 -1
- data/lib/lookbook/rendered_example.rb +37 -0
- data/lib/lookbook/services/code/code_beautifier.rb +1 -1
- data/lib/lookbook/services/code/code_highlighter.rb +1 -1
- data/lib/lookbook/services/code/code_indenter.rb +14 -0
- data/lib/lookbook/services/data/resolvers/data_resolver.rb +2 -2
- data/lib/lookbook/services/data/resolvers/method_resolver.rb +1 -1
- data/lib/lookbook/services/entities/entity_tree_builder.rb +45 -0
- data/lib/lookbook/services/position_prefix_parser.rb +16 -0
- data/lib/lookbook/stores/config_store.rb +1 -1
- data/lib/lookbook/stores/panel_store.rb +2 -2
- data/lib/lookbook/support/store.rb +1 -34
- data/lib/lookbook/support/tree_node.rb +83 -0
- data/lib/lookbook/support/utils/path_utils.rb +26 -2
- data/lib/lookbook/support/utils/utils.rb +24 -0
- data/lib/lookbook/tags/component_tag.rb +6 -0
- data/lib/lookbook/tags/custom_tag.rb +2 -0
- data/lib/lookbook/tags/id_tag.rb +1 -1
- data/lib/lookbook/tags/logical_path_tag.rb +3 -0
- data/lib/lookbook/tags/param_tag.rb +2 -0
- data/lib/lookbook/tags/position_tag.rb +1 -1
- data/lib/lookbook/tags/source_tag.rb +7 -0
- data/lib/lookbook/tags/yard_tag.rb +35 -7
- data/lib/lookbook/theme.rb +8 -0
- data/lib/lookbook/version.rb +1 -1
- data/lib/lookbook.rb +11 -7
- data/public/lookbook-assets/css/lookbook.css +55 -125
- data/public/lookbook-assets/css/lookbook.css.map +1 -1
- data/public/lookbook-assets/css/themes/blue.css.map +1 -1
- data/public/lookbook-assets/css/themes/green.css +68 -0
- data/public/lookbook-assets/css/themes/green.css.map +1 -0
- data/public/lookbook-assets/css/themes/indigo.css.map +1 -1
- data/public/lookbook-assets/css/themes/rose.css +68 -0
- data/public/lookbook-assets/css/themes/rose.css.map +1 -0
- data/public/lookbook-assets/css/themes/zinc.css.map +1 -1
- data/public/lookbook-assets/js/embed.js +9 -0
- data/public/lookbook-assets/js/embed.js.map +1 -1
- data/public/lookbook-assets/js/lookbook.js +288 -565
- data/public/lookbook-assets/js/lookbook.js.map +1 -1
- metadata +41 -18
- data/lib/lookbook/collection.rb +0 -161
- data/lib/lookbook/component.rb +0 -34
- data/lib/lookbook/entity.rb +0 -47
- data/lib/lookbook/page.rb +0 -194
- data/lib/lookbook/page_collection.rb +0 -19
- data/lib/lookbook/page_section.rb +0 -29
- data/lib/lookbook/preview.rb +0 -181
- data/lib/lookbook/preview_collection.rb +0 -23
- data/lib/lookbook/preview_example.rb +0 -93
- data/lib/lookbook/preview_group.rb +0 -58
- data/lib/lookbook/source_inspector.rb +0 -76
- data/lib/lookbook/support/utils/attribute_utils.rb +0 -14
- data/lib/lookbook/utils.rb +0 -65
data/lib/lookbook/param.rb
CHANGED
@@ -33,10 +33,10 @@ module Lookbook
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def input_options
|
36
|
-
return @
|
36
|
+
return @_input_options if @_input_options
|
37
37
|
|
38
38
|
runtime_options = options.except([*methods, :name, :value_default, :description])
|
39
|
-
@
|
39
|
+
@_input_options ||= Store.new(input_config.options.merge(runtime_options))
|
40
40
|
end
|
41
41
|
|
42
42
|
def input_partial
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class RenderedExample
|
3
|
+
delegate_missing_to :example
|
4
|
+
|
5
|
+
attr_reader :output, :example
|
6
|
+
|
7
|
+
def initialize(example, output, params)
|
8
|
+
@example = example
|
9
|
+
@params = params
|
10
|
+
@output = output
|
11
|
+
end
|
12
|
+
|
13
|
+
def source
|
14
|
+
has_custom_template? ? template_source(template) : example.source
|
15
|
+
end
|
16
|
+
|
17
|
+
def source_lang
|
18
|
+
has_custom_template? ? template_lang(template) : example.source_lang
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
attr_reader :params
|
24
|
+
|
25
|
+
def render_args
|
26
|
+
@_render_args ||= preview.render_args(example.name, params: params)
|
27
|
+
end
|
28
|
+
|
29
|
+
def template
|
30
|
+
render_args[:template]
|
31
|
+
end
|
32
|
+
|
33
|
+
def has_custom_template?
|
34
|
+
template != "view_components/preview" && !custom_source?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -12,7 +12,7 @@ module Lookbook
|
|
12
12
|
def call
|
13
13
|
language = opts.fetch(:language, "html")
|
14
14
|
stripped_source = source.strip
|
15
|
-
result = language.downcase == "html" ? HtmlBeautifier.beautify(stripped_source, opts) : stripped_source
|
15
|
+
result = (language.downcase == "html") ? HtmlBeautifier.beautify(stripped_source, opts) : stripped_source
|
16
16
|
result.to_s.strip.html_safe
|
17
17
|
rescue
|
18
18
|
source.strip.html_safe
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class CodeIndenter < Service
|
3
|
+
def initialize(source)
|
4
|
+
@source = source.to_s
|
5
|
+
end
|
6
|
+
|
7
|
+
def call
|
8
|
+
source = @source.chomp
|
9
|
+
last = source.split(/\r?\n/).last
|
10
|
+
indent = last ? last[/^([ \t]*)/, 1].length : 0
|
11
|
+
source.gsub(/^[ \t]{#{indent}}/, "")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class EntityTreeBuilder < Service
|
3
|
+
attr_reader :include_hidden
|
4
|
+
|
5
|
+
def initialize(entities, include_hidden: false)
|
6
|
+
@entities = entities.to_a
|
7
|
+
@include_hidden = include_hidden
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
root_node = TreeNode.new
|
12
|
+
entities.each do |entity|
|
13
|
+
current_node = root_node
|
14
|
+
path_segments = parse_segments(entity.logical_path)
|
15
|
+
path_segments.each.with_index(1) do |segment, i|
|
16
|
+
name, position_prefix = segment
|
17
|
+
content = entity if entity.depth == i # entities are always on the leaf nodes
|
18
|
+
|
19
|
+
current_node.add_child(name, content, position: position_prefix) unless current_node.has_child?(name)
|
20
|
+
current_node = current_node.get_child(name)
|
21
|
+
|
22
|
+
if content && content.type == :preview
|
23
|
+
content.visible_examples.each do |example|
|
24
|
+
current_node.add_child(example.name, example)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
root_node
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse_segments(path)
|
33
|
+
path.split("/").map do |segment|
|
34
|
+
unless segment.start_with?(".")
|
35
|
+
position, name = PositionPrefixParser.call(segment)
|
36
|
+
[name, position || 10000]
|
37
|
+
end
|
38
|
+
end.compact
|
39
|
+
end
|
40
|
+
|
41
|
+
def entities
|
42
|
+
include_hidden ? @entities : @entities.select(&:visible?)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class PositionPrefixParser < Service
|
3
|
+
POSITION_PREFIX_REGEX = /^(\d+?)[-_]/
|
4
|
+
|
5
|
+
attr_reader :input
|
6
|
+
|
7
|
+
def initialize(input)
|
8
|
+
@input = String(input)
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
matches = input.match(POSITION_PREFIX_REGEX)
|
13
|
+
matches ? [matches[1].to_i, input.gsub(POSITION_PREFIX_REGEX, "")] : [nil, input]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -96,7 +96,7 @@ module Lookbook
|
|
96
96
|
config.each do |group, panels|
|
97
97
|
panels.map! do |opts|
|
98
98
|
opts.transform_values! do |value|
|
99
|
-
value.is_a?(String) && value.start_with?("->") ? eval(value) : value # standard:disable Security/Eval
|
99
|
+
(value.is_a?(String) && value.start_with?("->")) ? eval(value) : value # standard:disable Security/Eval
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
@@ -111,7 +111,7 @@ module Lookbook
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def insert_index(position, items_count)
|
114
|
-
index = position == 0 ? 1 : (position || 0).to_int
|
114
|
+
index = (position == 0) ? 1 : (position || 0).to_int
|
115
115
|
last_position = items_count + 1
|
116
116
|
index = last_position if index > last_position
|
117
117
|
index - 1
|
@@ -25,39 +25,6 @@ module Lookbook
|
|
25
25
|
true
|
26
26
|
end
|
27
27
|
|
28
|
-
# def [](key)
|
29
|
-
# key = key.to_sym
|
30
|
-
# if respond_to? key
|
31
|
-
# public_send(key)
|
32
|
-
# else
|
33
|
-
# self[key]
|
34
|
-
# end
|
35
|
-
# end
|
36
|
-
|
37
|
-
# def []=(key, value)
|
38
|
-
# setter_key = "#{key}=".to_sym
|
39
|
-
# if respond_to? setter_key
|
40
|
-
# public_send(setter_key, value)
|
41
|
-
# else
|
42
|
-
# _set(key.to_sym, normalize_value(value))
|
43
|
-
# end
|
44
|
-
# end
|
45
|
-
|
46
|
-
# def method_missing(key, *args)
|
47
|
-
# if key.to_s.end_with?("=")
|
48
|
-
# args[0] = normalize_value(args[0])
|
49
|
-
# end
|
50
|
-
# public_send(key.to_sym, *args)
|
51
|
-
# end
|
52
|
-
|
53
|
-
# def respond_to_missing?(key, *args)
|
54
|
-
# key?(key.to_sym)
|
55
|
-
# end
|
56
|
-
|
57
|
-
# def fetch(key, *args)
|
58
|
-
# super.fetch(key.to_sym, *args)
|
59
|
-
# end
|
60
|
-
|
61
28
|
def to_h
|
62
29
|
transform_values do |value|
|
63
30
|
value.is_a?(Store) ? value.to_h : value
|
@@ -71,7 +38,7 @@ module Lookbook
|
|
71
38
|
protected
|
72
39
|
|
73
40
|
def normalize_value(value)
|
74
|
-
@recursive && !value.is_a?(Store) && value.is_a?(Hash) ? Store.new(value, recursive: @recursive) : value
|
41
|
+
(@recursive && !value.is_a?(Store) && value.is_a?(Hash)) ? Store.new(value, recursive: @recursive) : value
|
75
42
|
end
|
76
43
|
end
|
77
44
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class TreeNode
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
delegate_missing_to :content
|
6
|
+
|
7
|
+
attr_accessor :path, :content
|
8
|
+
attr_reader :children
|
9
|
+
|
10
|
+
def initialize(path = nil, content = nil, position: 10000)
|
11
|
+
@path = path.to_s
|
12
|
+
@content = content
|
13
|
+
@position = position
|
14
|
+
@children = []
|
15
|
+
end
|
16
|
+
|
17
|
+
def id
|
18
|
+
Utils.id(content_value(:id, path))
|
19
|
+
end
|
20
|
+
|
21
|
+
def name
|
22
|
+
segments.last
|
23
|
+
end
|
24
|
+
|
25
|
+
def label
|
26
|
+
content_value(:label, name.titleize)
|
27
|
+
end
|
28
|
+
|
29
|
+
def position
|
30
|
+
content_value(:position, @position)
|
31
|
+
end
|
32
|
+
|
33
|
+
def type
|
34
|
+
content_value(:type, :directory)
|
35
|
+
end
|
36
|
+
|
37
|
+
def depth
|
38
|
+
path.split("/").size
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_child(name, content = nil, position: 10000)
|
42
|
+
children << TreeNode.new("#{path}/#{name}", content, position: position)
|
43
|
+
sort_children
|
44
|
+
end
|
45
|
+
|
46
|
+
def has_child?(name)
|
47
|
+
!!get_child(name)
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_child(name)
|
51
|
+
children.find { |child| child.name == name }
|
52
|
+
end
|
53
|
+
|
54
|
+
def content?
|
55
|
+
content.present?
|
56
|
+
end
|
57
|
+
|
58
|
+
def each(&block)
|
59
|
+
if block
|
60
|
+
children.each do |child|
|
61
|
+
yield child
|
62
|
+
end
|
63
|
+
else
|
64
|
+
to_enum(:each)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
protected
|
69
|
+
|
70
|
+
def content_value(method_name, fallback = nil)
|
71
|
+
value = content.send(method_name) if content
|
72
|
+
value || fallback
|
73
|
+
end
|
74
|
+
|
75
|
+
def sort_children
|
76
|
+
@children.sort_by! { |child| [child.position, child.label] }
|
77
|
+
end
|
78
|
+
|
79
|
+
def segments
|
80
|
+
path.split("/")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -5,10 +5,30 @@ module Lookbook
|
|
5
5
|
File.absolute_path(path.to_s, Rails.root)
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
8
|
+
def to_lookup_path(file_path)
|
9
|
+
path = file_path.to_s.downcase
|
10
|
+
|
11
|
+
directory_path = File.dirname(path)
|
12
|
+
directory_path = nil if directory_path.start_with?(".")
|
13
|
+
|
14
|
+
file_name = File.basename(path).split(".").first
|
15
|
+
|
16
|
+
segments = [*directory_path&.split("/"), file_name].compact
|
17
|
+
stripped_segments = segments.map! do |segment|
|
18
|
+
PositionPrefixParser.call(segment).last.tr("-", "_")
|
19
|
+
end
|
20
|
+
|
21
|
+
to_path(stripped_segments)
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_path(*args)
|
25
|
+
args.flatten.compact.map(&:to_s).join("/")
|
26
|
+
end
|
27
|
+
|
28
|
+
def normalize_paths(paths, allow_root: false)
|
9
29
|
Array(paths).map do |path|
|
10
30
|
full_path = to_absolute(path)
|
11
|
-
if
|
31
|
+
if File.exist?(full_path)
|
12
32
|
full_path if allow_root || !root_path?(full_path)
|
13
33
|
end
|
14
34
|
end.compact.uniq
|
@@ -17,6 +37,10 @@ module Lookbook
|
|
17
37
|
def root_path?(path)
|
18
38
|
Rails.application.root.to_s == path.to_s
|
19
39
|
end
|
40
|
+
|
41
|
+
def strip_slashes(path)
|
42
|
+
path.to_s.gsub(/\A\/|\/\z/, "")
|
43
|
+
end
|
20
44
|
end
|
21
45
|
end
|
22
46
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Lookbook
|
2
|
+
module Utils
|
3
|
+
class << self
|
4
|
+
def id(*args)
|
5
|
+
parts = args.map { |arg| arg.to_s }
|
6
|
+
id_str = parts.join("-").force_encoding("UTF-8").parameterize.dasherize
|
7
|
+
PathUtils.strip_slashes(id_str).tr("/", "-").gsub("--", "-")
|
8
|
+
end
|
9
|
+
|
10
|
+
def name(str)
|
11
|
+
str.to_s.parameterize.tr("-", "_")
|
12
|
+
end
|
13
|
+
|
14
|
+
def value_or_fallback(value, fallback = nil, &block)
|
15
|
+
if value.nil?
|
16
|
+
fallback_block = block || proc { fallback }
|
17
|
+
fallback_block.call
|
18
|
+
else
|
19
|
+
value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/lookbook/tags/id_tag.rb
CHANGED
@@ -26,23 +26,51 @@ module Lookbook
|
|
26
26
|
# i.e. for the @hidden tag this would return boolean true/false.
|
27
27
|
alias_method :value, :text
|
28
28
|
|
29
|
+
def self.supports_options(value = true)
|
30
|
+
@supports_options = !!value
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.supports_options?
|
34
|
+
@supports_options.nil? ? false : @supports_options
|
35
|
+
end
|
36
|
+
|
37
|
+
supports_options
|
38
|
+
|
29
39
|
protected
|
30
40
|
|
31
41
|
def tag_parts
|
32
42
|
if @tag_parts.nil?
|
33
|
-
options, text =
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
43
|
+
options, text = if self.class.supports_options?
|
44
|
+
TagOptionsParser.call(@text, {
|
45
|
+
file: host_file,
|
46
|
+
base_dir: host_file&.dirname,
|
47
|
+
eval_context: host_class_instance,
|
48
|
+
permit_eval: Lookbook.config.preview_params_options_eval
|
49
|
+
})
|
50
|
+
else
|
51
|
+
[{}, @text]
|
52
|
+
end
|
39
53
|
end
|
40
54
|
@tag_parts ||= {options: options, text: text}
|
41
55
|
end
|
42
56
|
|
57
|
+
def resolve_path(path)
|
58
|
+
return unless host_file
|
59
|
+
|
60
|
+
dir = path.start_with?(".") ? host_file.dirname : host_file_base_directory
|
61
|
+
Pathname(File.expand_path(path, dir))
|
62
|
+
end
|
63
|
+
|
43
64
|
def host_file
|
44
65
|
location = object&.files&.first # [file, line_number]
|
45
|
-
location
|
66
|
+
Pathname(location.first) if location
|
67
|
+
end
|
68
|
+
|
69
|
+
def host_file_base_directory
|
70
|
+
return unless host_file
|
71
|
+
|
72
|
+
directories = Engine.preview_paths.map(&:to_s).sort_by(&:length).reverse
|
73
|
+
directories.first { |dir| host_file.to_s.start_with?(dir) }
|
46
74
|
end
|
47
75
|
|
48
76
|
def host_class_instance
|
data/lib/lookbook/theme.rb
CHANGED
@@ -12,6 +12,14 @@ module Lookbook
|
|
12
12
|
blue: {
|
13
13
|
favicon_light_mode: "#2563EB",
|
14
14
|
favicon_dark_mode: "#60A5FA"
|
15
|
+
},
|
16
|
+
green: {
|
17
|
+
favicon_light_mode: "#16a34a",
|
18
|
+
favicon_dark_mode: "#66E093"
|
19
|
+
},
|
20
|
+
rose: {
|
21
|
+
favicon_light_mode: "#E11D48",
|
22
|
+
favicon_dark_mode: "#FFA0B5"
|
15
23
|
}
|
16
24
|
}
|
17
25
|
|
data/lib/lookbook/version.rb
CHANGED
data/lib/lookbook.rb
CHANGED
@@ -16,23 +16,27 @@ module Lookbook
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def config
|
19
|
-
@
|
19
|
+
@_config ||= ConfigStore.init_from_config
|
20
20
|
end
|
21
21
|
|
22
22
|
def configure
|
23
23
|
yield(config)
|
24
24
|
end
|
25
25
|
|
26
|
+
def engine
|
27
|
+
Engine
|
28
|
+
end
|
29
|
+
|
26
30
|
def data
|
27
|
-
@
|
31
|
+
@_data ||= Store.new
|
28
32
|
end
|
29
33
|
|
30
34
|
def data=(new_data)
|
31
|
-
@
|
35
|
+
@_data = Store.new(new_data)
|
32
36
|
end
|
33
37
|
|
34
38
|
def logger
|
35
|
-
@
|
39
|
+
@_logger ||= if Rails.logger.present? && config.log_use_rails_logger
|
36
40
|
Rails.logger
|
37
41
|
else
|
38
42
|
logger = Logger.new($stdout)
|
@@ -55,11 +59,11 @@ module Lookbook
|
|
55
59
|
end
|
56
60
|
|
57
61
|
def previews
|
58
|
-
|
62
|
+
Engine.previews
|
59
63
|
end
|
60
64
|
|
61
65
|
def pages
|
62
|
-
|
66
|
+
Engine.pages
|
63
67
|
end
|
64
68
|
|
65
69
|
def broadcast(event_name, data = {})
|
@@ -67,7 +71,7 @@ module Lookbook
|
|
67
71
|
end
|
68
72
|
|
69
73
|
def theme
|
70
|
-
@
|
74
|
+
@_theme ||= Lookbook::Theme.new(config.ui_theme, config.ui_theme_overrides)
|
71
75
|
end
|
72
76
|
|
73
77
|
def define_param_input(*args)
|