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

Commit

Permalink
Add twitter card for user list
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulsom committed Sep 13, 2016
1 parent 42a5a67 commit c06a516
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
18 changes: 9 additions & 9 deletions src/main/webapp/WEB-INF/groovy/userlist.groovy
Expand Up @@ -3,23 +3,23 @@ import services.LgtmService

String userName = params.username
UserList myList = LgtmService.instance.getUserList(userName)
def imageList = LgtmService.instance.imageList.findAll { img ->
myList.hashes && myList.hashes.contains(img.hash)
}
def imageList = LgtmService.instance.imageList.findAll { img -> myList.hashes && myList.hashes.contains(img.hash) }

def PAGESIZE = 32
def page = (params.page ? params.page as int : 1)
def page = params.page ? params.int('page') : 1
def start = (page - 1) * PAGESIZE
def stop = Math.min(start+PAGESIZE-1, imageList.size() - 1)
def stop = Math.min(start + PAGESIZE - 1, imageList.size() - 1)
request.setAttribute 'imageList', imageList[start..stop]
request.setAttribute 'username', userName
if (stop + 1 < imageList.size()) {
request.setAttribute 'next', page + 1
request.setAttribute 'next', page + 1
}
if (start > 0) {
request.setAttribute 'prev', page - 1
request.setAttribute 'prev', page - 1
}

if (params.page != null) {
forward '/WEB-INF/pages/browse.gtpl'
forward '/WEB-INF/pages/browse.gtpl'
} else {
forward '/WEB-INF/pages/browsePage.gtpl'
forward '/WEB-INF/pages/browsePage.gtpl'
}
22 changes: 19 additions & 3 deletions src/main/webapp/WEB-INF/pages/browsePage.gtpl
@@ -1,3 +1,19 @@
<div class="row" id="imageList">
<% include '/WEB-INF/pages/browse.gtpl' %>
</div>
<html>
<head>
<% def username = request.getAttribute('username') %>
<% if (username) { %>
<title>$username</title>

<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@lgtmin" />
<meta name="twitter:title" content="Looks good to me" />
<meta name="twitter:description" content="View the image on LGTM.in." />
<meta name="twitter:image" content="https://github.com/${username}.png" />
<% } %>
</head>
<body>
<div class="row" id="imageList">
<% include '/WEB-INF/pages/browse.gtpl' %>
</div>
</body>
</html>

0 comments on commit c06a516

Please sign in to comment.