Skip to content

tslmy/t.t.t

Repository files navigation

logo t.t.t

pre-commit Build Status codecov HitCount

A database-free blog engine that reads from a folder of Markdown files.

Screenshot

Deploy

Setup

Locally

Assuming you have Composer installed somewhere in your $PATH, do:

composer install # install dependencies
php -S localhost:9000 -t public  # actually start the server

Via Docker

Set up an environment variable $PATH_TO_NOTES to the path to the posts you'd like to render with t.t.t.

You can run t.t.t via Dockerfile:

# Build the Docker image:
docker build -t ttt .

# Create a Docker container with the image built above, mapping $PATH_TO_NOTES to the content folder:
docker run -p 80:80 --rm --name ttt-demo -v $PATH_TO_NOTES:/var/www/html/public/content:ro ttt

... or via Docker Compose: docker-compose up.

Via Kubernetes

I will be using minikube in this walkthrough. I will be using the local Docker Registry as the source of the Kubenetes image.

# Start the cluster:
minikube start
# Register the Docker Registry to minikube -- This is because we will be building the image from the Dockerfile for Kubenetes:
eval $(minikube docker-env)
# Build the Docker image for Kubenetes:
docker build -t ttt .
# Apply the Deployment (which manages the Pods/"virtual hosts" in the minikube cluster for the app) as well as the Service (which is a Load Balancer in this case that exposes the web app in the Pods) using the manifest file:
kubectl apply -f kubernetes-manifest.yml
# Access the web app:
minikube service ttt-demo-service

Usage

To post a new article, simply upload your txt file to public/content/.

To organize posts into categories, simply create subdirectories under public/content/ and put txt files there. Nested directories are accepted.

To change the favicon, replace these files:

  • android-chrome-192x192.png
  • android-chrome-512x512.png
  • apple-touch-icon.png
  • favicon-16x16.png
  • favicon-32x32.png
  • favicon.ico
  • site.webmanifest

FAQ

  • When should I use it? This engine is great when you want to publish a folder of txt files as a blog real quick.
  • Why the name "t.t.t"? It was an acronym for my old blog, the.tslimi.tk. Apparently, it has lost this origin as I moved on to other blogging platforms. Feel free to interpret it any way you like.
  • Why PHP? This project was developed during an era where cPanel-based free web-hosting were popular. These web-hosting providers usually only allow PHP as the only dynamic web language on their platforms, hence the choice.

Development

I recommend running the PHP Coding Standards Fixer (PHP CS Fixer) everytime before committing.

Changelog

This project was originally written more than a decade ago while I was still a middle schooler. I didn't update this repo until recently (Dec 2020), during which time I removed/modified a number of features:

  • Instead of hard-wiring all the dependencies within the repo, t.t.t currently exploits CDNs and package managers for importing libraries.
  • The "quick access" list has been removed. Instead, use your favorite search engine.
  • The _intro.txt behavior has been removed to reduce complexity in the rendering process.
  • The caching behavior has been removed. It was a fun experience to have implemented my own caching mechanism, but the complexity-efficiency trade-off was just not paying off.
  • Instead of writing my own CSS, I'm now using the mvp.css template. This switch keeps the HTML in this repo more semantic and the CSS more up to modern standards.
  • Instead of using one favicon.ico file, the blog engine is now using a whole set of favicon files generated from favicon.io.

License

GPL-3.0. See LICENSE.