mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 03:26:16 +00:00
Make Metadata Parser readable with ChatGPT 💀
Remove useless code for fullscreening image
This commit is contained in:
parent
e6d289ed64
commit
b0a9271265
7 changed files with 48 additions and 103 deletions
|
@ -5,7 +5,7 @@
|
||||||
| |_| | | | | | |_| | |__| __/ (_| \__ \
|
| |_| | | | | | |_| | |__| __/ (_| \__ \
|
||||||
\___/|_| |_|_|\__, |_____\___|\__, |___/
|
\___/|_| |_|_|\__, |_____\___|\__, |___/
|
||||||
|___/ |___/
|
|___/ |___/
|
||||||
Created by Fluffy Bean - Version 23.03.09
|
Created by Fluffy Bean - Version 23.03.10
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Import system modules
|
# Import system modules
|
||||||
|
@ -48,7 +48,7 @@ def create_app(test_config=None):
|
||||||
"""
|
"""
|
||||||
app = Flask(__name__,instance_path=os.path.join(USER_DIR, 'instance'))
|
app = Flask(__name__,instance_path=os.path.join(USER_DIR, 'instance'))
|
||||||
assets = Environment()
|
assets = Environment()
|
||||||
cache = Cache(config={'CACHE_TYPE': 'SimpleCache', 'CACHE_DEFAULT_TIMEOUT': 69})
|
cache = Cache(config={'CACHE_TYPE': 'SimpleCache', 'CACHE_DEFAULT_TIMEOUT': 300})
|
||||||
compress = Compress()
|
compress = Compress()
|
||||||
|
|
||||||
# App configuration
|
# App configuration
|
||||||
|
@ -59,8 +59,6 @@ def create_app(test_config=None):
|
||||||
ALLOWED_EXTENSIONS=conf['upload']['allowed-extensions'],
|
ALLOWED_EXTENSIONS=conf['upload']['allowed-extensions'],
|
||||||
MAX_CONTENT_LENGTH=1024 * 1024 * conf['upload']['max-size'],
|
MAX_CONTENT_LENGTH=1024 * 1024 * conf['upload']['max-size'],
|
||||||
WEBSITE=conf['website'],
|
WEBSITE=conf['website'],
|
||||||
ADMIN=conf['admin'],
|
|
||||||
APP_VERSION='23.03.09',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if test_config is None:
|
if test_config is None:
|
||||||
|
@ -74,43 +72,23 @@ def create_app(test_config=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Load theme
|
||||||
theme_manager.CompileTheme('default', app.root_path)
|
theme_manager.CompileTheme('default', app.root_path)
|
||||||
|
|
||||||
|
|
||||||
# Bundle JS files
|
# Bundle JS files
|
||||||
js = Bundle('js/*.js', output='gen/packed.js')
|
js = Bundle('js/*.js', output='gen/packed.js')
|
||||||
assets.register('js_all', js)
|
assets.register('js_all', js)
|
||||||
|
|
||||||
|
|
||||||
@app.errorhandler(405)
|
|
||||||
def method_not_allowed(err):
|
|
||||||
error = '405'
|
|
||||||
msg = err.description
|
|
||||||
return render_template('error.html', error=error, msg=msg), 404
|
|
||||||
|
|
||||||
@app.errorhandler(404)
|
|
||||||
def page_not_found(err):
|
|
||||||
error = '404'
|
|
||||||
msg = err.description
|
|
||||||
return render_template('error.html', error=error, msg=msg), 404
|
|
||||||
|
|
||||||
@app.errorhandler(403)
|
@app.errorhandler(403)
|
||||||
def forbidden(err):
|
@app.errorhandler(404)
|
||||||
error = '403'
|
@app.errorhandler(405)
|
||||||
msg = err.description
|
|
||||||
return render_template('error.html', error=error, msg=msg), 403
|
|
||||||
|
|
||||||
@app.errorhandler(410)
|
@app.errorhandler(410)
|
||||||
def gone(err):
|
|
||||||
error = '410'
|
|
||||||
msg = err.description
|
|
||||||
return render_template('error.html', error=error, msg=msg), 410
|
|
||||||
|
|
||||||
@app.errorhandler(500)
|
@app.errorhandler(500)
|
||||||
def internal_server_error(err):
|
def error_page(err):
|
||||||
error = '500'
|
error = err.code
|
||||||
msg = err.description
|
msg = err.description
|
||||||
return render_template('error.html', error=error, msg=msg), 500
|
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 . import auth
|
||||||
|
@ -136,6 +114,7 @@ def create_app(test_config=None):
|
||||||
|
|
||||||
logging.info('Gallery started successfully!')
|
logging.info('Gallery started successfully!')
|
||||||
|
|
||||||
|
|
||||||
assets.init_app(app)
|
assets.init_app(app)
|
||||||
cache.init_app(app)
|
cache.init_app(app)
|
||||||
compress.init_app(app)
|
compress.init_app(app)
|
||||||
|
|
|
@ -64,47 +64,18 @@ class Metadata:
|
||||||
'File': {},
|
'File': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
for data in encoded_exif:
|
# Thanks chatGPT xP
|
||||||
if data in PHOTOGRAHER_MAPPING:
|
for key, value in encoded_exif.items():
|
||||||
exif['Photographer'][PHOTOGRAHER_MAPPING[data][0]] = {
|
for mapping_name, mapping in EXIF_MAPPING:
|
||||||
'raw': encoded_exif[data],
|
if key in mapping:
|
||||||
}
|
if len(mapping[key]) == 2:
|
||||||
continue
|
exif[mapping_name][mapping[key][0]] = {
|
||||||
elif data in CAMERA_MAPPING:
|
'raw': value,
|
||||||
if len(CAMERA_MAPPING[data]) == 2:
|
'formatted': getattr(helpers, mapping[key][1])(value),
|
||||||
# Camera - Exif Tag name
|
|
||||||
exif['Camera'][CAMERA_MAPPING[data][0]] = {
|
|
||||||
'raw': encoded_exif[data],
|
|
||||||
'formatted':
|
|
||||||
getattr(helpers, CAMERA_MAPPING[data][1])(encoded_exif[data]), # pylint: disable=E0602
|
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
exif['Camera'][CAMERA_MAPPING[data][0]] = {
|
exif[mapping_name][mapping[key][0]] = {
|
||||||
'raw': encoded_exif[data],
|
'raw': value,
|
||||||
}
|
|
||||||
continue
|
|
||||||
elif data in SOFTWARE_MAPPING:
|
|
||||||
if len(SOFTWARE_MAPPING[data]) == 2:
|
|
||||||
exif['Software'][SOFTWARE_MAPPING[data][0]] = {
|
|
||||||
'raw': encoded_exif[data],
|
|
||||||
'formatted':
|
|
||||||
getattr(helpers, SOFTWARE_MAPPING[data][1])(encoded_exif[data]), # pylint: disable=E0602
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
exif['Software'][SOFTWARE_MAPPING[data][0]] = {
|
|
||||||
'raw': encoded_exif[data],
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
elif data in FILE_MAPPING:
|
|
||||||
if len(FILE_MAPPING[data]) == 2:
|
|
||||||
exif['File'][FILE_MAPPING[data][0]] = {
|
|
||||||
'raw': encoded_exif[data],
|
|
||||||
'formatted':
|
|
||||||
getattr(helpers, FILE_MAPPING[data][1])(encoded_exif[data]), # pylint: disable=E0602
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
exif['File'][FILE_MAPPING[data][0]] = {
|
|
||||||
'raw': encoded_exif[data]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove empty keys
|
# Remove empty keys
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
OnlyLegs - Metatada Parser
|
OnlyLegs - Metatada Parser
|
||||||
Mapping for metadata
|
Mapping for metadata
|
||||||
"""
|
"""
|
||||||
|
|
||||||
PHOTOGRAHER_MAPPING = {
|
PHOTOGRAHER_MAPPING = {
|
||||||
'Artist': ['Artist'],
|
'Artist': ['Artist'],
|
||||||
'UserComment': ['Comment'],
|
'UserComment': ['Comment'],
|
||||||
|
@ -59,3 +60,5 @@ FILE_MAPPING = {
|
||||||
'Rating': ['Rating', 'rating'],
|
'Rating': ['Rating', 'rating'],
|
||||||
'RatingPercent': ['Rating Percent', 'rating_percent'],
|
'RatingPercent': ['Rating Percent', 'rating_percent'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXIF_MAPPING = [('Photographer', PHOTOGRAHER_MAPPING),('Camera', CAMERA_MAPPING),('Software', SOFTWARE_MAPPING),('File', FILE_MAPPING)]
|
||||||
|
|
|
@ -124,6 +124,7 @@ function uploadFile() {
|
||||||
function openUploadTab() {
|
function openUploadTab() {
|
||||||
// Stop scrolling
|
// Stop scrolling
|
||||||
document.querySelector("html").style.overflow = "hidden";
|
document.querySelector("html").style.overflow = "hidden";
|
||||||
|
document.querySelector(".content").tabIndex = "-1";
|
||||||
|
|
||||||
// Open upload tab
|
// Open upload tab
|
||||||
const uploadTab = document.querySelector(".upload-panel");
|
const uploadTab = document.querySelector(".upload-panel");
|
||||||
|
@ -137,6 +138,7 @@ function openUploadTab() {
|
||||||
function closeUploadTab() {
|
function closeUploadTab() {
|
||||||
// un-Stop scrolling
|
// un-Stop scrolling
|
||||||
document.querySelector("html").style.overflow = "auto";
|
document.querySelector("html").style.overflow = "auto";
|
||||||
|
document.querySelector(".content").tabIndex = "";
|
||||||
|
|
||||||
// Close upload tab
|
// Close upload tab
|
||||||
const uploadTab = document.querySelector(".upload-panel");
|
const uploadTab = document.querySelector(".upload-panel");
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,48,88H208a8,8,0,0,1,5.66,13.66Z"></path></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,48,88H208a8,8,0,0,1,5.66,13.66Z"></path></svg>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<a class="pill-item" id="img-download" href="/api/uploads/{{ image.file_name }}" download>
|
<a class="pill-item" href="/api/uploads/{{ image.file_name }}" download onclick="addNotification('Download started!', 4)">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M232,136v64a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V136a8,8,0,0,1,8-8H224A8,8,0,0,1,232,136Z" opacity="0.2"></path><path d="M240,136v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V136a16,16,0,0,1,16-16H72a8,8,0,0,1,0,16H32v64H224V136H184a8,8,0,0,1,0-16h40A16,16,0,0,1,240,136Zm-117.66-2.34a8,8,0,0,0,11.32,0l48-48a8,8,0,0,0-11.32-11.32L136,108.69V24a8,8,0,0,0-16,0v84.69L85.66,74.34A8,8,0,0,0,74.34,85.66ZM200,168a12,12,0,1,0-12,12A12,12,0,0,0,200,168Z"></path></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path d="M232,136v64a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V136a8,8,0,0,1,8-8H224A8,8,0,0,1,232,136Z" opacity="0.2"></path><path d="M240,136v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V136a16,16,0,0,1,16-16H72a8,8,0,0,1,0,16H32v64H224V136H184a8,8,0,0,1,0-16h40A16,16,0,0,1,240,136Zm-117.66-2.34a8,8,0,0,0,11.32,0l48-48a8,8,0,0,0-11.32-11.32L136,108.69V24a8,8,0,0,0-16,0v84.69L85.66,74.34A8,8,0,0,0,74.34,85.66ZM200,168a12,12,0,1,0-12,12A12,12,0,0,0,200,168Z"></path></svg>
|
||||||
<span class="tool-tip">
|
<span class="tool-tip">
|
||||||
Download
|
Download
|
||||||
|
@ -213,22 +213,25 @@
|
||||||
$('.image-fullscreen').click(function() {
|
$('.image-fullscreen').click(function() {
|
||||||
// un-Stop scrolling
|
// un-Stop scrolling
|
||||||
document.querySelector("html").style.overflow = "auto";
|
document.querySelector("html").style.overflow = "auto";
|
||||||
|
let fullscreen = document.querySelector('.image-fullscreen')
|
||||||
|
|
||||||
$('.image-fullscreen').addClass('image-fullscreen__hide');
|
fullscreen.classList.remove('active');
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$('.image-fullscreen').removeClass('image-fullscreen__active image-fullscreen__hide');
|
fullscreen.style.display = 'none';
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
$('#img-fullscreen').click(function() {
|
$('#img-fullscreen').click(function() {
|
||||||
// Stop scrolling
|
// Stop scrolling
|
||||||
document.querySelector("html").style.overflow = "hidden";
|
document.querySelector("html").style.overflow = "hidden";
|
||||||
|
let fullscreen = document.querySelector('.image-fullscreen')
|
||||||
|
|
||||||
$('.image-fullscreen').addClass('image-fullscreen__active');
|
fullscreen.querySelector('img').src = '/api/uploads/{{ image.file_name }}';
|
||||||
|
fullscreen.style.display = 'flex';
|
||||||
|
|
||||||
if ($('.image-fullscreen img').attr('src') == '') {
|
setTimeout(function() {
|
||||||
$('.image-fullscreen img').attr('src', '/api/uploads/{{ image.file_name }}');
|
fullscreen.classList.add('active');
|
||||||
}
|
}, 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#img-share').click(function() {
|
$('#img-share').click(function() {
|
||||||
|
@ -239,9 +242,6 @@
|
||||||
addNotification("Failed to copy link! Are you on HTTP?", 2);
|
addNotification("Failed to copy link! Are you on HTTP?", 2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#img-download').click(function() {
|
|
||||||
addNotification("Download started!", 4);
|
|
||||||
});
|
|
||||||
|
|
||||||
{% if g.user['id'] == image['author_id'] %}
|
{% if g.user['id'] == image['author_id'] %}
|
||||||
$('#img-delete').click(function() {
|
$('#img-delete').click(function() {
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
height: 100dvh
|
height: 100dvh
|
||||||
|
|
||||||
position: fixed
|
position: fixed
|
||||||
top: -100%
|
top: 0
|
||||||
left: 0
|
left: 0
|
||||||
|
|
||||||
display: flex
|
display: none
|
||||||
opacity: 0 // hide
|
opacity: 0 // hide
|
||||||
|
|
||||||
background-color: rgba($black, 0.8)
|
background-color: rgba($black, 0.8)
|
||||||
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
box-sizing: border-box
|
box-sizing: border-box
|
||||||
|
|
||||||
|
transition: opacity 0.2s cubic-bezier(.79, .14, .15, .86)
|
||||||
|
|
||||||
img
|
img
|
||||||
margin: auto
|
margin: auto
|
||||||
padding: 0
|
padding: 0
|
||||||
|
@ -30,22 +32,10 @@
|
||||||
object-position: center
|
object-position: center
|
||||||
|
|
||||||
transform: scale(0.8)
|
transform: scale(0.8)
|
||||||
|
transition: transform 0.2s cubic-bezier(.68,-0.55,.27,1.55)
|
||||||
|
|
||||||
.image-fullscreen__active
|
&.active
|
||||||
top: 0
|
|
||||||
|
|
||||||
opacity: 1 // show
|
opacity: 1 // show
|
||||||
|
|
||||||
transition: opacity 0.3s cubic-bezier(.79, .14, .15, .86)
|
|
||||||
|
|
||||||
img
|
img
|
||||||
transform: scale(1)
|
transform: scale(1)
|
||||||
transition: transform 0.2s cubic-bezier(.68,-0.55,.27,1.55)
|
|
||||||
.image-fullscreen__hide
|
|
||||||
opacity: 0 // hide
|
|
||||||
|
|
||||||
transition: opacity 0.2s cubic-bezier(.79, .14, .15, .86)
|
|
||||||
|
|
||||||
img
|
|
||||||
transform: scaleY(0) // scale(0.8)
|
|
||||||
transition: transform 0.2s ease
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "onlylegs"
|
name = "onlylegs"
|
||||||
version = "23.03.09"
|
version = "23.03.10"
|
||||||
description = "Gallery built for fast and simple image management"
|
description = "Gallery built for fast and simple image management"
|
||||||
authors = ["Fluffy-Bean <michal-gdula@protonmail.com>"]
|
authors = ["Fluffy-Bean <michal-gdula@protonmail.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue