~m15o/riku

96d9bf0d0c0e23b712cf3a455133ae4175f883b1 — m15o 6 months ago 2e6d702
Finalizing repo
A LICENSE => LICENSE +22 -0
@@ 0,0 1,22 @@
Copyright (c) 2022 m15o <m15o@posteo.net> . All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file

A README.md => README.md +51 -0
@@ 0,0 1,51 @@
# Riku

Collect responses from HTML forms.

## Installation

In order to compile Riku, you need to have:
* go
* git
* make

Here is how to build Riku:
1. `git clone git.sr.ht/~m15o/riku`
2. `cd vpub`
3. `make`

You should now have `riku` in `./bin/`. You can keep it there, or move it to `/usr/riku` or anywhere else.

## Postgres

Riku needs a Postgres database to run. Install Postgres and create a database:

```
apt-get install postgresql
su - postgres
createuser -P riku
createdb -O riku riku
```

## systemd service

Here's an example service file. Create it on `/etc/systemd/system/riku.service`.

```
[Install]
WantedBy=multi-user.target

[Unit]
Description=vpub

[Service]
Environment="DATABASE_URL=postgres://riku:riku@localhost/riku?sslmode=disable"
ExecStart=/usr/sbin/riku
```

The following ENV variable are available:

* `Port` defaults to 8888
* `Key` defaults to `the_coffee_tastes_great`. It's the key requested when creating an account.
* `DatabaseURL`
* `SessionKey`

M config/config.go => config/config.go +5 -0
@@ 6,6 6,7 @@ type Config struct {
	Port        string
	DatabaseURL string
	SessionKey  string
	Key         string
}

func New() *Config {


@@ 13,6 14,10 @@ func New() *Config {
		Port:        os.Getenv("PORT"),
		DatabaseURL: os.Getenv("DATABASE_URL"),
		SessionKey:  os.Getenv("SESSION_KEY"),
		Key:         os.Getenv("KEY"),
	}
	if cfg.Key == "" {
		cfg.Key = "the_coffee_tastes_great"
	}
	if cfg.Port == "" {
		cfg.Port = "8888"

M web/handler/html.go => web/handler/html.go +1 -1
@@ 35,7 35,7 @@ var TplMap = map[string]string{

<p>Questions? Send me an email at m15o at posteo dot net</p>

<p><a href="/manual">Want to learn more? Read the manual!</a></p>
<p><a href="/manual">Read the manual to learn more</a></p>
{{ end }}`,
	"login": `{{ define "title" }}Login{{ end }}


M web/handler/html/index.html => web/handler/html/index.html +3 -3
@@ 21,14 21,14 @@
&lt;/form&gt;
</pre>

<p>...and retrieve all the responses on the web interface or via the RSS feed.</p>
<p>...and retrieve all the responses on the web interface or via the atom feed.</p>

<p>
    <a href="/register">Register</a><br>
    <a href="">Source code</a>
</p>

<p>Questions? Send me an email at m15o at posteo dot net</p>
<p>Questions? Send me an email at m15o at posteo dot net.</p>

<p><a href="/manual">Want to learn more? Read the manual!</a></p>
<p><a href="/manual">Read the manual to learn more</a></p>
{{ end }}
\ No newline at end of file

M web/handler/html/manual.html => web/handler/html/manual.html +4 -1
@@ 10,7 10,6 @@

<pre>
&lt;form action=&quot;&quot; method=&quot;post&quot;&gt;

  &lt;div class=&quot;field&quot;&gt;
    &lt;label for=&quot;name&quot;&gt;Name&lt;/label&gt;
    &lt;input type=&quot;text&quot; name=&quot;name&quot; id="name" required&gt;


@@ 64,4 63,8 @@

<p>Now all requests coming from the contact form will be labeled with "contact".</p>

<h2>Getting a notification for your responses</h2>

<p>Riku provides an atom feed that you can find on the navigation bar at the top. Pass the feed to your feed reader of choice.</p>

{{ end }}
\ No newline at end of file