mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 11:36:16 +00:00
Move routes to their own folder
This commit is contained in:
parent
79db45f7a2
commit
0d10de923d
7 changed files with 35 additions and 44 deletions
|
@ -79,25 +79,15 @@ def create_app(test_config=None):
|
||||||
return render_template('error.html', error=error, msg=msg), err.code
|
return render_template('error.html', error=error, msg=msg), err.code
|
||||||
|
|
||||||
# Load login, registration and logout manager
|
# Load login, registration and logout manager
|
||||||
from . import auth
|
from gallery import auth
|
||||||
app.register_blueprint(auth.blueprint)
|
app.register_blueprint(auth.blueprint)
|
||||||
|
|
||||||
# Load routes for home and images
|
# Load the different routes
|
||||||
from . import routing
|
from .routes import api, groups, routing, settings
|
||||||
app.register_blueprint(routing.blueprint)
|
|
||||||
app.add_url_rule('/', endpoint='index')
|
|
||||||
|
|
||||||
# Load routes for groups
|
|
||||||
from . import groups
|
|
||||||
app.register_blueprint(groups.blueprint)
|
|
||||||
|
|
||||||
# Load routes for settings
|
|
||||||
from . import settings
|
|
||||||
app.register_blueprint(settings.blueprint)
|
|
||||||
|
|
||||||
# Load APIs
|
|
||||||
from . import api
|
|
||||||
app.register_blueprint(api.blueprint)
|
app.register_blueprint(api.blueprint)
|
||||||
|
app.register_blueprint(groups.blueprint)
|
||||||
|
app.register_blueprint(routing.blueprint)
|
||||||
|
app.register_blueprint(settings.blueprint)
|
||||||
|
|
||||||
logging.info('Gallery started successfully!')
|
logging.info('Gallery started successfully!')
|
||||||
|
|
||||||
|
|
|
@ -136,3 +136,4 @@ class Bans (base): # pylint: disable=too-few-public-methods, C0103
|
||||||
# check if database file exists, if not create it
|
# check if database file exists, if not create it
|
||||||
if not os.path.isfile(DB_PATH):
|
if not os.path.isfile(DB_PATH):
|
||||||
base.metadata.create_all(engine)
|
base.metadata.create_all(engine)
|
||||||
|
print('Database created')
|
|
@ -18,8 +18,8 @@ from PIL import Image, ImageOps, ImageFilter
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
from gallery.auth import login_required
|
from gallery.auth import login_required
|
||||||
|
|
||||||
from . import db
|
from gallery import db
|
||||||
from . import metadata as mt
|
from gallery import metadata as mt
|
||||||
|
|
||||||
|
|
||||||
blueprint = Blueprint('api', __name__, url_prefix='/api')
|
blueprint = Blueprint('api', __name__, url_prefix='/api')
|
|
@ -9,10 +9,7 @@ from datetime import datetime as dt
|
||||||
from flask import Blueprint, abort, jsonify, render_template, url_for, request, g
|
from flask import Blueprint, abort, jsonify, render_template, url_for, request, g
|
||||||
|
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
from gallery import db
|
||||||
from gallery.auth import login_required
|
|
||||||
|
|
||||||
from . import db # Import db to create a session
|
|
||||||
|
|
||||||
|
|
||||||
blueprint = Blueprint('group', __name__, url_prefix='/group')
|
blueprint = Blueprint('group', __name__, url_prefix='/group')
|
||||||
|
@ -31,15 +28,11 @@ def groups():
|
||||||
thumbnail = db_session.query(db.GroupJunction.post_id).filter(db.GroupJunction.group_id == group.id).order_by(db.GroupJunction.date_added.desc()).first()
|
thumbnail = db_session.query(db.GroupJunction.post_id).filter(db.GroupJunction.group_id == group.id).order_by(db.GroupJunction.date_added.desc()).first()
|
||||||
|
|
||||||
if thumbnail is not None:
|
if thumbnail is not None:
|
||||||
group.thumbnail = db_session.query(db.Posts.file_name,
|
group.thumbnail = db_session.query(db.Posts.file_name, db.Posts.post_alt, db.Posts.image_colours, db.Posts.id).filter(db.Posts.id == thumbnail[0]).first()
|
||||||
db.Posts.post_alt,
|
|
||||||
db.Posts.image_colours,
|
|
||||||
db.Posts.id).filter(db.Posts.id == thumbnail[0]).first()
|
|
||||||
else:
|
|
||||||
group.thumbnail = None
|
|
||||||
|
|
||||||
return render_template('groups/list.html', groups=groups)
|
return render_template('groups/list.html', groups=groups)
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route('/<int:group_id>')
|
@blueprint.route('/<int:group_id>')
|
||||||
def group(group_id):
|
def group(group_id):
|
||||||
"""
|
"""
|
||||||
|
@ -48,7 +41,7 @@ def group(group_id):
|
||||||
group = db_session.query(db.Groups).filter(db.Groups.id == group_id).first()
|
group = db_session.query(db.Groups).filter(db.Groups.id == group_id).first()
|
||||||
|
|
||||||
if group is None:
|
if group is None:
|
||||||
abort(404, 'Group not found')
|
abort(404, 'Group not found! D:')
|
||||||
|
|
||||||
group.author_username = db_session.query(db.Users.username).filter(db.Users.id == group.author_id).first()[0]
|
group.author_username = db_session.query(db.Users.username).filter(db.Users.id == group.author_id).first()[0]
|
||||||
|
|
||||||
|
@ -61,6 +54,7 @@ def group(group_id):
|
||||||
|
|
||||||
return render_template('groups/group.html', group=group, images=images)
|
return render_template('groups/group.html', group=group, images=images)
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route('/<int:group_id>/<int:image_id>')
|
@blueprint.route('/<int:group_id>/<int:image_id>')
|
||||||
def group_post(group_id, image_id):
|
def group_post(group_id, image_id):
|
||||||
"""
|
"""
|
|
@ -7,9 +7,7 @@ from flask import Blueprint, render_template, url_for
|
||||||
from werkzeug.exceptions import abort
|
from werkzeug.exceptions import abort
|
||||||
|
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
from gallery import db
|
||||||
from . import db
|
|
||||||
from . import metadata as mt
|
|
||||||
|
|
||||||
|
|
||||||
blueprint = Blueprint('gallery', __name__)
|
blueprint = Blueprint('gallery', __name__)
|
|
@ -139,6 +139,7 @@
|
||||||
<td><span class="time">{{ image.created_at }}</span></td>
|
<td><span class="time">{{ image.created_at }}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
{% if group and image.author_id == g.user.id %}
|
||||||
<div class="img-groups">
|
<div class="img-groups">
|
||||||
{% for group in image.groups %}
|
{% for group in image.groups %}
|
||||||
<a href="/group/{{ group.id }}" class="tag-icon">
|
<a href="/group/{{ group.id }}" class="tag-icon">
|
||||||
|
@ -146,13 +147,20 @@
|
||||||
{{ group['name'] }}
|
{{ group['name'] }}
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if image.author_id == g.user.id %}
|
|
||||||
<button class="tag-icon" id="#img-group">
|
<button class="tag-icon" id="#img-group">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"></path></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"></path></svg>
|
||||||
Add
|
Add
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
{% elif image.author_id == g.user.id %}
|
||||||
|
<div class="img-groups">
|
||||||
|
<button class="tag-icon" id="#img-group">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"></path></svg>
|
||||||
|
Add
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% for tag in image.image_exif %}
|
{% for tag in image.image_exif %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue