Skip to content

Commit

Permalink
Merge pull request #2 from ucsb-cs56-f18/master
Browse files Browse the repository at this point in the history
Updating ZH branch
  • Loading branch information
ZackHiggins authored Dec 4, 2018
2 parents 0653122 + d0796ef commit c8b93a2
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 84 deletions.
Binary file added images/bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.3.3.RELEASE</version>
</dependency>
</dependency>
</dependencies>

<properties>
Expand Down
27 changes: 23 additions & 4 deletions src/main/java/kitchen/Application.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
package com.kitchen.ingredients;

import java.security.Principal;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
public class Application {
@EnableOAuth2Sso
public class Application extends WebSecurityConfigurerAdapter {


@Override
protected void configure(HttpSecurity http) throws Exception {
http.antMatcher("/**")
.authorizeRequests()
.antMatchers("/login**", "/")
.permitAll()
.anyRequest()
.authenticated();
}

public static void main(String[] args) {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

SpringApplication.run(Application.class, args);
}
}
40 changes: 0 additions & 40 deletions src/main/java/kitchen/HelloController.java

This file was deleted.

39 changes: 39 additions & 0 deletions src/main/java/kitchen/KitchenController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.kitchen.ingredients;

import java.security.Principal;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;


@EnableOAuth2Sso
@Controller
public class KitchenController {

@RequestMapping("/login")
public String login() {
return "ingredients";
}

@RequestMapping("/ingredients")
public String ingridients() {
return "ingredients";
}

@RequestMapping("/recipes")
public String recipes() {
return "recipes";
}

@RequestMapping("/page3")
public String page3() {
return "page3";
}


}
23 changes: 0 additions & 23 deletions src/main/java/kitchen/Security.java

This file was deleted.

15 changes: 15 additions & 0 deletions src/main/java/kitchen/UserController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.kitchen.ingredients;

import java.security.Principal;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

@RequestMapping("/user")
public Principal user(Principal principal) {
return principal;
}
}
41 changes: 37 additions & 4 deletions src/main/resources/templates/index.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,46 @@
<html>
<head>
<title>Kitchen Ingredients</title>
<#include "head.ftl" />
<script src="https://www.gstatic.com/firebasejs/5.5.8/firebase.js"></script>
<script src="/API.js"></script>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js"></script>
</head>
<style>
body {
text-align: center;
display: block;
margin-left: auto;
margin-right: auto;
position: relative;
padding: 250px;
}
center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
<body>
<h1>Kitchen Ingredients</h1>
<p>This is a web app to help find you recipes you could create with only the ingredients found in your kitchen!</p>
<a href="/login">Login with Google </a>
<div class="center">
<h1>Kitchen Ingredients</h1>
<p>This is a web app to help find you recipes you could create with only the ingredients found in your kitchen!</p>
<a href="ingredients" style="text-transform:none" class="container unauthenticated">
Login with Google
</a>
</div>
<div class="container authenticated" style="display: none">
Logged in as: <span id="user"></span>
</div>
<script>
$.get("/user", function(data) {
$("#user").html(data.userAuthentication.details.name);
$(".unauthenticated").hide()
$(".authenticated").show()
});
</script>
</body>
</html>
22 changes: 12 additions & 10 deletions src/main/resources/templates/ingredients.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
table, td {
border: 1px solid black;
}
</style>

<title>Ingredients</title>
Expand Down Expand Up @@ -102,10 +101,9 @@ function add1() {
var row = table.insertRow(0);
var cell = row.insertCell(0);
cell.innerHTML = x;
var z = document.getElementById("mySelect");
z.remove(z.selectedIndex);
//var z = document.getElementById("mySelect");
//z.remove(z.selectedIndex);
}
function remove2() {
document.getElementById("myTable").deleteRow(0);
}
Expand Down Expand Up @@ -180,18 +178,22 @@ function add2() {
for (index in obj){
select.options[select.options.length] = new Option(obj[index]);
}
var elmtTable = document.getElementById('myTable');
var tableRows = elmtTable.getElementsByTagName('tr');
var rowCount = tableRows.length;
for (var x=rowCount-1; x>=0; x--) {
document.getElementById("myTable").deleteRow(x);
}
}
</script>
</body>
<div class="container authenticated">
Logged in as: <span id="user"></span>
</div>
<script>
$.get("/user", function(data) {
$("#user").html(data.userAuthentication.details.name);
$(".unauthenticated").hide()
$(".authenticated").show()
});
</script> </body>
</html>



1 change: 1 addition & 0 deletions src/main/resources/templates/recipes.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<#include "head.ftl" />
</head>
<body>
<#include "navbar.ftl"/>
<h1>Recipes</h1>
<p>Here, a user would see a list of recipes found in our database.</p>

Expand Down

0 comments on commit c8b93a2

Please sign in to comment.