Skip to content

Commit ade4b4d

Browse files
author
teja.ct
committed
Fixed issue 6
1 parent beed2a1 commit ade4b4d

10 files changed

+326
-3
lines changed

.classpath

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src/main/java"/>
4+
<classpathentry kind="src" path="src/main/resources"/>
5+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6+
<classpathentry exported="true" kind="con" path="org.springsource.ide.eclipse.gradle.classpathcontainer"/>
7+
<classpathentry kind="output" path="bin"/>
8+
</classpath>

.project

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>flashy</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.springsource.ide.eclipse.gradle.core.nature</nature>
16+
<nature>org.eclipse.jdt.core.javanature</nature>
17+
</natures>
18+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#org.springsource.ide.eclipse.gradle.core.preferences.GradleImportPreferences
2+
#Sat Aug 27 13:50:17 EDT 2016
3+
addResourceFilters=true
4+
afterTasks=afterEclipseImport;
5+
beforeTasks=cleanEclipse;eclipse;
6+
enableAfterTasks=true
7+
enableBeforeTasks=true
8+
enableDependendencyManagement=true
9+
projects=;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#org.springsource.ide.eclipse.gradle.core.preferences.GradleProjectPreferences
2+
#Sat Aug 27 13:50:18 EDT 2016
3+
build.family.org.gradle.tooling.model.eclipse.HierarchicalEclipseProject=;
4+
org.springsource.ide.eclipse.gradle.linkedresources=
5+
org.springsource.ide.eclipse.gradle.rootprojectloc=
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#org.springsource.ide.eclipse.gradle.core.actions.GradleRefreshPreferences
2+
#Sat Aug 27 13:50:18 EDT 2016
3+
addResourceFilters=true
4+
afterTasks=afterEclipseImport;
5+
beforeTasks=cleanEclipse;eclipse;
6+
enableAfterTasks=true
7+
enableBeforeTasks=true
8+
useHierarchicalNames=false

