Skip to content

Commit 70f5970

Browse files
authored
Merge 2ef95e7 into 621a64f
2 parents 621a64f + 2ef95e7 commit 70f5970

File tree

6 files changed

+68
-54
lines changed

6 files changed

+68
-54
lines changed

card/lib/card/format/render.rb

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,57 @@ def final_render view
4141
add_debug_info view, method, rendered
4242
end
4343

44+
def pretty_path source_location
45+
"#{source_location.first.gsub(%r{^.+mod\d+-([^/]+)},
46+
'\1: ')}:#{source_location.second}"
47+
end
48+
49+
# see {Abstract::Format}
50+
# (:default), :yes, :deep, :always, :never
51+
def view_cache_setting view
52+
voo&.cache || view_setting(:cache, view) || :default
53+
end
54+
55+
def view_setting setting_name, view
56+
try Card::Set::Format.view_setting_method_name(view, setting_name)
57+
end
58+
59+
def stub_render cached_content
60+
return cached_content if Cardio.config.view_cache == :debug
61+
62+
# stub_debugging do
63+
expand_stubs cached_content
64+
# end
65+
end
66+
67+
def view_method view
68+
unless supports_view? view
69+
raise Card::Error::UserError, unsupported_view_error_message(view)
70+
end
71+
72+
method Card::Set::Format.view_method_name(view)
73+
end
74+
75+
def supports_view? view
76+
respond_to? Card::Set::Format.view_method_name(view)
77+
end
78+
79+
def current_view view
80+
old_view = @current_view
81+
@current_view = view
82+
yield
83+
ensure
84+
@current_view = old_view
85+
end
86+
87+
def stub_nest stub_hash
88+
prepare_stub_nest(stub_hash) do |stub_card, view_opts|
89+
nest stub_card, view_opts, stub_hash[:format_opts]
90+
end
91+
end
92+
93+
private
94+
4495
def wrap_and_render view
4596
current_view(view) { with_wrapper { final_render view } }
4697
rescue StandardError => e
@@ -64,27 +115,6 @@ def show_debug_info?
64115
Env.params[:debug] == "view"
65116
end
66117

67-
def pretty_path source_location
68-
"#{source_location.first.gsub(%r{^.+mod\d+-([^/]+)},
69-
'\1: ')}:#{source_location.second}"
70-
end
71-
72-
# see {Abstract::Format}
73-
# (:default), :yes, :deep, :always, :never
74-
def view_cache_setting view
75-
voo&.cache || view_setting(:cache, view) || :default
76-
end
77-
78-
def view_setting setting_name, view
79-
try Card::Set::Format.view_setting_method_name(view, setting_name)
80-
end
81-
82-
def stub_render cached_content
83-
# stub_debugging do
84-
expand_stubs cached_content
85-
# end
86-
end
87-
88118
# def stub_debugging
89119
# result = yield
90120
# if Rails.env.development? && result.is_a?(String) && result =~ /StUb/
@@ -118,32 +148,6 @@ def expand_stubs cached_content
118148
conto.to_s
119149
end
120150
end
121-
122-
def view_method view
123-
unless supports_view? view
124-
raise Card::Error::UserError, unsupported_view_error_message(view)
125-
end
126-
127-
method Card::Set::Format.view_method_name(view)
128-
end
129-
130-
def supports_view? view
131-
respond_to? Card::Set::Format.view_method_name(view)
132-
end
133-
134-
def current_view view
135-
old_view = @current_view
136-
@current_view = view
137-
yield
138-
ensure
139-
@current_view = old_view
140-
end
141-
142-
def stub_nest stub_hash
143-
prepare_stub_nest(stub_hash) do |stub_card, view_opts|
144-
nest stub_card, view_opts, stub_hash[:format_opts]
145-
end
146-
end
147151
end
148152
end
149153
end

card/lib/card/query.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module Query
8383
# "dir" is DEPRECATED in favor of sort_dir
8484
# "sort" is DEPRECATED in favor of sort_by, except in cases where sort's value
8585
# is a hash
86-
MODIFIERS = %i[conj return sort_by sort_as sort_dir sort dir group limit offset]
86+
MODIFIERS = %i[conj return index sort_by sort_as sort_dir sort dir group limit offset]
8787
.each_with_object({}) { |v, h| h[v] = nil }
8888

8989
OPERATORS =

card/lib/card/query/card_query/relational_attributes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class CardQuery
44
# interpret CQL attributes that relate multiple cards
55
# each method below corresponds to a relational CQL term
66
#
7-
# NOTE: methods using "restrict" can be executed without
7+
# NOTE: methods using "restrict" can be executed without
88
# tying in an additional query if the val in question can be
99
# reduced to an id.
1010
module RelationalAttributes

card/lib/card/query/sql_statement.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def build
2424
@fields = fields
2525
@tables = tables
2626
@joins = joins
27+
@indexes = indexes
2728
@where = where
2829
@group = group
2930
@order = order
@@ -33,7 +34,8 @@ def build
3334

3435
def to_s
3536
[
36-
comment, select, from, @joins, @where, @group, @order, @limit_and_offset
37+
comment, select, from,
38+
@joins, @indexes, @where, @group, @order, @limit_and_offset
3739
].compact.join " "
3840
end
3941

@@ -103,6 +105,11 @@ def limit_and_offset
103105
end
104106
end
105107

108+
def indexes
109+
return unless @mods[:index]
110+
"USE INDEX (#{Array.wrap(@mods[:index]).join ', '})"
111+
end
112+
106113
def full_syntax
107114
@query.full? ? yield : return
108115
end

mod/carrierwave/set/abstract/attachment/00_upload_cache.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def assign_attachment file, original_filename
5858

5959
# at some point uploaded files of canceled file card creation
6060
# should be deleted. We do this when ever an new file is created.
61+
# FIXME: move to cron job
6162
event :clear_draft_files, :integrate_with_delay, priority: 100, on: :create do
6263
Card.delete_tmp_files_of_cached_uploads
6364
end

mod/format/lib/card/format/html_format.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ def mime_type
2525
"text/html"
2626
end
2727

28+
def stylesheet_link_tag path
29+
tag "link", href: path, media: "all", rel: "stylesheet", type: "text/css"
30+
end
31+
32+
private
33+
2834
def final_render_call method
2935
rendered = super
3036
rendered.is_a?(Array) ? output(rendered) : rendered
3137
end
32-
33-
def stylesheet_link_tag path
34-
tag "link", href: path, media: "all", rel: "stylesheet", type: "text/css"
35-
end
3638
end
3739
end
3840
end

0 commit comments

Comments
 (0)