view libervia/pages/files/page_meta.py @ 1344:472267dcd4d8

browser (alt_media_player): native player support + poster + flags + restricted area: - alt_media_player will now use native player when possible. This allows to use its controls and behaviour instead of native ones. - a poster can be specified when instanciated manually - video is not preloaded anymore - handle events propagation to plays nicely when used in slideshow - a "restricted area" mode can be used to let click propagation on video border, and thus catch only play/pause in the center. This is notably useful when used in the slideshow, as border can be used to show/hide slideshow controls - player can be reset, in which case the play button overlay is put back, and video is put at its beginning - once video is played at least once, a `in_use` class is added to the element, play button overlay is removed then. This fix a bug when the overlay was still appearing when using bottom play button. - VideoPlayer has been renamed to MediaPlayer
author Goffi <goffi@goffi.org>
date Mon, 24 Aug 2020 23:04:35 +0200
parents f511f8fbbf8a
children e065c8886b81
line wrap: on
line source

#!/usr/bin/env python3


from libervia.server.constants import Const as C
from twisted.internet import defer
from twisted.words.protocols.jabber import jid
from sat.core.log import getLogger

log = getLogger(__name__)
"""files handling pages"""

name = "files"
access = C.PAGES_ACCESS_PROFILE
template = "file/discover.html"


@defer.inlineCallbacks
def prepare_render(self, request):
    profile = self.getProfile(request)
    template_data = request.template_data
    namespace = self.host.ns_map["fis"]
    entities_services, entities_own, entities_roster = yield self.host.bridgeCall(
        "discoFindByFeatures", [namespace], [], False, True, True, True, False, profile
    )
    tpl_service_entities = template_data["disco_service_entities"] = {}
    tpl_own_entities = template_data["disco_own_entities"] = {}
    tpl_roster_entities = template_data["disco_roster_entities"] = {}
    entities_url = template_data["entities_url"] = {}

    # we store identities in dict of dict using category and type as keys
    # this way it's easier to test category in the template
    for tpl_entities, entities_map in (
        (tpl_service_entities, entities_services),
        (tpl_own_entities, entities_own),
        (tpl_roster_entities, entities_roster),
    ):
        for entity_str, entity_ids in entities_map.items():
            entity_jid = jid.JID(entity_str)
            tpl_entities[entity_jid] = identities = {}
            for cat, type_, name in entity_ids:
                identities.setdefault(cat, {}).setdefault(type_, []).append(name)
            entities_url[entity_jid] = self.getPageByName("files_list").getURL(
                entity_jid.full()
            )


def on_data_post(self, request):
    jid_str = self.getPostedData(request, "jid")
    try:
        jid_ = jid.JID(jid_str)
    except RuntimeError:
        self.pageError(request, C.HTTP_BAD_REQUEST)
    url = self.getPageByName("files_list").getURL(jid_.full())
    self.HTTPRedirect(request, url)