Class: AssetsRequest
Instance Attribute Summary
#menv
Class Method Summary
collapse
Instance Method Summary
collapse
#`, `, attr_accessor, attr_reader, attr_writer, #attrs, box, #box, color, division, division!, division?, inherited, menv_accessor, menv_reader, menv_writer, on_connected, panel, #panel, plural, require, requirements, sh, #sh, singular, subsystem, subsystem!, subsystem?, subsystem_token, token
Methods inherited from Liza::Unit
_erbs_for, #add, add, cl, #cl, class_methods_defined, const_added, const_missing, constants_defined, define_error, descendants_select, division, erbs_available, erbs_defined, erbs_for, errors, #fetch, fetch, get, #get, instance_methods_defined, log, #log, log?, #log?, #log_array, log_array, log_hash, #log_hash, #log_level, log_level, #log_level?, log_level?, log_levels, #log_levels, #log_render_convert, #log_render_format, #log_render_in, #log_render_out, method_added, methods_defined, namespace, part, raise_error, #raise_error, reload!, #reload!, #render, #render!, #render_stack, renderable_formats_for, renderable_names, section, sections, #set, set, #settings, settings, singleton_method_added, sleep, #sleep, stick, #stick, sticks, #sticks, subclasses_select, subunits, system, #system, system?, test_class, time_diff, #time_diff
Class Method Details
.call(env) ⇒ Object
3
4
5
6
|
# File 'app/web/requests/assets_request.rb', line 3
def self.call env
super
new.call env
end
|
Instance Method Details
#call(env) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/web/requests/assets_request.rb', line 8
def call env
action = env["LIZA_ACTION"].to_sym
format = env["LIZA_FORMAT"].to_sym
status = 200
= {
"Framework" => "Liza #{Lizarb::VERSION}"
}
body = ""
body = render_action_admin_format_js if action == :admin && format == :js
body = render_action_admin_format_css if action == :admin && format == :css
body = render_action_app_format_js if action == :app && format == :js
body = render_action_app_format_css if action == :app && format == :css
[status, , [body]]
end
|
#random_color ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'app/web/requests/assets_request.rb', line 62
def random_color
s = ""
3.times do |i|
s += Array(3..9).sample.to_s(16)
s += "0"
end
s
end
|
#random_string ⇒ Object
58
59
60
|
# File 'app/web/requests/assets_request.rb', line 58
def random_string
Array("A".."z").sample(16).join
end
|
34
35
36
|
# File 'app/web/requests/assets_request.rb', line 34
def render_action_admin_format_css
"body { background: gray }"
end
|
30
31
32
|
# File 'app/web/requests/assets_request.rb', line 30
def render_action_admin_format_js
"alert('it works')"
end
|
49
50
51
52
53
54
55
56
|
# File 'app/web/requests/assets_request.rb', line 49
def render_action_app_format_css
<<-CODE
body {
background: ##{random_color};
font-family: Roboto;
}
CODE
end
|
38
39
40
41
42
43
44
45
46
47
|
# File 'app/web/requests/assets_request.rb', line 38
def render_action_app_format_js
<<-CODE
window.onload = () => {
var h1 = document.createElement("h1");
h1.setAttribute("style", "color: white");
h1.innerHTML="JS file has been loaded. Random String: #{random_string}";
document.body.append(h1);
}
CODE
end
|