diff --git a/gallery/__init__.py b/gallery/__init__.py index 8746fc4..03f252b 100644 --- a/gallery/__init__.py +++ b/gallery/__init__.py @@ -58,7 +58,9 @@ def create_app(test_config=None): UPLOAD_FOLDER=os.path.join(USER_DIR, 'uploads'), ALLOWED_EXTENSIONS=conf['upload']['allowed-extensions'], MAX_CONTENT_LENGTH=1024 * 1024 * conf['upload']['max-size'], - WEBSITE=conf['website'], + ADMIN_CONF=conf['admin'], + UPLOAD_CONF=conf['upload'], + WEBSITE_CONF=conf['website'], ) if test_config is None: diff --git a/gallery/api.py b/gallery/api.py index 7e386dc..f5c5a92 100644 --- a/gallery/api.py +++ b/gallery/api.py @@ -49,6 +49,48 @@ def file(file_name): return send_from_directory(os.path.dirname(thumb), os.path.basename(thumb)) +# @blueprint.route('/page', methods=['get']) +# def page(): +# """ +# Returns a json object with all the images +# info required to generate a page +# """ +# page_num = request.args.get('page', default=1, type=int) +# limit = current_app.config['UPLOAD_CONF']['max-load'] + +# if not page_num: +# abort(400, 'No page number specified') +# if not isinstance(page_num, int): +# abort(400, 'Page number is not a number') +# if int(page_num) < 1: +# abort(400, 'Page number is less than 1') + +# # get the total number of images in the database +# # calculate the total number of pages, and make sure the page number is valid +# total_images = db_session.query(db.Posts.id).count() +# pages = ceil(max(total_images, limit) / limit) +# if page_num > pages: +# abort(404, 'You have gone above and beyond, but this isnt a fairy tale.') + +# # get the images for the current page +# images = (db_session.query(db.Posts.filename, db.Posts.alt, db.Posts.colours, +# db.Posts.created_at, db.Posts.id) +# .order_by(db.Posts.id.desc()) +# .offset((page_num - 1) * limit) +# .limit(limit) +# .all()) +# image_list = [] +# for image in images: +# image_list.append({ +# 'id': image.id, +# 'filename': image.filename, +# 'alt': image.alt, +# 'colours': image.colours, +# 'created_at': image.created_at, +# }) +# return jsonify(image_list) + + @blueprint.route('/upload', methods=['POST']) @login_required def upload(): diff --git a/gallery/templates/image.html b/gallery/templates/image.html index e651835..de2b433 100644 --- a/gallery/templates/image.html +++ b/gallery/templates/image.html @@ -1,6 +1,6 @@ {% extends 'layout.html' %} {% block page_index %} -{% if return_page > 1 %}?page={{ return_page }}{% endif %}{% endblock %} +{% if return_page %}?page={{ return_page }}{% endif %}{% endblock %} {% block head %} diff --git a/gallery/templates/index.html b/gallery/templates/index.html index 19224f0..36ae2d7 100644 --- a/gallery/templates/index.html +++ b/gallery/templates/index.html @@ -3,7 +3,7 @@ {% block content %}