diff --git a/gallery/__init__.py b/gallery/__init__.py index 40d4d0a..6599620 100644 --- a/gallery/__init__.py +++ b/gallery/__init__.py @@ -5,7 +5,7 @@ | |_| | | | | | |_| | |__| __/ (_| \__ \ \___/|_| |_|_|\__, |_____\___|\__, |___/ |___/ |___/ -Created by Fluffy Bean - Version 23.03.09 +Created by Fluffy Bean - Version 23.03.10 """ # Import system modules @@ -48,7 +48,7 @@ def create_app(test_config=None): """ app = Flask(__name__,instance_path=os.path.join(USER_DIR, 'instance')) assets = Environment() - cache = Cache(config={'CACHE_TYPE': 'SimpleCache', 'CACHE_DEFAULT_TIMEOUT': 69}) + cache = Cache(config={'CACHE_TYPE': 'SimpleCache', 'CACHE_DEFAULT_TIMEOUT': 300}) compress = Compress() # App configuration @@ -59,8 +59,6 @@ def create_app(test_config=None): ALLOWED_EXTENSIONS=conf['upload']['allowed-extensions'], MAX_CONTENT_LENGTH=1024 * 1024 * conf['upload']['max-size'], WEBSITE=conf['website'], - ADMIN=conf['admin'], - APP_VERSION='23.03.09', ) if test_config is None: @@ -74,43 +72,23 @@ def create_app(test_config=None): pass + # Load theme theme_manager.CompileTheme('default', app.root_path) - - # Bundle JS files js = Bundle('js/*.js', output='gen/packed.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) - def forbidden(err): - error = '403' - msg = err.description - return render_template('error.html', error=error, msg=msg), 403 - + @app.errorhandler(404) + @app.errorhandler(405) @app.errorhandler(410) - def gone(err): - error = '410' - msg = err.description - return render_template('error.html', error=error, msg=msg), 410 - @app.errorhandler(500) - def internal_server_error(err): - error = '500' + def error_page(err): + error = err.code 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 from . import auth @@ -136,6 +114,7 @@ def create_app(test_config=None): logging.info('Gallery started successfully!') + assets.init_app(app) cache.init_app(app) compress.init_app(app) diff --git a/gallery/metadata/__init__.py b/gallery/metadata/__init__.py index 430ce53..41698d5 100644 --- a/gallery/metadata/__init__.py +++ b/gallery/metadata/__init__.py @@ -63,48 +63,19 @@ class Metadata: 'Software': {}, 'File': {}, } - - for data in encoded_exif: - if data in PHOTOGRAHER_MAPPING: - exif['Photographer'][PHOTOGRAHER_MAPPING[data][0]] = { - 'raw': encoded_exif[data], - } - continue - elif data in CAMERA_MAPPING: - if len(CAMERA_MAPPING[data]) == 2: - # 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 + + # Thanks chatGPT xP + for key, value in encoded_exif.items(): + for mapping_name, mapping in EXIF_MAPPING: + if key in mapping: + if len(mapping[key]) == 2: + exif[mapping_name][mapping[key][0]] = { + 'raw': value, + 'formatted': getattr(helpers, mapping[key][1])(value), } - else: - exif['Camera'][CAMERA_MAPPING[data][0]] = { - 'raw': encoded_exif[data], - } - 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] + else: + exif[mapping_name][mapping[key][0]] = { + 'raw': value, } # Remove empty keys diff --git a/gallery/metadata/mapping.py b/gallery/metadata/mapping.py index 7de9ac3..bbfedca 100644 --- a/gallery/metadata/mapping.py +++ b/gallery/metadata/mapping.py @@ -2,6 +2,7 @@ OnlyLegs - Metatada Parser Mapping for metadata """ + PHOTOGRAHER_MAPPING = { 'Artist': ['Artist'], 'UserComment': ['Comment'], @@ -59,3 +60,5 @@ FILE_MAPPING = { 'Rating': ['Rating', 'rating'], 'RatingPercent': ['Rating Percent', 'rating_percent'], } + +EXIF_MAPPING = [('Photographer', PHOTOGRAHER_MAPPING),('Camera', CAMERA_MAPPING),('Software', SOFTWARE_MAPPING),('File', FILE_MAPPING)] diff --git a/gallery/static/js/main.js b/gallery/static/js/main.js index b79a9e9..d601b6c 100644 --- a/gallery/static/js/main.js +++ b/gallery/static/js/main.js @@ -124,6 +124,7 @@ function uploadFile() { function openUploadTab() { // Stop scrolling document.querySelector("html").style.overflow = "hidden"; + document.querySelector(".content").tabIndex = "-1"; // Open upload tab const uploadTab = document.querySelector(".upload-panel"); @@ -137,6 +138,7 @@ function openUploadTab() { function closeUploadTab() { // un-Stop scrolling document.querySelector("html").style.overflow = "auto"; + document.querySelector(".content").tabIndex = ""; // Close upload tab const uploadTab = document.querySelector(".upload-panel"); diff --git a/gallery/templates/image.html b/gallery/templates/image.html index 2773c48..4b00959 100644 --- a/gallery/templates/image.html +++ b/gallery/templates/image.html @@ -52,7 +52,7 @@ - + Download @@ -213,22 +213,25 @@ $('.image-fullscreen').click(function() { // un-Stop scrolling document.querySelector("html").style.overflow = "auto"; + let fullscreen = document.querySelector('.image-fullscreen') - $('.image-fullscreen').addClass('image-fullscreen__hide'); + fullscreen.classList.remove('active'); setTimeout(function() { - $('.image-fullscreen').removeClass('image-fullscreen__active image-fullscreen__hide'); + fullscreen.style.display = 'none'; }, 200); }); $('#img-fullscreen').click(function() { // Stop scrolling document.querySelector("html").style.overflow = "hidden"; - - $('.image-fullscreen').addClass('image-fullscreen__active'); - - if ($('.image-fullscreen img').attr('src') == '') { - $('.image-fullscreen img').attr('src', '/api/uploads/{{ image.file_name }}'); - } + let fullscreen = document.querySelector('.image-fullscreen') + + fullscreen.querySelector('img').src = '/api/uploads/{{ image.file_name }}'; + fullscreen.style.display = 'flex'; + + setTimeout(function() { + fullscreen.classList.add('active'); + }, 10); }); $('#img-share').click(function() { @@ -239,9 +242,6 @@ 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'] %} $('#img-delete').click(function() { diff --git a/gallery/themes/default/components/image-view/fullscreen.sass b/gallery/themes/default/components/image-view/fullscreen.sass index 46b11f6..f0bb507 100644 --- a/gallery/themes/default/components/image-view/fullscreen.sass +++ b/gallery/themes/default/components/image-view/fullscreen.sass @@ -6,10 +6,10 @@ height: 100dvh position: fixed - top: -100% + top: 0 left: 0 - display: flex + display: none opacity: 0 // hide background-color: rgba($black, 0.8) @@ -17,6 +17,8 @@ box-sizing: border-box + transition: opacity 0.2s cubic-bezier(.79, .14, .15, .86) + img margin: auto padding: 0 @@ -30,22 +32,10 @@ object-position: center transform: scale(0.8) - -.image-fullscreen__active - top: 0 - - opacity: 1 // show - - transition: opacity 0.3s cubic-bezier(.79, .14, .15, .86) - - img - 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) + &.active + opacity: 1 // show - img - transform: scaleY(0) // scale(0.8) - transition: transform 0.2s ease \ No newline at end of file + img + transform: scale(1) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 1777005..3f06105 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "onlylegs" -version = "23.03.09" +version = "23.03.10" description = "Gallery built for fast and simple image management" authors = ["Fluffy-Bean "] license = "MIT"