Skip to content
This repository has been archived by the owner on Aug 8, 2021. It is now read-only.

Commit

Permalink
Disable uploads and announce shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulsom committed Sep 2, 2018
1 parent 089978d commit ff983cc
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 46 deletions.
88 changes: 44 additions & 44 deletions src/main/webapp/WEB-INF/groovy/store.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
//}
3 changes: 3 additions & 0 deletions src/main/webapp/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ div.favorited .fa-heart-o {
display: none;
}

a.disabled {
pointer-events: none;
}
7 changes: 7 additions & 0 deletions src/main/webapp/decorators/main.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
<%@include file="messages.jsp" %>
<%@include file="protip.jsp" %>

<div class="alert alert-danger">
LGTM.in is shutting down on 2018-10-01.
I've been busy with a lot of things, and cannot spend time on this.
The source is available on <a href="https://github.com/rahulsom/lgtmin">github.com/rahulsom/lgtmin</a> and can be used to spin up a similar service.
If you're interested in purchasing the domain and continuing to run this service, let me know, and we can work something out.
</div>

<decorator:body/>

</div>
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/decorators/nav.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<a href="/g">Random</a>
</li>
<li class="${request.servletPath == '/WEB-INF/pages/upload.gtpl' ? 'active' : ''}">
<a href="/upload">Submit</a>
<a href="/upload" class="disabled">Submit</a>
</li>
<li class="${request.servletPath == '/WEB-INF/pages/browse.gtpl' ? 'active' : ''}">
<a href="/browse">Browse</a>
Expand Down
7 changes: 6 additions & 1 deletion src/main/webapp/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ $(function () {
});
}

$('a.disabled').on('click', function(event){
event.preventDefault();
})

});

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
Expand All @@ -47,4 +51,5 @@ $(function () {

ga('create', 'UA-40490747-1', 'lgtm.in');
ga('require', 'displayfeatures');
ga('send', 'pageview');
ga('send', 'pageview');

0 comments on commit ff983cc

Please sign in to comment.