KB68 Newsletter registration and deregistration.

Change-Id: Ic79fe64f03ce887879bffc7623e59cb697065ee6
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index b7c54da..088e4e0 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -68,6 +68,12 @@
 quarkus.mailer.port = 587
 quarkus.mailer.start-tls = REQUIRED
 quarkus.mailer.username = mulkcms@benkard.de
+mulkcms.imap.port = 993
+
+%dev.quarkus.mailer.host = mail.benkard.de
+%dev.quarkus.mailer.from = test@benkard.de
+%dev.quarkus.mailer.username = test@benkard.de
+%dev.quarkus.mailer.password = test
 
 # Deployment
 docker.registry = docker.benkard.de
diff --git a/src/main/resources/db/changeLog-1.7.xml b/src/main/resources/db/changeLog-1.7.xml
index 8824115..cfdad49 100644
--- a/src/main/resources/db/changeLog-1.7.xml
+++ b/src/main/resources/db/changeLog-1.7.xml
@@ -52,4 +52,18 @@
     </createTable>
   </changeSet>
 
+  <changeSet author="mulk" id="1.7-3">
+    <addColumn tableName="newsletter_subscriptions" schemaName="benki">
+      <column name="registration_key" type="VARCHAR">
+        <constraints unique="true" uniqueConstraintName="newsletter_subscriptions_registration_key_key"/>
+      </column>
+    </addColumn>
+
+    <createIndex tableName="newsletter_subscriptions"
+                 schemaName="benki"
+                 indexName="newsletter_subscriptions_registration_key_idx">
+      <column name="registration_key"/>
+    </createIndex>
+  </changeSet>
+
 </databaseChangeLog>
diff --git a/src/main/resources/templates/NewsletterResource/completeRegistration.html b/src/main/resources/templates/NewsletterResource/completeRegistration.html
new file mode 100644
index 0000000..0cdb874
--- /dev/null
+++ b/src/main/resources/templates/NewsletterResource/completeRegistration.html
@@ -0,0 +1,24 @@
+{#include base.html}
+
+{#title}Newsletter Registration &#8212; Benki{/title}
+{#siteSection}Newsletter{/siteSection}
+{#wikiClass}this-page{/wikiClass}
+
+{#nav}{#navbar siteSection="Newsletter" /}
+
+{#head}{/head}
+
+{#body}
+<article id="newsletter-registration">
+  <header>
+    <h1>Newsletter Registration</h1>
+  </header>
+
+  <section>
+    <p>In order to complete your registration, please check your email inbox and click
+      the link in the confirmation mail.</p>
+  </section>
+</article>
+{/body}
+
+{/include}
diff --git a/src/main/resources/templates/NewsletterResource/index.html b/src/main/resources/templates/NewsletterResource/index.html
new file mode 100644
index 0000000..84098bd
--- /dev/null
+++ b/src/main/resources/templates/NewsletterResource/index.html
@@ -0,0 +1,32 @@
+{#include base.html}
+
+{#title}Newsletter &#8212; Benki{/title}
+{#siteSection}Newsletter{/siteSection}
+{#wikiClass}this-page{/wikiClass}
+
+{#nav}{#navbar siteSection="Newsletter" /}
+
+{#head}{/head}
+
+{#body}
+<article id="newsletter-registration">
+  <header>
+    <h1>Newsletter</h1>
+  </header>
+
+  <section>
+    <p>To get a weekly digest of all posted articles and bookmarks into your email inbox,
+      enter your email address and submit the form below.</p>
+
+    <p>Your registration is subject to the <a href="/privacy">privacy policy</a>.</p>
+
+    <form class="pure-form pure-form-aligned" action="/newsletter/register" method="post">
+      <label for="email-input">E-mail address: </label>
+      <input type="email" name="email" id="email-input" placeholder="E-mail address" required/>
+      <input class="pure-button pure-button-primary" type="submit" value="Subscribe"/>
+    </form>
+  </section>
+</article>
+{/body}
+
+{/include}
diff --git a/src/main/resources/templates/NewsletterResource/registered.html b/src/main/resources/templates/NewsletterResource/registered.html
new file mode 100644
index 0000000..e82618e
--- /dev/null
+++ b/src/main/resources/templates/NewsletterResource/registered.html
@@ -0,0 +1,26 @@
+{#include base.html}
+
+{#title}Newsletter Registration &#8212; Benki{/title}
+{#siteSection}Newsletter{/siteSection}
+{#wikiClass}this-page{/wikiClass}
+
+{#nav}{#navbar siteSection="Newsletter" /}
+
+{#head}{/head}
+
+{#body}
+<article id="newsletter-registration">
+  <header>
+    <h1>Newsletter Registration</h1>
+  </header>
+
+  <section>
+    <p>Thank you. You are now subscribed to the weekly email digest.</p>
+
+    <p>To unsubscribe, send an email to
+      <a href="mailto:mulkcms+unsubscribe@benkard.de">mulkcms+unsubscribe@benkard.de</a>.</p>
+  </section>
+</article>
+{/body}
+
+{/include}
diff --git a/src/main/resources/templates/NewsletterResource/registrationMail.txt b/src/main/resources/templates/NewsletterResource/registrationMail.txt
new file mode 100644
index 0000000..c86b385
--- /dev/null
+++ b/src/main/resources/templates/NewsletterResource/registrationMail.txt
@@ -0,0 +1,12 @@
+{@java.lang.String registrationKey}
+Hello!
+
+Someone (you, one would hope) entered your email address to subscribe to the MulkCMS
+benkard.de newsletter.  In order to complete your registration, open the following
+link in your web browser:
+
+    https://matthias.benkard.de/newsletter/finish-registration?key={registrationKey}
+
+If someone is playing a trick on you and you would not actually like to subscribe to
+the newsletter, you may ignore this email.  In this case, your registration record
+will be deleted within a week.
\ No newline at end of file
diff --git a/src/main/resources/templates/NewsletterUnsubscriber/unsubscribedMail.txt b/src/main/resources/templates/NewsletterUnsubscriber/unsubscribedMail.txt
new file mode 100644
index 0000000..56f8d0e
--- /dev/null
+++ b/src/main/resources/templates/NewsletterUnsubscriber/unsubscribedMail.txt
@@ -0,0 +1,7 @@
+You have been unsubscribed from the MulkCMS newsletter because we
+received an unsubscription request from your email address.
+
+To register for the newsletter again, open the following page in
+your web browser:
+
+  https://matthias.benkard.de/newsletter
diff --git a/src/main/resources/templates/tags/navbar.html b/src/main/resources/templates/tags/navbar.html
index 63f88f1..d79a952 100644
--- a/src/main/resources/templates/tags/navbar.html
+++ b/src/main/resources/templates/tags/navbar.html
@@ -9,6 +9,8 @@
   <li class='{#if siteSection == "Wiki"}this-page{/}' data-site-section="Wiki"><a href="/wiki/Home">Wiki</a></li>
   {/if}
 
+  <li class='{#if siteSection == "Newsletter"}this-page{/}' data-site-section="Newsletter"><a href="/newsletter">Newsletter</a></li>
+
   <li class='{#if siteSection == "About"}this-page{/}' data-site-section="About"><a href="/about">Contact Info</a></li>
   <li class='{#if siteSection == "Privacy"}this-page{/}' data-site-section="Privacy"><a href="/privacy">Privacy Policy</a></li>