Skip to content

Commit 74eac52

Browse files
committed
commit 1
1 parent 8219dea commit 74eac52

7 files changed

Lines changed: 59 additions & 23 deletions

File tree

src/main/java/org/launchcode/codingevents/CodingEventsApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ public static void main(String[] args) {
1010
SpringApplication.run(CodingEventsApplication.class, args);
1111
}
1212

13-
}
13+
}
Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package org.launchcode.codingevents.controllers;
22

33
import org.springframework.stereotype.Controller;
4+
import org.springframework.ui.Model;
45
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.PostMapping;
57
import org.springframework.web.bind.annotation.RequestMapping;
6-
import org.springframework.ui.Model;
8+
import org.springframework.web.bind.annotation.RequestParam;
79

810
import java.util.ArrayList;
911
import java.util.List;
@@ -15,15 +17,25 @@
1517
@RequestMapping("events")
1618
public class EventController {
1719

20+
private static List<String> events = new ArrayList<>();
21+
1822
@GetMapping
1923
public String displayAllEvents(Model model) {
20-
List<String> events = new ArrayList<>();
21-
events.add("Code With Pride");
22-
events.add("Strange Loop");
23-
events.add("Apple WWDC");
24-
events.add("SpringOne Platform");
24+
model.addAttribute("title", "All Events");
2525
model.addAttribute("events", events);
2626
return "events/index";
2727
}
2828

29-
}
29+
@GetMapping("create")
30+
public String displayCreateEventForm(Model model) {
31+
model.addAttribute("title", "Create Event");
32+
return "events/create";
33+
}
34+
35+
@PostMapping("create")
36+
public String processCreateEventForm(@RequestParam String eventName) {
37+
events.add(eventName);
38+
return "redirect:";
39+
}
40+
41+
}

src/main/java/org/launchcode/codingevents/controllers/HomeController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ public String index() {
1414
return "index";
1515
}
1616

17-
}
17+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
3+
<head th:replace="fragments :: head"></head>
4+
<body>
5+
6+
<header th:replace="fragments :: header"></header>
7+
8+
<form method="post">
9+
<input type="text" name="eventName">
10+
<input type="submit" value="Create">
11+
</form>
12+
13+
</body>
14+
</html>

src/main/resources/templates/events/index.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<!DOCTYPE html>
22
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
3-
<head>
4-
<meta charset="UTF-8"/>
5-
<title>Coding Events</title>
6-
</head>
3+
<head th:replace="fragments :: head"></head>
74
<body>
85

9-
<h1>All Events</h1>
6+
<header th:replace="fragments :: header"></header>
107

118
<ul>
129
<th:block th:each="event : ${events}">
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
3+
<head th:fragment="head">
4+
<meta charset="UTF-8"/>
5+
<title>Coding Events</title>
6+
<link rel="stylesheet" th:href="@{/styles.css}">
7+
<script th:src="@{/script.js}"></script>
8+
</head>
9+
<body>
10+
11+
<nav th:fragment="header">
12+
<h1 th:text="${title}">Coding Events</h1>
13+
<ul>
14+
<li><a href="/events">All Events</a></li>
15+
<li><a href="/events/create">Create Event</a></li>
16+
</ul>
17+
</nav>
18+
19+
</body>
20+
</html>
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
<!DOCTYPE html>
22
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
3-
<head>
4-
<meta charset="UTF-8"/>
5-
<title>Coding Events</title>
6-
</head>
3+
<head th:replace="fragments :: head"></head>
74
<body>
85

96
<h1>Coding Events</h1>
107

11-
<nav>
12-
<ul>
13-
<li><a href="/events">All Events</a></li>
14-
</ul>
15-
</nav>
8+
<header th:replace="fragments :: header"></header>
169

1710
</body>
1811
</html>

0 commit comments

Comments
 (0)