Lichen v1.2


This unmaintained version of Lichen is written in PHP. It requires a more complex server setup with various .htaccess rewrites.


Download Lichen v1.2



Changelog


1.2 (2022-05-15)



1.1 (2022-05-10)



1.0 (2022-05-09)




Directory Structure


.
├── cms
│   ├── edit.php
│   ├── gemtext.php
│   └── render.php
├── theme
│   └── layout.php
├── .htaccess
├── index.gmi
└── assets
	├── image.jpg
	└── stylesheet.css


Nginx


If you'd like to use Nginx instead of Apache, delete all of the .htaccess files and use this configuration:


map $is_redirected $auth_type {
	default "Restricted";
	true "off";
}

server {
	listen 80;
	root /var/www/html;

	include mime.types;
	index index.gmi;

	location / {
		# --- discard .gmi extensions and redirect
		rewrite (.*)\.gmi$ $1 permanent;

		# --- try .gmi files without extensions
		if (-f ${document_root}${uri}.gmi) {
			set $redirect_url ${uri}.gmi;
			set $is_redirected true;
			rewrite ^(.*)$ /cms/render.php?${redirect_url} last;
		}
		# --- try index files
		if (-f ${document_root}${uri}index.gmi) {
			set $redirect_url ${uri}index.gmi;
			set $is_redirected true;
			rewrite ^(.*)$ /cms/render.php?${redirect_url} last;
		}
		try_files $uri $uri/ =404;
	}

	location /cms/ {
		auth_basic $auth_type;
		auth_basic_user_file /home/private/lichen.htpasswd;

		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		set $path_info $fastcgi_path_info;

		fastcgi_pass unix:/run/php/php-fpm.sock;
		include fastcgi_params;


		fastcgi_param REDIRECT_URL $redirect_url if_not_empty;
		fastcgi_param SCRIPT_FILENAME ${document_root}${fastcgi_script_name};
		fastcgi_param PATH_INFO $path_info;

		try_files $fastcgi_script_name =404;
	}

	location /theme/ {
		return 404;
	}
}


Layout


The main HTML template is 'theme/layout.php'. This template is rendered with the content of the current Gemtext file. The following PHP variables are provided:



Image Processing


Not everyone is familiar with appropriate resolutions and image optimization for the web, so PHP's GD can be used to automatically resize uploaded images. The original source image will be discarded when this is enabled. Use the following environment variables:



These environment variables can be set in .htaccess if Apache's mod_env is enabled. See the provided .htaccess file.


Note that filenames must not have spaces in order to be compatible with the Gemtext link format. To facilitate this, spaces in filenames are automatically replaced with underscores when uploading via the editor UI.