Skip to content

Commit

Permalink
Merge c085e04 into 357c6a6
Browse files Browse the repository at this point in the history
  • Loading branch information
dickschoeller committed May 17, 2020
2 parents 357c6a6 + c085e04 commit 5ec2f01
Show file tree
Hide file tree
Showing 20 changed files with 212 additions and 115 deletions.
4 changes: 4 additions & 0 deletions gedbrowser-datamodel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
</properties>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- Need to fix dependency on commons-beanutils before using this. (,1.9.1 -->
<!-- dependency>
<groupId>org.gedcom4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package org.schoellerfamily.gedbrowser.datamodel.util;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.StringTokenizer;

import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;

/**
* @author Dick Schoeller
*/
Expand All @@ -20,6 +25,17 @@ public final class DateParser extends SimpleDateParser {
/** */
private static final String BET = "BET";

/**
* List of prefixes handled by strip and simple approximation.
*/
private static final List<Pair<String, Approximation>> LIST = new ArrayList<>();
static {
LIST.add(new ImmutablePair<>(ABT, Approximation.ABOUT));
LIST.add(new ImmutablePair<>(EST, Approximation.ABOUT));
LIST.add(new ImmutablePair<>(BEF, Approximation.BEFORE));
LIST.add(new ImmutablePair<>(AFT, Approximation.AFTER));
}

/** */
private final String inputString;
/** */
Expand Down Expand Up @@ -83,21 +99,11 @@ private String stripApproximationKeywords() {
final String dateString = inputString;

approximation = Approximation.EXACT;
if (startsWithIgnoreCase(dateString, ABT)) {
approximation = Approximation.ABOUT;
return stripPrefix(dateString, ABT);
}
if (startsWithIgnoreCase(dateString, EST)) {
approximation = Approximation.ABOUT;
return stripPrefix(dateString, EST);
}
if (startsWithIgnoreCase(dateString, BEF)) {
approximation = Approximation.BEFORE;
return stripPrefix(dateString, BEF);
}
if (startsWithIgnoreCase(dateString, AFT)) {
approximation = Approximation.AFTER;
return stripPrefix(dateString, AFT);
for (final Pair<String, Approximation> pair : LIST) {
if (startsWithIgnoreCase(dateString, pair.getLeft())) {
approximation = pair.getRight();
return stripPrefix(dateString, pair.getLeft());
}
}
if (dateString.charAt(0) == '(') {
approximation = Approximation.ABOUT;
Expand Down Expand Up @@ -146,6 +152,21 @@ private String handleFTMBizzareDateFormat(final String dateString) {
// be treated as a plain string with no approximation semantics.
return "";
}
string = handleBizzareApproximations(string);
string = truncateAt(string, "-");
string = truncateAt(string, " TO ");
if (string.length() <= 2) {
// Probably like 10-11 Nov 2017
string = stripPrefix(dateString, "(").trim();
string = stripSuffix(string, ")").trim();
string = removeBeginningAt(string, "-");
string = removeBeginningAt(string, " TO ");
}
return string;
}

private String handleBizzareApproximations(final String inString) {
String string = inString;
if (startsWithIgnoreCase(string, ABT)) {
string = stripPrefix(string, ABT).trim();
approximation = DateParser.Approximation.ABOUT;
Expand All @@ -161,15 +182,6 @@ private String handleFTMBizzareDateFormat(final String dateString) {
if (startsWithIgnoreCase(string, FROM)) {
string = stripPrefix(string, FROM).trim();
}
string = truncateAt(string, "-");
string = truncateAt(string, " TO ");
if (string.length() <= 2) {
// Probably like 10-11 Nov 2017
string = stripPrefix(dateString, "(").trim();
string = stripSuffix(string, ")").trim();
string = removeBeginningAt(string, "-");
string = removeBeginningAt(string, " TO ");
}
return string;
}

Expand Down
7 changes: 4 additions & 3 deletions gedbrowser/src/main/resources/templates/dataSetNotFound.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title
th:utext="'Data set not found - ' + ${error.exception.datasetName}">Dataset not found - xyzzy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title
th:utext="'Data set not found - ' + ${error.exception.datasetName}">Dataset
not found - xyzzy</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" href="css/gedbrowser.css" rel="stylesheet" />
</head>
<body>
Expand Down
77 changes: 50 additions & 27 deletions gedbrowser/src/main/resources/templates/fragments/footer.html
Original file line number Diff line number Diff line change
@@ -1,40 +1,63 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<link href="../../../resources/css/bootstrap.min.css" rel="stylesheet" media="screen" th:href="@{/resources/css/bootstrap.min.css}"/>
<link href="../../../resources/css/bootstrap.min.css" rel="stylesheet"
media="screen" th:href="@{/resources/css/bootstrap.min.css}" />
</head>
<body>
<!--/* Multiple fragments may be defined in one file */-->
<div th:fragment="footer-admin" th:align="center">
&copy; <span th:text="${#temporals.format(#temporals.createNow(), 'yyyy')}">2017</span>
<span>My Awesome App </span><span th:text="${@environment.getProperty('app.version')}"></span>
&copy; <span
th:text="${#temporals.format(#temporals.createNow(), 'yyyy')}">2017</span>
<span>My Awesome App </span><span
th:text="${@environment.getProperty('app.version')}"></span>
</div>

<div th:fragment="footer">
<hr class="final"/>
<table class="buttonrow">
<tr class="buttonrow">
<td class="brleft">
<p class="maintainer">Maintained by <a id="maintainerMail" th:href="'mailto:' + ${appInfo.maintainerEmail}" th:text="${appInfo.maintainerName}"></a>.<br/>
Created with <a th:href="${appInfo.applicationURL}" th:text="${appInfo.applicationName}"></a>, version <span th:text="${appInfo.version}">2.0</span> on <span th:text="${#dates.format(#dates.createToday(),'MMMMM dd, yyyy')}"></span>.<br/>
Get the sources on <a th:href="${appInfo.applicationURL}">GitHub</a> <a th:href="${appInfo.applicationURL}"><img src="images/github-25.png" style="vertical-align:top"/></a></p>
</td>
</tr>
</table>
</div>
<div th:fragment="footer">
<hr class="final" />
<table class="buttonrow">
<tr class="buttonrow">
<td class="brleft">
<p class="maintainer">
Maintained by <a id="maintainerMail"
th:href="'mailto:' + ${appInfo.maintainerEmail}"
th:text="${appInfo.maintainerName}"></a>.<br /> Created with <a
th:href="${appInfo.applicationURL}"
th:text="${appInfo.applicationName}"></a>, version <span
th:text="${appInfo.version}">2.0</span> on <span
th:text="${#dates.format(#dates.createToday(),'MMMMM dd, yyyy')}">
</span>.<br />
Get the sources on <a th:href="${appInfo.applicationURL}">GitHub</a>
<a th:href="${appInfo.applicationURL}"><img
src="images/github-25.png" style="vertical-align: top" /></a>
</p>
</td>
</tr>
</table>
</div>

<div th:fragment="footer-error">
<hr class="final"/>
<table class="buttonrow">
<tr class="buttonrow">
<td class="brleft">
<p class="maintainer">Maintained by <a id="maintainerMail" th:href="'mailto:' + ${error.maintainerEmail}" th:text="${error.maintainerName}"></a>.<br/>
Created with <a th:href="${error.applicationURL}" th:text="${error.applicationName}"></a>, version <span th:text="${error.version}">2.0</span> on <span th:text="${#dates.format(#dates.createToday(),'MMMMM dd, yyyy')}"></span>.<br/>
Get the sources on <a th:href="${error.applicationURL}">GitHub</a> <a th:href="${error.applicationURL}"><img src="images/github-25.png" style="vertical-align:top"/></a></p>
</td>
</tr>
</table>
</div>
<div th:fragment="footer-error">
<hr class="final" />
<table class="buttonrow">
<tr class="buttonrow">
<td class="brleft">
<p class="maintainer">
Maintained by <a id="maintainerMail"
th:href="'mailto:' + ${error.maintainerEmail}"
th:text="${error.maintainerName}"></a>.<br /> Created with
<a th:href="${error.applicationURL}"
th:text="${error.applicationName}"></a>,
version <span th:text="${error.version}">2.0</span> on
<span th:text="${#dates.format(#dates.createToday(),'MMMMM dd, yyyy')}">
</span>.<br />
Get the sources on <a th:href="${error.applicationURL}">GitHub</a>
<a th:href="${error.applicationURL}"><img
src="images/github-25.png" style="vertical-align: top" /></a>
</p>
</td>
</tr>
</table>
</div>



Expand Down
35 changes: 24 additions & 11 deletions gedbrowser/src/main/resources/templates/fragments/header.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<link href="../../../resources/css/bootstrap.min.css" rel="stylesheet" media="screen" th:href="@{/resources/css/bootstrap.min.css}"/>
<link href="../../../resources/css/bootstrap.min.css" rel="stylesheet" media="screen"
th:href="@{/resources/css/bootstrap.min.css}"/>
</head>
<body>

Expand All @@ -12,16 +13,20 @@
<span><a th:href="${model.indexHref}" id="index-menu">Index</a></span>
<span><a th:href="${model.sourcesHref}" id="sources-menu">Sources</a></span>
<span><a th:href="${model.submittersHref}" id="submitters-menu">Submitters</a></span>
<span><a th:if="${model.hasRole('ADMIN')}" th:href="${model.saveHref}" id="save-menu" th:attr="download=${model.saveFilename}">Save</a></span>
<span><a th:if="${model.hasRole('ADMIN')}" th:href="${model.livingHref}" id="living-menu">Living</a></span>
<span><a th:if="${model.hasRole('ADMIN')}" th:href="${model.placesHref}" id="places-menu">Places</a></span>
<span><a th:if="${model.hasRole('ADMIN')}" th:href="${model.saveHref}"
id="save-menu" th:attr="download=${model.saveFilename}">Save</a></span>
<span><a th:if="${model.hasRole('ADMIN')}" th:href="${model.livingHref}"
id="living-menu">Living</a></span>
<span><a th:if="${model.hasRole('ADMIN')}" th:href="${model.placesHref}"
id="places-menu">Places</a></span>
</span>
<div th:if="${#httpServletRequest.remoteUser} != null" class="right">
<form th:action="@{logout}" method="post">
<input class="menubar" type="submit" th:value="'Logout ' + ${model.userFirstname}"/>
</form>
</div>
<span th:if="${#httpServletRequest.remoteUser} == null" class="right" th:inline="text"><a th:href="@{login}">Login</a></span>
<span th:if="${#httpServletRequest.remoteUser} == null" class="right"
th:inline="text"><a th:href="@{login}">Login</a></span>
</div>

<!-- Bad enough error that the context is lost. DB not found, 404 or 500 error. -->
Expand All @@ -34,7 +39,8 @@
<input class="menubar" type="submit" th:value="'Logout ' + ${error.userFirstname}"/>
</form>
</div>
<span th:if="${#httpServletRequest.remoteUser} == null" class="right" th:inline="text"><a th:href="@{login}">Login</a></span>
<span th:if="${#httpServletRequest.remoteUser} == null" class="right"
th:inline="text"><a th:href="@{login}">Login</a></span>
</div>

<!-- DB is good, syntax is good, but object not found. -->
Expand All @@ -45,17 +51,24 @@
<span><a th:href="${error.exception.headerHref}" id="header-menu">Header</a></span>
<span><a th:href="${error.exception.indexHref}" id="index-menu">Index</a></span>
<span><a th:href="${error.exception.sourcesHref}" id="sources-menu">Sources</a></span>
<span><a th:href="${error.exception.submittersHref}" id="submitters-menu">Submitters</a></span>
<span><a th:if="${error.exception.hasRole('ADMIN')}" th:href="${error.exception.saveHref}" id="save-menu">Save</a></span>
<span><a th:if="${error.exception.hasRole('ADMIN')}" th:href="${error.exception.livingHref}" id="living-menu">Living</a></span>
<span><a th:if="${error.exception.hasRole('ADMIN')}" th:href="${error.exception.placesHref}" id="places-menu">Places</a></span>
<span><a th:href="${error.exception.submittersHref}"
id="submitters-menu">Submitters</a></span>
<span><a th:if="${error.exception.hasRole('ADMIN')}" th:href="${error.exception.saveHref}"
id="save-menu">Save</a></span>
<span><a th:if="${error.exception.hasRole('ADMIN')}"
th:href="${error.exception.livingHref}"
id="living-menu">Living</a></span>
<span><a th:if="${error.exception.hasRole('ADMIN')}"
th:href="${error.exception.placesHref}"
id="places-menu">Places</a></span>
</span>
<div th:if="${#httpServletRequest.remoteUser} != null" class="right">
<form th:action="@{logout}" method="post">
<input class="menubar" type="submit" th:value="'Logout ' + ${error.userFirstname}"/>
</form>
</div>
<span th:if="${#httpServletRequest.remoteUser} == null" class="right" th:inline="text"><a th:href="@{login}">Login</a></span>
<span th:if="${#httpServletRequest.remoteUser} == null" class="right"
th:inline="text"><a th:href="@{login}">Login</a></span>
</div>

</body>
Expand Down
3 changes: 2 additions & 1 deletion gedbrowser/src/main/resources/templates/living.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ <h2 th:if="${model.hasRole('ADMIN')}">Living</h2>
<h2 th:if="!${model.hasRole('ADMIN')}">Administrators Only!</h2>
<h3 th:if="${model.hasRole('ADMIN')}">A tabulation of people estimated to be living</h3>
<ul th:if="${model.hasRole('ADMIN')}">
<li th:each="bucket : ${model.buckets}"><a th:name="${bucket.lower}"></a><span th:utext="${bucket.lower} + ' - ' + ${bucket.upper}" class="label">0 to 9</span>
<li th:each="bucket : ${model.buckets}"><a th:name="${bucket.lower}"></a><span
th:utext="${bucket.lower} + ' - ' + ${bucket.upper}" class="label">0 to 9</span>
<ul>
<li th:each="person : ${bucket.persons}" th:utext="${person.indexName}">name</li>
</ul>
Expand Down
9 changes: 6 additions & 3 deletions gedbrowser/src/main/resources/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ <h2 class="login">Welcome to gedbrowser</h2>
<tr>
<td align="center">
<table class="login">
<tr><td class="form">Username:</td><td><input type="text" name="username"/></td></tr>
<tr><td class="form">Password:</td><td><input type="password" name="password"/></td></tr>
<tr><td class="form" colspan="2" align="center"><input type="submit" value="Login"/></td></tr>
<tr><td class="form">Username:</td><td><input type="text"
name="username"/></td></tr>
<tr><td class="form">Password:</td><td><input type="password"
name="password"/></td></tr>
<tr><td class="form" colspan="2" align="center"><input type="submit"
value="Login"/></td></tr>
</table>
</td>
</tr>
Expand Down
6 changes: 4 additions & 2 deletions gedbrowser/src/main/resources/templates/note.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title
th:text="${model.titleString} + ' - ' + ${model.idString} + ' - ' + ${model.gedObject.dbName}">Church
th:text="${model.titleString} + ' - ' + ${model.idString} + ' - '
+ ${model.gedObject.dbName}">Church
Record - N9999 - schoeller</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" href="css/gedbrowser.css" rel="stylesheet" />
Expand All @@ -22,7 +23,8 @@ <h3 class="attributes" th:text="'Note: ' + ${model.idString} + ' - ' + ${model.t
<div th:if="${not model.getAttributes().isEmpty()}">
<hr class="attributes"/>
<ul>
<li th:each="attribute : ${model.getAttributes()}" th:utext="${attribute.listItemContents}"></li>
<li th:each="attribute : ${model.getAttributes()}"
th:utext="${attribute.listItemContents}"></li>
</ul>
</div>

Expand Down
6 changes: 4 additions & 2 deletions gedbrowser/src/main/resources/templates/noteNotFound.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title
th:text="'Note not found - ' + ${error.exception.noteId} + ' - ' + ${error.exception.datasetName}">Note
th:text="'Note not found - ' + ${error.exception.noteId} + ' - '
+ ${error.exception.datasetName}">Note
not found - N99999 - schoeller</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" href="css/gedbrowser.css" rel="stylesheet" />
Expand All @@ -13,7 +14,8 @@
<div class="middle">
<div class="inner">
<h1 th:utext="${error.message}">Note</h1>
<h2 class="name"><span th:utext="${error.exception.noteId}">N1</span> not found in dataset <span th:utext="${error.exception.datasetName}"></span></h2>
<h2 class="name"><span th:utext="${error.exception.noteId}">N1</span>
not found in dataset <span th:utext="${error.exception.datasetName}"></span></h2>

<div th:replace="fragments/footer :: footer-error">&nbsp;</div>

Expand Down
Loading

0 comments on commit 5ec2f01

Please sign in to comment.