예제 #1
0
def feed_episodes(web, mode):
    try:
        episodes = Episode.find().order_by(Episode.date).all()
    except: return notfound("No Episodes not found.")
    if mode == "atom":
        return template_episodes_atom(
            title = "Pentamedia-Portal // Episodes",
            episodes = episodes
                            )
    elif mode == "json":
        return template_json(web, {
            "episodes": list(map(episode_to_json, episodes))
                            })
    else: return notfound("Type not supported.")
예제 #2
0
def feed_episodes_by_category(web, site, mode):
    try:
        episodes = Episode.find().filter_by(category = site).\
                    order_by(Episode.date).all()
    except: return notfound("Category not found.")
    if mode == "atom":
        return template_episodes_atom(
            title = "Pentamedia-Portal // P{0} // Episodes".format(site[1:]),
            episodes = episodes
                            )
    elif mode == "json":
        return template_json(web, {
            "episodes": list(map(episode_to_json, episodes))
                            })
    else: return notfound("Type not supported.")
예제 #3
0
def datenspuren(web, errors=[]):
    try: # FIXME wrap db queries into one
        episodes = Episode.find().filter(Episode.category.startswith("ds")).\
                order_by(Episode.date).all()
        episodes.reverse()
        comments_count, ratings = [], []
        for episode in episodes:
            ids = list(map(lambda e:e.id, Episode.find(Episode.id).\
                filter_by(category = "file/{0}/{1}".\
                format(episode.category, episode.link)).all()))
            f_rts = Rating.find().filter(Rating.episode.in_(ids)).all()
            e_rts = Rating.find().filter_by(episode = episode.id).all()
            ratings += [ do_the_ratings(web, "", e_rts + f_rts)['rating'] ]
            comments_count += [
                Comment.find().filter(Comment.episode.in_(ids)).count() +
                Comment.find().filter_by( episode = episode.id).count() ]
            count = File.find().filter_by(episode = episode.id).count()
            episode.filescount = "// {0} File{1}".format(count,
                count != 1 and "s" or "")
    except Exception as e: return notfound(str(e))
    return template("episodes.tpl",
                    errors      = errors,
                    css         = "episode",
                    episodepage = zip(episodes, comments_count, ratings),
                    site        = "datenspuren"
                   )
예제 #4
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
                   )
예제 #5
0
def comments_per_episode(web, episode, comments, site, mode):
    comments = build_comment_tree(comments)
    if mode == "atom":
        return template_atom(
            title    = "Pentamedia-Portal // {0} // Comments".format(episode.name),
            episodes = {episode.id: episode},
            comments = comments
                            )
    elif mode == "json":
        if web.input("html"):
            html = template("comments.inner_html.tpl",
                            isjson       = True,
                            episode      = episode,
                            site         = site,
                            comments     = comments
                           )
            return template_json(web, {
                "html"    : html.body,
                "new_link": "/{0}/{1}/comments/comment#new".format(site, episode.link)
                                })
        return template_json(web ,{
            "comments": list(map(comment_to_json,comments)),
            "new_link": "/{0}/{1}/comments/comment#new".format(episode.category, episode.link)
                            })
    else:  return notfound("Type not supported.")
예제 #6
0
def feed_comments_by_slug(web, site, id, mode):
    try: # FIXME wrap db queries into one
        episode  = Episode.find().filter_by(link = id).one()
        comments = Comment.find().filter_by(episode = episode.id).\
                    order_by(Comment.date).all()
    except: return notfound("Episode not found.")
    return comments_per_episode(web, episode, comments, site, mode)
예제 #7
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
                   )
예제 #8
0
def cat_image(web, typ):
    try:
        hash = web['QUERY_STRING']
        iscat = typ in cache(hash)[2]
        nr = cache(hash)[3][ord(typ)-65]
    except Exception as e: return notfound(str(e))
    yield_file("static/img/{0}acat{1}.jpeg".\
        format(not iscat and "not" or "", nr))
예제 #9
0
def comments(web, site, id, mode, errors=[]):
    try: # FIXME wrap db queries into one
        episode  = Episode.find().filter_by(link = id).one()
        comments = Comment.find().filter_by(episode = episode.id).\
                   order_by(Comment.date).all()
    except: return notfound("Episode not found.")
    return template_mode(web, site, episode, mode,
                         errors   = errors,
                         comments = comments
                        )
예제 #10
0
def ratings(web, site, id, mode, errors=[]):
    try: # FIXME wrap db queries into one
        episode  = Episode.find().filter_by(link = id).one()
        ratings = Rating.find().filter_by(episode = episode.id).all()
    except: return notfound("Episode not found.")
    return template_mode(web, site, episode,
                         (mode == '/' or mode is None) and "/rating" or mode,
                         errors             = errors,
                         hide_rating_detail = True,
                         ratings = ratings)
예제 #11
0
def rating_by_filename(web, filename, mode):
    filename = "content/news/{0}.xml".format(filename)
    try: # FIXME wrap db queries into one
        episode  = Episode.find().filter_by(filename = filename).one()
        ratings  = Rating.find().filter_by(episode = episode.id).all()
        if   "radio" in filename: site = "pentaradio"
        elif "cast"  in filename: site = "pentacast"
        elif "music" in filename: site = "pentamusic"
        else: site = 42 / 0
    except: return notfound("Episode not found.")
    return rating_per_episode(web, episode, ratings, site, mode)
