Move the remaining template_global into 'template-utils' blueprint

This commit is contained in:
Kfir Hadas
2017-07-22 06:29:38 +03:00
parent 93f94023d1
commit c539795fdc
3 changed files with 8 additions and 9 deletions

View File

@@ -1,15 +1,8 @@
from nyaa import api_handler, app, template_utils, views
from nyaa.backend import get_category_id_map
DEBUG_API = False
@app.template_global()
def category_name(cat_id):
''' Given a category id (eg. 1_2), returns a category name (eg. Anime - English-translated) '''
return ' - '.join(get_category_id_map().get(cat_id, ['???']))
# #################################### BLUEPRINTS ####################################
def register_blueprints(flask_app):

View File

@@ -6,6 +6,7 @@ import flask
from werkzeug.urls import url_encode
from nyaa import app
from nyaa.backend import get_category_id_map
bp = flask.Blueprint('template-utils', __name__)
_static_cache = {} # For static_cachebuster
@@ -54,6 +55,12 @@ def filter_truthy(input_list):
return [item for item in input_list if item]
@bp.app_template_global()
def category_name(cat_id):
""" Given a category id (eg. 1_2), returns a category name (eg. Anime - English-translated) """
return ' - '.join(get_category_id_map().get(cat_id, ['???']))
# ######################### TEMPLATE FILTERS #########################
@bp.app_template_filter('utc_time')