Class: Cosmo::Web::Controllers::Streams
Constant Summary
Constants included
from Renderer
Renderer::ASSETS_ROOT, Renderer::VIEWS_ROOT
Instance Method Summary
collapse
Methods inherited from Application
#content_for, #hx_request?, #initialize, #params, #path, #render
Methods included from Renderer
#no_content, #not_found, #ok, #redirect_to, #serve, #url_for
Instance Method Details
#_info ⇒ Object
47
48
49
50
51
|
# File 'lib/cosmo/web/controllers/streams.rb', line 47
def _info
name = Rack::Utils.unescape(@request.params["name"])
stream = API::Stream.new(name)
ok render("streams/_info", stream.info.merge(name:, paused: stream.paused?))
end
|
#_table ⇒ Object
42
43
44
45
|
# File 'lib/cosmo/web/controllers/streams.rb', line 42
def _table
streams = API::Stream.all.map { row_locals(_1) }
ok render("streams/_table", { streams: streams })
end
|
#index ⇒ Object
9
10
11
12
13
14
|
# File 'lib/cosmo/web/controllers/streams.rb', line 9
def index
return _table if hx_request?
content_for :title, "Streams"
ok render("streams/index", layout: true)
end
|
#info ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/cosmo/web/controllers/streams.rb', line 16
def info
name = Rack::Utils.unescape(@request.params["name"])
return _info if hx_request?
content_for :title, "Streams"
ok render("streams/info", { name: name }, layout: true)
end
|
#pause ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/cosmo/web/controllers/streams.rb', line 24
def pause
name = Rack::Utils.unescape(@request.params["name"])
stream = API::Stream.new(name)
stream.pause!
return ok render("streams/_pause_banner", banner_locals(stream)) if @request.params["banner"]
ok render("streams/_stream_row", { stream: row_locals(stream) })
end
|
#unpause ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/cosmo/web/controllers/streams.rb', line 33
def unpause
name = Rack::Utils.unescape(@request.params["name"])
stream = API::Stream.new(name)
stream.unpause!
return ok render("streams/_pause_banner", banner_locals(stream)) if @request.params["banner"]
ok render("streams/_stream_row", { stream: row_locals(stream) })
end
|