Esempio n. 1
0
def episode(web, site, id, mode, errors=[]):
    try: # FIXME wrap db queries into one
        episode  = Episode.find().filter_by(link = id).one()
        files    = File.find().filter_by(episode = episode.id).all()
        links    = Link.find().filter_by(episode = episode.id).all()
        comments = Comment.find().filter_by(episode = episode.id).\
                   order_by(Comment.date).all()
        ratings  = Rating.find().filter_by(episode = episode.id).all()
        trackbacks = Trackback.find().filter_by(episode = episode.id).\
                     order_by(Trackback.date).all()
    except Exception as e: return notfound(str(e))
    if mode is None: mode = ""
    if len(mode): mode = mode[1:]
    opts = {}
    opts.update(create_session(web, mode))
    opts.update(do_the_comments(web, mode, comments))
    opts.update(do_the_ratings(web, mode, ratings))
    return template("episode.tpl",
                    errors     = errors,
                    css        = "episode",
                    episode    = episode,
                    episodes   = {episode.id: episode},
                    site       = site,
                    trackbacks = trackbacks,
                    files      = files,
                    links      = links,
                    csss       = [ "../lib/audio-js/audio-js",
                                   "../lib/audio-js/skins/vim",
                                   "vim"],
                    **opts
                   )
Esempio n. 2
0
def datenspur(web, id, mode, errors=[]):
    try: # FIXME wrap db queries into one
        episodes = Episode.find().filter(Episode.category.endswith(id)).\
                order_by(Episode.date).all()
        episodes.reverse()
        comments_count = [ Comment.find().filter_by(episode = e.id).count()
                        for e in episodes ]
        ratings = [ do_the_ratings(web, "", Rating.find().\
                    filter_by(episode = e.id).all())['rating']
                    for e in episodes ]
        episode = Episode.find().filter_by(link = id).one()
        for ep in episodes:
            ep.has_screen = True
            ep.files = File.find().filter_by(episode = ep.id).all()
            ep.preview = get_preview(Preview.find().\
                filter_by(episode = episode.id).all(), ep.files)
        comments = Comment.find().filter_by(episode = episode.id).all()
        rating = Rating.find().filter_by(episode = episode.id).all()
    except Exception as e: return notfound(str(e))
    if mode is None: mode = ""
    if len(mode): mode = mode[1:]
    opts = {}
    opts.update(create_session(web, mode))
    opts.update(do_the_comments(web, mode, comments))
    opts.update(do_the_ratings(web, mode, rating))
    return template("datenspuren.tpl",
                    errors      = errors,
                    css         = "episode",
                    episodepage = zip(episodes, comments_count, ratings),
                    site        = "datenspuren",
                    full_site   = "datenspuren/" + id,
                    episode     = episode,
                    **opts
                   )
Esempio n. 3
0
def template_mode(web, site, episode, mode, **kwargs):
    opts, func = {}, template_comments
    if mode is None: mode = ""
    if len(mode): mode = mode[1:]
    if mode in _template_functions:
        func = _template_functions[mode]
    tpl, worker = func()
    kwargs = dict(kwargs)
    kwargs.update(site = site, episode = episode)
    wopts = worker(web, mode, **kwargs)
    opts.update(create_session(web, mode))
    opts.update(css = "episode")
    opts.update(kwargs)
    opts.update(wopts)
    return template(tpl, **opts)
Esempio n. 4
0
def datenspur_file(web, id, filename, mode, errors=[]):
    try: # FIXME wrap db queries into one
        episode = Episode.find().filter_by(link = filename).\
                filter(Episode.category.endswith(id)).\
                order_by(Episode.date).one()
        comments = Comment.find().filter_by(episode = episode.id).all()
        files    = File.find().filter_by(episode = episode.id).all()
        ratings  = Rating.find().filter_by(episode = episode.id).all()
        previews = Preview.find().filter_by(episode = episode.id).all()
        trackbacks = Trackback.find().filter_by(episode = episode.id).\
                    order_by(Trackback.date).all()
    except Exception as e: return notfound(str(e))
    episode.files = files
    if mode is None: mode = ""
    if len(mode): mode = mode[1:]
    opts = {}
    opts.update(create_session(web, mode))
    opts.update(do_the_comments(web, mode, comments))
    opts.update(do_the_ratings(web, mode, ratings))
    preview = get_preview(previews, files)
    csss = [ "../lib/video-js/video-js", "../lib/video-js/skins/vim", "vim"]
    if episode.isaudio():
        csss = list(map(lambda s:s.replace("video", "audio"), csss))
    return template("datenspur.tpl",
                    errors     = errors,
                    css        = "episode",
                    episode    = episode,
                    episodes   = {episode.id: episode},
                    site       = "datenspuren",
                    full_site  = "datenspuren/" + id,
                    trackbacks = trackbacks,
                    files      = files,
                    preview    = preview,
                    csss       = csss,
                    **opts
                   )