diff --git a/gallery/metadata/helpers.py b/gallery/metadata/helpers.py index e642fec..9115fb9 100644 --- a/gallery/metadata/helpers.py +++ b/gallery/metadata/helpers.py @@ -215,13 +215,6 @@ def scene_capture_type(value): return None -def scene_type(value): # pylint: disable=W0613 # Itss fiiiineeee - """ - Maps the value of the scene type to a human readable format - """ - return 'Directly photographed image' - - def white_balance(value): """ Maps the value of the white balance to a human readable format diff --git a/gallery/metadata/mapping.py b/gallery/metadata/mapping.py index a45188c..7de9ac3 100644 --- a/gallery/metadata/mapping.py +++ b/gallery/metadata/mapping.py @@ -40,7 +40,6 @@ CAMERA_MAPPING = { 'MeteringMode': ['Metering Mode', 'metering_mode'], 'LightSource': ['Light Source', 'light_source'], 'SceneCaptureType': ['Scene Capture Type', 'scene_capture_type'], - 'SceneType': ['Scene Type', 'scene_type'], } SOFTWARE_MAPPING = { 'Software': ['Software'], diff --git a/gallery/routing.py b/gallery/routing.py index 9766f0c..b242905 100644 --- a/gallery/routing.py +++ b/gallery/routing.py @@ -46,8 +46,22 @@ def image(image_id): author = db_session.query(db.Users.username).filter(db.Users.id == img.author_id).first()[0] img.author_username = author + + next = db_session.query(db.Posts.id).filter(db.Posts.id > image_id).order_by(db.Posts.id.asc()).first() + prev = db_session.query(db.Posts.id).filter(db.Posts.id < image_id).order_by(db.Posts.id.desc()).first() + + if next is not None: + next = next[0] + if prev is not None: + prev = prev[0] - return render_template('image.html', image=img, exif=img.image_exif) + return render_template('image.html', + image=img, + exif=img.image_exif, + next=next, + prev=prev, + next_id=next, + prev_id=prev) @blueprint.route('/group', methods=['GET', 'POST']) def groups(): diff --git a/gallery/static/js/login.js b/gallery/static/js/login.js deleted file mode 100644 index d66c25a..0000000 --- a/gallery/static/js/login.js +++ /dev/null @@ -1,108 +0,0 @@ -function showLogin() { - popUpShow( - 'idk what to put here, just login please', - 'Need an account? Register!', - '', - '
\ - \ - \ -
' - ); -}; -function showRegister() { - popUpShow( - 'Who are you?', - 'Already have an account? Login!', - '', - '
\ - \ - \ - \ - \ -
' - ); -}; - -function login(event) { - // AJAX takes control of subby form - event.preventDefault(); - - if ($("#username").val() === "" || $("#password").val() === "") { - addNotification("Please fill in all fields", 3); - } else { - // Make form - var formData = new FormData(); - formData.append("username", $("#username").val()); - formData.append("password", $("#password").val()); - - $.ajax({ - url: '/auth/login', - type: 'post', - data: formData, - contentType: false, - processData: false, - success: function (response) { - location.reload(); - }, - error: function (response) { - switch (response.status) { - case 500: - addNotification('Server exploded, F\'s in chat', 2); - break; - case 403: - addNotification('None but devils play past here... Wrong information', 2); - break; - default: - addNotification('Error logging in, blame someone', 2); - break; - } - } - }); - } -} -function register(obj) { - // AJAX takes control of subby form - event.preventDefault(); - - if ($("#username").val() === "" || $("#email").val() === "" || $("#password").val() === "" || $("#password-repeat").val() === "") { - addNotification("Please fill in all fields", 3); - } else { - // Make form - var formData = new FormData(); - formData.append("username", $("#username").val()); - formData.append("email", $("#email").val()); - formData.append("password", $("#password").val()); - formData.append("password-repeat", $("#password-repeat").val()); - - $.ajax({ - url: '/auth/register', - type: 'post', - data: formData, - contentType: false, - processData: false, - success: function (response) { - if (response === "gwa gwa") { - addNotification('Registered successfully! Now please login to continue', 1); - showLogin(); - } else { - for (var i = 0; i < response.length; i++) { - addNotification(response[i], 2); - } - } - }, - error: function (response) { - switch (response.status) { - case 500: - addNotification('Server exploded, F\'s in chat', 2); - break; - case 403: - addNotification('None but devils play past here...', 2); - break; - default: - addNotification('Error logging in, blame someone', 2); - break; - } - } - }); - } -} \ No newline at end of file diff --git a/gallery/static/js/main.js b/gallery/static/js/main.js index d8cdaa0..0c0d38d 100644 --- a/gallery/static/js/main.js +++ b/gallery/static/js/main.js @@ -35,3 +35,235 @@ for (let i = 0; i < times.length; i++) { // Convert to local time times[i].innerHTML = dateTime.toLocaleDateString() + ' ' + dateTime.toLocaleTimeString(); } + +function uploadFile(){ + // AJAX takes control of subby form + event.preventDefault(); + + const jobList = document.querySelector(".upload-jobs"); + + // Check for empty upload + if ($("#file").val() === "") { + addNotification("Please select a file to upload", 2); + } else { + // Make form + let formData = new FormData(); + formData.append("file", $("#file").prop("files")[0]); + formData.append("alt", $("#alt").val()); + formData.append("description", $("#description").val()); + formData.append("tags", $("#tags").val()); + formData.append("submit", $("#submit").val()); + + // Upload the information + $.ajax({ + url: '/api/upload', + type: 'post', + data: formData, + contentType: false, + processData: false, + beforeSend: function() { + jobContainer = document.createElement("div"); + jobContainer.classList.add("job"); + + jobStatus = document.createElement("span"); + jobStatus.classList.add("job__status"); + jobStatus.innerHTML = "Uploading..."; + + jobProgress = document.createElement("span"); + jobProgress.classList.add("progress"); + + jobImg = document.createElement("img"); + jobImg.src = URL.createObjectURL($("#file").prop("files")[0]); + + jobImgFilter = document.createElement("span"); + jobImgFilter.classList.add("img-filter"); + + jobContainer.appendChild(jobStatus); + jobContainer.appendChild(jobProgress); + jobContainer.appendChild(jobImg); + jobContainer.appendChild(jobImgFilter); + jobList.appendChild(jobContainer); + }, + success: function (response) { + jobContainer.classList.add("success"); + jobStatus.innerHTML = "Uploaded!"; + if (!document.querySelector(".upload-panel").classList.contains("open")) { + addNotification("Image uploaded successfully", 1); + } + }, + error: function (response) { + jobContainer.classList.add("critical"); + switch (response.status) { + case 500: + jobStatus.innerHTML = "Server exploded, F's in chat"; + break; + case 400: + case 404: + jobStatus.innerHTML = "Error uploading. Blame yourself"; + break; + case 403: + jobStatus.innerHTML = "None but devils play past here..."; + break; + case 413: + jobStatus.innerHTML = "File too large!!!!!!"; + break; + default: + jobStatus.innerHTML = "Error uploading file, blame someone"; + break; + } + if (!document.querySelector(".upload-panel").classList.contains("open")) { + addNotification("Error uploading file", 2); + } + }, + }); + + // Empty values + $("#file").val(""); + $("#alt").val(""); + $("#description").val(""); + $("#tags").val(""); + } +}; + +function openUploadTab() { + // Stop scrolling + document.querySelector("html").style.overflow = "hidden"; + + // Open upload tab + const uploadTab = document.querySelector(".upload-panel"); + uploadTab.style.display = "block"; + + setTimeout( function() { + uploadTab.classList.add("open"); + }, 10); +} + +function closeUploadTab() { + // un-Stop scrolling + document.querySelector("html").style.overflow = "auto"; + + // Close upload tab + const uploadTab = document.querySelector(".upload-panel"); + uploadTab.classList.remove("open"); + + setTimeout( function() { + uploadTab.style.display = "none"; + }, 250); +} + +function toggleUploadTab() { + if (document.querySelector(".upload-panel").classList.contains("open")) { + closeUploadTab(); + } else { + openUploadTab(); + } +} + +function showLogin() { + popUpShow( + 'idk what to put here, just login please', + 'Need an account? Register!', + '', + '
\ + \ + \ +
' + ); +}; +function showRegister() { + popUpShow( + 'Who are you?', + 'Already have an account? Login!', + '', + '
\ + \ + \ + \ + \ +
' + ); +}; + +function login(event) { + // AJAX takes control of subby form + event.preventDefault(); + + if ($("#username").val() === "" || $("#password").val() === "") { + addNotification("Please fill in all fields", 3); + } else { + // Make form + var formData = new FormData(); + formData.append("username", $("#username").val()); + formData.append("password", $("#password").val()); + + $.ajax({ + url: '/auth/login', + type: 'post', + data: formData, + contentType: false, + processData: false, + success: function (response) { + location.reload(); + }, + error: function (response) { + switch (response.status) { + case 500: + addNotification('Server exploded, F\'s in chat', 2); + break; + case 403: + addNotification('None but devils play past here... Wrong information', 2); + break; + default: + addNotification('Error logging in, blame someone', 2); + break; + } + } + }); + } +} +function register(obj) { + // AJAX takes control of subby form + event.preventDefault(); + + if ($("#username").val() === "" || $("#email").val() === "" || $("#password").val() === "" || $("#password-repeat").val() === "") { + addNotification("Please fill in all fields", 3); + } else { + // Make form + var formData = new FormData(); + formData.append("username", $("#username").val()); + formData.append("email", $("#email").val()); + formData.append("password", $("#password").val()); + formData.append("password-repeat", $("#password-repeat").val()); + + $.ajax({ + url: '/auth/register', + type: 'post', + data: formData, + contentType: false, + processData: false, + success: function (response) { + if (response === "gwa gwa") { + addNotification('Registered successfully! Now please login to continue', 1); + showLogin(); + } else { + for (var i = 0; i < response.length; i++) { + addNotification(response[i], 2); + } + } + }, + error: function (response) { + switch (response.status) { + case 500: + addNotification('Server exploded, F\'s in chat', 2); + break; + case 403: + addNotification('None but devils play past here...', 2); + break; + default: + addNotification('Error logging in, blame someone', 2); + break; + } + } + }); + } +} diff --git a/gallery/static/js/ui/popup.js b/gallery/static/js/ui/popup.js index 4e71651..2a9701a 100644 --- a/gallery/static/js/ui/popup.js +++ b/gallery/static/js/ui/popup.js @@ -1,4 +1,7 @@ function popUpShow(title, body, actions, content) { + // Stop scrolling + document.querySelector("html").style.overflow = "hidden"; + var popup = document.querySelector('.pop-up'); var popupContent = document.querySelector('.pop-up-content'); var popupActions = document.querySelector('.pop-up-controlls'); @@ -30,6 +33,9 @@ function popUpShow(title, body, actions, content) { } function popupDissmiss() { + // un-Stop scrolling + document.querySelector("html").style.overflow = "auto"; + var popup = document.querySelector('.pop-up'); popup.classList.add('pop-up__hide'); diff --git a/gallery/static/js/upload.js b/gallery/static/js/upload.js deleted file mode 100644 index bc2bd56..0000000 --- a/gallery/static/js/upload.js +++ /dev/null @@ -1,107 +0,0 @@ -function uploadFile(){ - // AJAX takes control of subby form - event.preventDefault(); - - const jobList = document.querySelector(".upload-jobs"); - - // Check for empty upload - if ($("#file").val() === "") { - addNotification("Please select a file to upload", 2); - } else { - // Make form - let formData = new FormData(); - formData.append("file", $("#file").prop("files")[0]); - formData.append("alt", $("#alt").val()); - formData.append("description", $("#description").val()); - formData.append("tags", $("#tags").val()); - formData.append("submit", $("#submit").val()); - - // Upload the information - $.ajax({ - url: '/api/upload', - type: 'post', - data: formData, - contentType: false, - processData: false, - beforeSend: function() { - jobContainer = document.createElement("div"); - jobContainer.classList.add("job"); - - jobStatus = document.createElement("span"); - jobStatus.classList.add("job__status"); - jobStatus.innerHTML = "Uploading..."; - - jobProgress = document.createElement("span"); - jobProgress.classList.add("progress"); - - jobImg = document.createElement("img"); - jobImg.src = URL.createObjectURL($("#file").prop("files")[0]); - - jobImgFilter = document.createElement("span"); - jobImgFilter.classList.add("img-filter"); - - jobContainer.appendChild(jobStatus); - jobContainer.appendChild(jobProgress); - jobContainer.appendChild(jobImg); - jobContainer.appendChild(jobImgFilter); - jobList.appendChild(jobContainer); - }, - success: function (response) { - jobContainer.classList.add("success"); - jobStatus.innerHTML = "Uploaded!"; - if (!document.querySelector(".upload-panel").classList.contains("open")) { - addNotification("Image uploaded successfully", 1); - } - }, - error: function (response) { - jobContainer.classList.add("critical"); - switch (response.status) { - case 500: - jobStatus.innerHTML = "Server exploded, F's in chat"; - break; - case 400: - case 404: - jobStatus.innerHTML = "Error uploading. Blame yourself"; - break; - case 403: - jobStatus.innerHTML = "None but devils play past here..."; - break; - case 413: - jobStatus.innerHTML = "File too large!!!!!!"; - break; - default: - jobStatus.innerHTML = "Error uploading file, blame someone"; - break; - } - if (!document.querySelector(".upload-panel").classList.contains("open")) { - addNotification("Error uploading file", 2); - } - }, - }); - - // Empty values - $("#file").val(""); - $("#alt").val(""); - $("#description").val(""); - $("#tags").val(""); - } -}; - -function openUploadTab() { - // Open upload tab - const uploadTab = document.querySelector(".upload-panel"); - uploadTab.style.display = "block"; - - setTimeout( function() { - uploadTab.classList.add("open"); - }, 10); -} - -function closeUploadTab() { - // Close upload tab - const uploadTab = document.querySelector(".upload-panel"); - uploadTab.classList.remove("open"); - setTimeout( function() { - uploadTab.style.display = "none"; - }, 250); -} \ No newline at end of file diff --git a/gallery/templates/image.html b/gallery/templates/image.html index 3649348..cd5a102 100644 --- a/gallery/templates/image.html +++ b/gallery/templates/image.html @@ -24,24 +24,46 @@
+ {% if next_id %} +
+ + + + + + Previous + + + +
+ {% endif %}
- + - Download + + Download + +
{% if g.user['id'] == image['author_id'] %} @@ -50,16 +72,35 @@ - Delete + + Delete + +
{% endif %} + {% if prev_id %} +
+ + + + + + Next + + + +
+ {% endif %}
@@ -180,12 +221,19 @@ } $('.image-fullscreen').click(function() { + // un-Stop scrolling + document.querySelector("html").style.overflow = "auto"; + $('.image-fullscreen').addClass('image-fullscreen__hide'); + setTimeout(function() { $('.image-fullscreen').removeClass('image-fullscreen__active image-fullscreen__hide'); }, 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') == '') { diff --git a/gallery/templates/layout.html b/gallery/templates/layout.html index 6f6c173..b81841a 100644 --- a/gallery/templates/layout.html +++ b/gallery/templates/layout.html @@ -13,10 +13,6 @@ - - - - @@ -50,22 +46,31 @@ - Home + + Home + + - Groups + + Groups + + {% if g.user %} - {% endif %} @@ -76,21 +81,30 @@ - Profile + + Profile + + - Settings + + Settings + + {% else %} {% endif %}
@@ -100,21 +114,23 @@ {% endblock %} -
- -
-

Upload stuffs

-

May the world see your stuff 👀

-
- - - - - -
-
+ {% if g.user %} +
+ +
+

Upload stuffs

+

May the world see your stuff 👀

+
+ + + + + +
+
+
-
+ {% endif %}