Example #1
0
 def get_ajax_context(self, *args, **kwargs):
     config['pdf_fullscreen'] = not config['pdf_fullscreen']
     active_slide = get_active_slide()
     if active_slide['callback'] == 'mediafile':
         ProjectorSocketHandler.send_updates(
             {'calls': {'toggle_fullscreen': config['pdf_fullscreen']}})
     return {'fullscreen': config['pdf_fullscreen']}
Example #2
0
 def load_other_page(self, active_slide):
     """
     Tell connected clients to load an other pdf page.
     """
     config['projector_active_slide'] = active_slide
     ProjectorSocketHandler.send_updates(
         {'calls': {'load_pdf_page': active_slide['page_num']}})
Example #3
0
def update_projector_overlay(overlay):
    """
    Update one or all overlay on the projector.

    Checks if the overlay is activated and updates it in this case.

    The argument 'overlay' has to be an overlay object, the name of a
    ovleray or None. If it is None, all overlays will be updated.
    """
    if overlay is None:
        overlays = [item for item in get_overlays().values()]
    elif isinstance(overlay, basestring):
        overlays = [get_overlays()[overlay]]
    else:
        overlays = [overlay]

    overlay_dict = {}
    for overlay in overlays:
        if overlay.is_active():
            overlay_dict[overlay.name] = {
                'html': overlay.get_projector_html(),
                'javascript': overlay.get_javascript()}
        else:
            overlay_dict[overlay.name] = None
    ProjectorSocketHandler.send_updates({'overlays': overlay_dict})
Example #4
0
def update_projector_overlay(overlay):
    """
    Update one or all overlay on the projector.

    Checks if the overlay is activated and updates it in this case.

    The argument 'overlay' has to be an overlay object, the name of a
    ovleray or None. If it is None, all overlays will be updated.
    """
    if overlay is None:
        overlays = [item for item in get_overlays().values()]
    elif isinstance(overlay, str):
        overlays = [get_overlays()[overlay]]
    else:
        overlays = [overlay]

    overlay_dict = {}
    for overlay in overlays:
        if overlay.is_active():
            overlay_dict[overlay.name] = {
                'html': overlay.get_projector_html(),
                'javascript': overlay.get_javascript()
            }
        else:
            overlay_dict[overlay.name] = None
    ProjectorSocketHandler.send_updates({'overlays': overlay_dict})
Example #5
0
 def update_video_state(self, active_slide):
     config['video_playing'] = active_slide['video_playing']
     config['video_fullscreen'] = active_slide['video_fullscreen']
     ProjectorSocketHandler.send_updates(
         {'calls': {'control_video': [
             active_slide['video_playing'],
             active_slide['video_fullscreen']
         ]}})
Example #6
0
 def get_ajax_context(self, *args, **kwargs):
     config['pdf_fullscreen'] = not config['pdf_fullscreen']
     active_slide = get_active_slide()
     if active_slide['callback'] == 'mediafile':
         ProjectorSocketHandler.send_updates(
             {'calls': {
                 'toggle_fullscreen': config['pdf_fullscreen']
             }})
     return {'fullscreen': config['pdf_fullscreen']}
Example #7
0
 def load_other_page(self, active_slide):
     """
     Tell connected clients to load an other pdf page.
     """
     config['projector_active_slide'] = active_slide
     ProjectorSocketHandler.send_updates(
         {'calls': {
             'load_pdf_page': active_slide['page_num']
         }})
Example #8
0
def call_on_projector(calls):
    """
    Sends data to the projector.

    The argument call has to be a dictionary with the javascript function name
    as key and the argument for it as value.
    """
    projector_js_cache = config['projector_js_cache']
    projector_js_cache.update(calls)
    config['projector_js_cache'] = projector_js_cache
    ProjectorSocketHandler.send_updates({'calls': calls})
Example #9
0
def call_on_projector(calls):
    """
    Sends data to the projector.

    The argument call has to be a dictionary with the javascript function name
    as key and the argument for it as value.
    """
    projector_js_cache = config['projector_js_cache']
    projector_js_cache.update(calls)
    config['projector_js_cache'] = projector_js_cache
    ProjectorSocketHandler.send_updates({'calls': calls})
Example #10
0
 def pre_redirect(self, request, *args, **kwargs):
     if (kwargs['callback'] == 'mediafile' and
             get_active_slide()['callback'] == 'mediafile'):
         # If the current slide is a pdf and the new page is also a slide,
         # we dont have to use set_active_slide, because is causes a content
         # reload.
         kwargs.update({'page_num': 1, 'pk': request.GET.get('pk')})
         url = Mediafile.objects.get(pk=kwargs['pk'], is_presentable=True).mediafile.url
         config['projector_active_slide'] = kwargs
         ProjectorSocketHandler.send_updates(
             {'calls': {'load_pdf': {'url': url, 'page_num': kwargs['page_num']}}})
     else:
         set_active_slide(kwargs['callback'], **dict(request.GET.items()))
     call_on_projector({'scroll': config['projector_scroll'],
                        'scale': config['projector_scale']})
Example #11
0
 def pre_redirect(self, request, *args, **kwargs):
     if (kwargs['callback'] == 'mediafile' and
             get_active_slide()['callback'] == 'mediafile'):
         # TODO: find a way to do this in the mediafile-app
         # If the current slide is a pdf and the new page is also a slide,
         # we dont have to use set_active_slide, because is causes a content
         # reload.
         kwargs.update({'page_num': 1, 'pk': request.GET.get('pk')})
         url = Mediafile.objects.get(pk=kwargs['pk'], is_presentable=True).mediafile.url
         config['projector_active_slide'] = kwargs
         ProjectorSocketHandler.send_updates(
             {'calls': {'load_pdf': {'url': url, 'page_num': kwargs['page_num']}}})
     else:
         set_active_slide(kwargs['callback'], **dict(request.GET.items()))
     call_on_projector({'scroll': config['projector_scroll'],
                        'scale': config['projector_scale']})
Example #12
0
 def get_ajax_context(self, *args, **kwargs):
     config["pdf_fullscreen"] = not config["pdf_fullscreen"]
     active_slide = get_active_slide()
     if active_slide["callback"] == "mediafile":
         ProjectorSocketHandler.send_updates({"calls": {"toggle_fullscreen": config["pdf_fullscreen"]}})
     return {"fullscreen": config["pdf_fullscreen"]}
Example #13
0
 def load_other_page(self, active_slide):
     """
     Tell connected clients to load an other pdf page.
     """
     config["projector_active_slide"] = active_slide
     ProjectorSocketHandler.send_updates({"calls": {"load_pdf_page": active_slide["page_num"]}})
Example #14
0
def update_projector():
    """
    Sends the data to the clients, who listen to the projector.
    """
    # TODO: only send necessary html
    ProjectorSocketHandler.send_updates({'content': get_projector_content()})
Example #15
0
def update_projector():
    """
    Sends the data to the clients, who listen to the projector.
    """
    # TODO: only send necessary html
    ProjectorSocketHandler.send_updates({'content': get_projector_content()})