Ejemplo n.º 1
0
 def get_impl(self):
     threads = self._get_threads()
     for thread in threads:
         board_id = thread["board"]
         board = db.session.query(Board).get(board_id)
         thread["board"] = board.name
     render_for_catalog(threads)
     return threads
Ejemplo n.º 2
0
def view_catalog(board_id):
    threads = BoardCatalog().retrieve(board_id)
    board_name = db.session.query(Board).filter(
        Board.id == board_id).one().name
    render_for_catalog(threads)
    return render_template("catalog.html",
                           threads=threads,
                           board_id=board_id,
                           board_name=board_name)
Ejemplo n.º 3
0
def catalog(board_id):
    threads = BoardCatalog().retrieve(board_id)
    board = db.session.query(Board).get(board_id)
    board_name = board.name
    render_for_catalog(threads)
    return render_template("catalog.html",
                           threads=threads,
                           board=board,
                           board_name=board_name)
Ejemplo n.º 4
0
def catalog(board_id):
    current_theme = session.get("theme") or app.config.get(
        "DEFAULT_THEME") or "stock"
    response_cache_key = "board-%d-%d-%s-render" % (
        board_id, get_slip_bitmask(), current_theme)
    cache_connection = cache.Cache()
    cached_response_body = cache_connection.get(response_cache_key)
    etag_value = "%s-%f" % (response_cache_key, time.time())
    etag_cache_key = "%s-etag" % response_cache_key
    if cached_response_body:
        etag_header = request.headers.get("If-None-Match")
        current_etag = cache_connection.get(etag_cache_key)
        if etag_header:
            parsed_etag = parse_etags(etag_header)
            if parsed_etag.contains_weak(current_etag):
                return make_response("", 304)
        cached_response = make_response(cached_response_body)
        cached_response.set_etag(current_etag, weak=True)
        cached_response.headers["Cache-Control"] = "public,must-revalidate"
        return cached_response
    threads = BoardCatalog().retrieve(board_id)
    board = db.session.query(Board).get(board_id)
    board_name = board.name
    render_for_catalog(threads)
    tag_styles = get_tags(threads)
    catalog_data = {}
    catalog_data["tag_styles"] = tag_styles
    for thread in threads:
        del thread["last_updated"]
    catalog_data["threads"] = threads
    extra_data = {}
    if app.config.get("CAPTCHA_METHOD") == "CAPTCHOULI":
        extra_data = renderer.captchouli_to_json(captchouli.request_captcha())
    template = renderer.render_catalog(catalog_data, board_name, board_id,
                                       extra_data)
    uncached_response = make_response(template)
    uncached_response.set_etag(etag_value, weak=True)
    uncached_response.headers["Cache-Control"] = "public,must-revalidate"
    cache_connection.set(response_cache_key, template)
    cache_connection.set(etag_cache_key, etag_value)
    return uncached_response
Ejemplo n.º 5
0
def catalog(board_id):
    current_theme = session.get("theme") or app.config.get(
        "DEFAULT_THEME") or "stock"
    response_cache_key = "board-%d-%d-%s-render" % (
        board_id, get_slip_bitmask(), current_theme)
    cache_connection = cache.Cache()
    cached_response_body = cache_connection.get(response_cache_key)
    etag_value = "%s-%f" % (response_cache_key, time.time())
    etag_cache_key = "%s-etag" % response_cache_key
    if cached_response_body:
        etag_header = request.headers.get("If-None-Match")
        current_etag = cache_connection.get(etag_cache_key)
        if etag_header:
            parsed_etag = parse_etags(etag_header)
            if parsed_etag.contains_weak(current_etag):
                return make_response("", 304)
        cached_response = make_response(cached_response_body)
        cached_response.set_etag(current_etag, weak=True)
        cached_response.headers["Cache-Control"] = "public,must-revalidate"
        return cached_response
    threads = BoardCatalog().retrieve(board_id)
    board = db.session.query(Board).get(board_id)
    board_name = board.name
    render_for_catalog(threads)
    tag_styles = get_tags(threads)
    template = render_template("catalog.html",
                               threads=threads,
                               board=board,
                               board_name=board_name,
                               tag_styles=tag_styles)
    uncached_response = make_response(template)
    uncached_response.set_etag(etag_value, weak=True)
    uncached_response.headers["Cache-Control"] = "public,must-revalidate"
    cache_connection.set(response_cache_key, template)
    cache_connection.set(etag_cache_key, etag_value)
    return uncached_response
Ejemplo n.º 6
0
 def get_impl(self):
     threads = self._get_threads()
     render_for_catalog(threads)
     return threads