Skip to content

Commit

Permalink
Added web artcode reader
Browse files Browse the repository at this point in the history
  • Loading branch information
ktg committed Nov 10, 2020
1 parent 0947648 commit 85f6df4
Show file tree
Hide file tree
Showing 12 changed files with 319 additions and 159 deletions.
53 changes: 31 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
buildscript {
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.5'
}
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.2.0'
}
}

// Put build files in user home
buildDir = "${System.properties['user.home']}/.gradle/builds/${rootProject.name}/${project.name}"

repositories {
jcenter()
google()
mavenCentral()
jcenter()
google()
mavenCentral()
}

apply plugin: 'java'
Expand All @@ -39,18 +42,24 @@ apply plugin: 'idea'
apply plugin: 'com.google.cloud.tools.appengine'

dependencies {
compile 'com.google.appengine:appengine-api-1.0-sdk:+'
compile 'com.google.api-client:google-api-client:+'
compile 'com.google.http-client:google-http-client-gson:+'
compile 'com.google.appengine.tools:appengine-gcs-client:+'
compile 'com.github.spullara.mustache.java:compiler:+'
compile 'javax.servlet:javax.servlet-api:+'
compile 'com.googlecode.objectify:objectify:+'
compile 'com.google.code.gson:gson:+'
compile 'com.google.appengine:appengine-api-1.0-sdk:+'
compile 'com.google.api-client:google-api-client:+'
compile 'com.google.http-client:google-http-client-gson:+'
compile 'com.google.appengine.tools:appengine-gcs-client:+'
compile 'com.github.spullara.mustache.java:compiler:+'
compile 'javax.servlet:javax.servlet-api:+'
compile 'com.googlecode.objectify:objectify:+'
compile 'com.google.code.gson:gson:+'
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

appengine {
deploy {
project = 'aestheticodes'
}
deploy {
projectId = 'aestheticodes'
version = 'GCLOUD_CONFIG'
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Thu May 28 09:44:41 BST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
final ExperienceEntry entry = DataStore.load().type(ExperienceEntry.class).id(experienceID).now();
if (entry != null)
{
// TODO NullPointerException here. Handle missing User-Agent
final String userAgent = request.getHeader("User-Agent").toLowerCase();
if (userAgent.startsWith("artcodes/") || "json".equals(request.getParameter("format")))
{
Expand All @@ -137,6 +138,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
variables.put("author", experience.getAuthor());
variables.put("image", experience.getImage());
variables.put("icon", experience.getIcon());
variables.put("json", entry.getJson());

response.setCharacterEncoding("UTF-8");
response.setContentType("text/html");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,13 @@ protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws I
{
final String id = getImageID(req);
final GcsFileMetadata metadata = getMetadata(req.getServerName(), id);
setAccessControlHeaders(resp);
if (metadata == null)
{
setAccessControlHeaders(resp);
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
else
{
setAccessControlHeaders(resp);
resp.setStatus(HttpServletResponse.SC_OK);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse resp) throws I
}

@Override
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws IOException
{
doGet(req, resp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

public class RecommendedServlet extends ArtcodeServlet
{
private class Nearby
private static class Nearby
{
private final String uri;
private final double distance;
Expand All @@ -46,7 +46,7 @@ private class Nearby
}
}

private class LatLng
private static class LatLng
{
private static final double precision = 1000d;
private final double latitude;
Expand All @@ -65,7 +65,7 @@ public String toString()
}
}

private class Result
private static class Result
{
private final Set<String> ids = new HashSet<>();
private final Map<String, List<String>> result = new HashMap<>();
Expand Down
Loading

0 comments on commit 85f6df4

Please sign in to comment.