{"id":19951260,"url":"https://github.com/torchbox/wagtail-footnotes","last_synced_at":"2025-05-03T18:33:55.033Z","repository":{"id":38743681,"uuid":"284717369","full_name":"torchbox/wagtail-footnotes","owner":"torchbox","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-22T10:27:48.000Z","size":81,"stargazers_count":18,"open_issues_count":20,"forks_count":19,"subscribers_count":16,"default_branch":"main","last_synced_at":"2024-04-14T06:23:29.381Z","etag":null,"topics":["django","hacktoberfest","rich-text","wagtail","wagtail-cms","wagtail-plugin"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/torchbox.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-08-03T14:09:11.000Z","updated_at":"2024-04-15T16:31:33.240Z","dependencies_parsed_at":"2024-04-15T16:31:30.135Z","dependency_job_id":"500b5a94-74a1-47c6-b546-c61b705c101b","html_url":"https://github.com/torchbox/wagtail-footnotes","commit_stats":{"total_commits":62,"total_committers":13,"mean_commits":4.769230769230769,"dds":0.3870967741935484,"last_synced_commit":"8531551726d820f709d0396d4bb09befa2f1e563"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torchbox%2Fwagtail-footnotes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torchbox%2Fwagtail-footnotes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torchbox%2Fwagtail-footnotes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torchbox%2Fwagtail-footnotes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/torchbox","download_url":"https://codeload.github.com/torchbox/wagtail-footnotes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224370068,"owners_count":17299969,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","hacktoberfest","rich-text","wagtail","wagtail-cms","wagtail-plugin"],"created_at":"2024-11-13T01:07:20.654Z","updated_at":"2025-05-03T18:33:55.020Z","avatar_url":"https://github.com/torchbox.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wagtail Footnotes\n\n[![PyPI](https://img.shields.io/pypi/v/wagtail-footnotes.svg)](https://pypi.org/project/wagtail-footnotes/)\n[![PyPI downloads](https://img.shields.io/pypi/dm/wagtail-footnotes.svg)](https://pypi.org/project/wagtail-footnotes/)\n[![Build Status](https://github.com/torchbox/wagtail-footnotes/workflows/CI/badge.svg)](https://github.com/torchbox/wagtail-footnotes/actions)\n\nAdd footnotes functionality to your Wagtail project.\n\n## ⚡ Quick start\n\nAdd `wagtail_footnotes` to `INSTALLED_APPS`:\n\n```python\n# settings.py\n\nINSTALLED_APPS = [\n    # ...\n    \"wagtail_footnotes\",\n    # ...\n]\n```\n\nAdd the footnotes `urls.py` to your project's `urls.py`:\n\n```python\n# urls.py\n# ...\nfrom wagtail_footnotes import urls as footnotes_urls\n\n\nurlpatterns = [\n    # ...\n    path(\"footnotes/\", include(footnotes_urls)),\n    # ...\n]\n```\n\n*Note*: The URL has to be defined as above as it is currently hardcoded in the JavaScript.\n\nUpdate your page models to show the footnotes panel:\n\n```python\nfrom wagtail.models import Page\nfrom wagtail.admin.panels import InlinePanel\n\n\nclass InformationPage(Page):\n    # ...\n    content_panels = [\n        # ...\n        InlinePanel(\"footnotes\", label=\"Footnotes\"),\n    ]\n```\n\nMake and run migrations:\n\n```shell\npython manage.py makemigrations\npython manage.py migrate\n```\n\n### Showing footnotes in page templates\n\nUpdate your page templates to include `{% include \"wagtail_footnotes/includes/footnotes.html\" %}`. You can copy from this template and instead include your own customized version.\n\n### Using footnotes in `RichTextField`\n\nUpdate any `RichTextField`s that you want to add footnotes feature.\nAdd `\"footnotes\"` to the `features` argument for each `RichTextField` that you want to have this functionality. For instance:\n\n```python\nclass InformationPage(Page):\n    body = RichTextField(\n        features=[\n            \"h1\",\n            \"h2\",\n            \"h3\",\n            \"h4\",\n            \"footnotes\",  # Make sure this line is part of the features\n        ],\n    )\n\n```\n\n[See Wagtail's documentation](https://docs.wagtail.org/en/stable/advanced_topics/customisation/page_editing_interface.html#limiting-features-in-a-rich-text-field) for a list of features that you may want to configure since we are overwriting the defaults.\n\n### Using footnotes in `StreamField`s\n\nIn order to have footnotes available in a `RichTextBlock`, you will need to change `RichTextBlock`s to `wagtail_footnotes.blocks.RichTextBlockWithFootnotes`. For instance:\n\n```python\nfrom wagtail_footnotes.blocks import RichTextBlockWithFootnotes\n# ...\n\nclass MyPage(Page):\n    body = StreamField(\n        [\n            # ...\n            (\"paragraph\", RichTextBlockWithFootnotes()),  # Using RichTextBlockWithFootnotes\n            # ...\n        ],\n    )\n```\n\n### Adding footnotes as a global default\n\nYou might want to simply have all RichText editors display footnotes. But remember that you will need the footnotes `InlinePanel` added\non all your Page models for the footnotes functionality to be enabled.\n\n```python\n# settings.py\n# ...\nWAGTAILADMIN_RICH_TEXT_EDITORS = {\n    \"default\": {\n        \"WIDGET\": \"wagtail.admin.rich_text.DraftailRichTextArea\",\n        \"OPTIONS\": {\"features\": [\"bold\", \"italic\", \"h3\", \"h4\", \"ol\", \"ul\", \"link\", \"footnotes\"]},\n    }\n}\n```\n\n## ⚙️ Settings\n\n- `WAGTAIL_FOOTNOTES_TEXT_FEATURES`\n  - Default: `[\"bold\", \"italic\", \"link\"]`\n  - Use this to update a list of Rich Text features allowed in the footnote text.\n\n- `WAGTAIL_FOOTNOTES_REFERENCE_TEMPLATE`\n  - Default: `\"wagtail_footnotes/includes/footnote_reference.html\"`\n  - Use this to set a template that renders footnote references. The template receives the footnote `index` in its context.\n\n## 🌍 Internationalisation\n\nWagtail Footnotes can be translated. Note that in a multi-lingual setup, the URL setup for footnotes\nneeds to be in a `i18n_patterns()` call with `prefix_default_language=False`:\n\n```python\n# urls.py\n\nurlpatterns += i18n_patterns(\n    path(\"footnotes/\", include(footnotes_urls)),\n    # ...\n    path(\"\", include(wagtail_urls)),\n    prefix_default_language=False,\n)\n```\n\nor outside `i18n_patterns()`:\n\n```python\n# urls.py\n\nurlpattherns += [\n    path(\"footnotes/\", include(footnotes_urls)),\n]\nurlpatterns += i18n_patterns(\n    # ...\n    path(\"\", include(wagtail_urls)),\n)\n```\n\n## 💡 Common issues\n\n- I click on the `Fn` button in the editor and it stops working\n  - This is likely because the URL in the JS does not match the URL of the footnotes view. Check the URL in `wagtail_footnotes/static/footnotes/js/footnotes.js` matches the URL you set.\n- `NoneType` error when rendering page.\n  - Make sure you are rendering the field in the template using `{% include_block page.field_name %}`\n\n## Contributing\n\nAll contributions are welcome!\n\n### Install\n\nTo make changes to this project, first clone this repository:\n\n```sh\ngit clone git@github.com:torchbox/wagtail-footnotes.git\ncd wagtail-footnotes\n```\n\nWith your preferred virtualenv activated, install testing dependencies:\n\n```shell\npython -m pip install -e '.[testing]' -U\n```\n\n### pre-commit\n\nNote that this project uses [pre-commit](https://github.com/pre-commit/pre-commit). To set up locally:\n\n```shell\n# set up your virtual environment of choice\n$ python -m pip install pre-commit\n# initialize pre-commit\n$ pre-commit install\n# Optional, run all checks once for this, then the checks will run only on the changed files\n$ pre-commit run --all-files\n```\n\n### How to run tests\n\nTo run all tests in all environments:\n\n```shell\ntox\n```\n\nTo run tests for a specific environment:\n\n```shell\ntox -e python3.12-django5.0-wagtail5.2\n```\n\nTo run a single test method in a specific environment:\n\n```shell\ntox -e python3.12-django5.0-wagtail5.2 -- tests.test.test_blocks.TestBlocks.test_block_with_features\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorchbox%2Fwagtail-footnotes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftorchbox%2Fwagtail-footnotes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorchbox%2Fwagtail-footnotes/lists"}