mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-11-01 00:25:53 +00:00
Move static routes into a blueprint
and update templates Routes: * /help * /rules * /xmlns/nyaa * /about (commented out)
This commit is contained in:
parent
7e16616a5d
commit
911fbc317f
|
@ -19,7 +19,7 @@ import config
|
||||||
from itsdangerous import BadSignature, URLSafeSerializer
|
from itsdangerous import BadSignature, URLSafeSerializer
|
||||||
from sqlalchemy.orm import joinedload
|
from sqlalchemy.orm import joinedload
|
||||||
|
|
||||||
from nyaa import api_handler, app, backend, db, forms, models, torrents, utils
|
from nyaa import api_handler, app, backend, db, forms, models, torrents, utils, views
|
||||||
from nyaa.search import search_db, search_elastic
|
from nyaa.search import search_db, search_elastic
|
||||||
|
|
||||||
DEBUG_API = False
|
DEBUG_API = False
|
||||||
|
@ -452,11 +452,6 @@ def render_rss(label, query, use_elastic, magnet_links=False):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
# @app.route('/about', methods=['GET'])
|
|
||||||
# def about():
|
|
||||||
# return flask.render_template('about.html')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/login', methods=['GET', 'POST'])
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
def login():
|
def login():
|
||||||
if flask.g.user:
|
if flask.g.user:
|
||||||
|
@ -1006,24 +1001,17 @@ def timesince(dt, default='just now'):
|
||||||
|
|
||||||
return default
|
return default
|
||||||
|
|
||||||
# #################################### STATIC PAGES ####################################
|
|
||||||
|
# #################################### BLUEPRINTS ####################################
|
||||||
|
|
||||||
|
def register_blueprints(flask_app):
|
||||||
|
""" Register the blueprints using the flask_app object """
|
||||||
|
|
||||||
|
# API routes
|
||||||
|
flask_app.register_blueprint(api_handler.api_blueprint, url_prefix='/api')
|
||||||
|
# Site routes
|
||||||
|
flask_app.register_blueprint(views.site_bp)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/rules', methods=['GET'])
|
# When done, this can be moved to nyaa/__init__.py instead of importing this file
|
||||||
def site_rules():
|
register_blueprints(app)
|
||||||
return flask.render_template('rules.html')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/help', methods=['GET'])
|
|
||||||
def site_help():
|
|
||||||
return flask.render_template('help.html')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/xmlns/nyaa', methods=['GET'])
|
|
||||||
def xmlns_nyaa():
|
|
||||||
return flask.render_template('xmlns.html')
|
|
||||||
|
|
||||||
|
|
||||||
# #################################### API ROUTES ####################################
|
|
||||||
|
|
||||||
app.register_blueprint(api_handler.api_blueprint, url_prefix='/api')
|
|
||||||
|
|
|
@ -78,8 +78,8 @@
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li {% if request.path == url_for('site_rules') %}class="active"{% endif %}><a href="{{ url_for('site_rules') }}">Rules</a></li>
|
<li {% if request.path == url_for('site.rules') %}class="active"{% endif %}><a href="{{ url_for('site.rules') }}">Rules</a></li>
|
||||||
<li {% if request.path == url_for('site_help') %}class="active"{% endif %}><a href="{{ url_for('site_help') }}">Help</a></li>
|
<li {% if request.path == url_for('site.help') %}class="active"{% endif %}><a href="{{ url_for('site.help') }}">Help</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="{% if rss_filter %}{{ url_for('home', page='rss', **rss_filter) }}{% else %}{{ url_for('home', page='rss') }}{% endif %}">RSS</a></li>
|
<li><a href="{% if rss_filter %}{{ url_for('home', page='rss', **rss_filter) }}{% else %}{{ url_for('home', page='rss') }}{% endif %}">RSS</a></li>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:nyaa="{{ url_for('xmlns_nyaa', _external=True) }}" version="2.0">
|
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:nyaa="{{ url_for('site.xmlns_nyaa', _external=True) }}" version="2.0">
|
||||||
<channel>
|
<channel>
|
||||||
<title>{{ config.SITE_NAME }} - {{ term }} - {% if not magnet_links %}Torrent File{% else %}Magnet URI{% endif %} RSS</title>
|
<title>{{ config.SITE_NAME }} - {{ term }} - {% if not magnet_links %}Torrent File{% else %}Magnet URI{% endif %} RSS</title>
|
||||||
<description>RSS Feed for {{ term }}</description>
|
<description>RSS Feed for {{ term }}</description>
|
||||||
|
|
|
@ -191,7 +191,7 @@
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="alert alert-warning" role="alert">
|
<div class="alert alert-warning" role="alert">
|
||||||
Before submitting a report, please check that the torrent
|
Before submitting a report, please check that the torrent
|
||||||
actually breaks <a href="{{ url_for('site_rules') }}">the
|
actually breaks <a href="{{ url_for('site.rules') }}">the
|
||||||
rules</a>. Useless reports like "download is slow" or
|
rules</a>. Useless reports like "download is slow" or
|
||||||
"thanks" can get you banned from the site.
|
"thanks" can get you banned from the site.
|
||||||
</div>
|
</div>
|
||||||
|
|
5
nyaa/views/__init__.py
Normal file
5
nyaa/views/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from nyaa.views import (
|
||||||
|
site,
|
||||||
|
)
|
||||||
|
|
||||||
|
site_bp = site.bp
|
23
nyaa/views/site.py
Normal file
23
nyaa/views/site.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import flask
|
||||||
|
|
||||||
|
bp = flask.Blueprint('site', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
# @bp.route('/about', methods=['GET'])
|
||||||
|
# def about():
|
||||||
|
# return flask.render_template('about.html')
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route('/rules', methods=['GET'])
|
||||||
|
def rules():
|
||||||
|
return flask.render_template('rules.html')
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route('/help', methods=['GET'])
|
||||||
|
def help():
|
||||||
|
return flask.render_template('help.html')
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route('/xmlns/nyaa', methods=['GET'])
|
||||||
|
def xmlns_nyaa():
|
||||||
|
return flask.render_template('xmlns.html')
|
Loading…
Reference in a new issue