diff --git a/ISSUE_TEMPLATE/tools/test_feps.py b/ISSUE_TEMPLATE/tools/test_feps.py deleted file mode 100644 index 5347be0..0000000 --- a/ISSUE_TEMPLATE/tools/test_feps.py +++ /dev/null @@ -1,65 +0,0 @@ -import pytest -import glob -import hashlib - - -def get_fep_ids(): - for fep in glob.glob("fep/*"): - yield fep.removeprefix("fep/") - - -def parsefile(f): - lines = f.readlines() - - status = 0 - frontmatter = [] - content = [] - - for line in lines: - if line == "---\n": - status += 1 - elif status == 1: - frontmatter.append(line.removesuffix("\n")) - elif status >= 2: - content.append(line.removesuffix("\n")) - - return frontmatter, content - - -def parse_frontmatter(frontmatter): - split = [x.split(":", 1) for x in frontmatter] - return {a: b.removeprefix(" ") for a, b in split} - - -@pytest.mark.parametrize("fep", get_fep_ids()) -def test_fep(fep): - filename = f"fep/{fep}/fep-{fep}.md" - - with open(filename) as f: - frontmatter, content = parsefile(f) - - assert len(frontmatter) > 0 - assert len(content) > 0 - parsed_frontmatter = parse_frontmatter(frontmatter) - - assert "status" in parsed_frontmatter - assert parsed_frontmatter["status"] in ["DRAFT", "FINAL"] - assert parsed_frontmatter["slug"] == f'"{fep}"' - assert "authors" in parsed_frontmatter - - assert "## Summary" in content - assert "## Copyright" in content - - titles = [x for x in content if x.startswith("# ")] - assert len(titles) > 0 - - title = titles[0] - - begin_title = f"# FEP-{fep}: " - - assert title.startswith(begin_title) - true_title = title.removeprefix(begin_title) - - expected_slug = hashlib.sha256(true_title.encode("utf-8")).hexdigest()[:4] - - assert expected_slug == fep diff --git a/README.md b/README.md index 513e35d..9338a40 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,11 @@ The FEP Process is an initiative of the [SocialHub](https://socialhub.activitypu | Title | Status | Tracking issue | `dateReceived` | `dateFinalized` (or `dateWithdrawn`) | | --- | --- | ----- | ------- | ------ | -| [FEP-a4ed: The Fediverse Enhancement Proposal Process](./fep/a4ed/fep-a4ed.md) | `FINAL` | [#10](https://git.activitypub.dev/ActivityPubDev/Fediverse-Enhancement-Proposals/issues/10) | 2020-10-16 | 2020-01-18 | -| [FEP-8fcf: Followers collection synchronization across servers](./fep/8fcf/fep-8fcf.md) | `FINAL` | [#6](https://codeberg.org/fediverse/fep/issues/6) [#11](https://git.activitypub.dev/ActivityPubDev/Fediverse-Enhancement-Proposals/issues/11) | 2020-10-24 | 2022-02-07 | -| [FEP-f1d5: NodeInfo in Fediverse Software](./fep/f1d5/fep-f1d5.md) | `FINAL` | [#50](https://codeberg.org/fediverse/fep/issues/50) [#12](https://git.activitypub.dev/ActivityPubDev/Fediverse-Enhancement-Proposals/issues/12) | 2022-12-17 | 2023-06-02 | -| [FEP-400e: Publicly-appendable ActivityPub collections](./fep/400e/fep-400e.md) | `FINAL` | [#5](https://codeberg.org/fediverse/fep/issues/5) | 2021-02-16 | 2020-02-04 | -| [FEP-8c3f: Web Monetization](./fep/8c3f/fep-8c3f.md) | `DRAFT` | [#3](https://codeberg.org/fediverse/fep/issues/3) | 2022-01-18 | - | +| [FEP-a4ed: The Fediverse Enhancement Proposal Process](./fep/a4ed/fep-a4ed.md) | `FINAL` | [#10](https://git.activitypub.dev/ActivityPubDev/Fediverse-Enhancement-Proposals/issues/10) | 2020-10-16 | 2021-01-18 | +| [FEP-8fcf: Followers collection synchronization across servers](./fep/8fcf/fep-8fcf.md) | `FINAL` | [#6](https://codeberg.org/fediverse/fep/issues/6) [#11](https://git.activitypub.dev/ActivityPubDev/Fediverse-Enhancement-Proposals/issues/11) | 2020-10-24 | 2022-02-07 | +| [FEP-f1d5: NodeInfo in Fediverse Software](./fep/f1d5/fep-f1d5.md) | `FINAL` | [#50](https://codeberg.org/fediverse/fep/issues/50) [#12](https://git.activitypub.dev/ActivityPubDev/Fediverse-Enhancement-Proposals/issues/12) | 2020-12-13 | 2023-06-02 | +| [FEP-400e: Publicly-appendable ActivityPub collections](./fep/400e/fep-400e.md) | `FINAL` | [#5](https://codeberg.org/fediverse/fep/issues/5) | 2021-02-16 | 2022-02-04 | +| [FEP-8c3f: Web Monetization](./fep/8c3f/fep-8c3f.md) | `DRAFT` | [#3](https://codeberg.org/fediverse/fep/issues/3) | 2022-01-18 | - | | [FEP-2100: Unbound Group and Organization](./fep/2100/fep-2100.md) | `DRAFT` | [#36](https://codeberg.org/fediverse/fep/issues/36) | 2022-03-31 | - | | [FEP-e232: Object Links](./fep/e232/fep-e232.md) | `DRAFT` | [#14](https://codeberg.org/fediverse/fep/issues/14) | 2022-08-01 | - | | [FEP-5624: Per-object reply control policies](./fep/5624/fep-5624.md) | `DRAFT` | [#18](https://codeberg.org/fediverse/fep/issues/18) | 2022-08-23 | - | @@ -32,7 +32,7 @@ The FEP Process is an initiative of the [SocialHub](https://socialhub.activitypu | [FEP-7888: Demystifying the context property](./fep/7888/fep-7888.md) | `DRAFT` | [#68](https://codeberg.org/fediverse/fep/issues/68) | 2023-03-14 | - | | [FEP-d767: Extend ActivityPub with Valueflows](./fep/d767/fep-d767.md) | `DRAFT` | [#76](https://codeberg.org/fediverse/fep/issues/76) | 2023-04-02 | - | | [FEP-5bf0: Collection sorting and filtering](./fep/5bf0/fep-5bf0.md) | `DRAFT` | [#80](https://codeberg.org/fediverse/fep/issues/80) | 2023-04-10 | - | -| [FEP-888d: Using https://w3id.org/fep as a base for FEP-specific namespaces](./fep/888d/fep-888d.md) | `DRAFT` | [#83](https://codeberg.org/fediverse/fep/issues/83) | 2023-04-11 | - | +| [FEP-888d: Using https://w3id.org/fep as a base for FEP-specific namespaces](./fep/888d/fep-888d.md) | `DRAFT` | [#83](https://codeberg.org/fediverse/fep/issues/83) | 2023-04-10 | - | | [FEP-0ea0: Payment Links](./fep/0ea0/fep-0ea0.md) | `DRAFT` | [#88](https://codeberg.org/fediverse/fep/issues/88) | 2023-04-18 | - | | [FEP-612d: Identifying ActivityPub Objects through DNS](./fep/612d/fep-612d.md) | `DRAFT` | [#89](https://codeberg.org/fediverse/fep/issues/89) | 2023-04-18 | - | | [FEP-fffd: Proxy Objects](./fep/fffd/fep-fffd.md) | `DRAFT` | [#95](https://codeberg.org/fediverse/fep/issues/95) | 2023-04-29 | - | diff --git a/fep/1b12/fep-1b12.md b/fep/1b12/fep-1b12.md index 703024f..33e0846 100644 --- a/fep/1b12/fep-1b12.md +++ b/fep/1b12/fep-1b12.md @@ -4,6 +4,7 @@ authors: Felix Ableitner status: FINAL dateReceived: 2022-11-12 dateFinalized: 2023-02-09 +discussionsTo: https://codeberg.org/fediverse/fep/issues/22 --- # FEP-1b12: Group federation diff --git a/fep/2100/fep-2100.md b/fep/2100/fep-2100.md index 5222ad0..e0056ff 100644 --- a/fep/2100/fep-2100.md +++ b/fep/2100/fep-2100.md @@ -3,6 +3,7 @@ slug: "2100" authors: Diogo Peralta Cordeiro status: DRAFT dateReceived: 2022-03-31 +discussionsTo: https://codeberg.org/fediverse/fep/issues/36 --- # FEP-2100: Unbound Group and Organization diff --git a/fep/2e40/fep-2e40.md b/fep/2e40/fep-2e40.md index d8b2423..c6c6d5b 100644 --- a/fep/2e40/fep-2e40.md +++ b/fep/2e40/fep-2e40.md @@ -3,6 +3,7 @@ slug: "2e40" authors: Helge Krueger status: DRAFT dateReceived: 2023-02-13 +discussionsTo: https://codeberg.org/fediverse/fep/issues/62 --- # FEP-2e40: The FEP Vocabulary Extension Process diff --git a/fep/400e/fep-400e.md b/fep/400e/fep-400e.md index f1801e2..1e80f67 100644 --- a/fep/400e/fep-400e.md +++ b/fep/400e/fep-400e.md @@ -4,6 +4,7 @@ authors: Gregory Klyushnikov status: FINAL dateReceived: 2021-02-16 dateFinalized: 2022-02-04 +discussionsTo: https://codeberg.org/fediverse/fep/issues/5 --- # FEP-400e: Publicly-appendable ActivityPub collections diff --git a/fep/4adb/fep-4adb.md b/fep/4adb/fep-4adb.md index 89fc266..3ff2290 100644 --- a/fep/4adb/fep-4adb.md +++ b/fep/4adb/fep-4adb.md @@ -3,6 +3,7 @@ slug: "4adb" authors: Helge status: DRAFT dateReceived: 2023-05-13 +discussionsTo: https://codeberg.org/fediverse/fep/issues/100 --- # FEP-4adb: Dereferencing identifiers with webfinger diff --git a/fep/5624/fep-5624.md b/fep/5624/fep-5624.md index d1da00a..78769ad 100644 --- a/fep/5624/fep-5624.md +++ b/fep/5624/fep-5624.md @@ -3,6 +3,7 @@ slug: "5624" authors: Claire status: DRAFT dateReceived: 2022-08-23 +discussionsTo: https://codeberg.org/fediverse/fep/issues/18 --- # FEP-5624: Per-object reply control policies diff --git a/fep/5bf0/fep-5bf0.md b/fep/5bf0/fep-5bf0.md index 774164c..d085de6 100644 --- a/fep/5bf0/fep-5bf0.md +++ b/fep/5bf0/fep-5bf0.md @@ -3,6 +3,7 @@ slug: "5bf0" authors: Michael Puckett status: DRAFT dateReceived: 2023-04-10 +discussionsTo: https://codeberg.org/fediverse/fep/issues/80 --- # FEP-5bf0: Collection sorting and filtering diff --git a/fep/612d/fep-612d.md b/fep/612d/fep-612d.md index 8a3f562..50d6e3d 100644 --- a/fep/612d/fep-612d.md +++ b/fep/612d/fep-612d.md @@ -3,6 +3,7 @@ slug: "612d" authors: Helge status: DRAFT dateReceived: 2023-04-18 +discussionsTo: https://codeberg.org/fediverse/fep/issues/89 --- # FEP-612d: Identifying ActivityPub Objects through DNS diff --git a/fep/7888/fep-7888.md b/fep/7888/fep-7888.md index 3ae8cb0..1124de3 100644 --- a/fep/7888/fep-7888.md +++ b/fep/7888/fep-7888.md @@ -3,6 +3,7 @@ slug: "7888" authors: a status: DRAFT dateReceived: 2023-03-14 +discussionsTo: https://codeberg.org/fediverse/fep/issues/68 --- # FEP-7888: Demystifying the context property diff --git a/fep/888d/fep-888d.md b/fep/888d/fep-888d.md index 75dc343..a76daca 100644 --- a/fep/888d/fep-888d.md +++ b/fep/888d/fep-888d.md @@ -3,6 +3,7 @@ slug: "888d" authors: a status: DRAFT dateReceived: 2023-04-10 +discussionsTo: https://codeberg.org/fediverse/fep/issues/83 --- # FEP-888d: Using https://w3id.org/fep as a base for FEP-specific namespaces diff --git a/fep/8c3f/fep-8c3f.md b/fep/8c3f/fep-8c3f.md index 68dcf2e..1ac6f3e 100644 --- a/fep/8c3f/fep-8c3f.md +++ b/fep/8c3f/fep-8c3f.md @@ -3,6 +3,7 @@ slug: "8c3f" authors: Diogo Peralta Cordeiro , Phablulo Joel status: DRAFT dateReceived: 2022-01-18 +discussionsTo: https://codeberg.org/fediverse/fep/issues/3 --- # FEP-8c3f: Web Monetization diff --git a/fep/8fcf/fep-8fcf.md b/fep/8fcf/fep-8fcf.md index 98d4e61..deda274 100644 --- a/fep/8fcf/fep-8fcf.md +++ b/fep/8fcf/fep-8fcf.md @@ -4,6 +4,7 @@ authors: Claire status: FINAL dateReceived: 2020-10-24 dateFinalized: 2022-02-07 +discussionsTo: https://codeberg.org/fediverse/fep/issues/6, https://git.activitypub.dev/ActivityPubDev/Fediverse-Enhancement-Proposals/issues/11 --- # FEP-8fcf: Followers collection synchronization across servers diff --git a/fep/a4ed/fep-a4ed.md b/fep/a4ed/fep-a4ed.md index 80f4126..af3d6c3 100644 --- a/fep/a4ed/fep-a4ed.md +++ b/fep/a4ed/fep-a4ed.md @@ -4,6 +4,7 @@ authors: pukkamustard status: FINAL dateReceived: 2020-10-16 dateFinalized: 2021-01-18 +discussionsTo: https://git.activitypub.dev/ActivityPubDev/Fediverse-Enhancement-Proposals/issues/10 --- # FEP-a4ed: The Fediverse Enhancement Proposal Process diff --git a/fep/c118/fep-c118.md b/fep/c118/fep-c118.md index c1cfa5c..cff8580 100644 --- a/fep/c118/fep-c118.md +++ b/fep/c118/fep-c118.md @@ -3,6 +3,7 @@ slug: "c118" authors: Tim Bray status: DRAFT dateReceived: 2023-01-16 +discussionsTo: https://codeberg.org/fediverse/fep/issues/57 --- # FEP-c118: Content licensing support diff --git a/fep/cb76/fep-cb76.md b/fep/cb76/fep-cb76.md index 85f3f66..32810b0 100644 --- a/fep/cb76/fep-cb76.md +++ b/fep/cb76/fep-cb76.md @@ -3,6 +3,7 @@ slug: "cb76" authors: a status: DRAFT dateReceived: 2022-11-29 +discussionsTo: https://codeberg.org/fediverse/fep/issues/41 --- # FEP-cb76: Content Addressed Vocabulary diff --git a/fep/d767/fep-d767.md b/fep/d767/fep-d767.md index 411c940..44d7ee6 100644 --- a/fep/d767/fep-d767.md +++ b/fep/d767/fep-d767.md @@ -3,6 +3,7 @@ slug: "d767" authors: Lynn Foster status: DRAFT dateReceived: 2023-04-02 +discussionsTo: https://codeberg.org/fediverse/fep/issues/76 --- # FEP-d767: Extend ActivityPub with Valueflows diff --git a/fep/f1d5/fep-f1d5.md b/fep/f1d5/fep-f1d5.md index 2d8d5f5..b30bc48 100644 --- a/fep/f1d5/fep-f1d5.md +++ b/fep/f1d5/fep-f1d5.md @@ -3,7 +3,8 @@ slug: "f1d5" authors: CJ , silverpill status: FINAL dateReceived: 2020-12-13 -discussionsTo: https://codeberg.org/fediverse/fep/issues/50 +dateFinalized: 2023-06-02 +discussionsTo: https://codeberg.org/fediverse/fep/issues/50, https://git.activitypub.dev/ActivityPubDev/Fediverse-Enhancement-Proposals/issues/12 --- # FEP-f1d5: NodeInfo in Fediverse Software diff --git a/fep/fb2a/fep-fb2a.md b/fep/fb2a/fep-fb2a.md index 38c6f30..9b4acf6 100644 --- a/fep/fb2a/fep-fb2a.md +++ b/fep/fb2a/fep-fb2a.md @@ -3,6 +3,7 @@ slug: "fb2a" authors: a status: DRAFT dateReceived: 2022-12-09 +discussionsTo: https://codeberg.org/fediverse/fep/issues/45 --- # FEP-fb2a: Actor metadata diff --git a/fep/fffd/fep-fffd.md b/fep/fffd/fep-fffd.md index b50f461..d2947be 100644 --- a/fep/fffd/fep-fffd.md +++ b/fep/fffd/fep-fffd.md @@ -3,6 +3,7 @@ slug: "fffd" authors: Adam R. Nelson status: DRAFT dateReceived: 2023-04-29 +discussionsTo: https://codeberg.org/fediverse/fep/issues/95 --- # FEP-fffd: Proxy Objects diff --git a/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 0000000..d344ba6 --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1 @@ +config.json diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..68dcd26 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,63 @@ +# tools for fep editors + +Please follow the steps in configuration before following "Merge a FEP". + +## Merge a FEP + +Merge the Pull Request in [https://codeberg.org/fediverse/fep/pulls](https://codeberg.org/fediverse/fep/pulls) +and note the slug. + +```bash +python scripts/create_issue.py $SLUG +``` + +creates the tracking issue and updates the fep with the information. +This script prints the issue url, you will need it later to add the +link to the SocialHub discussion. Then run + +```bash +python scripts/create_readme.py +``` + +to update the table in `README.md`. You are now ready to commit the +changes to the FEP (added discussionsTo to frontmatter) and README.md, +added the new FEP. + +Run + +```bash +python scripts/create_topic.py $SLUG +``` + +and following the instructions to create a topic on SocialHub to discuss +the FEP. + +Finally, add the link to the SocialHub issue to the tracking issue, created above. + +## Configuration + +Add a file `config.json` to the directory `scripts` with content + +```json +{ + "repo": "fep", + "owner": "fediverse", + "token": "CODEBERG_API_TOKEN" +} +``` + +The API token can be obtained by visiting [https://codeberg.org/user/settings/applications](https://codeberg.org/user/settings/applications) and generating one with scope "public_repo". + +## Setup for running pytest + +Ensure dependencies (use a virtualenv) + +```bash +pip install pytest +``` + +Check validity + +```bash +pytest +``` diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/backmatter.md b/scripts/backmatter.md new file mode 100644 index 0000000..ffb10f1 --- /dev/null +++ b/scripts/backmatter.md @@ -0,0 +1,36 @@ + +## Submitting a FEP + +Do you have an idea, opinion or information that you want to share with the wider Fediverse community? You may do so with a Fediverse Enhancement Proposal (FEP). + +To create and submit a FEP: + +1. Fork this repository, and then clone it to your local machine. Check the Codeberg [Cheat sheet](https://docs.codeberg.org/collaborating/pull-requests-and-git-flow/#cheat-sheet) on how to prepare your Pull Request. +2. Think of a title for the FEP you want to submit. +3. Compute the identifier of the FEP by computing the hash of the title. This can be done with following Unix command: +``` +$ echo -n "The title of my proposal" | sha256sum | cut -c-4 +b3f0 +``` +4. Create a subdirectory of `fep/`(fep/) using the identifier you just computed. +5. Copy the FEP template ([fep-xxxx-template.md](./fep-xxxx-template.md)) to this subdirectory and change the filename appropriately. +6. Use the identifer as the "slug" when filling out the frontmatter. + + - For example, if your computed identifier was `abcd`, then your file would be located at `fep/abcd/fep-abcd.md` and your frontmatter would include `slug: "abcd"`. + +7. Write down your idea in the newly created file and commit it to a new branch in your repository (ex. fep-xxxx). +8. Create a Pull Request to complete Step 1 of [FEP-a4ed: The Fediverse Enhancement Proposal Process](./feps/fep-a4ed.md). Further process is described in FEP-a4ed. + +## Editors + +The list of FEP's is facilitated by Editors who are listed in the [EDITORS.md](EDITORS.md) file. Editors are neutral custodians of the FEP process, who merge PR's, create tracking issues, and start discussion threads for each FEP in the [SocialHub](https://socialhub.activitypub.rocks) developer community forum. + +## Contributing + +Do you have ideas to improve the FEP Process? Post your suggestions to the issue tracker, or on the SocialHub forum. The SocialHub developer community is a "DoOcracy" which means: “pick up any task you want, and then steer it to completion”. Your contributions are most welcome, so delve in and find out how you can help. + +## License + +CC0 1.0 Universal (CC0 1.0) Public Domain Dedication + +To the extent possible under law, the authors of this document have waived all copyright and related or neighboring rights to this work. diff --git a/scripts/create_issue.py b/scripts/create_issue.py new file mode 100644 index 0000000..1a65a39 --- /dev/null +++ b/scripts/create_issue.py @@ -0,0 +1,56 @@ +from argparse import ArgumentParser +from datetime import date, timedelta +from tools import FepFile + +import json +from urllib.request import Request, urlopen + +parser = ArgumentParser("Create tracking issue for FEP") +parser.add_argument("fep", help="slug of the FEP") +args = parser.parse_args() + +fep_file = FepFile(args.fep) + +if "discussionsTo" in fep_file.parsed_frontmatter: + print("File already has discussionsTo") + exit(1) + +title = f"[TRACKING] FEP-{args.fep}: {fep_file.title}" + +date_received = date.fromisoformat(fep_file.parsed_frontmatter["dateReceived"]) + +date1 = date_received.isoformat() +date2 = (date_received + timedelta(days=365)).isoformat() + +body = f""" +The [proposal](https://codeberg.org/fediverse/fep/src/branch/main/{fep_file.filename}) has been received. Thank you! + +This issue tracks discussions and updates to the proposal during the `DRAFT` period. + +Please post links to relevant discussions as comment to this issue. + +`dateReceived`: {date1} + +If no further actions are taken, the proposal may be set by editors to `WITHDRAWN` on {date2} (in 1 year). +""" + +with open("scripts/config.json") as f: + config = json.load(f) + +request = Request( + f"https://codeberg.org/api/v1/repos/{config['owner']}/{config['repo']}/issues" +) +request.add_header("Content-Type", "application/json; charset=utf-8") +request_body = json.dumps({"title": title, "body": body}).encode("utf-8") +request.add_header("authorization", f"Bearer {config['token']}") +request.add_header("Content-Length", len(request_body)) +request.data = request_body +response = urlopen(request) + + +issue_url = json.loads(response.read())["html_url"] + +fep_file.frontmatter.append(f"discussionsTo: {issue_url}") +fep_file.write() + +print(f"Issue url: {issue_url}") diff --git a/scripts/create_readme.py b/scripts/create_readme.py new file mode 100644 index 0000000..e625757 --- /dev/null +++ b/scripts/create_readme.py @@ -0,0 +1,45 @@ +from tools import FepFile, get_fep_ids + +fep_files = [FepFile(fep) for fep in get_fep_ids()] +fep_files = reversed(fep_files) +fep_files = sorted(fep_files, key=lambda x: x.parsed_frontmatter["dateReceived"]) + +result = [] + + +def build_url_link(url): + url_number = url.split("/")[-1] + return f"[#{url_number}]({url})" + + +for fep in fep_files: + link = f"[FEP-{fep.fep}: {fep.title}](./{fep.filename})" + parsed = fep.parsed_frontmatter + + if "discussionsTo" in parsed: + url = parsed["discussionsTo"] + urls = url.split(", ") + discussions = " ".join(build_url_link(url) for url in urls) + else: + discussions = "" + + if "dateFinalized" in parsed: + date_final = parsed["dateFinalized"] + else: + date_final = "-" + result.append( + f"""| {link} | `{parsed["status"]}` | {discussions} | {parsed["dateReceived"]} | {date_final} |\n""" + ) + + +# | [FEP-a4ed: The Fediverse Enhancement Proposal Process](./fep/a4ed/fep-a4ed.md) | `FINAL` | [#10](https://git.activitypub.dev/ActivityPubDev/Fediverse-Enhancement-Proposals/issues/10) | 2020-10-16 | 2020-01-18 + + +with open("README.md", "w") as f1: + with open("scripts/frontmatter.md") as f: + f1.write(f.read().removesuffix("\n")) + + f1.writelines(result) + + with open("scripts/backmatter.md") as f: + f1.write(f.read()) diff --git a/scripts/create_topic.py b/scripts/create_topic.py new file mode 100644 index 0000000..245b38c --- /dev/null +++ b/scripts/create_topic.py @@ -0,0 +1,36 @@ +from argparse import ArgumentParser +from tools import FepFile + +parser = ArgumentParser("Create topic for FEP") +parser.add_argument("fep", help="slug of the FEP") +args = parser.parse_args() + +fep_file = FepFile(args.fep) + +fep_file.write() + +url = f"https://codeberg.org/fediverse/fep/src/branch/main/fep/{args.fep}/fep-{args.fep}.md" + + +body = f""" +Hello! + +This is a discussion thread for the proposed [FEP-{args.fep}: {fep_file.title}]({url}). +Please use this thread to discuss the proposed FEP and any potential problems +or improvements that can be addressed. + +__Summary__ + +{fep_file.summary} +""" + +print("Create a new topic on https://socialhub.activitypub.rocks/c/standards/fep/54") +print("with title") +print(f" FEP-{args.fep}: {fep_file.title}") +print("and tags") +print(f" fep, fep-{args.fep}, draft") +print("and body") +print(body) +print("") +discussionsTo = fep_file.parsed_frontmatter["discussionsTo"] +print(f"After creating the issue add a link to the tracking issue {discussionsTo}") diff --git a/scripts/frontmatter.md b/scripts/frontmatter.md new file mode 100644 index 0000000..2578f1b --- /dev/null +++ b/scripts/frontmatter.md @@ -0,0 +1,17 @@ +# Fediverse Enhancement Proposals + + + +This is the Git repository containing Fediverse Enhancment Proposals (FEPs). + +A Fediverse Enhancement Proposal (FEP) is a document that provides information to the Fediverse community. The goal of a FEP is to improve interoperability and well-being of diverse services, applications and communities that form the Fediverse. + +The FEP Process is an initiative of the [SocialHub](https://socialhub.activitypub.rocks) developer community, a liaison of the [W3C Social Web Incubator Community Group](https://www.w3.org/community/SocialCG/). For ongoing and past discussion see the [SocialHub FEP category](https://socialhub.activitypub.rocks/c/standards/fep/54). + +## FEPs + + + +| Title | Status | Tracking issue | `dateReceived` | `dateFinalized` (or `dateWithdrawn`) | +| --- | --- | ----- | ------- | ------ | + diff --git a/scripts/pull_request.py b/scripts/pull_request.py new file mode 100644 index 0000000..d6da146 --- /dev/null +++ b/scripts/pull_request.py @@ -0,0 +1,27 @@ +from argparse import ArgumentParser +from datetime import date, timedelta +from tools import FepFile + + +import json +import requests + +parser = ArgumentParser("Pullrequest") +parser.add_argument("pr", help="Pull request id") +args = parser.parse_args() + +with open("ISSUE_TEMPLATE/config.json") as f: + config = json.load(f) +print( + f"https://codeberg.org/api/v1/repos/{config['owner']}/{config['repo']}/pulls/{args.pr}" +) +response = requests.get( + f"https://codeberg.org/api/v1/repos/{config['owner']}/{config['repo']}/pulls/{args.pr}", + headers={"authorization": f"Bearer {config['token']}"}, +) + +print(response) +print(response.text) + + +print(json.dumps(response.json(), indent=2)) diff --git a/scripts/tools/__init__.py b/scripts/tools/__init__.py new file mode 100644 index 0000000..223c117 --- /dev/null +++ b/scripts/tools/__init__.py @@ -0,0 +1,75 @@ +import glob + + +def get_fep_ids(): + for fep in glob.glob("fep/*"): + yield fep.removeprefix("fep/") + + +class FepFile: + def __init__(self, fep): + self.fep = fep + with open(self.filename) as f: + self.frontmatter, self.content = FepFile.parsefile(f) + + @property + def filename(self): + return f"fep/{self.fep}/fep-{self.fep}.md" + + @property + def summary(self): + result = [] + is_summary = False + for x in self.content: + if is_summary: + if x.startswith("##"): + return "\n".join(result) + result.append(x) + elif x == "## Summary": + is_summary = True + + def write(self): + with open(self.filename, "w") as f: + f.write("---\n") + for x in self.frontmatter: + f.write(x + "\n") + f.write("---\n") + for x in self.content: + f.write(x + "\n") + + @property + def parsed_frontmatter(self): + split = [x.split(":", 1) for x in self.frontmatter] + return {a: b.strip() for a, b in split} + + @property + def title(self): + titles = [x for x in self.content if x.startswith("# ")] + assert len(titles) > 0 + + title = titles[0] + + begin_title = f"# FEP-{self.fep}: " + + assert title.startswith(begin_title) + true_title = title.removeprefix(begin_title) + + return true_title + + @staticmethod + def parsefile(f): + lines = f.readlines() + + status = 0 + frontmatter = [] + content = [] + + for line in lines: + if line == "---\n" and status <= 2: + status += 1 + elif status == 1: + frontmatter.append(line.removesuffix("\n")) + elif status >= 2: + content.append(line.removesuffix("\n")) + + return frontmatter, content diff --git a/scripts/tools/test_feps.py b/scripts/tools/test_feps.py new file mode 100644 index 0000000..ab916dd --- /dev/null +++ b/scripts/tools/test_feps.py @@ -0,0 +1,34 @@ +import pytest +import hashlib + +from scripts.tools import get_fep_ids, FepFile + + +@pytest.mark.parametrize("fep", get_fep_ids()) +def test_fep(fep): + fep_file = FepFile(fep) + + content = fep_file.content + parsed_frontmatter = fep_file.parsed_frontmatter + + assert "status" in parsed_frontmatter + assert parsed_frontmatter["status"] in ["DRAFT", "FINAL"] + assert parsed_frontmatter["slug"] == f'"{fep}"' + assert "authors" in parsed_frontmatter + + assert "## Summary" in content + assert "## Copyright" in content + + titles = [x for x in content if x.startswith("# ")] + assert len(titles) > 0 + + title = titles[0] + + begin_title = f"# FEP-{fep}: " + + assert title.startswith(begin_title) + true_title = title.removeprefix(begin_title) + + expected_slug = hashlib.sha256(true_title.encode("utf-8")).hexdigest()[:4] + + assert expected_slug == fep diff --git a/ISSUE_TEMPLATE/tracking_issue.md b/scripts/tracking_issue.md similarity index 100% rename from ISSUE_TEMPLATE/tracking_issue.md rename to scripts/tracking_issue.md