mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 03:26: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
|
||||
|
||||
# Load login, registration and logout manager
|
||||
from . import auth
|
||||
from gallery import auth
|
||||
app.register_blueprint(auth.blueprint)
|
||||
|
||||
# Load routes for home and images
|
||||
from . import routing
|
||||
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
|
||||
# Load the different routes
|
||||
from .routes import api, groups, routing, settings
|
||||
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!')
|
||||
|
||||
|
|
|
@ -136,3 +136,4 @@ class Bans (base): # pylint: disable=too-few-public-methods, C0103
|
|||
# check if database file exists, if not create it
|
||||
if not os.path.isfile(DB_PATH):
|
||||
base.metadata.create_all(engine)
|
||||
print('Database created')
|
|
@ -18,8 +18,8 @@ from PIL import Image, ImageOps, ImageFilter
|
|||
from sqlalchemy.orm import sessionmaker
|
||||
from gallery.auth import login_required
|
||||
|
||||
from . import db
|
||||
from . import metadata as mt
|
||||
from gallery import db
|
||||
from gallery import metadata as mt
|
||||
|
||||
|
||||
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 sqlalchemy.orm import sessionmaker
|
||||
|
||||
from gallery.auth import login_required
|
||||
|
||||
from . import db # Import db to create a session
|
||||
from gallery import db
|
||||
|
||||
|
||||
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()
|
||||
|
||||
if thumbnail is not None:
|
||||
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()
|
||||
else:
|
||||
group.thumbnail = None
|
||||
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()
|
||||
|
||||
return render_template('groups/list.html', groups=groups)
|
||||
|
||||
|
||||
@blueprint.route('/<int: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()
|
||||
|
||||
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]
|
||||
|
||||
|
@ -61,6 +54,7 @@ def group(group_id):
|
|||
|
||||
return render_template('groups/group.html', group=group, images=images)
|
||||
|
||||
|
||||
@blueprint.route('/<int:group_id>/<int: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 sqlalchemy.orm import sessionmaker
|
||||
|
||||
from . import db
|
||||
from . import metadata as mt
|
||||
from gallery import db
|
||||
|
||||
|
||||
blueprint = Blueprint('gallery', __name__)
|
|
@ -139,20 +139,28 @@
|
|||
<td><span class="time">{{ image.created_at }}</span></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="img-groups">
|
||||
{% for group in image.groups %}
|
||||
<a href="/group/{{ group.id }}" class="tag-icon">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M224,88V200.89a7.11,7.11,0,0,1-7.11,7.11H40a8,8,0,0,1-8-8V64a8,8,0,0,1,8-8H93.33a8,8,0,0,1,4.8,1.6l27.74,20.8a8,8,0,0,0,4.8,1.6H216A8,8,0,0,1,224,88Z" opacity="0.2"></path><path d="M216,72H130.67L102.93,51.2a16.12,16.12,0,0,0-9.6-3.2H40A16,16,0,0,0,24,64V200a16,16,0,0,0,16,16H216.89A15.13,15.13,0,0,0,232,200.89V88A16,16,0,0,0,216,72Zm0,128H40V64H93.33l27.74,20.8a16.12,16.12,0,0,0,9.6,3.2H216Z"></path></svg>
|
||||
{{ group['name'] }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% if image.author_id == g.user.id %}
|
||||
{% if group and image.author_id == g.user.id %}
|
||||
<div class="img-groups">
|
||||
{% for group in image.groups %}
|
||||
<a href="/group/{{ group.id }}" class="tag-icon">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M224,88V200.89a7.11,7.11,0,0,1-7.11,7.11H40a8,8,0,0,1-8-8V64a8,8,0,0,1,8-8H93.33a8,8,0,0,1,4.8,1.6l27.74,20.8a8,8,0,0,0,4.8,1.6H216A8,8,0,0,1,224,88Z" opacity="0.2"></path><path d="M216,72H130.67L102.93,51.2a16.12,16.12,0,0,0-9.6-3.2H40A16,16,0,0,0,24,64V200a16,16,0,0,0,16,16H216.89A15.13,15.13,0,0,0,232,200.89V88A16,16,0,0,0,216,72Zm0,128H40V64H93.33l27.74,20.8a16.12,16.12,0,0,0,9.6,3.2H216Z"></path></svg>
|
||||
{{ group['name'] }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
||||
<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>
|
||||
{% 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>
|
||||
{% for tag in image.image_exif %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue