Added individual song and service pages.

This commit is contained in:
Jonathan Bernard 2015-03-17 22:30:55 -05:00
parent 5bcd4d91c3
commit 73be769483
7 changed files with 314 additions and 4 deletions

View File

@ -35,11 +35,53 @@
<servlet-class>groovy.servlet.TemplateServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>SongViewServlet</servlet-name>
<servlet-class>groovy.servlet.TemplateServlet</servlet-class>
<init-param>
<param-name>resource.name.regex</param-name>
<param-value>/song/?.*</param-value>
</init-param>
<init-param>
<param-name>resource.name.replacement</param-name>
<param-value>/song/index.gsp</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>ServiceViewServlet</servlet-name>
<servlet-class>groovy.servlet.TemplateServlet</servlet-class>
<init-param>
<param-name>resource.name.regex</param-name>
<param-value>/service/?.*</param-value>
</init-param>
<init-param>
<param-name>resource.name.replacement</param-name>
<param-value>/service/index.gsp</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>New Life Songs REST API</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SongViewServlet</servlet-name>
<url-pattern>/song/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServiceViewServlet</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>GroovyTemplate</servlet-name>
<url-pattern>*.gsp</url-pattern>

View File

@ -1,3 +1,11 @@
package com.jdbernard.nlsongs.model;
public enum ServiceType { SUN_AM, SUN_PM, WED }
public enum ServiceType {
SUN_AM("Sunday AM"), SUN_PM("Sunday PM"), WED("Wednesday");
private String displayName;
ServiceType(String displayName) { this.displayName = displayName; }
@Override public String toString() { return this.displayName; }
}

View File

@ -1,7 +1,16 @@
package com.jdbernard.nlsongs.servlet
import com.jdbernard.nlsongs.db.NLSongsDB
import com.jdbernard.nlsongs.model.Service
import com.jdbernard.nlsongs.model.Song
public class NLSongsContext {
public static NLSongsDB songsDB }
public static NLSongsDB songsDB
public static String mediaUrlBase
public static String makeUrl(Service service, Song song) {
return mediaUrlBase + service.@date.toString('yyyy-MM-dd') +
'/' + song.name.replaceAll(/\s/, '') + '.ogg' }
}

View File

@ -0,0 +1,92 @@
<!DOCTYPE html>
<%
import com.jdbernard.nlsongs.servlet.NLSongsContext
import static com.jdbernard.nlsongs.model.ServiceType.*
songsDB = NLSongsContext.songsDB
pathInfo = ((request.pathInfo?:"").split('/') as List).findAll()
if (pathInfo.size() != 1 || !pathInfo[0].isInteger()) {
response.sendError(response.SC_NOT_FOUND); return }
service = songsDB.findService(pathInfo[0] as int)
if (!service) { response.sendError(response.SC_NOT_FOUND); return }
%>
<html>
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="../images/favicon.ico">
<title><%= service.@date.toString("yyyy-MM-dd")
%> (<%= service.serviceType%>) - New Life Songs Database</title>
<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<!--<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"></script>-->
<!--<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>-->
<script type="application/javascript" src="https://cdn.datatables.net/1.10.5/js/jquery.dataTables.js"></script>
<!--<script type="application/javascript" src="https://cdn.datatables.net/1.10.5/js/jquery.dataTables.min.js"></script>-->
<!--<script type="application/javascript" src="../js/new-life-songs-@version@.js"></script>-->
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed|Roboto|Lato|Cuprum|Dosis|Cantarell' rel='stylesheet' type='text/css'>
<link href='http://cdn.datatables.net/1.10.5/css/jquery.dataTables.css' rel='stylesheet' type='text/css'>
<link href='../css/new-life-songs-@version@.css' rel='stylesheet' type='text/css'>
</head>
<body>
<header>
<h1>New Life Songs</h1>
<h2><%= service.@date.toString("yyyy-MM-dd") %> (<%=
service.serviceType %>)</h2>
<nav><ul>
<li><a href="../admin/">Admin</a></li>
<li><a href="../songs/">Songs</a></li>
<li><a href="../services/">Services</a></li>
</ul></nav>
</header>
<section class=service>
<h2>Performances</h2>
<table id=performances-table class="row-border dataTable hover compact" cellspacing=0>
<thead><tr>
<th class="dt-left">Song</th>
<th class="dt-left">Artists</th>
<th class="dt-left">Worship Leader</th>
<th class="dt-left">Piano</th>
<th class="dt-left">Organ</th>
<th class="dt-left">Bass</th>
<th class="dt-left">Drums</th>
<th class="dt-left">Guitar</th>
</tr></thead>
<tbody>
<% songsDB.findPerformancesForServiceId(service.id).
collect { [perf: it, song: songsDB.findSong(it.songId)] }.
sort { it.song.name }.each { row -> %>
<tr><td><a href='../song/<%= row.song.id %>'><%=
row.song.name %></a></td>
<td><%= row.song.artists.join(", ") %></td>
<td><%= row.perf.leader ?: "" %></td>
<td><%= row.perf.pianist ?: "" %></td>
<td><%= row.perf.organist ?: "" %></td>
<td><%= row.perf.bassist ?: "" %></td>
<td><%= row.perf.drummer ?: "" %></td>
<td><%= row.perf.guitarist ?: "" %></td></tr><% } %>
</tbody>
<tfoot><tr>
<th class="dt-left">Song</th>
<th class="dt-left">Artists</th>
<th class="dt-left">Worship Leader</th>
<th class="dt-left">Piano</th>
<th class="dt-left">Organ</th>
<th class="dt-left">Bass</th>
<th class="dt-left">Drums</th>
<th class="dt-left">Guitar</th>
</tr></tfoot>
</table>
</section>
<script type="application/javascript">
window.onload = function() { \$("#performances-table").dataTable(); };
</script>
</body>
</html>

