forked from rc/aircox
		
	move files
This commit is contained in:
		
							
								
								
									
										134
									
								
								liquidsoap/templates/aircox/liquidsoap/controller.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								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/source.html' %}
 | 
			
		||||
                    {% endwith %}
 | 
			
		||||
 | 
			
		||||
                    {% with source=controller.dealer %}
 | 
			
		||||
                    {% include 'aircox_liquidsoap/source.html' %}
 | 
			
		||||
                    {% endwith %}
 | 
			
		||||
 | 
			
		||||
                    {% for source in controller.streams.values %}
 | 
			
		||||
                    {% include 'aircox_liquidsoap/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 %}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										14
									
								
								liquidsoap/templates/aircox/liquidsoap/source.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								liquidsoap/templates/aircox/liquidsoap/source.html
									
									
									
									
									
										Normal file
									
								
							@ -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 %}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										81
									
								
								liquidsoap/templates/aircox/liquidsoap/station.liq
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								liquidsoap/templates/aircox/liquidsoap/station.liq
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,81 @@
 | 
			
		||||
{# Context: #}
 | 
			
		||||
{# - controller: controller used to generate the current file #}
 | 
			
		||||
{# - settings: global settings #}
 | 
			
		||||
def interactive_source (id, s) = \
 | 
			
		||||
    def handler(m) = \
 | 
			
		||||
        file = string.escape(m['filename']) \
 | 
			
		||||
        system('{{ log_script }} -s "#{id}" -p "#{file}" -c "liquidsoap: play" &') \
 | 
			
		||||
    end \
 | 
			
		||||
    \
 | 
			
		||||
    s = on_track(id=id, handler, 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", \
 | 
			
		||||
                 reload_mode='watch', file) \
 | 
			
		||||
    interactive_source(id, s) \
 | 
			
		||||
end \
 | 
			
		||||
\
 | 
			
		||||
{# Config #}
 | 
			
		||||
set("server.socket", true) \
 | 
			
		||||
set("server.socket.path", "{{ controller.socket_path }}") \
 | 
			
		||||
{% for key, value in settings.AIRCOX_LIQUIDSOAP_SET.items %}
 | 
			
		||||
set("{{ key|safe }}", {{ value|safe }}) \
 | 
			
		||||
{% endfor %}
 | 
			
		||||
\
 | 
			
		||||
{# station #}
 | 
			
		||||
{{ controller.id }} = interactive_source ( \
 | 
			
		||||
    "{{ controller.id }}", \
 | 
			
		||||
    fallback(track_sensitive = false, [ \
 | 
			
		||||
        {# dealer #}
 | 
			
		||||
        {% with source=controller.dealer %}
 | 
			
		||||
        {% if source %}
 | 
			
		||||
        at(interactive.bool('{{ source.id }}_on', false), \
 | 
			
		||||
            interactive_source('{{ source.id }}', playlist.once( \
 | 
			
		||||
                reload_mode='watch', \
 | 
			
		||||
                "{{ source.path }}", \
 | 
			
		||||
            )) \
 | 
			
		||||
        ), \
 | 
			
		||||
        {% endif %}
 | 
			
		||||
        {% endwith %}
 | 
			
		||||
 | 
			
		||||
        {# streams #}
 | 
			
		||||
        interactive_source("{{ controller.id }}_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 %}
 | 
			
		||||
        ])), \
 | 
			
		||||
 | 
			
		||||
        {# fallback #}
 | 
			
		||||
        {% if controller.station.fallback %}
 | 
			
		||||
            single("{{ controller.station.fallback }}"), \
 | 
			
		||||
        {% else %}
 | 
			
		||||
            blank(), \
 | 
			
		||||
        {% endif %}
 | 
			
		||||
    ]) \
 | 
			
		||||
) \
 | 
			
		||||
\
 | 
			
		||||
{% for output in controller.outputs %}
 | 
			
		||||
output.{{ output.get_type_display }}( \
 | 
			
		||||
   {{ controller.id }}
 | 
			
		||||
    {% if controller.settings %}, \
 | 
			
		||||
    {{ controller.settings }}
 | 
			
		||||
    {% endif %}
 | 
			
		||||
) \
 | 
			
		||||
{% endfor %}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user