Skip to content

Commit 2531bb0

Browse files
committed
split readme into separate files in doc, nicer doc view
1 parent d32bbb8 commit 2531bb0

File tree

6 files changed

+168
-153
lines changed

6 files changed

+168
-153
lines changed

README.md

Lines changed: 15 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,36 @@
1-
# Meh...
1+
# Meh... another comment system
22

3+
## Features
34

4-
A simple comment system for your static (or non-static) site.
5+
## Overview
56

7+
## Devel Quick Start
68

7-
## Quick Start
9+
You can use this to get a development environment up and running quickly. This is not suitable for production use. But should answer all your questions about how Meh works.
810

911
cd backend
1012
composer install
1113
cd ../frontend
1214
npm install
1315
npm run build
1416
cd ..
17+
cp .env.example .env
18+
$EDITOR .env
1519
./meh migrate
16-
./meh config site_url https://myblog.example.com
17-
./meh config admin_password supersecret
20+
php -s localhost:8000 -t public
1821

19-
Point your Apache to the `public` directory and you're good to go.
22+
You can then use `http://localhost:8000/` as the base URL for all components.
2023

21-
## Command Line Tool
24+
## Server
2225

23-
Meh comes with a command line tool that helps you manage your comment system. The `meh` command provides utilities for database management, configuration, and importing comments from other platforms.
2426

25-
To see available commands:
27+
* [Command Line Tool](doc/cli.md)
28+
* [Database Setup and Upgrade](doc/migrate.md)
29+
* [Configuration](doc/config.md)
30+
* [Mastodon Integration](doc/mastodon.md)
2631

27-
./meh
2832

29-
All commands support the `--site` (or `-s`) parameter to specify which site to operate on. This is useful if you're managing multiple sites with the same Meh installation.
30-
31-
./meh --site myblog config
32-
33-
If not specified, the default site name "meh" will be used. Site names have to be lowercase and can only contain letters, numbers, and underscores. Each site corresponds to a separate SQLite database.
34-
35-
## Database Migration
36-
37-
The `migrate` command is essential for setting up and maintaining your Meh installation:
38-
39-
```
40-
./meh migrate
41-
```
42-
43-
This command:
44-
45-
1. Creates a new SQLite database for your site if it doesn't exist yet
46-
2. Applies any pending database schema migrations to keep your database structure up-to-date
47-
3. Generates a secure JWT secret if one doesn't exist
48-
49-
You should run this command:
50-
- When first setting up Meh
51-
- After updating to a new version of Meh
52-
- When creating a new site in a multi-site setup (with the `--site` parameter)
53-
54-
For multi-site setups, specify the site name:
55-
56-
```
57-
./meh --site blog2 migrate
58-
```
59-
60-
It is important to run this command for each of your sites when upgrading to a new version of Meh.
61-
62-
## Configuration
63-
64-
Meh uses a layered configuration system that allows for flexible setup across multiple sites:
65-
66-
1. **Default Values**: Every configuration option has a sensible default value.
67-
68-
2. **Environment Variables**: Defaults can be overridden by environment variables prefixed with `MEH_` (e.g., the `site_url` config can be set via the `MEH_SITE_URL` env var).
69-
70-
3. **`.env` File**: For convenience, you can place environment variables in a `.env` file in the project root. The project contains a `.env.example` file that you can copy and modify.
71-
72-
4. **Database Storage**: Site-specific configurations can stored in each site's database and take precedence over environment variables.
73-
74-
### Configuration Hierarchy
75-
76-
When Meh looks for a configuration value, it checks these sources in order:
77-
78-
1. Default values (lowest priority)
79-
2. Environment variables / `.env` file
80-
3. Database values (highest priority)
81-
82-
### Managing Configuration
83-
84-
Use the `meh config` command to view or modify database configuration values:
85-
86-
```
87-
# View all configuration values and their sources
88-
./meh config
89-
90-
# View a specific configuration value
91-
./meh config site_url
92-
93-
# Set a configuration value in the database
94-
./meh config site_url https://example.com
95-
96-
# Remove a database configuration (revert to environment or default)
97-
./meh config site_url ""
98-
```
99-
100-
For multi-site setups, use the `--site` parameter:
101-
102-
```
103-
./meh --site blog1 config site_url https://blog1.example.com
104-
./meh --site blog2 config site_url https://blog2.example.com
105-
```
106-
107-
Configs set up via Environment always apply to all sites, while configs set up via the database are site-specific.
108-
109-
## Mastodon Integration
110-
111-
Meh includes built-in support for integrating with Mastodon, allowing you to import replies to your Mastodon posts as comments on your site.
112-
113-
### Configuration
114-
115-
To set up Mastodon integration:
116-
117-
1. Configure your Mastodon account in your site settings:
118-
119-
```
120-
./meh config mastodon_account "@yourusername@instance.social"
121-
```
122-
123-
2. If you're using GoToSocial, even read access requires an API token. The easiest way to get one is to use the [Access Token Generator for Mastodon API](https://takahashim.github.io/mastodon-access-token/). You only need the `read` scope.
124-
125-
```
126-
./meh config mastodon_token "your-api-token"
127-
```
128-
129-
3. Set up a cron job to periodically fetch new posts and replies:
130-
131-
```
132-
# Run every hour to check for new Mastodon posts and replies
133-
0 * * * * /path/to/meh mastodon
134-
```
135-
136-
For multi-site setups you need to set up a `mastodon_account` config and cron job for each site. But you can have all sites use the same account.
137-
138-
### How It Works
139-
140-
The Mastodon integration:
141-
142-
1. Fetches posts from your configured Mastodon account
143-
2. Identifies posts that link to your site
144-
3. Tracks these posts in the database
145-
4. Periodically checks for replies to these posts
146-
5. Imports replies as comments on the corresponding blog post
147-
148-
This creates a seamless bridge between discussions on your blog and on the Fediverse.
149-
150-
### Manual Import
151-
152-
You can manually trigger the Mastodon import process at any time:
153-
154-
```
155-
./meh mastodon
156-
```
157-
158-
This is useful for testing or for an initial import of existing conversations.
159-
160-
## Components
33+
## Client (your blog)
16134