View File

@ -0,0 +1,63 @@
<!DOCTYPE html>
<%
import com.jdbernard.nlsongs.servlet.NLSongsContext
import static com.jdbernard.nlsongs.model.ServiceType.*
songsDB = NLSongsContext.songsDB
%>
<html>
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="../images/favicon.ico">
<title>Services - New Life Songs Database</title>
<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<!--<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"></script>-->
<!--<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>-->
<script type="application/javascript" src="https://cdn.datatables.net/1.10.5/js/jquery.dataTables.js"></script>
<!--<script type="application/javascript" src="https://cdn.datatables.net/1.10.5/js/jquery.dataTables.min.js"></script>-->
<!--<script type="application/javascript" src="../js/new-life-songs-@version@.js"></script>-->
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed|Roboto|Lato|Cuprum|Dosis|Cantarell' rel='stylesheet' type='text/css'>
<link href='http://cdn.datatables.net/1.10.5/css/jquery.dataTables.css' rel='stylesheet' type='text/css'>
<link href='../css/new-life-songs-@version@.css' rel='stylesheet' type='text/css'>
</head>
<body>
<header>
<h1>New Life Songs</h1>
<h2>Services</h2>
<nav><ul>
<li><a href="../admin/">Admin</a></li>
<li><a href="../songs/">Songs</a></li>
<li><a href="../services/">Services</a></li>
</ul></nav>
</header>
<section class=services>
<table id=services-table class="row-border dataTable hover compact" cellspacing=0>
<thead><tr>
<th class="dt-left">Date</th>
<th class="dt-left">Service Type</th>
</tr></thead>
<tbody>
<% songsDB.findAllServices().sort { it.date }.reverse().each { service -> %>
<tr><td><a href="../service/<%= service.id %>"><%=
service.@date.toString("yyyy-MM-dd") %></a></td>
<td><% switch (service.serviceType) {
case SUN_PM: out.print("Sunday PM"); break
case SUN_AM: out.print("Sunday AM"); break
case WED: out.print("Wednesday"); break }
%></td></tr><% } %>
</tbody>
<tfoot><tr>
<th class="dt-left">Date</th>
<th class="dt-left">Service Type</th>
</tr></tfoot>
</table>
</section>
<script type="application/javascript">
window.onload = function() { \$("#services-table").dataTable(); };
</script>
</body>
</html>

