Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tobias young #7

Open
wants to merge 160 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
cf27a8b
travis and maven setup
luke-jones-1 Nov 18, 2019
03e97e3
travis and maven setup
luke-jones-1 Nov 18, 2019
2aa113c
usertablesetup
TobiasBenjaminYoungCGI Nov 18, 2019
366e587
table
Nov 18, 2019
a72963a
added to README.md
Adam1824 Nov 18, 2019
0ad22de
added user stories to readme
Adam1824 Nov 18, 2019
ebfe226
starting
TobiasBenjaminYoungCGI Nov 18, 2019
11ad944
working tests for database/ model
EarthWormGym Nov 18, 2019
d725a9c
create post and store in database
EarthWormGym Nov 18, 2019
b8e9dd6
posts are displayed on website
Adam1824 Nov 19, 2019
01037b7
page function
TobiasBenjaminYoungCGI Nov 19, 2019
ebfc4dd
usertable insert
TobiasBenjaminYoungCGI Nov 19, 2019
73f4b93
getting code coverage working hopefully
luke-jones-1 Nov 19, 2019
9788988
added time field to db, timestamp displayed next to post
Adam1824 Nov 19, 2019
0c721c9
some directory stuff
luke-jones-1 Nov 19, 2019
3346aa9
getting code coverage working on travis
luke-jones-1 Nov 19, 2019
0b23210
getting code coverage working on travis
luke-jones-1 Nov 19, 2019
c45a12b
getting code coverage working on travis
luke-jones-1 Nov 19, 2019
fd24096
getting code coverage working on travis
luke-jones-1 Nov 19, 2019
0bdf52d
getting code coverage working on travis
luke-jones-1 Nov 19, 2019
5649d97
signup done no tests
TobiasBenjaminYoungCGI Nov 19, 2019
47b8984
in progress of like button
Adam1824 Nov 19, 2019
903bf7f
getting code coverage working on travis
luke-jones-1 Nov 19, 2019
3745f76
getting code coverage working on travis
luke-jones-1 Nov 19, 2019
0b26326
getting code coverage working on travis
luke-jones-1 Nov 19, 2019
f4b424a
getting code coverage working on travis
luke-jones-1 Nov 19, 2019
4f464a7
sign-in page
TobiasBenjaminYoungCGI Nov 19, 2019
90e463c
like button working
EarthWormGym Nov 19, 2019
e71ff37
Merge pull request #1 from luke-jones-1/Tobias-young
TobiasBenjaminYoungCGI Nov 19, 2019
88a62fc
Merge branch 'master' into leatherhead
EarthWormGym Nov 19, 2019
25c52eb
Merge pull request #2 from luke-jones-1/leatherhead
EarthWormGym Nov 19, 2019
96052bb
extra file delete
TobiasBenjaminYoungCGI Nov 19, 2019
51737de
resolving merge conflict
luke-jones-1 Nov 19, 2019
ca9450f
Merge pull request #3 from luke-jones-1/Tobias-combined
TobiasBenjaminYoungCGI Nov 19, 2019
fb9d364
fixed tests after merge
EarthWormGym Nov 19, 2019
32eecff
Merge pull request #4 from luke-jones-1/leatherhead
luke-jones-1 Nov 19, 2019
90a38ef
resolving stuff
luke-jones-1 Nov 19, 2019
ad354dc
resolving stuff
luke-jones-1 Nov 19, 2019
aa6cd49
please work
luke-jones-1 Nov 19, 2019
1b904bf
Merge pull request #5 from luke-jones-1/luke-jones
luke-jones-1 Nov 19, 2019
6e3e4bc
trying to get travis to do something
luke-jones-1 Nov 19, 2019
61825c2
file structure change
luke-jones-1 Nov 19, 2019
2317c6a
branch-start
TobiasBenjaminYoungCGI Nov 19, 2019
e61d346
file structure change
luke-jones-1 Nov 20, 2019
79ec59d
file structure change
luke-jones-1 Nov 20, 2019
5d5dbc4
file structure change
luke-jones-1 Nov 20, 2019
60db343
file structure change
luke-jones-1 Nov 20, 2019
1e288c4
file structure change
luke-jones-1 Nov 20, 2019
29be1b4
css
Nov 20, 2019
d65a6f1
file structure change
luke-jones-1 Nov 20, 2019
d459961
file structure change
luke-jones-1 Nov 20, 2019
400c4c3
file structure change
luke-jones-1 Nov 20, 2019
9fff7d9
file structure change
luke-jones-1 Nov 20, 2019
e113702
file structure change
luke-jones-1 Nov 20, 2019
5772116
file structure change
luke-jones-1 Nov 20, 2019
58cfea1
file structure change
luke-jones-1 Nov 20, 2019
629e60a
test for adding comment (one post to many comments) complete
EarthWormGym Nov 20, 2019
175286e
trying out some more stuff to get travis working
luke-jones-1 Nov 20, 2019
e46ca51
sign-in
TobiasBenjaminYoungCGI Nov 20, 2019
530c63d
trying out some more stuff to get travis working
luke-jones-1 Nov 20, 2019
e3e6beb
comment feature plus working model test and NAV buttons
Adam1824 Nov 20, 2019
2404b37
test structure
TobiasBenjaminYoungCGI Nov 20, 2019
5d02838
travis working and running tests
luke-jones-1 Nov 20, 2019
35d4060
Merge pull request #6 from luke-jones-1/Tobias-young
TobiasBenjaminYoungCGI Nov 20, 2019
f15469b
Merge branch 'master' into leatherhead
EarthWormGym Nov 20, 2019
ddfc9b7
Merge pull request #7 from luke-jones-1/leatherhead
EarthWormGym Nov 20, 2019
fc8c547
resolving merge conflicts
luke-jones-1 Nov 20, 2019
f267ebd
Merge pull request #8 from luke-jones-1/luke-jones
luke-jones-1 Nov 20, 2019
ff68918
README changes
luke-jones-1 Nov 20, 2019
7a96b78
Merge branch 'master' of https://github.com/luke-jones-1/acebook-java…
luke-jones-1 Nov 20, 2019
b6cbf63
Jetremove
TobiasBenjaminYoungCGI Nov 20, 2019
4286894
Merge pull request #9 from luke-jones-1/luke-jones
luke-jones-1 Nov 20, 2019
0456e98
ush
TobiasBenjaminYoungCGI Nov 20, 2019
b2d8882
added sign up and in buttons
Adam1824 Nov 20, 2019
0df1180
getting mainTest.java working and testing
luke-jones-1 Nov 20, 2019
da79c9d
removing test Tests
luke-jones-1 Nov 20, 2019
fafcfbc
like button test passing
Adam1824 Nov 20, 2019
4c2256e
added delete functionality for comments and posts
Adam1824 Nov 20, 2019
e41bbaf
very minor formatting changes
EarthWormGym Nov 20, 2019
75b263f
removing test Tests
luke-jones-1 Nov 21, 2019
53e3bd6
removing test Tests
luke-jones-1 Nov 21, 2019
5b98918
commenting out MainTest as its failing and im not sure why
luke-jones-1 Nov 21, 2019
e6955d9
first try adding codecov test coverage reports
luke-jones-1 Nov 21, 2019
fa8c46e
extra nav buttons with bootstrap
EarthWormGym Nov 21, 2019
47e6937
required fields
TobiasBenjaminYoungCGI Nov 21, 2019
4139d0f
push
Nov 21, 2019
aca1680
Merge pull request #13 from luke-jones-1/leatherhead
Adam1824 Nov 21, 2019
b4d174c
errorfix
TobiasBenjaminYoungCGI Nov 21, 2019
c916cee
Merge pull request #11 from luke-jones-1/luke-jones
luke-jones-1 Nov 21, 2019
1bd8569
Merge pull request #10 from luke-jones-1/Tobias-young
TobiasBenjaminYoungCGI Nov 21, 2019
96bc7d0
Merge branch 'master' into Josie
luke-jones-1 Nov 21, 2019
7603efb
Merge branch 'master' into Josie
luke-jones-1 Nov 21, 2019
45d8259
Merge pull request #12 from luke-jones-1/Josie
luke-jones-1 Nov 21, 2019
24588c1
top bants
luke-jones-1 Nov 21, 2019
750b308
Merge pull request #14 from luke-jones-1/luke-jones
luke-jones-1 Nov 21, 2019
eefb90a
stuf
Nov 21, 2019
52b28d6
Merge branch 'master' of https://github.com/luke-jones-1/acebook-java…
Nov 21, 2019
fad72b8
CodeCov badge
luke-jones-1 Nov 21, 2019
75097c6
Merge pull request #15 from luke-jones-1/luke-jones
luke-jones-1 Nov 21, 2019
7279bb5
trying to get comment bot working
luke-jones-1 Nov 21, 2019
44e9e0d
test add
TobiasBenjaminYoungCGI Nov 21, 2019
90fff02
passing tests for deleting a post and a comment
Adam1824 Nov 21, 2019
0363135
Merge pull request #17 from luke-jones-1/Tobias-young
TobiasBenjaminYoungCGI Nov 21, 2019
148ccec
CreateUser
TobiasBenjaminYoungCGI Nov 21, 2019
8ddbd56
passing test for Comment class
Adam1824 Nov 21, 2019
abb5530
refactor
TobiasBenjaminYoungCGI Nov 21, 2019
03fed02
CodeCov bot hopefully working
luke-jones-1 Nov 21, 2019
389e343
Merge pull request #16 from luke-jones-1/luke-jones
luke-jones-1 Nov 21, 2019
0276ea3
truncate
TobiasBenjaminYoungCGI Nov 21, 2019
3aa12df
Merge branch 'master' into leatherhead
Adam1824 Nov 21, 2019
0e5e892
Merge pull request #18 from luke-jones-1/leatherhead
Adam1824 Nov 21, 2019
80023be
added missing curly bracket in deleteComment test
Adam1824 Nov 21, 2019
e016359
Merge pull request #20 from luke-jones-1/leatherhead
Adam1824 Nov 21, 2019
793547d
Merge branch 'master' into Tobias-young
TobiasBenjaminYoungCGI Nov 21, 2019
c62e1c9
Merge pull request #19 from luke-jones-1/Tobias-young
TobiasBenjaminYoungCGI Nov 21, 2019
26a621e
fixing stuff
luke-jones-1 Nov 21, 2019
b43f8e0
fix
TobiasBenjaminYoungCGI Nov 21, 2019
ed448bc
testing bug fixed
Adam1824 Nov 21, 2019
4299bcb
completed posts page
EarthWormGym Nov 21, 2019
a255fe3
Merge pull request #21 from luke-jones-1/luke-jones
luke-jones-1 Nov 21, 2019
5ed34a4
doublefix
TobiasBenjaminYoungCGI Nov 21, 2019
360df61
Merge branch 'leatherhead' into bootstrap
EarthWormGym Nov 21, 2019
85e7b88
Merge pull request #22 from luke-jones-1/bootstrap
EarthWormGym Nov 21, 2019
0ab35b1
Merge pull request #23 from luke-jones-1/Tobias-young
TobiasBenjaminYoungCGI Nov 21, 2019
f44aafb
added tests
TobiasBenjaminYoungCGI Nov 21, 2019
c3264f7
please dont break nuthin
luke-jones-1 Nov 21, 2019
2a9e6a4
Merge pull request #25 from luke-jones-1/Tobias-young
TobiasBenjaminYoungCGI Nov 21, 2019
d88806b
please dont break nuthin
luke-jones-1 Nov 21, 2019
040e742
email validation
Adam1824 Nov 21, 2019
2b8e66d
work pls
luke-jones-1 Nov 21, 2019
b851f94
work pls
luke-jones-1 Nov 21, 2019
f991cba
changed order of codcov.yml
luke-jones-1 Nov 21, 2019
d0ba89a
minor changes to bootstrap
EarthWormGym Nov 21, 2019
b1fdc42
confused
EarthWormGym Nov 21, 2019
d7d9732
used *'s in file path
luke-jones-1 Nov 21, 2019
3d7f6bf
sign up and sign in
Nov 21, 2019
3dc83bb
Merge branch 'master' into leatherhead
Adam1824 Nov 21, 2019
00c48bd
changed filepath to file name and extension
luke-jones-1 Nov 21, 2019
a75a03a
Merge pull request #26 from luke-jones-1/leatherhead
Adam1824 Nov 21, 2019
88c4344
filepath wilcard .java
luke-jones-1 Nov 21, 2019
0b200ca
filepath wilcard .java
luke-jones-1 Nov 21, 2019
7de0be0
upsie
TobiasBenjaminYoungCGI Nov 21, 2019
2cab07e
stufff
Nov 21, 2019
f4b9f32
added . to beginning of codecov.yml
luke-jones-1 Nov 21, 2019
8661070
Merge pull request #27 from luke-jones-1/Tobias-young
TobiasBenjaminYoungCGI Nov 21, 2019
b4c1ec6
rearrange of file structure to put Main and VTE into package
luke-jones-1 Nov 21, 2019
8e935ef
added icon
EarthWormGym Nov 21, 2019
fea5422
Merge branch 'leatherhead' of https://github.com/luke-jones-1/acebook…
EarthWormGym Nov 21, 2019
a227df4
rearrange of file structure to put Main and VTE into package
luke-jones-1 Nov 21, 2019
25da976
Merge pull request #28 from luke-jones-1/css
josiepollard Nov 21, 2019
946d23b
Merge pull request #29 from luke-jones-1/leatherhead
EarthWormGym Nov 21, 2019
4336d67
rearrange of file structure to put Main and VTE into package
luke-jones-1 Nov 21, 2019
76a0e22
amended createPost test
Adam1824 Nov 21, 2019
e6229ec
Merge branch 'leatherhead' of https://github.com/luke-jones-1/acebook…
Adam1824 Nov 21, 2019
cc407de
getting ready for pull
luke-jones-1 Nov 21, 2019
77c4f25
Merge branch 'master' of https://github.com/luke-jones-1/acebook-java…
luke-jones-1 Nov 21, 2019
bafe000
Merge pull request #30 from luke-jones-1/leatherhead
Adam1824 Nov 21, 2019
96075c9
Merge pull request #24 from luke-jones-1/luke-jones
luke-jones-1 Nov 21, 2019
2a805fc
PostTestFix
TobiasBenjaminYoungCGI Nov 21, 2019
87d438d
Coverage
TobiasBenjaminYoungCGI Nov 21, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target/
.idea/
.DS_Store
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: java
jdk: openjdk13
services: postgresql
before_install: psql -c 'CREATE DATABASE acebook_test;' -U postgres
install: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -V
script: mvn clean test
after_success: bash <(curl -s https://codecov.io/bash)
env:
global:
- CODECOV_TOKEN=b9222ee2-bb39-4262-94d4-52926dd25dba
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
### Acebook

[![Build Status](https://travis-ci.org/luke-jones-1/acebook-java-spark-template.svg?branch=master)](https://travis-ci.org/luke-jones-1/acebook-java-spark-template)
[![codecov](https://codecov.io/gh/luke-jones-1/acebook-java-spark-template/branch/master/graph/badge.svg)](https://codecov.io/gh/luke-jones-1/acebook-java-spark-template)

#### Running the application

- Make sure postgres is running
Expand Down Expand Up @@ -31,3 +34,19 @@
- [Velocity template blog post](https://www.learnhowtoprogram.com/java-old-reference-only/web-applications-in-java/velocity-templates-in-spark)
- [Velocity template + spark project example](https://github.com/epicodus-lessons/java-hello-friend-with-spark)
- [Flyway migrations (db schema management) docs](https://flywaydb.org/documentation/migrations)

#### Posting user stories (Leatherhead)
- As a user I would like to see the latest posts
listed on the acebook
- As a user I would like to create a new post
and have it appear with the latest posts
- As a user I would like to be able to like a post
and see the number of likes next to the post
- As a user I only want people to be able to
like a post once to avoid spam
- As a user I would like to be able to make
and receive comments on posts
- As a user I would like to see
the date of a post

heyfrens
50 changes: 50 additions & 0 deletions acebook.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.flywaydb:flyway-core:6.0.1" level="project" />
<orderEntry type="library" name="Maven: com.sparkjava:spark-core:2.7.2" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-server:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-http:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-util:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-io:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-webapp:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-xml:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-servlet:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-security:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-server:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-common:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-client:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-client:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-servlet:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-api:9.4.8.v20171121" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.5" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-log4j12:1.7.5" level="project" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: org.sql2o:sql2o:1.5.4" level="project" />
<orderEntry type="library" name="Maven: org.postgresql:postgresql:9.4-1201-jdbc41" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.10" level="project" />
<orderEntry type="library" name="Maven: org.apache.velocity:velocity:1.7" level="project" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.4" level="project" />
<orderEntry type="library" name="Maven: org.junit.jupiter:junit-jupiter-api:5.5.2" level="project" />
<orderEntry type="library" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />
<orderEntry type="library" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.junit.platform:junit-platform-commons:1.5.2" level="project" />
<orderEntry type="library" name="Maven: com.despegar:spark-test:1.1.8" level="project" />
<orderEntry type="library" name="Maven: com.despegar:http-java-native-client:1.0.4" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains:annotations:17.0.0" level="project" />
</component>
</module>
35 changes: 35 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
codecov:
require_ci_to_pass: yes

ignore:
- "src/main/java/*.java"
- "src/main/java/VelocityTemplateEngine.java"

coverage:
precision: 2
round: down
range: "70...100"

status:
project: yes
patch: yes
changes: no

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach, diff, flags, files"
behavior: default
require_changes: false # if true: only post the comment if coverage changes
require_base: no # [yes :: must have a base report to post]
require_head: yes # [yes :: must have a head report to post]
branches: null # branch names that can post comment
after_n_builds: 1 #e.g., 5. The number of uploaded reports codecov will receive before posting a comment on a pull request.


57 changes: 56 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,59 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->

<dataFile>target/jacoco.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>target/my-reports</outputDirectory>

</configuration>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>${project.build.directory}/target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -57,7 +105,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>edge-SNAPSHOT</version>
<version>1.18.10</version>
</dependency>

<dependency>
Expand All @@ -71,11 +119,18 @@
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
</dependency>

<dependency>
<groupId>com.despegar</groupId>
<artifactId>spark-test</artifactId>
<version>1.1.8</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>

</dependencies>
</project>
107 changes: 99 additions & 8 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import models.Model;
import models.Sql2oModel;
import models.*;
import org.apache.log4j.BasicConfigurator;
import org.flywaydb.core.Flyway;
import org.sql2o.Sql2o;
import org.sql2o.converters.UUIDConverter;
import org.sql2o.quirks.PostgresQuirks;
import spark.ModelAndView;
import spark.Spark;

import java.util.HashMap;
import java.util.UUID;

import static spark.Spark.get;

import static spark.Spark.*;

public class Main {

Expand All @@ -28,18 +29,108 @@ public static void main(String[] args) {
});

Model model = new Sql2oModel(sql2o);
UserModel userModel = new Sql2oModel(sql2o);

Spark.get("/posts", (req, res) -> {
HashMap posts = new HashMap();
posts.put("posts", model.getAllPosts());
posts.put("comments", model.getAllComments());

get("/", (req, res) -> "Hello World");
return new ModelAndView(posts, "templates/posts.vtl");
}, new VelocityTemplateEngine());


get("/posts", (req, res) -> {
Spark.get("/newpost", (req, res) -> {
return new ModelAndView(new HashMap<>(),"templates/newPost.vtl");
}, new VelocityTemplateEngine());

post("/newpost", (request, response) -> {
String title;
String content;
title = request.queryParams("title");
content = request.queryParams("content");
response.redirect("/posts");
UUID id = model.createPost(title, content);
return null;
});

HashMap posts = new HashMap();
post("/likepost", (request, response) -> {
String id;
id = request.queryParams("id");
model.addLike(id);
response.redirect("/posts");
return null;
});

//Sign in methods

return new ModelAndView(posts, "templates/posts.vtl");
Spark.get("/", (req, res) -> {
HashMap users = new HashMap();
return new ModelAndView(users, "templates/sign-in.vtl");
}, new VelocityTemplateEngine());
}


post("/sign-in", (req,res) -> {

String password = req.queryParams("password");
String email = req.queryParams("email");

if(userModel.verifyUser(email, password)) {
res.redirect("/posts");
}
res.redirect("/");
return null;
});


//Sign up methods

Spark.get("/sign-up", (req, res) -> {
HashMap users = new HashMap();
return new ModelAndView(users, "templates/sign-up.vtl");
}, new VelocityTemplateEngine());

post("/sign-up", (req,res) -> {
String first_name = req.queryParams("first_name");
String last_name = req.queryParams("last_name");
String password = req.queryParams("password");
String email = req.queryParams("email");

if (model.doesEmailExist(email)) {
res.redirect("/sign-up");
} else {
userModel.createUser(first_name, last_name, password, email);
res.redirect("/posts");
}
return null;
});

post("/postcomment", (request, response) -> {
String comment = request.queryParams("comment");
String post_id = request.queryParams("post_id");

model.postComment(comment, post_id);

response.redirect("/posts");
return null;
});

post("/deletecomment", (request, response) -> {
String comment_id = request.queryParams("comment_id");

model.deleteComment(comment_id);

response.redirect("/posts");
return null;
});

post("/deletepost", (request, response) -> {
String post_id = request.queryParams("post_id");

model.deletePost(post_id);

response.redirect("/posts");
return null;
});
};
}
22 changes: 22 additions & 0 deletions src/main/java/models/Comment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package models;

import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.List;
import java.util.UUID;

import lombok.Data;
@Data

public class Comment {
UUID post_id;
UUID comment_id;
String comment;

public Comment (UUID post_id, UUID comment_id, String comment) {
this.post_id = post_id;
this.comment_id = comment_id;
this.comment = comment;
}
}
8 changes: 8 additions & 0 deletions src/main/java/models/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
public interface Model {
UUID createPost(String title, String content);
List getAllPosts();
void addLike(String id);
String gettingComments(UUID post_id);
String gettingPost(String title);
void postComment(String comment, String post_id);
List getAllComments();
void deleteComment(String comment_id);
void deletePost(String post_id);
boolean doesEmailExist(String email);
}


Loading