The software behind the Interactive Fiction Database (IFDB)
This is the source code for IFDB, the Interactive Fiction Database.
The IFDB web app is a LAMP app (Linux, Apache, MySQL, PHP). The development environment runs on Docker.
Install Docker and Docker Compose. https://docs.docker.com/get-docker/
Run ./prepare_dev_environment.sh in this directory. That will download the current latest IFDB database backup from IFArchive, and put it in a place where Docker will expect to find it.
Run docker compose up --build. That will launch a MySQL Docker container and an Apache container with PHP, available on port 8080.
Go to http://localhost:8080 on your machine. You should see IFDB running. You can login as ifdbadmin at ifdb.org with the password secret to sign in as an administrator. The administrator has access to the "system maintenance panel" at http://localhost:8080/adminops.
Alternatively, you can login as test at ifdb.org with the password secret to sign in as a regular test user named Test Tester.
Optionally, you can query the database using phpMyAdmin at http://localhost:8081 or run ./query-docker.sh to use the MySQL command-line interface.
Changes to the database's schema or content are made with migrations: SQL files in ./sql/migrations, applied by dbmate. Each database keeps track of which migrations it has already applied. Your local database applies any new ones whenever you start it with docker compose up, and dev.ifdb.org and ifdb.org apply them when they're deployed.
Once your development environment is set up, you can make a database change at any time, whether or not it's running:
Create a migration file:
./docker-dbmate.sh new add_example_to_games
Replace add_example_to_games with a few words describing your change, in lowercase with underscores instead of spaces. The command creates sql/migrations/<timestamp>_add_example_to_games.sql.
In that file, put the SQL for your change under -- migrate:up, and SQL that undoes it under -- migrate:down:
-- migrate:up
ALTER TABLE games ADD COLUMN example VARCHAR(255);
-- migrate:down
ALTER TABLE games DROP COLUMN example;
If your change can't be undone, put SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Irreversible'; under -- migrate:down, so that trying to undo it fails with an error.
Apply it to your local database:
./docker-dbmate.sh
That applies every migration your database doesn't have yet, so you never name a specific one. You don't need to restart anything.
To change a migration you've applied but haven't merged yet, edit the file, then rebuild your local database with docker compose down and docker compose up. Once a migration is merged, don't edit it; databases that already applied it won't run it again. Make a new migration instead.
Our PHP dependencies are checked into composer.json and composer.lock. To update those files, you'll need to run composer inside a Docker container, using the docker-php-composer.sh script, like this:
./docker-php-composer.sh update
./docker-php-composer.sh require whatever/dependency
Then, stop your server and restart your dev environment with these commands:
./prepare_dev_environment.sh
docker compose down
docker compose up --build
Once your dependency is installed, you'll consume the dependency by adding a require_once 'vendor/autoload.php'; line to your code.
Unit tests live in test/unit and use PHPUnit. Run them with Docker:
./docker-phpunit.sh
./docker-phpunit.sh --filter FixDesc
We use PHP-CS-Fixer for coding style.
Run it with Docker:
./docker-php-cs-fixer.sh
./docker-php-cs-fixer.sh --dry-run --diff
EMAIL: NOT SENDING EMAIL IN LOCAL DEVELOPMENT MODE.To reset the Docker environment, run this:
./prepare_dev_environment.sh && docker compose down && docker compose up --build
./prepare_dev_environment.sh populates the initdb directory, which is only run when you docker compose up on a container for the first time.
If you just docker compose up, it will launch the container you already built. If you docker compose down and docker compose up without --build, it will reuse the existing Docker image, without incorporating changes to the Dockerfile.
If you see a 500 error loading http://localhost:8080, check the Docker logs. If you see one of these errors, then something went wrong during the ./prepare_dev_environment.sh step.
PHP Warning: include_once(local-credentials.php): failed to open stream: No such file or directoryPHP Warning: include_once(): Failed opening 'local-credentials.php' for inclusionPHP Fatal error: Uncaught Error: Call to undefined function localCredentials()If you see these errors, run ./prepare_dev_environment.sh && docker compose down && docker compose up --build again.
Undo merging a game listing into another one
https://github.com/iftechfoundation/ifdb/issues/1594
Labels: moderation tools
When you delete a comment, replies to it appear as top-level comments
https://github.com/iftechfoundation/ifdb/issues/1562
Labels: accurate data, needs discussion, reviews
Accessing viewgame?coverart&ldesc in development should not redirect to ifdb.org
https://github.com/iftechfoundation/ifdb/issues/1560
Labels: 없음
Searches negating an author id don't work
https://github.com/iftechfoundation/ifdb/issues/1555
Labels: 없음
Reject concurrent game edits instead of merging them
https://github.com/iftechfoundation/ifdb/issues/1552
Labels: accurate data, code cleanup
Preview user profile when making edits
https://github.com/iftechfoundation/ifdb/issues/1548
Labels: accurate data, profiles
When resetting passwords, we link to login and lostpass before the form
https://github.com/iftechfoundation/ifdb/issues/1534
Labels: 없음
Delete expired activationcode values
https://github.com/iftechfoundation/ifdb/issues/1531
Labels: 없음
Don't count author's rating in the game's average
https://github.com/iftechfoundation/ifdb/issues/1530
Labels: reviews
main branch. Please rebase your PRs and keep each commit small and focused. It's OK to have a big PR, as long as each commit in the PR is small, but smaller PRs are better, if feasible.test directory (npm test from test/, with local IFDB running). Please don't break the tests!