diff --git a/src/main/webapp/WEB-INF/groovy/store.groovy b/src/main/webapp/WEB-INF/groovy/store.groovy index d83c3d5..9edf46f 100644 --- a/src/main/webapp/WEB-INF/groovy/store.groovy +++ b/src/main/webapp/WEB-INF/groovy/store.groovy @@ -15,50 +15,50 @@ log.info "Image Url saved will be ${imageUrl}" def githubAuthUtil = new GithubAuthUtil(request, response) response.setHeader 'Strict-Transport-Security', 'max-age=300; preload' -if (githubAuthUtil.isAuthenticated()) { - if (!imageUrl.startsWith('https://i.imgur.com')) { - imageUrl = new ImgurUtil().uploadImage(imageUrl) - } - def username = session.getAttribute(GithubAuthUtil.GITHUB_USERNAME) as String - def newImage = new Image( - imageUrl: imageUrl, - uploader: username, - uploaderEmail: session.getAttribute(GithubAuthUtil.GITHUB_EMAIL_PRIMARY) - ) - UserList myList = LgtmService.instance.getUserList(username).blockingGet() - try { - - if (myList.bannedFromUpload) { - request.setAttribute 'message', "You're not allowed to upload images" - redirect '/' - } else { - newImage.validate() - newImage.save() - request.setAttribute 'image', newImage - request.setAttribute 'dataUrl', newImage.dataUrl - - if (!myList.hashes.contains(newImage.hash)) { - myList.hashes.add newImage.hash - } - myList.save() - AppUtil.instance.store "/l/${username}", myList - - response.setHeader "Content-Type", "text/html" - redirect "/i/${newImage.hash}" - } - } catch (UniqueConstraintViolatedException e) { - request.setAttribute 'message', 'That image was already uploaded.' - redirect "/i/${e.hash}" - } catch (ValidationException e) { - request.setAttribute 'banned', myList.bannedFromUpload - request.setAttribute 'message', e.message - request.setAttribute 'imageUrl', imageUrl - response.setHeader "Content-Type", "text/html" - forward '/WEB-INF/pages/upload.gtpl' - } -} else { - request.setAttribute 'message', "You're not logged in yet!" +//if (githubAuthUtil.isAuthenticated()) { +// if (!imageUrl.startsWith('https://i.imgur.com')) { +// imageUrl = new ImgurUtil().uploadImage(imageUrl) +// } +// def username = session.getAttribute(GithubAuthUtil.GITHUB_USERNAME) as String +// def newImage = new Image( +// imageUrl: imageUrl, +// uploader: username, +// uploaderEmail: session.getAttribute(GithubAuthUtil.GITHUB_EMAIL_PRIMARY) +// ) +// UserList myList = LgtmService.instance.getUserList(username).blockingGet() +// try { +// +// if (myList.bannedFromUpload) { +// request.setAttribute 'message', "You're not allowed to upload images" +// redirect '/' +// } else { +// newImage.validate() +// newImage.save() +// request.setAttribute 'image', newImage +// request.setAttribute 'dataUrl', newImage.dataUrl +// +// if (!myList.hashes.contains(newImage.hash)) { +// myList.hashes.add newImage.hash +// } +// myList.save() +// AppUtil.instance.store "/l/${username}", myList +// +// response.setHeader "Content-Type", "text/html" +// redirect "/i/${newImage.hash}" +// } +// } catch (UniqueConstraintViolatedException e) { +// request.setAttribute 'message', 'That image was already uploaded.' +// redirect "/i/${e.hash}" +// } catch (ValidationException e) { +// request.setAttribute 'banned', myList.bannedFromUpload +// request.setAttribute 'message', e.message +// request.setAttribute 'imageUrl', imageUrl +// response.setHeader "Content-Type", "text/html" +// forward '/WEB-INF/pages/upload.gtpl' +// } +//} else { + request.setAttribute 'message', "Uploading has been disabled." request.setAttribute 'imageUrl', imageUrl response.setHeader "Content-Type", "text/html" forward '/WEB-INF/pages/upload.gtpl' -} +//} diff --git a/src/main/webapp/css/app.css b/src/main/webapp/css/app.css index a7431a9..dcea6bb 100644 --- a/src/main/webapp/css/app.css +++ b/src/main/webapp/css/app.css @@ -43,3 +43,6 @@ div.favorited .fa-heart-o { display: none; } +a.disabled { + pointer-events: none; +} \ No newline at end of file diff --git a/src/main/webapp/decorators/main.jsp b/src/main/webapp/decorators/main.jsp index c003a2c..9873be4 100644 --- a/src/main/webapp/decorators/main.jsp +++ b/src/main/webapp/decorators/main.jsp @@ -35,6 +35,13 @@ <%@include file="messages.jsp" %> <%@include file="protip.jsp" %> +