mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 11:36:16 +00:00
Unifying style of the gallery
Fixed HTML and Sass layout Moved upload and login pages to popups Added deletion confirmation
This commit is contained in:
parent
0414cda5d3
commit
bb98701430
44 changed files with 1777 additions and 1631 deletions
|
@ -4,8 +4,10 @@ from werkzeug.utils import secure_filename
|
|||
from gallery.auth import login_required
|
||||
from gallery.db import get_db
|
||||
from PIL import Image
|
||||
from PIL.ExifTags import TAGS
|
||||
import os
|
||||
import datetime
|
||||
|
||||
dt = datetime.datetime.now()
|
||||
|
||||
blueprint = Blueprint('gallery', __name__)
|
||||
|
@ -14,19 +16,60 @@ blueprint = Blueprint('gallery', __name__)
|
|||
@blueprint.route('/')
|
||||
def index():
|
||||
db = get_db()
|
||||
images = db.execute(
|
||||
'SELECT * FROM posts'
|
||||
' ORDER BY created_at DESC'
|
||||
).fetchall()
|
||||
|
||||
images = db.execute('SELECT * FROM posts'
|
||||
' ORDER BY created_at DESC').fetchall()
|
||||
|
||||
return render_template('index.html', images=images)
|
||||
|
||||
|
||||
@blueprint.route('/image/<int:id>')
|
||||
def image(id):
|
||||
# Get image from database
|
||||
db = get_db()
|
||||
image = db.execute('SELECT * FROM posts'
|
||||
' WHERE id = ?', (id, )).fetchone()
|
||||
|
||||
if image is None:
|
||||
abort(404)
|
||||
|
||||
# Get exif data from image
|
||||
try:
|
||||
file = Image.open(
|
||||
os.path.join(current_app.config['UPLOAD_FOLDER'],
|
||||
image['file_name']))
|
||||
raw_exif = file.getexif()
|
||||
human_exif = {}
|
||||
|
||||
for tag in raw_exif:
|
||||
name = TAGS.get(tag, tag)
|
||||
value = raw_exif.get(tag)
|
||||
|
||||
if isinstance(value, bytes):
|
||||
value = value.decode()
|
||||
|
||||
human_exif[name] = value
|
||||
|
||||
if len(human_exif) == 0:
|
||||
human_exif = False
|
||||
except:
|
||||
# Cringe, no file present
|
||||
human_exif = False
|
||||
file = False
|
||||
|
||||
# All in le head
|
||||
return render_template('image.html',
|
||||
image=image,
|
||||
exif=human_exif,
|
||||
file=file)
|
||||
|
||||
|
||||
@blueprint.route('/group')
|
||||
def groups():
|
||||
return render_template('group.html', group_id='gwa gwa')
|
||||
|
||||
|
||||
@blueprint.route('/group/<int:id>')
|
||||
def group(id):
|
||||
def group(id):
|
||||
return render_template('group.html', group_id=id)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue