From 20d07e7f2505301514dc60a2ca246a877e430739 Mon Sep 17 00:00:00 2001 From: Angela Date: Sun, 2 Aug 2020 03:18:20 +0000 Subject: [PATCH] Fixed sharing by removing odd div, implementing gmail share, and adding proper links to social sharing. Also fixed recipe-grid with tomgom/angelapl conflict. --- .../servlets/TestDisplayRecipesServlet.java | 60 ------------------- src/main/webapp/browse-recipes.html | 2 +- src/main/webapp/recipe.html | 9 +-- src/main/webapp/script.js | 14 ++++- 4 files changed, 18 insertions(+), 67 deletions(-) delete mode 100644 src/main/java/shef/servlets/TestDisplayRecipesServlet.java diff --git a/src/main/java/shef/servlets/TestDisplayRecipesServlet.java b/src/main/java/shef/servlets/TestDisplayRecipesServlet.java deleted file mode 100644 index fcb76b9..0000000 --- a/src/main/java/shef/servlets/TestDisplayRecipesServlet.java +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package shef.servlets; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import shef.data.TestRecipe; -import com.google.appengine.api.datastore.DatastoreService; -import com.google.appengine.api.datastore.DatastoreServiceFactory; -import com.google.appengine.api.datastore.Entity; -import com.google.appengine.api.datastore.PreparedQuery; -import com.google.appengine.api.datastore.Query; -import com.google.appengine.api.datastore.Query.SortDirection; -import com.google.gson.Gson; -import java.io.IOException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** Servlet responsible for displaying recipes. */ -@WebServlet("/display-recipes") -public class TestDisplayRecipesServlet extends HttpServlet { - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { - Query query = new Query("Recipe").addSort("timestamp", SortDirection.DESCENDING); - - DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); - PreparedQuery results = datastore.prepare(query); - - List testRecipes = new LinkedList<>(); - for (Entity entity : results.asIterable()) { - long id = entity.getKey().getId(); - ArrayList searchStrings = (ArrayList) entity.getProperty("search-strings"); - long timestamp = (long) entity.getProperty("timestamp"); - - TestRecipe testRecipe = new TestRecipe(id, searchStrings, timestamp); - testRecipes.add(testRecipe); - } - - Gson gson = new Gson(); - - response.setContentType("application/json;"); - response.getWriter().println(gson.toJson(testRecipes)); - } -} diff --git a/src/main/webapp/browse-recipes.html b/src/main/webapp/browse-recipes.html index f957534..deca6cb 100644 --- a/src/main/webapp/browse-recipes.html +++ b/src/main/webapp/browse-recipes.html @@ -25,7 +25,7 @@

Browse Recipes

-
+
diff --git a/src/main/webapp/recipe.html b/src/main/webapp/recipe.html index da40da1..0ae5483 100644 --- a/src/main/webapp/recipe.html +++ b/src/main/webapp/recipe.html @@ -34,7 +34,7 @@ - +
@@ -62,18 +62,19 @@