<img src="raw/screenshot.png" alt="screenshot of the site in action" style="float: right;">

# Famsite

A minimal social website for families (and friends).

JavaScript and PHP. SQLite database.

Very small. It's neat how much functionality you get with just modern HTML,
JavaScript, and CSS.

This uses my little RetroV JavaScript rendering library to draw
the interface and posts to the DOM:

[https://ratfactor.com/retrov/](https://ratfactor.com/retrov/)

And my little emoji picker library:

[https://ratfactor.com/faceclick/](https://ratfactor.com/faceclick/)


## Features

* Post text and images
* Image uploads with progress and thumbnail creation
* Special display grouping for daily word games
* Emoji picker with keyword search
* Emoji "reactions" to posts with optional small note
* Hidden spoilers and markdown-lite formatting
* 5-second polling to show new posts/edits/reaction

Not implemented:

* No admin or account management

If you need any additional functionality, feel free to add it and I might take
your pull request. :-)

## Install/Setup

You'll need a SQLite database, directories for avatars,
and image uploads.

### SQLite database setup

The top of `fam.php` has the path to the DB file:

    $GLOBALS['db'] = new PDO('sqlite:/data/famsite.db');

Run the `newdb.sql` script to make the two tables:

    $ sqlite3 ../data/famsite.db
    sqlite> .read newdb.sql

For now, you'll need to manually create your users!

    sqlite> insert into users (id, name, login)
            values (1, 'dave', '<rather long string>');

That's the only thing that's _really_ required. Visit the site in a browser and
it should prompt you to log in with the "login" code you entered in the DB for
your user account.

### Avatar images and image upload path

And put avatar images in an `/avatars/` directory with a naming scheme `1.png`
for user with id `1` and so forth.

(There is currently no way to upload an avatar image. I haven't needed it, so
it doesn't exist. Yes, that's nuts!)

The top of `fam.php` has the path to the upload directory:

    $GLOBALS['uploads_dir'] = '/htdocs/famsite/uploads/';

NOTE that the paths above are for my OpenBSD httpd setup, which runs the
application in a chroot, so the absolute paths are actually relative to a
common web application root.

You'll need to set appropriate file permissions before uploads will work.

### Upload file size limit

Note: The concept applies to many web servers, but these exact settings/paths
are specific to OpenBSD!

    # /etc/httpd.conf
    server "..." {
        connection max request body 8388608
    }

    # /etc/php-8.3.ini
    post_max_size = 8M
    upload_max_filesize = 8M

Restart each with (again, OpenBSD/my setup):

    $ doas httpd -n # test it
    $ doas rcctl reload httpd
    $ doas rcctl restart php83_fpm

### Header include

If you want to include additional info in the header area of
the website, write any PHP (or HTML) you would like to include
in a file named:

    myheader.php

Anything you put in there will show up in the header of the site.


## License

GPL, probably. I dunno, I'm getting kind of burnt out on licensing
debates lately. Contact me if you think you need a license for this.
