Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyThomas-Dev committed May 1, 2020
0 parents commit 3ea2153
Show file tree
Hide file tree
Showing 109 changed files with 2,291 additions and 0 deletions.
Empty file added README.md
Empty file.
23 changes: 23 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<project default="compile">
<path id="libs">
<fileset dir="lib">
<include name="*.jar" />
</fileset>
</path>
<target name="compile">
<mkdir dir="target"/>
<javac srcdir="src" destdir="target">
<classpath refid="libs" />
</javac>
</target>
<target name="run">
<java classname="uk.ac.bris.cs.databases.web.Server">
<classpath>
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<pathelement path="target" />
</classpath>
</java>
</target>
</project>
30 changes: 30 additions & 0 deletions lib/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Please download and install the following libraries into this folder.

https://repo1.maven.org/maven2/org/freemarker/freemarker/2.3.23/freemarker-2.3.23.jar

https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.8.7/jackson-databind-2.8.7.jar

https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/1.5.8/mariadb-java-client-1.5.8.jar

https://repo1.maven.org/maven2/org/nanohttpd/nanohttpd/2.3.0/nanohttpd-2.3.0.jar

https://repo1.maven.org/maven2/org/nanohttpd/nanohttpd-nanolets/2.3.0/nanohttpd-nanolets-2.3.0.jar

https://repo1.maven.org/maven2/net/java/dev/jna/jna/4.3.0/jna-4.3.0.jar

https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/4.3.0/jna-platform-4.3.0.jar

---

Coursework 2 involves developing the data access layer of a web-based forum application. You can do this either on a lab machine or on your own laptop.

Please follow the instructions in the PDF file, which are repeated here:

Download cw2-student.zip and unzip it; this creates a folder cw2-student/.
Go to cw2-student/lib/ and open README.txt; download the libraries indicated into the cw2-student/lib/ folder.
In the cw2-student/ folder, run ant compile. Start the DB VM database as usual (vagrant up, ensure you can log in with mysql) and run ant run from the cw2-student/ folder.
Browse to http://localhost:8000 and you should see "Hello world!"
You are required to submit all files in a single zip on the Blackboard course site.
If you need to re-submit a file, you must resubmit your full zip again, updated appropriately.

For CS2 support, please use the Unit Forums (Discussion Boards) on BlackBoard, or book an appointment.
Binary file added lib/freemarker-2.3.23.jar
Binary file not shown.
Binary file added lib/jackson-databind-2.8.7.jar
Binary file not shown.
Binary file added lib/jna-4.3.0.jar
Binary file not shown.
Binary file added lib/jna-platform-4.3.0.jar
Binary file not shown.
Binary file added lib/mariadb-java-client-1.5.8.jar
Binary file not shown.
Binary file added lib/nanohttpd-2.3.0.jar
Binary file not shown.
Binary file added lib/nanohttpd-nanolets-2.3.0.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions resources/gridlex.css

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions resources/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
body {
background-color: #eee8d5; /* base2 */
font-family: sans-serif;
}

div.menu {
margin-bottom: 1ex;
padding: 1ex;
background-color: #859900;
color: #002b36;
}

div.menuitem a {
color: #002b36;
}

h1 {
color: #cb4b16;
}

div.section {
display: block;
background-color: #fdf6e3; /* base3 */
color: #2aa198;
padding-top: 0.5ex;
padding-bottom: 0.5ex;
margin: 1ex;
}

div.section h2 {
padding-left: 1ex;
color: #dc322f;
}

div.section p {
padding-left: 2ex;
padding-right: 2ex;
}

div.section a {
color: #6c71c4;
}

div.outer {
background-color: #073642; /* base02 */
}

div.subsection {
margin: 1ex;
padding: 0.25ex;
display: block;
background-color: #fdf6e3; /* base3 */
color: #859900;
/* border: 1px solid #268bd2; */
}

pre {
margin: 1ex;
padding: 1ex;
color: #d33682;
}


div.alt {
background-color: #859900;
color: #002b36;
}

div.alt a {
color: #002b36;
}

span.key {
width: 12em;
color: #859900;
float: left;
}

span.login {
float: right;
}

span.like {
float: right;
}
21 changes: 21 additions & 0 deletions resources/templates/ForumView.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<#include "header.html">

<h1>Forum: ${data.title}</h1>

<#list data.topics as t>
<div class="section">
<p><b><a href="/topic/${t.topicId}">${t.title}</a></b>
</p>
</div>
</#list>

<div class="section alt">
<#if session??>
<p><a href="/newtopic/${data.id}">Create new topic</a></p>
<#else>
<p><a href="/people">Log in</a> to create new topics.</p>
</#if>
</div>

<#include "footer.html">

16 changes: 16 additions & 0 deletions resources/templates/ForumsView.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<#include "header.html">

<h1>Forums</h1>

