Skip to content

Repository files navigation

Wikisource Viewer

A small local editor for projects following the wikisource-agent corpus layout. It keeps wikitext and facsimiles on your machine while using the project's configured MediaWiki API for read-only previews.

Licensed under the MIT License.

Wikisource Viewer showing the rendered page and its facsimile

Start

The default Compose configuration targets the sibling ../wikisource-agent project:

docker compose up --build

Open http://127.0.0.1:8080. To use another compatible project or port:

WIKISOURCE_PROJECT_PATH=/absolute/path/to/project \
WIKISOURCE_VIEWER_PORT=8081 \
docker compose up --build

Compose runs the application as UID/GID 1000:1000 so saved files belong to the local user. Override these when needed:

WIKISOURCE_VIEWER_UID="$(id -u)" \
WIKISOURCE_VIEWER_GID="$(id -g)" \
docker compose up --build

The project mount is read-only except for the nested pages/corrected mount. The viewer never authenticates with or writes to Wikisource.

Behavior

  • Previous, next, and direct view-number navigation follow facsimile/CORPUS_MANIFEST.json.
  • Existing pages/corrected/page-NNNN.txt files are edited as-is.
  • Missing corrected pages start as unsaved level-1 drafts seeded from the manifest's raw text file.
  • Save uses a content revision hash and refuses to overwrite a file changed by another tool after it was loaded.
  • Preview sends the current editor buffer to the configured MediaWiki parser. Successful renderings are cached in memory for 24 hours, with only the newest rendering retained for each of up to 256 pages. Page navigation uses the cache when the editor content is unchanged; Refresh preview bypasses and replaces it. Facsimiles and local editing continue to work when the network is unavailable.

Development

Install dependencies and run the test suite:

python3 -m pip install -r requirements-dev.txt
python3 -m unittest discover -s tests -v

Run the server directly against a project:

WIKISOURCE_PROJECT_ROOT=../wikisource-agent python3 app.py

Pull requests are checked automatically with the test suite and Python syntax validation in GitHub Actions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages