This is my blog, built for my own needs.
- Non-authenticated users are only able to:
- Read the published articles.
- Read the articles from a bunch of RSS feeds I find useful, mostly programming related.
- Authenticated users are also able to:
- Manage articles (publish, edit and delete).
- Manage the followed RSS feeds.
- Force the reload of the RSS feeds cache.
The blog articles support Markdown and code syntax highlighting.
NOTE: to correctly display the RSS articles, HTML sanitization is bypassed (only for this case), so that
<iframe>
elements are displayed as intended.
This means that only trusted RSS feeds should be followed, as no HTML sanitization means XSS!
The articles fetched from the followed RSS feeds are cached for a few hours to drastically improve loading times and to reduce the server's workload... bandwidth ain't free.
Recommended for production.
- Docker
- Docker Compose
-
Generate SSL certificates for HTTPS and save the files inside a secure location on your server.
You can use Cloudflare origin CA to generate the files
origin.pem
andprivate.pem
. -
Navigate to the repository root, copy the file
.env.example
, rename it to.env
, then set your sensitive data. -
Generate the private and public keys used to create the login tokens. Please refer to
backend/src/main/resources/certs/README.md
for instructions. -
Run the application:
docker compose up -d --build
-
Change the password (along the other details) of the default user:
docker exec -it tino-blog-db bash psql -d tino_blog -U postgres
Enter your password, then execute the update statement:
UPDATE users SET username = 'your_username', email = 'your@email.org', password = 'your_super_secret_bcrypt_encrypted_password' WHERE id = '4c7dbc23-b524-4dd2-95f0-c0cb974588c7';
-
Open the webapp: https://localhost
- Java 21
- PostgreSQL 17 (15 and 16 are also both fine as well)
- Angular CLI
Remember that after modifying the files
*.properties
, it may be necessary to run:mvn clean package
-
Configure the Spring "active profile" to
dev
, so thatapplication-dev.properties
is used overapplication.properties
: this allows Spring to generate the database tables and to use default certificates for user authentication. -
The database must be created manually using PostgreSQL: the default name is "tino_blog", but it can be customized using environment variables (see point number 3): the tables will be created by Spring during the first run.
-
To initialize the database with default data (first user and a bunch of RSS feeds), you can run this:
psql -U postgres -d tino_blog -f backend/src/main/resources/data.sql
Credentials of the first admin user, created during data initialization:
Email: admin@test.org
Password: password -
Configure the following environment variables for the backend (it can be done using IntelliJ IDEA "run configuration" or via system, for example, by running
export MY_ENV_VAR=123
on Linux and macOS):- DB_HOST (default "localhost")
- DB_PORT (default "5432")
- DB_NAME (default "tino_blog")
- DB_USER
- DB_PASSWORD
-
Navigate to the
backend
directory and compile it:mvn clean package
-
Run the backend:
java -jar target/tino-blog-1.2.0.war
-
Navigate to the
frontend
directory and run it:npm install ng serve
-
Open the webapp: http://localhost:4200
If the database schema changes, the DDL instructions must be exported into the file
backend/src/main/resources/schema.sql
, which is used when building the Docker image for the database.
This can be done with:
pg_dump -U db_username tino_blog >> schema.sql
Then, remove all the instructions like:
ALTER TABLE public.articles
OWNER TO postgres;
otherwise it won't be possible to specify custom database users in the .env
file.
By removing the explicit tables' ownership to a specific user, ownership will default to the user creating them, allowing for easier customization of the database username to improve security.
Scripts to migrate the database must be created inside backend/src/main/resources/sql-updates
to keep compatibility
with existing builds.
Migration scripts must be executed manually when updating from an older version.
Some Bootstrap colors were changed in the file frontend/src/custom_bootstrap/custom.scss
.
If the SASS changes, it needs to be compiled again in CSS:
-
Install SASS:
npm install -g sass
-
Compile the
.scss
file to.css
:sass --watch frontend/src/custom_bootstrap/custom.scss frontend/src/custom_bootstrap/custom.css
The full reference can be found here.
Yes, I did steal some colors from the color palette of GitHub, as it's perfect, and I'm no good designer.