forked from rc/aircox
start to restructure the project tree
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
{% with metadata=source.metadata %}
|
||||
<div class="source {% if metadata.initial_uri == controller.master.metadata.initial_uri %}on_air{% endif %}">
|
||||
<h2>{{ source.name }}</h2>
|
||||
<time>{{ metadata.on_air }}</time>
|
||||
<span class="path">{{ metadata.initial_uri }}</span>
|
||||
<span class="status" status="{{ metadata.status }}">{{ metadata.status }}</span>
|
||||
|
||||
<button onclick="liquid_action('{{controller.id}}','{{source.id}}','skip');">
|
||||
skip
|
||||
</button>
|
||||
</div>
|
||||
{% endwith %}
|
||||
|
||||
|
26
aircox/liquidsoap/templates/aircox_liquidsoap/config.liq
Normal file
26
aircox/liquidsoap/templates/aircox_liquidsoap/config.liq
Normal file
@ -0,0 +1,26 @@
|
||||
{# Utilities #}
|
||||
def interactive_source (id, s, ) = \
|
||||
s = store_metadata(id=id, size=1, s) \
|
||||
add_skip_command(s) \
|
||||
s \
|
||||
end \
|
||||
\
|
||||
def stream (id, file) = \
|
||||
s = playlist(id = '#{id}_playlist', mode = "random", file) \
|
||||
interactive_source(id, s) \
|
||||
end \
|
||||
\
|
||||
{# Config #}
|
||||
set("server.socket", true) \
|
||||
set("server.socket.path", "{{ settings.AIRCOX_LIQUIDSOAP_SOCKET }}") \
|
||||
{% for key, value in settings.AIRCOX_LIQUIDSOAP_SET.items %}
|
||||
set("{{ key|safe }}", {{ value|safe }}) \
|
||||
{% endfor %}
|
||||
\
|
||||
\
|
||||
{% for controller in monitor.controllers.values %}
|
||||
{% include 'aircox_liquidsoap/station.liq' %} \
|
||||
{{ controller.id }} = make_station_{{ controller.id }}() \
|
||||
output.alsa({{ controller.id }}) \
|
||||
{% endfor %}
|
||||
|
134
aircox/liquidsoap/templates/aircox_liquidsoap/controller.html
Normal file
134
aircox/liquidsoap/templates/aircox_liquidsoap/controller.html
Normal file
@ -0,0 +1,134 @@
|
||||
{% if not embed %}
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
.station {
|
||||
margin: 2em;
|
||||
border: 1px grey solid;
|
||||
}
|
||||
|
||||
.sources {
|
||||
padding: 0.5em;
|
||||
box-shadow: inset 0.1em 0.1em 0.5em rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.station h1 {
|
||||
font-size: 1.2em;
|
||||
margin: 0.2em;
|
||||
}
|
||||
|
||||
.source {
|
||||
border-left: 0.5em solid grey;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.on_air {
|
||||
display: block;
|
||||
border-left: 0.5em solid #f00;
|
||||
}
|
||||
|
||||
.source h2 {
|
||||
display: inline-block;
|
||||
min-width: 10em;
|
||||
font-size: 1em;
|
||||
margin: 0.2em;
|
||||
}
|
||||
|
||||
.source time {
|
||||
display: inline-block;
|
||||
margin-right: 2em;
|
||||
}
|
||||
|
||||
.source span {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.error {
|
||||
padding: 0.2em;
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
|
||||
function get_token() {
|
||||
return document.cookie.replace(/.*csrftoken=([^;]+)(;.*|$)/, '$1');
|
||||
}
|
||||
|
||||
function liquid_action (controller, source, action) {
|
||||
params = 'controller=' + controller + '&&source=' + source +
|
||||
'&&action=' + action;
|
||||
|
||||
req = new XMLHttpRequest()
|
||||
req.open('POST', '{% url 'liquid-controller' %}', false);
|
||||
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
req.setRequestHeader("Content-length", params.length);
|
||||
req.setRequestHeader("Connection", "close");
|
||||
req.setRequestHeader("X-CSRFToken", get_token());
|
||||
|
||||
req.send(params);
|
||||
liquid_update()
|
||||
}
|
||||
|
||||
function liquid_update (update) {
|
||||
req = new XMLHttpRequest()
|
||||
req.open('GET', '{% url 'liquid-controller' %}?embed', true);
|
||||
|
||||
req.onreadystatechange = function() {
|
||||
if(req.readyState != 4 || (req.status != 200 && req.status != 0))
|
||||
return;
|
||||
document.getElementById('liquid-stations').innerHTML =
|
||||
req.responseText;
|
||||
|
||||
if(update)
|
||||
window.setTimeout(function() { liquid_update(update);}, 5000);
|
||||
};
|
||||
req.send();
|
||||
}
|
||||
|
||||
liquid_update(true);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<main id="liquid-stations">
|
||||
{% endif %}
|
||||
{% for c_id, controller in monitor.controllers.items %}
|
||||
{% with on_air=controller.on_air %}
|
||||
<div id="{{ c_id }}" class="station">
|
||||
<header>
|
||||
{% if not controller.connector.available %}
|
||||
<span class="error" style="float:right;">disconnected</span>
|
||||
{% endif %}
|
||||
<h1>
|
||||
{{ controller.station.name }}
|
||||
</h1>
|
||||
</header>
|
||||
<div class="sources">
|
||||
{% with source=controller.master %}
|
||||
{% include 'aircox_liquidsoap/base_source.html' %}
|
||||
{% endwith %}
|
||||
|
||||
{% with source=controller.dealer %}
|
||||
{% include 'aircox_liquidsoap/base_source.html' %}
|
||||
{% endwith %}
|
||||
|
||||
{% for source in controller.streams.values %}
|
||||
{% include 'aircox_liquidsoap/base_source.html' %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="next">
|
||||
{% for diffusion in controller.next_diffusions %}
|
||||
{{ diffusion }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
|
||||
{% if not embed %}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
{% endif %}
|
||||
|
54
aircox/liquidsoap/templates/aircox_liquidsoap/station.liq
Normal file
54
aircox/liquidsoap/templates/aircox_liquidsoap/station.liq
Normal file
@ -0,0 +1,54 @@
|
||||
{% comment %}
|
||||
A station has multiple sources:
|
||||
- dealer: a controlled playlist playing once each track, that reloads on file
|
||||
change. This is used for scheduled sounds.
|
||||
- streams: a rotate source with all playlists
|
||||
- single: security song
|
||||
{% endcomment %}
|
||||
def make_station_{{ controller.id }} () = \
|
||||
{# dealer #}
|
||||
{% with source=controller.dealer %}
|
||||
{% if source %}
|
||||
dealer = interactive_source('{{ source.id }}', playlist.once( \
|
||||
reload_mode='watch', \
|
||||
"{{ source.path }}", \
|
||||
)) \
|
||||
\
|
||||
dealer_on = interactive.bool("{{ source.id }}_on", false) \
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
\
|
||||
{# streams #}
|
||||
streams = interactive_source("streams", rotate([ \
|
||||
{% for source in controller.streams.values %}
|
||||
{% with info=source.stream_info %}
|
||||
{% if info.delay %}
|
||||
delay({{ info.delay }}., stream("{{ source.id }}", "{{ source.path }}")), \
|
||||
{% elif info.begin and info.end %}
|
||||
at({ {{info.begin}}-{{info.end}} }, stream("{{ source.id }}", "{{ source.path }}")), \
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
|
||||
{% for source in controller.streams.values %}
|
||||
{% if not source.stream_info %}
|
||||
stream("{{ source.id }}", "{{ source.path }}"), \
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
])) \
|
||||
\
|
||||
{# station #}
|
||||
interactive_source ( \
|
||||
"{{ controller.id }}", \
|
||||
fallback(track_sensitive = false, [ \
|
||||
at(dealer_on, dealer), \
|
||||
streams, \
|
||||
{% if controller.station.fallback %}
|
||||
single("{{ controller.station.fallback }}"), \
|
||||
{% else %}
|
||||
blank(), \
|
||||
{% endif %}
|
||||
]) \
|
||||
) \
|
||||
end \
|
||||
|
Reference in New Issue
Block a user