Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ca79391
Add theme support and remove all Node/Gulp traces
jamiefdhurst Jan 7, 2025
4d1f9f3
Add theme support and remove all Node/Gulp traces (#112)
jamiefdhurst Jan 7, 2025
9baa8af
Update workflow to only run on PR
jamiefdhurst Jan 7, 2025
8f5c0f6
Better pagination support for > 9 pages at once
jamiefdhurst Jan 8, 2025
33c37e5
Better pagination support for > 9 pages at once (#114)
jamiefdhurst Jan 8, 2025
b1847ad
Add date links into footer, remove 'Posted On'
jamiefdhurst Jan 8, 2025
18cf7da
Add date links into footer, remove 'Posted On' (#115)
jamiefdhurst Jan 8, 2025
e98836c
Remove giphy adapter and all usages
jamiefdhurst Jan 8, 2025
a50e535
Remove giphy adapter and all usages (#116)
jamiefdhurst Jan 8, 2025
8b79de9
Merge branch 'main' into release/1.0.0
jamiefdhurst Jan 8, 2025
747d3aa
Make static and theme folders configurable
jamiefdhurst Mar 18, 2025
a392e1f
Update to supported version of GitHub upload artifact action
jamiefdhurst Mar 18, 2025
17681f6
Make static and theme folders configurable (#117)
jamiefdhurst Mar 18, 2025
cc23743
Form data is now preserved when an error occurs
jamiefdhurst Mar 19, 2025
8e5563f
Form data is now preserved when an error occurs (#118)
jamiefdhurst Mar 19, 2025
03106d6
Initial audit to get things baselined between devices
jamiefdhurst Mar 28, 2025
3efad9f
Simplify and standardise fonts on devices
jamiefdhurst Mar 30, 2025
e2dc845
Theme audit to standardise fonts and spacing between devices (#119)
jamiefdhurst Mar 30, 2025
d1265df
Update index and view logic and JSON responses
jamiefdhurst Mar 31, 2025
ec46a8f
Update edit and new logic, extracting session methods
jamiefdhurst Apr 26, 2025
6228d8e
Fix all current tests
jamiefdhurst Apr 26, 2025
2e014ed
Add tests to sitemap and fix logic
jamiefdhurst Apr 27, 2025
2707bdc
Add openapi spec and update README file
jamiefdhurst May 1, 2025
188ceb5
Add OpenAPI validation test
jamiefdhurst May 1, 2025
cb67567
Fix API Logic and Refactor Controllers (#123)
jamiefdhurst May 1, 2025
9561fbd
Migrate content from HTML to Markdown
jamiefdhurst May 4, 2025
53fab27
Migrate from HTML to Markdown for content (#126)
jamiefdhurst May 4, 2025
bcec0d4
Add random article link and API call
jamiefdhurst May 4, 2025
1c2b74b
Use the existing spec and tidy up some files
jamiefdhurst May 4, 2025
bcd0400
Fix API call to match others
jamiefdhurst May 4, 2025
e2695d4
Add random article link and API call (#127)
jamiefdhurst May 4, 2025
0d53789
Add basic stats web page and tests
jamiefdhurst May 23, 2025
165691a
Add API endpoint for stats
jamiefdhurst May 24, 2025
580bd3c
Rename migrations table to be singular, same as journal
jamiefdhurst May 25, 2025
2acbefe
Add visits table
jamiefdhurst May 25, 2025
8af086a
Enable visit and API tracking
jamiefdhurst May 25, 2025
f46c71c
Add visits into stats page and API
jamiefdhurst May 26, 2025
43713ed
Stats page (#132)
jamiefdhurst May 26, 2025
d80c1b0
Update SQLite driver to remove CGO and update to go 1.23
jamiefdhurst May 26, 2025
9200304
Update SQLite driver to remove CGO and update to go 1.23 (#133)
jamiefdhurst May 26, 2025
31b3512
Remove CGO from Makefile
jamiefdhurst May 26, 2025
5122f61
Add basic SSL support
jamiefdhurst Jun 8, 2025
8f8f249
Force HTTP/2 to be available
jamiefdhurst Jun 8, 2025
d829cee
Add basic HSTS support
jamiefdhurst Jun 8, 2025
151e7c7
Add XSS and CSP headers
jamiefdhurst Jun 15, 2025
ac1cfc3
Add relevant tests for additional headers
jamiefdhurst Jun 15, 2025
4b5c3df
Add HTTP2 and Native SSL Support (#134)
jamiefdhurst Jun 15, 2025
8e8c936
[WIP] Calendar
jamiefdhurst Sep 21, 2025
2146551
[WIP] Calendar functionality
jamiefdhurst Oct 5, 2025
79e306c
Calendar tests and fixes for bad requests and container issues
jamiefdhurst Oct 27, 2025
a1a2fae
Calendar (#136)
jamiefdhurst Oct 27, 2025
f25ee52
Configurable excerpt through environment variables for index page
jamiefdhurst Oct 27, 2025
bad695a
Configurable excerpt through environment variables for index page (#137)
jamiefdhurst Oct 27, 2025
df822a9
Add configurable session and cookie settings
jamiefdhurst Nov 1, 2025
95dd363
Session cookie config (#138)
jamiefdhurst Nov 1, 2025
bc26511
Add support for .env files
jamiefdhurst Nov 1, 2025
d6c773e
Add support for .env files (#139)
jamiefdhurst Nov 1, 2025
54d14ea
Add timestamps for created and updated and track these in view page a…
jamiefdhurst Dec 10, 2025
41533a9
Ensure migration creates the new created_at/updated_at fields
jamiefdhurst Dec 10, 2025
70b9539
Ensure migrations run as part of the full end-to-end testing
jamiefdhurst Dec 10, 2025
cc12dbd
Add timestamps for created and updated and track these in view page a…
jamiefdhurst Dec 10, 2025
aa97f61
Fix API inconsistencies and session decrypt issue
jamiefdhurst Dec 17, 2025
6de0c97
Fix API inconsistencies and session decrypt issue (#142)
jamiefdhurst Dec 17, 2025
30e1097
switch out default config names and articles/posts
jamiefdhurst Feb 8, 2026
7c55824
Switch out default config names and articles/posts (#145)
jamiefdhurst Feb 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[*]
indent_size = 4
indent_style = space

[*.yml]
indent_size = 2
indent_style = space

[*.yaml]
indent_size = 2
indent_style = space
10 changes: 8 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ jobs:
with:
files: 'web/app/package.json'
replacements: '${{ steps.latest_clean.outputs.name }}=${{ steps.version.outputs.value }}'
- name: Update Version in Files (3)
if: ${{ contains(steps.latest.outputs.name, '.') }}
uses: datamonsters/replace-action@v2
with:
files: 'web/static/openapi.yml'
replacements: '${{ steps.latest_clean.outputs.name }}=${{ steps.version.outputs.value }}'
- name: File Save Delay
uses: jakejarvis/wait-action@master
with:
Expand All @@ -82,13 +88,13 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
go-version: '1.24'
cache-dependency-path: go.sum
- name: Build Binary
run: |
sudo apt-get install -y build-essential libsqlite3-dev
go mod download
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -v -o journal-bin_linux_x64-v${{ steps.version.outputs.value }} .
GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -v -o journal-bin_linux_x64-v${{ steps.version.outputs.value }} .
cp journal-bin_linux_x64-v${{ steps.version.outputs.value }} bootstrap
zip -r journal-lambda_al2023-v${{ steps.version.outputs.value }}.zip bootstrap web -x web/app/\*
- name: Create Release
Expand Down
38 changes: 14 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Test

on:
push:
branches:
- '*'
- '!main'
pull_request: {}

permissions:
Expand All @@ -17,7 +13,6 @@ env:
GOPATH: /home/runner/work/journal/journal/go
J_ARTICLES_PER_PAGE: ''
J_DB_PATH: ''
J_GIPHY_API_KEY: ''
J_PORT: ''
J_TITLE: ''

Expand All @@ -32,7 +27,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
go-version: '1.24'
cache-dependency-path: go/src/github.com/jamiefdhurst/journal/go.sum
- name: Install Dependencies
working-directory: go/src/github.com/jamiefdhurst/journal
Expand All @@ -44,12 +39,12 @@ jobs:
working-directory: go/src/github.com/jamiefdhurst/journal
run: make test
- name: Upload Test Results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: tests
path: go/src/github.com/jamiefdhurst/journal/tests.xml
- name: Upload Coverage
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage
path: go/src/github.com/jamiefdhurst/journal/coverage.xml
Expand All @@ -60,21 +55,16 @@ jobs:
action_fail: true
files: |
go/src/github.com/jamiefdhurst/journal/tests.xml
- name: Publush Code Coverage
uses: irongut/CodeCoverageSummary@v1.3.0
- name: Create Code Coverage Report
uses: im-open/code-coverage-report-generator@4.9.0
with:
filename: go/src/github.com/jamiefdhurst/journal/coverage.xml
badge: false
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '80 90'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
reports: go/src/github.com/jamiefdhurst/journal/coverage.xml
reporttypes: MarkdownSummary
title: Go Test Code Coverage
- name: Publish Code Coverage
uses: im-open/process-code-coverage-summary@v2.2.3
with:
recreate: true
path: code-coverage-results.md
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-file: './coverage-results/Summary.md'
check-name: 'Code Coverage'
line-threshold: 80
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ _testmain.go
!Dockerfile.test
*.out
*.prof
coverage.xml
data
journal
node_modules
test/data/test.db
tests.xml
.vscode
.DS_Store
.history
bootstrap
*.zip
.env
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ COPY --from=0 /go/src/github.com/jamiefdhurst/journal/web web
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --assume-yes libsqlite3-0

ENV GOPATH "/go"
ENV J_ARTICLES_PER_PAGE ""
ENV J_CREATE ""
ENV J_DB_PATH ""
ENV J_GIPHY_API_KEY ""
ENV J_DESCRIPTION ""
ENV J_EDIT ""
ENV J_GA_CODE ""
ENV J_PORT ""
ENV J_POSTS_PER_PAGE ""
ENV J_THEME ""
ENV J_TITLE ""

VOLUME /go/data
Expand Down
8 changes: 6 additions & 2 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
FROM golang:1.22-bookworm
LABEL org.opencontainers.image.source=https://github.com/jamiefdhurst/journal

ENV J_ARTICLES_PER_PAGE ""
ENV J_CREATE ""
ENV J_DB_PATH ""
ENV J_GIPHY_API_KEY ""
ENV J_DESCRIPTION ""
ENV J_EDIT ""
ENV J_GA_CODE ""
ENV J_PORT ""
ENV J_POSTS_PER_PAGE ""
ENV J_THEME ""
ENV J_TITLE ""

WORKDIR /go/src/github.com/jamiefdhurst/journal
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: build test

build:
@CC=x86_64-unknown-linux-gnu-gcc CGO_ENABLED=1 GOARCH=amd64 GOOS=linux go build -v -o bootstrap .
@CC=x86_64-unknown-linux-gnu-gcc GOARCH=amd64 GOOS=linux go build -v -o bootstrap .
@zip -r lambda.zip bootstrap web -x web/app/\*

test:
Expand Down
58 changes: 38 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ with the addition of an API.

It makes use of a SQLite database to store the journal entries.

[API Documentation](api/README.md)
[API Documentation](api/README.md) - also available via `openapi.yml` as a URL
when deployed.

## Purpose

Expand Down Expand Up @@ -43,23 +44,40 @@ _Please note: you will need Docker installed on your local machine._
docker run --rm -v ./data:/go/data -p 3000:3000 -it journal:latest
```

## Environment Variables
## Configuration through Environment Variables

* `J_ARTICLES_PER_PAGE` - Articles to display per page, default `20`
* `J_CREATE` - Set to `0` to disable article creation
The application uses environment variables to configure all aspects.

You can optionally supply these through a `.env` file that will be parsed before
any additional environment variables.

### General Configuration

* `J_CREATE` - Set to `0` to disable post creation
* `J_DB_PATH` - Path to SQLite DB - default is `$GOPATH/data/journal.db`
* `J_DESCRIPTION` - Set the HTML description of the Journal
* `J_EDIT` - Set to `0` to disable article modification
* `J_EDIT` - Set to `0` to disable post modification
* `J_EXCERPT_WORDS` - The length of the post shown as a preview/excerpt in the index, default `50`
* `J_GA_CODE` - Google Analytics tag value, starts with `UA-`, or ignore to disable Google Analytics
* `J_GIPHY_API_KEY` - Set to a GIPHY API key to use, or ignore to disable GIPHY
* `J_PORT` - Port to expose over HTTP, default is `3000`
* `J_POSTS_PER_PAGE` - Posts to display per page, default `20`
* `J_THEME` - Theme to use from within the _web/themes_ folder, defaults to `default`
* `J_TITLE` - Set the title of the Journal

To use the API key within your Docker setup, include it as follows:
### SSL/TLS Configuration

```bash
docker run --rm -e J_GIPHY_API_KEY=... -v ./data:/go/data -p 3000:3000 -it journal:latest
```
* `J_SSL_CERT` - Path to SSL certificate file for HTTPS (enables SSL when set)
* `J_SSL_KEY` - Path to SSL private key file for HTTPS

### Session and Cookie Security

* `J_SESSION_KEY` - 32-byte encryption key for session data (AES-256). Must be exactly 32 printable ASCII characters. If not set, a random key is generated on startup (sessions won't persist across restarts).
* `J_SESSION_NAME` - Cookie name for sessions, default `journal-session`
* `J_COOKIE_DOMAIN` - Domain restriction for cookies, default is current domain only
* `J_COOKIE_MAX_AGE` - Cookie expiry time in seconds, default `2592000` (30 days)
* `J_COOKIE_HTTPONLY` - Set to `0` or `false` to allow JavaScript access to cookies (not recommended). Default is `true` for XSS protection.

**Note:** When `J_SSL_CERT` is configured, session cookies automatically use the `Secure` flag to prevent transmission over unencrypted connections.

## Layout

Expand All @@ -77,9 +95,9 @@ The project layout follows the standard set out in the following document:
* `/test` - API tests
* `/test/data` - Test data
* `/test/mocks` - Mock files for testing
* `/web/app` - CSS/JS source files
* `/web/static` - Compiled static public assets
* `/web/templates` - View templates
* `/web/themes` - Front-end themes, a default theme is included

## Development

Expand All @@ -101,15 +119,17 @@ the binary itself.

#### Dependencies

The application currently only has one dependency:
The application has the following dependencies (using go.mod and go.sum):

* [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3)
- [github.com/ncruces/go-sqlite3](https://github.com/ncruces/go-sqlite3)
- [github.com/akrylysov/algnhsa](https://github.com/akrylysov/algnhsa)
- [github.com/aws/aws-lambda-go](https://github.com/aws/aws-lambda-go)
- [github.com/gomarkdown/markdown](https://github.com/gomarkdown/markdown)

This can be installed using the following commands from the journal folder:

```bash
go get -v ./...
go install -v ./...
```

#### Templates
Expand All @@ -121,13 +141,11 @@ content.

### Front-end

The front-end source files are in _web/app_ and require some tooling and
dependencies to be installed via `npm` such as gulp and webpack. You can then
use the following build targets:
The front-end source files are intended to be divided into themes within the
_web/themes_ folder. Each theme can include icons and a CSS stylesheet.

* `gulp sass` - Compiles the SASS source into CSS
* `gulp webpack` - Uglifies and minifies the JS
* `gulp` - Watches for changes in SASS/JS files and immediately compiles
A simple, basic and minimalist "default" theme is included, but any other
themes can be built and modified.

### Building/Testing

Expand Down
Loading