16235
* [meh-form](./frontend/src/components/meh-form/readme.md)
16336
* [meh-comments](./frontend/src/components/meh-comments/readme.md)

backend/src/FileController.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ class FileController
66
{
77
const DIST_PATH = __DIR__ . '/../../frontend/dist/meh';
88
const COMPONENTS_PATH = __DIR__ . '/../../frontend/src/components';
9+
const DOC_PATH = __DIR__ . '/../../doc';
910
const README = __DIR__ . '/../../README.md';
1011

1112
public function home()
1213
{
1314
header('Content-Type: text/html; charset=utf-8');
14-
echo '<html lang="en"><head><title>Meh</title></head><body>';
15+
echo '<html lang="en"><head><title>Meh</title>';
16+
echo '<link rel="stylesheet" href="https://unpkg.com/chota@latest">';
17+
echo '</head><body><div class="container">';
1518
echo '<h1>Welcome to Meh</h1>';
1619
echo '<p>It\'s a comment system.</p>';
1720
echo '<p>Check out the <a href="/doc/index">documentation</a>.</p>';
18-
echo '</body></html>';
21+
echo '</div></body></html>';
1922
}
2023

2124
/**
@@ -27,12 +30,12 @@ public function home()
2730
*/
2831
public function dist($file): void
2932
{
30-
// everything else should be already handle by the router match type
31-
if(str_contains($file, '..') || str_starts_with($file, '.')) {
33+
// everything else should be already handled by the router match type
34+
if (str_contains($file, '..') || str_starts_with($file, '.')) {
3235
throw new HttpException('Invalid file path', 400);
3336
}
3437

35-
if(!file_exists(self::DIST_PATH . '/' . $file)) {
38+
if (!file_exists(self::DIST_PATH . '/' . $file)) {
3639
throw new HttpException('File not found', 404);
3740
}
3841

@@ -55,26 +58,30 @@ public function i18n($file): void
5558

5659
public function doc($file): void
5760
{
58-
// everything else should be already handle by the router match type
59-
if(str_contains((string) $file, '..') || str_starts_with((string) $file, '.')) {
61+
// everything else should be already handled by the router match type
62+
if (str_contains((string)$file, '..') || str_starts_with((string)$file, '.')) {
6063
throw new HttpException('Invalid file path', 400);
6164
}
6265

63-
if($file === 'index') {
66+
if ($file === 'index') {
6467
$mdfile = self::README;
68+
} elseif (file_exists(self::DOC_PATH . '/' . $file . '.md')) {
69+
$mdfile = self::DOC_PATH . '/' . $file . '.md';
6570
} else {
6671
$mdfile = self::COMPONENTS_PATH . '/' . $file . '/readme.md';
6772
}
6873

69-
if(!file_exists($mdfile)) {
74+
if (!file_exists($mdfile)) {
7075
throw new HttpException('File not found', 404);
7176
}
7277

7378
$html = \Parsedown::instance()->text(file_get_contents($mdfile));
7479

7580
header('Content-Type: text/html; charset=utf-8');
76-
echo '<html lang="en"><head><title>' . $file . '</title></head><body>';
81+
echo '<html lang="en"><head><title>' . $file . '</title>';
82+
echo '<link rel="stylesheet" href="https://unpkg.com/chota@latest">';
83+
echo '</head><body><div class="container">';
7784
echo $html;
78-
echo '</body></html>';
85+
echo '</div></body></html>';
7986
}
8087
}

doc/cli.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Command Line Tool
2+
3+
Meh comes with a command line tool that helps you manage your comment system. The `meh` command provides utilities for database management, configuration, and importing comments from other platforms.
4+
5+
To see available commands:
6+
7+
./meh
8+
9+
All commands support the `--site` (or `-s`) parameter to specify which site to operate on. This is useful if you're managing multiple sites with the same Meh installation.
10+
11+
./meh --site myblog config
12+
13+
If not specified, the default site name "meh" will be used. Site names have to be lowercase and can only contain letters, numbers, and underscores. Each site corresponds to a separate SQLite database.

doc/config.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Configuration
2+
3+
Meh uses a layered configuration system that allows for flexible setup across multiple sites:
4+
5+
1. **Default Values**: Every configuration option has a sensible default value.
6+
7+
2. **Environment Variables**: Defaults can be overridden by environment variables prefixed with `MEH_` (e.g., the `site_url` config can be set via the `MEH_SITE_URL` env var).
8+
9+
3. **`.env` File**: For convenience, you can place environment variables in a `.env` file in the project root. The project contains a `.env.example` file that you can copy and modify.
10+
11+
4. **Database Storage**: Site-specific configurations can stored in each site's database and take precedence over environment variables.
12+
13+
## Configuration Hierarchy
14+
15+
When Meh looks for a configuration value, it checks these sources in order:
16+
17+
1. Default values (lowest priority)
18+
2. Environment variables / `.env` file
19+
3. Database values (highest priority)
20+
21+
## Managing Configuration
22+
23+
Use the `meh config` [CLI command](cli) to view or modify database configuration values:
24+
25+
```
26+
# View all configuration values and their sources
27+
./meh config
28+
29+
# View a specific configuration value
30+
./meh config site_url
31+
32+
# Set a configuration value in the database
33+
./meh config site_url https://example.com
34+
35+
# Remove a database configuration (revert to environment or default)
36+
./meh config site_url ""
37+
```
38+
39+
For multi-site setups, use the `--site` parameter:
40+
41+
```
42+
./meh --site blog1 config site_url https://blog1.example.com
43+
./meh --site blog2 config site_url https://blog2.example.com
44+
```
45+
46+
Configs set up via Environment always apply to all sites, while configs set up via the database are site-specific.

doc/mastodon.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## Mastodon Integration
2+
3+
Meh includes built-in support for integrating with Mastodon, allowing you to import replies to your Mastodon posts as comments on your site.
4+
5+
### Configuration
6+
7+
To set up Mastodon integration:
8+
9+
1. Configure your Mastodon account in your site settings:
10+
11+
```
12+
./meh config mastodon_account "@yourusername@instance.social"
13+
```
14+
15+
2. If you're using GoToSocial, even read access requires an API token. The easiest way to get one is to use the [Access Token Generator for Mastodon API](https://takahashim.github.io/mastodon-access-token/). You only need the `read` scope.
16+
17+
```
18+
./meh config mastodon_token "your-api-token"
19+
```
20+
21+
3. Set up a cron job to periodically fetch new posts and replies:
22+
23+
```
24+
# Run every hour to check for new Mastodon posts and replies
25+
0 * * * * /path/to/meh mastodon
26+
```
27+
28+
For multi-site setups you need to set up a `mastodon_account` config and cron job for each site. But you can have all sites use the same account.
29+
30+
### How It Works
31+
32+
The Mastodon integration:
33+
34+
1. Fetches posts from your configured Mastodon account (uses the Mastodon API)
35+
2. Identifies posts that link to your site
36+
3. Tracks these posts in the database
37+
4. Periodically checks for replies to these posts
38+
5. Imports replies as comments on the corresponding blog post
39+
40+
This creates a seamless bridge between discussions on your blog and on the Fediverse.
41+
42+
### Manual Import
43+
44+
You can manually trigger the Mastodon import process at any time:
45+
46+
```
47+
./meh mastodon
48+
```
49+
50+
This is useful for testing or for an initial import of existing conversations.

doc/migrate.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Database Setup and Upgrade
2+
3+
The `migrate` [CLI command](cli) is essential for setting up and maintaining your Meh installation:
4+
5+
```
6+
./meh migrate
7+
```
8+
9+
This command:
10+
11+
1. Creates a new SQLite database for your site if it doesn't exist yet
12+
2. Applies any pending database schema migrations to keep your database structure up-to-date
13+
3. Generates a secure JWT secret if one doesn't exist
14+
15+
You should run this command:
16+
- When first setting up Meh
17+
- After updating to a new version of Meh
18+
- When creating a new site in a multi-site setup (with the `--site` parameter)
19+
20+
For multi-site setups, specify the site name:
21+
22+
```
23+
./meh --site blog2 migrate
24+
```
25+
26+
It is important to run this command for each of your sites when upgrading to a new version of Meh.

0 commit comments

Comments
 (0)