예제 #12
0
def feed_comments_by_filename(web, filename, mode):
    filename = "content/news/{0}.xml".format(filename)
    try: # FIXME wrap db queries into one
        episode  = Episode.find().filter_by(filename = filename).one()
        comments = Comment.find().filter_by(episode = episode.id).\
                    order_by(Comment.date).all()
        if   "radio" in filename: site = "pentaradio"
        elif "cast"  in filename: site = "pentacast"
        elif "music" in filename: site = "pentamusic"
        else: site = 42 / 0
    except: return notfound("Episode not found.")
    return comments_per_episode(web, episode, comments, site, mode)
예제 #13
0
def rating_per_episode(web, episode, ratings, site, mode):
    opts = do_the_ratings(web, mode, ratings)
    opts.update( rating_form = False, site = site, episode = episode)
    if mode == "json":
        if web.input('html'):
            html = template("rating.inner_html.tpl", isjson = True, **opts)
            return template_json(web, {
                "html"     : html.body,
                "new_link" : "/{0}/{1}/ratings/rate#new".format(site, episode.link)
                                })
        return template_json(web ,{
            "rating": opts['rating'],
            "new_link": "/{0}/{1}/ratings/rate#new".format(episode.category, episode.link)
                            })
    else:  return notfound("Type not supported.")
예제 #14
0
def ratings_by_filename(web, filename, mode, errors=[]):
    filename = "content/news/{0}.xml".format(filename)
    try: # FIXME wrap db queries into one
        episode  = Episode.find().filter_by(filename = filename).one()
        ratings = Rating.find().filter_by(episode = episode.id).all()
        if   "radio" in filename: site = "pentaradio"
        elif "cast"  in filename: site = "pentacast"
        elif "music" in filename: site = "pentamusic"
        else: site = 42 / 0
    except Exception as e: return notfound(str(e))
    return template_mode(web, site, episode,
                         (mode == '/' or mode is None) and "/rating" or mode,
                         errors             = errors,
                         hide_rating_detail = True,
                         ratings = ratings)
예제 #15
0
def comments_by_filename(web, filename, mode, errors=[]):
    filename = "content/news/{0}.xml".format(filename)
    try: # FIXME wrap db queries into one
        episode  = Episode.find().filter_by(filename = filename).one()
        comments = Comment.find().filter_by(episode = episode.id).\
                   order_by(Comment.date).all()
        if   "radio" in filename: site = "pentaradio"
        elif "cast"  in filename: site = "pentacast"
        elif "music" in filename: site = "pentamusic"
        else: site = 42 / 0
    except Exception as e: return notfound(str(e))
    return template_mode(web, site, episode, mode,
                         errors   = errors,
                         comments = comments
                        )
예제 #16
0
def main(web, site, errors=[]):
    try: # FIXME wrap db queries into one
        episodes = Episode.find().filter_by(category=site).\
                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 ]
    except Exception as e: return notfound(str(e))
    return template("episodes.tpl",
                    errors      = errors,
                    css         = "episode",
                    episodepage = zip(episodes, comments_count, ratings),
                    site        = site
                   )
예제 #17
0
def feed_all_comments(web, mode):
    # FIXME wrap db queries into one
    episodes = Episode.find().all()
    comments = Comment.find().all()
    trackbacks = Trackback.find().all()
    if mode == "atom":
        entries = comments + trackbacks
        entries.sort(key=lambda e: e.date)
        entries.reverse()
        id_episodes = {}
        for episode in episodes:
            id_episodes[episode.id] = episode
        return template_atom(
                        title    = "Pentamedia-Portal // Comments",
                        episodes = id_episodes,
                        comments = entries
                       )
    elif mode == "json":
        return template_json(web, {
            "comments":   list(map(comment_to_json, comments)),
            "trackbacks": list(map(trackback_to_json, trackbacks))
                           })
    else:  return notfound("Type not supported.")
예제 #18
0
def feed_comments_by_category(web, site, mode):
    # FIXME wrap db queries into one
    episodes = Episode.find().filter_by(category = site).\
               order_by(Episode.date).all()
    episodes.reverse()
    comments, id_episodes = [], {}
    for episode in episodes:
        comments.extend(Comment.find().filter_by(episode = episode.id).all())
        id_episodes[episode.id] = episode
    comments.sort(key=lambda cmnt: cmnt.date)
    comments.reverse()
    if mode == "atom":
        return template_atom(
            title    = "Pentamedia-Portal // P{0} // Comments".format(site[1:]),
            episodes = id_episodes,
            comments = comments
                       )
    elif mode == "json":
        return template_json(web, {
            "comments": list(map(comment_to_json,comments)),
            "new_link": "/{0}/{1}/comment#new".format(episode.category,episode.link)
                                  })
    else: return  notfound("Type not supported.")
예제 #19
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
                   )
예제 #20
0
def rating_by_slug(web, site, id, mode):
    try: # FIXME wrap db queries into one
        episode  = Episode.find().filter_by(link = id).one()
        ratings  = Rating.find().filter_by(episode = episode.id).all()
    except: return notfound("Episode not found.")
    return rating_per_episode(web, episode, ratings, site, mode)