bin/static/css/global.css

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
html { font-family: sans-serif; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
2+
3+
body { margin: 0; }
4+
5+
article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { display: block; }
6+
7+
audio, canvas, progress, video { display: inline-block; vertical-align: baseline; }
8+
9+
audio:not([controls]) { display: none; height: 0; }
10+
11+
[hidden], template { display: none; }
12+
13+
a { background-color: transparent; }
14+
a:active, a:hover { outline: 0; }
15+
16+
abbr[title] { border-bottom: 1px dotted; }
17+
18+
b, strong { font-weight: bold; }
19+
20+
dfn { font-style: italic; }
21+
22+
h1 { font-size: 2em; margin: .67em 0; }
23+
24+
mark { background: #ff0; color: #000; }
25+
26+
small { font-size: 80%; }
27+
28+
sub { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
29+
30+
sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; top: -0.5em; }
31+
32+
sub { bottom: -0.25em; }
33+
34+
img { border: 0; }
35+
36+
svg:not(:root) { overflow: hidden; }
37+
38+
figure { margin: 1em 40px; }
39+
40+
hr { -moz-box-sizing: content-box; box-sizing: content-box; height: 0; }
41+
42+
pre { overflow: auto; }
43+
44+
code, kbd, pre, samp { font-family: monospace, monospace; font-size: 1em; }
45+
46+
button, input, optgroup, select, textarea { color: inherit; font: inherit; margin: 0; }
47+
48+
button { overflow: visible; text-transform: none; }
49+
50+
select { text-transform: none; }
51+
52+
button, html input[type="button"] { -webkit-appearance: button; cursor: pointer; }
53+
54+
input[type="reset"], input[type="submit"] { -webkit-appearance: button; cursor: pointer; }
55+
56+
button[disabled], html input[disabled] { cursor: default; }
57+
58+
button::-moz-focus-inner { border: 0; padding: 0; }
59+
60+
input { line-height: normal; }
61+
input::-moz-focus-inner { border: 0; padding: 0; }
62+
input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; }
63+
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { height: auto; }
64+
input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; }
65+
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
66+
67+
fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: .35em .625em .75em; }
68+
69+
legend { border: 0; padding: 0; }
70+
71+
textarea { overflow: auto; }
72+
73+
optgroup { font-weight: bold; }
74+
75+
table { border-collapse: collapse; border-spacing: 0; }
76+
77+
td, th { padding: 0; }
78+
79+
html { font-size: 62.5%; }
80+
81+
body { font-size: 1.5em; line-height: 1.8; font-weight: 400; font-family: "Roboto", sans-serif; color: #666; }
82+
83+
.button { font-family: "Suez One", serif; font-size: 1.6rem; padding: 18px 30px; border: 0; margin-right: 10px; border-radius: 8px; font-weight: bold; display: inline-block; white-space: nowrap; box-sizing: border-box; line-height: 1; text-decoration: none; color: #A61717; background: none; box-shadow: 0 0 0 2px #A61717 inset; position: relative; -webkit-transition: 0.2s; -moz-transition: 0.2s; -ms-transition: 0.2s; -o-transition: 0.2s; transition: 0.2s; }
84+
.button:hover { box-shadow: 0 0 0 2px #791111 inset; color: #791111; outline: 0; }
85+
.button:hover [class^="icon-"], .button:hover [class*=" icon-"] { color: #791111; }
86+
87+
.button.button-primary { color: #fff; background-color: #A61717; }
88+
.button.button-primary:hover, .button.button-primary:focus { background-color: #791111; }
89+
90+
.bounds { max-width: 1080px; margin: 0 auto; }
91+
92+
h1, h2, h3, h4, h5, h6 { margin-top: 0; margin-bottom: 2rem; font-weight: bold; font-family: "Suez One", serif; color: #222; }
93+
94+
h1 { font-size: 3.8rem; }
95+
96+
h2 { font-size: 2.4rem; }
97+
98+
h3 { font-size: 1.8rem; }
99+
100+
h4 { font-size: 1.6rem; }
101+
102+
h5 { font-size: 1.4rem; }
103+
104+
h6 { font-size: 1.4rem; font-weight: normal; color: #999; }
105+
106+
@media (min-width: 550px) { h1 { font-size: 3.8rem; }
107+
h2 { font-size: 2.4rem; }
108+
h3 { font-size: 1.8rem; }
109+
h4 { font-size: 1.6rem; }
110+
h5 { font-size: 1.4rem; }
111+
h6 { font-size: 1.4rem; } }
112+
p { margin-top: 0; font-size: 1.6rem; }
113+
114+
em { color: #222; font-weight: bold; font-style: normal; }
115+
116+
a { color: #A61717; -webkit-transition: color .2s; -moz-transition: color .2s; -ms-transition: color .2s; -o-transition: color .2s; transition: color .2s; }
117+
a:hover { color: #791111; }
118+
119+
* { box-sizing: border-box; }
120+
121+
html, body { height: 100%; }
122+
123+
body { background-color: #730303; overflow: hidden; position: relative; }
124+
125+
h1, h2, h3, h4, h5, h6 { color: #D92323; font-family: "Suez One", serif; line-height: 1; }
126+
127+
.index .logo { font-size: 7rem; }
128+
129+
.title { background-color: #410202; padding: 10px 0 5px 0; position: relative; text-align: center; z-index: 3; }
130+
.title .logo a { color: #ECBC28; font-size: 2.5rem; text-decoration: none; }
131+
132+
.bounds { text-align: center; position: absolute; left: 50%; }
133+
@media(max-width: 640px) { .bounds { top: 350px; }
134+
.index .bounds { top: 30px; left: 0; padding: 0 15px; } }
135+
@media(min-width: 641px) { .bounds { top: 50%; -moz-transform: translate(-50%, -60%); -o-transform: translate(-50%, -60%); -ms-transform: translate(-50%, -60%); -webkit-transform: translate(-50%, -60%); transform: translate(-50%, -60%); } }
136+
.card { background-color: #eee; border-radius: 8px; box-shadow: 0 0 0 12px #eee inset, 0 0 0 16px #ECBC28 inset, 0 4px 6px 0 #5a0202; color: #222; cursor: pointer; display: block; padding: 60px; text-align: center; text-decoration: none; -webkit-transition: background-color 100ms ease-in-out, box-shadow 100ms ease-in-out, transform 100ms ease-in-out; -moz-transition: background-color 100ms ease-in-out, box-shadow 100ms ease-in-out, transform 100ms ease-in-out; -ms-transition: background-color 100ms ease-in-out, box-shadow 100ms ease-in-out, transform 100ms ease-in-out; -o-transition: background-color 100ms ease-in-out, box-shadow 100ms ease-in-out, transform 100ms ease-in-out; transition: background-color 100ms ease-in-out, box-shadow 100ms ease-in-out, transform 100ms ease-in-out; }
137+
.card:hover { background-color: #f5f5f5; box-shadow: 0 0 0 12px #f5f5f5 inset, 0 0 0 18px #ECBC28 inset, 0 4px 6px 0 #5a0202; color: #222; }
138+
.card:hover .button { background-color: #791111; box-shadow: 0 0 0 2px #791111 inset; }
139+
.card-container { perspective: 1000px; }
140+
.card-container.flip .card-flipper { -moz-transform: rotateY(180deg); -o-transform: rotateY(180deg); -ms-transform: rotateY(180deg); -webkit-transform: rotateY(180deg); transform: rotateY(180deg); }
141+
.card-flipper { -webkit-transition: 0.4s; -moz-transition: 0.4s; -ms-transition: 0.4s; -o-transition: 0.4s; transition: 0.4s; transform-style: preserve-3d; position: relative; }
142+
.card-back, .card-front { backface-visibility: hidden; position: absolute; }
143+
@media(max-width: 640px) { .card-back, .card-front { top: -250px; left: -150px; } }
144+
@media(min-width: 641px) { .card-back, .card-front { top: -250px; left: -250px; } }
145+
.card-front { z-index: 2; /* for firefox 31 */ -moz-transform: rotateY(0deg); -o-transform: rotateY(0deg); -ms-transform: rotateY(0deg); -webkit-transform: rotateY(0deg); transform: rotateY(0deg); }
146+
.card-back { -moz-transform: rotateY(180deg); -o-transform: rotateY(180deg); -ms-transform: rotateY(180deg); -webkit-transform: rotateY(180deg); transform: rotateY(180deg); }
147+
@media(max-width: 640px) { .card-flash, .card-container { width: 300px; height: 250px; } }
148+
@media(min-width: 641px) { .card-flash, .card-container { width: 500px; height: 300px; } }
149+
.card-word, .card-definition { position: absolute; top: 50%; left: 50%; -moz-transform: translate(-50%, -50%); -o-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); }
150+
.card-next { color: #a2a2a2; font-size: 2rem; font-family: "Suez One", serif; text-transform: uppercase; position: absolute; bottom: 0; left: 50%; }
151+
@media(max-width: 640px) { .card-next { padding-top: 30px; -moz-transform: translate(-50%, 70%); -o-transform: translate(-50%, 70%); -ms-transform: translate(-50%, 70%); -webkit-transform: translate(-50%, 70%); transform: translate(-50%, 70%); } }
152+
@media(min-width: 641px) { .card-next { padding-top: 50px; -moz-transform: translate(-50%, 60%); -o-transform: translate(-50%, 60%); -ms-transform: translate(-50%, 60%); -webkit-transform: translate(-50%, 60%); transform: translate(-50%, 60%); } }
153+
.card-next:hover { color: #a2a2a2; }
154+
@media(max-width: 640px) { .card-next:hover { -moz-transform: translate(-50%, 66%); -o-transform: translate(-50%, 66%); -ms-transform: translate(-50%, 66%); -webkit-transform: translate(-50%, 66%); transform: translate(-50%, 66%); } }
155+
@media(min-width: 641px) { .card-next:hover { -moz-transform: translate(-50%, 56%); -o-transform: translate(-50%, 56%); -ms-transform: translate(-50%, 56%); -webkit-transform: translate(-50%, 56%); transform: translate(-50%, 56%); } }
156+
.card-viewed { color: #a2a2a2; font-size: 14px; text-align: center; position: absolute; top: 50%; left: 50%; }
157+
@media(max-width: 640px) { .card-viewed { -moz-transform: translate(-50%, 320%); -o-transform: translate(-50%, 320%); -ms-transform: translate(-50%, 320%); -webkit-transform: translate(-50%, 320%); transform: translate(-50%, 320%); } }
158+
@media(min-width: 641px) { .card-viewed { -moz-transform: translate(-50%, 420%); -o-transform: translate(-50%, 420%); -ms-transform: translate(-50%, 420%); -webkit-transform: translate(-50%, 420%); transform: translate(-50%, 420%); } }
159+
.button { border-radius: 100px; letter-spacing: 0.1em; margin-top: 20px; text-transform: uppercase; }

bin/templates/bootstrap_github.html

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!DOCTYPE html>
2+
<html lang="en" xmlns:th="http://www.thymeleaf.org">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Flashy</title>
6+
<meta name="description" content="A Flash Card game about Java terms" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<link href="https://fonts.googleapis.com/css?family=Roboto|Suez+One" rel="stylesheet" />
9+
<link rel="stylesheet" href="/css/global.css" />
10+
</head>
11+
<body class="index">
12+
<div class="bounds">
13+
<div class="card">
14+
<h1 class="logo">GitHub Bootstrap</h1>
15+
<div th:unless="${options.githubOauth}" style="text-align: left">
16+
<p>In order to copy issues across you need to create a <a href="https://github.com/settings/tokens" target="_blank">GitHub personal access token</a>.</p>
17+
<p>On that page, choose "Generate new token".
18+
<ol>
19+
<li>Name it something like "Treehouse Issue Copier"</li>
20+
<li>Check the repo scope. (The first one).</li>
21+
<li>Click Generate token.</li>
22+
<li>Copy the token to your clipboard</li>
23+
<li>Paste it in the box below:</li>
24+
</ol>
25+
</p>
26+
<form action="#" th:action="@{/bootstrap/github}" th:object="${options}" method="post">
27+
<div>
28+
<input type="text" placeholder="Enter your GitHub oauth token here" th:field="*{githubOauth}" size="50"/>
29+
</div>
30+
<input type="submit" value="Submit" class="button button-primary"/>
31+
</form>
32+
</div>
33+
<div th:if="${options.githubOauth}">
34+
<div th:unless="${options.shouldFork}">
35+
<p>Are you ready to fork the <code th:text="${repoName}"></code> and its issues to your <code th:text="${gitHubUserName}"></code> GitHub Account</p>
36+
<form action="#" th:action="@{/bootstrap/github}" th:object="${options}" method="post">
37+
<input type="hidden" th:field="*{githubOauth}" />
38+
<input type="hidden" id="shouldFork" name="shouldFork" th:value="true" />
39+
<input type="submit" value="Fork it!" class="button button-primary"/>
40+
</form>
41+
</div>
42+
<div th:if="${options.shouldFork}" style="text-align: left">
43+
<h2>Success!</h2>
44+
<p>The following actions were performed:
45+
<ul>
46+
<li th:each="action : ${actions}" th:text="${action}" />
47+
</ul>
48+
</p>
49+
</div>
50+
</div>
51+
</div>
52+
</div>
53+
</body>
54+
</html>

bin/templates/flashcard_show.html

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html lang="en" xmlns:th="http://www.thymeleaf.org">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title th:text="${flashCard.term}" />
6+
<meta name="description" content="A Flash Card game about Java terms" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<link href="https://fonts.googleapis.com/css?family=Roboto|Suez+One" rel="stylesheet" />
9+
<link rel="stylesheet" href="/css/global.css" />
10+
</head>
11+
<body>
12+
13+
<div class="title">
14+
<h1 class="logo"><a href="./index.html">Flashy</a></h1>
15+
</div>
16+
<div class="bounds">
17+
<a href="#" id="flashCard" class="card-container">
18+
<div class="card-flipper">
19+
<div class="card card-flash card-front">
20+
<h1 class="card-word" th:text="${flashCard.term}" />
21+
<p class="card-viewed">Viewed <span th:text="${viewCount}" /> times</p>
22+
</div>
23+
<div class="card card-flash card-back">
24+
<div class="card-definition" th:text="${flashCard.definition}" />
25+
</div>
26+
</div>
27+
</a>
28+
</div>
29+
<a href="/flashcard/next" class="card card-flash card-next">Next</a>
30+
31+
<script>
32+
document.getElementById('flashCard').addEventListener('click', function(e) {
33+
document.getElementById('flashCard').classList.toggle('flip')
34+
e.preventDefault();
35+
});
36+
</script>
37+
</body>
38+
</html>

bin/templates/index.html

+20
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>
4+
<meta charset="utf-8" />
5+
<title>Flashy</title>
6+
<meta name="description" content="A Flash Card game about Java terms" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<link href="https://fonts.googleapis.com/css?family=Roboto|Suez+One" rel="stylesheet" />
9+
<link rel="stylesheet" href="/css/global.css" />
10+
</head>
11+
<body class="index">
12+
<div class="bounds">
13+
<a href="/flashcard/next" class="card">
14+
<h1 class="logo">Flashy</h1>
15+
<p id="call-to-action" th:text="${cta}" />
16+
<div class="button button-primary">Get Started!</div>
17+
</a>
18+
</div>
19+
</body>
20+
</html>

src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,22 @@ public void setFlashCardService(FlashCardService flashCardService) {
2222
@RequestMapping("/")
2323
public String index(Model model) {
2424
StringBuilder ctaBuilder = new StringBuilder();
25-
List<FlashCard> cards = flashCardService.getRandomFlashCards(5);
25+
int noOfSampleWords = 3;
26+
List<FlashCard> cards = flashCardService.getRandomFlashCards(noOfSampleWords);
2627
ctaBuilder.append("Refresh your memory about ");
2728
for (FlashCard card : cards) {
2829
ctaBuilder.append(card.getTerm());
2930
if (card != cards.get(cards.size() - 1)) {
3031
ctaBuilder.append(", ");
3132
}
3233
}
33-
ctaBuilder.append(" and ");
3434
Long totalCount = flashCardService.getCurrentCount();
35-
ctaBuilder.append(totalCount);
35+
int remainingCards = (int) (totalCount-noOfSampleWords);
36+
if(remainingCards > 0) {
37+
ctaBuilder.append(" and ");
38+
ctaBuilder.append(totalCount-noOfSampleWords);
3639
ctaBuilder.append(" more");
40+
}
3741
model.addAttribute("cta", ctaBuilder.toString());
3842
model.addAttribute("flashCardCount", totalCount);
3943
return "index";

0 commit comments

Comments
 (0)