View File

@ -0,0 +1,96 @@
<!DOCTYPE html>
<%
import com.jdbernard.nlsongs.servlet.NLSongsContext
import static com.jdbernard.nlsongs.model.ServiceType.*
songsDB = NLSongsContext.songsDB
pathInfo = ((request.pathInfo?:"").split('/') as List).findAll()
if (pathInfo.size() != 1 || !pathInfo[0].isInteger()) {
response.sendError(response.SC_NOT_FOUND); return }
song = songsDB.findSong(pathInfo[0] as int)
if (!song) { response.sendError(response.SC_NOT_FOUND); return }
%>
<html>
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="../images/favicon.ico">
<title><%= song.name %> - New Life Songs Database</title>
<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<!--<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"></script>-->
<!--<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>-->
<script type="application/javascript" src="https://cdn.datatables.net/1.10.5/js/jquery.dataTables.js"></script>
<!--<script type="application/javascript" src="https://cdn.datatables.net/1.10.5/js/jquery.dataTables.min.js"></script>-->
<!--<script type="application/javascript" src="../js/new-life-songs-@version@.js"></script>-->
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed|Roboto|Lato|Cuprum|Dosis|Cantarell' rel='stylesheet' type='text/css'>
<link href='http://cdn.datatables.net/1.10.5/css/jquery.dataTables.css' rel='stylesheet' type='text/css'>
<link href='../css/new-life-songs-@version@.css' rel='stylesheet' type='text/css'>
</head>
<body>
<header>
<h1>New Life Songs</h1>
<h2><%= song.name %></h2><%
if (song.artists.findAll().size() > 0) {
%><h3>by <%= song.artists.join(", ") %></h3> <% } %>
<nav><ul>
<li><a href="../admin/">Admin</a></li>
<li><a href="../songs/">Songs</a></li>
<li><a href="../services/">Services</a></li>
</ul></nav>
</header>
<section class=song>
<h2>Performances</h2>
<table id=performances-table class="row-border dataTable hover compact" cellspacing=0>
<thead><tr>
<th class="dt-left">Date</th>
<th class="dt-left">Service Type</th>
<th class="dt-left">Worship Leader</th>
<th class="dt-left">Piano</th>
<th class="dt-left">Organ</th>
<th class="dt-left">Bass</th>
<th class="dt-left">Drums</th>
<th class="dt-left">Guitar</th>
</tr></thead>
<tbody>
<% songsDB.findPerformancesForSongId(song.id).
collect { [perf: it, svc: songsDB.findService(it.serviceId)] }.
sort { it.svc.date }.each { row -> %>
<tr><td><a href='../service/<%= row.svc.id %>'><%=
row.svc.@date.toString("yyyy-MM-dd") %></a></td>
<td><% switch (row.svc.serviceType) {
case SUN_PM: out.print("Sunday PM"); break
case SUN_AM: out.print("Sunday AM"); break
case WED: out.print("Wednesday"); break }
%></td>
<td><%= row.perf.leader ?: "" %></td>
<td><%= row.perf.pianist ?: "" %></td>
<td><%= row.perf.organist ?: "" %></td>
<td><%= row.perf.bassist ?: "" %></td>
<td><%= row.perf.drummer ?: "" %></td>
<td><%= row.perf.guitarist ?: "" %></td></tr><% } %>
</tbody>
<tfoot><tr>
<th class="dt-left">Date</th>
<th class="dt-left">Service Type</th>
<th class="dt-left">Worship Leader</th>
<th class="dt-left">Piano</th>
<th class="dt-left">Organ</th>
<th class="dt-left">Bass</th>
<th class="dt-left">Drums</th>
<th class="dt-left">Guitar</th>
</tr></tfoot>
</table>
</section>
<script type="application/javascript">
window.onload = function() { \$("#performances-table").dataTable(); };
</script>
</body>
</html>

View File

@ -1,6 +1,6 @@
#
#Tue Mar 17 19:44:02 CDT 2015
#Tue Mar 17 22:28:16 CDT 2015
major=2
version.release=false
minor=0
build=43
build=57