<#list data.data as forum>
<div class="section">
<p><b><a href="/forum/${forum.id}">${forum.title}</a></b></p>
</div>
</#list>

<div class="section alt">
<p><a href="/newforum">Create new forum</a></p>
</div>

<#include "footer.html">

16 changes: 16 additions & 0 deletions resources/templates/NewForumView.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<#include "header.html">

<h1>Create new forum</h1>

<div class="section">
<form method="POST" action="/createforum" enctype="multipart/form-data">

<p>Forum name:</p>
<p><input type="text" name="title" size="80" /></p>

<p><input type="submit" Value="Create"/></p>
</form>
</div>

<#include "footer.html">

22 changes: 22 additions & 0 deletions resources/templates/NewPersonView.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<#include "header.html">

<h1>Create new person</h1>

<div class="section">
<form method="POST" action="/createperson" enctype="multipart/form-data">

<p><span class="key">Name:</span>
<input type="text" name="name" size="40" /></p>

<p><span class="key">Username:</span>
<input type="text" name="username" size="40" /></p>

<p><span class="key">Student id:</span>
<input type="text" name="stuid" size="40" /></p>

<p><span class="key">&nbsp;</span><input type="submit" Value="Create"/></p>
</form>
</div>

<#include "footer.html">

16 changes: 16 additions & 0 deletions resources/templates/NewPostView.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<#include "header.html">

<h1>Create new post</h1>

<div class="section">
<form method="post" action="/createpost">

<p><textarea rows="10" cols="80" name="text"></textarea></p>

<input type="hidden" name="topic" value="${data.topic}" />
<p><input type="submit" Value="Post"/></p>
</form>
</div>

<#include "footer.html">

18 changes: 18 additions & 0 deletions resources/templates/NewTopic.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<#include "header.html">

<h1>Create new topic</h1>

<div class="section">
<form method="post" action="/createtopic">
<p>Title: </p>
<p><input type="text" name="title" size="80" /></p>
<p>Contents: </p>
<p><textarea rows="10" cols="80" name="text"></textarea></p>

<input type="hidden" name="forum" value="${data.forum}" />
<p><input type="submit" Value="Post"/></p>
</form>
</div>

<#include "footer.html">

18 changes: 18 additions & 0 deletions resources/templates/PeopleView.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<#include "header.html">

<h1>List of people</h1>

<div class="section">
<#list data.data as p>
<p><span class="key"><a href="/person/${p.key}">${p.value} [${p.key}]</a></span></p>
<p><a href="/login/${p.key}">(log in as ${p.value})</a></p>
</#list>
<p><a href="/login">(log out)</a></p>
</div>

<div class="section alt">
<p><a href="/newperson">add person</a></p>
</div>

<#include "footer.html">

28 changes: 28 additions & 0 deletions resources/templates/PersonView.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<#include "header.html">

<h1>Person: ${data.name}</h1>

<div class="section">
<h2>Information</h2>
<div class="grid">
<div class="col-2"></div>
<div class="col-4">Name</div>
<div class="col-4">${data.name}</div>
<div class="col-2"></div>
</div>
<div class="grid">
<div class="col-2"></div>
<div class="col-4">Username</div>
<div class="col-4">${data.username}</div>
<div class="col-2"></div>
</div>
<div class="grid">
<div class="col-2"></div>
<div class="col-4">Student id</div>
<div class="col-4">${data.studentId}</div>
<div class="col-2"></div>
</div>

</div>

<#include "footer.html">
15 changes: 15 additions & 0 deletions resources/templates/Success.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<#include "header.html">

<h1>Success</h1>

<div class="section">
<p>${data.value}</p>
</div>

<div class="section alt">
<a href="/forums">Back to main page</a>
</div>


<#include "footer.html">

28 changes: 28 additions & 0 deletions resources/templates/TopicView.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<#include "header.html">

<h1>Topic: ${data.title?html}</h1>

<#list data.posts as p>
<div class="section">
<p>Post #${p.postNumber} by ${p.author} at ${p.postedAt}
<#if session??>
</#if>
</p>
<pre>
${p.text?html}
</pre>
</div>
</#list>

<div class="section alt">
<p>
<#if session??>
<a href="/newpost/${data.topicId}">Reply</a>
<#else>
<a href="/people">Log in</a> to reply.
</#if>
</p>
</div>

<#include "footer.html">

3 changes: 3 additions & 0 deletions resources/templates/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
</body>
<html>

19 changes: 19 additions & 0 deletions resources/templates/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<html>
<head>
<link rel="stylesheet" href = "/styles.css"/>
<link rel="stylesheet" href = "/gridlex.css"/>
</head>
<body>
<div class="menu">
<a href="/forums">Main Page</a>
&nbsp;
<a href="/people">List of people</a>
<span class="login">
<#if session??>
You are logged in as ${session}.
<#else>
You are not logged in.
</#if>
</span>
</div>

Loading

0 comments on commit 3ea2153

Please sign in to comment.