From 14658725b74f5d1f9ad904bb11b6cf8da60895e7 Mon Sep 17 00:00:00 2001 From: John Mertic Date: Fri, 25 Oct 2024 10:22:27 -0400 Subject: [PATCH] Move default to having `lfx_committee_url` in the front matter Signed-off-by: John Mertic --- README.md | 59 ++++++-------------------------------- _layouts/default.html | 26 ++++++++++------- _plugins/externaljson.rb | 26 +++++++++++++++++ cip-governing-board.md | 3 ++ openapi-governing-board.md | 4 +++ 5 files changed, 58 insertions(+), 60 deletions(-) create mode 100644 _plugins/externaljson.rb create mode 100644 cip-governing-board.md create mode 100644 openapi-governing-board.md diff --git a/README.md b/README.md index fb88eef..5d9ebb6 100644 --- a/README.md +++ b/README.md @@ -53,68 +53,27 @@ Issues and pull requests to fix issues or add new renders or filters are always ## Adding a committee -It's an easy two-step process to add a new committee. Add a pull request to commit to this repo to host the committee HTML code. - -### Entry in _config.yml - -First, edit [_config.yml](_config.yml) and add the following lines under `jekyll_get_json:` - -```yaml - - data: # project name and committee in Kebab case - json: 'https://api-gw.platform.linuxfoundation.org/project-service/v2/public/projects/PROJECT_ID/committees/COMMITTEE_ID/members' -``` -You can get the `PROJECT_ID` and `COMMITTEE_ID` from the URL of the committee page in the LFX Project Control Center; see the URL below: - -``` -https://projectadmin.lfx.linuxfoundation.org/project/a0941000002wBymAAE/collaboration/committees/1c29a7fe-0ff4-4728-a21d-561c6b1c7676 -``` -In this example, `PROJECT_ID` would be `a0941000002wBymAAE` and `COMMITTEE_ID` would be `1c29a7fe-0ff4-4728-a21d-561c6b1c7676` - -Example of an entry: - -```yaml - - data: open-mainframe-project-governing-board - json: 'https://api-gw.platform.linuxfoundation.org/project-service/v2/public/projects/a0941000002wBymAAE/committees/1c29a7fe-0ff4-4728-a21d-561c6b1c7676/members' -``` - -### New page - -The easiest way to add new pages is to use the file naming convention below to indicate the `data-source`, `render`, and `filter` as follows: - -``` -__.md -``` - -For example, to create a view for the `data` key in the `_config.yml` file for the render `olddata` and filter `staff`, the filename would be: - -``` -open-mainframe-project-governing-board_olddata_staff.md -``` - -The default render is `slidedeck,` and the filter is `voting`; if you don't specify those options, these will be the defaults. For example, if for the data source `open-mainframe-project-governing-board,` we want a Slidedeck view of voting members, you can name the file: - -``` -open-mainframe-project-governing-board.md -``` - -Alternatively, you can add Jekyll front matter keys to override the filename-derived values. +It's an easy one-step process to add a new committee. Add a pull request to commit to this repo to host the committee HTML code. +Add a new page in the root directory with the extention `.md` with the contents as below. ```markdown --- -data-source: open-mainframe-project-tac -render: newsite -filter: all +lfx_committee_url: +render: # optional, defaults to 'slidedeck' +filter: # optional, defaults to 'voting' --- ``` +If you need to add additional contents or CSS for rendering, you can do this after the front matter. + ## Hosting on the site For WordPress, you can remove the Persons block in the page editor and replace it with a 'Raw HTML' block with the contents as below: ```html -
+
``` -`DATA_NAME` matches the `data:` key in the entry in the `_config.yml` file. +`FILENAME` matches the filename of the file created, substituing `.md` with `.html`. diff --git a/_layouts/default.html b/_layouts/default.html index 1317b3a..4cfa3ff 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -4,9 +4,15 @@ {% assign filenameparts = page.name | replace: ".md", "" | replace: ".html", "" | split: "_" %} {% if page.data-source %} -{% assign data-source = page.data-source %} +{% assign data-source = site.data[page.data-source] %} +{% elsif page.lfx_committee_url %} +{% assign urlparts = page.lfx_committee_url | split: "/" %} +{% capture committee_json_url %}https://api-gw.platform.linuxfoundation.org/project-service/v2/public/projects/{{ urlparts[4] }}/committees/{{ urlparts[7] }}/members{% endcapture %} +{% externalJSON jsondata from url {{ committee_json_url }} %} +{% assign data-source = jsondata %} {% else %} -{% assign data-source = filenameparts[0] %} +{% assign filenamepart1 = filenameparts[0] %} +{% assign data-source = site.data[filenamepart1] %} {% endif %} {% if page.render %} @@ -27,28 +33,28 @@ {% case filter %} {% when "allbutstaff" %} - {% assign committee_members = site.data[data-source].Data | where_exp:"Item", "Item.Role != 'LF Staff'" %} + {% assign committee_members = data-source.Data | where_exp:"Item", "Item.Role != 'LF Staff'" %} {% when "all" %} - {% assign committee_members = site.data[data-source].Data %} + {% assign committee_members = data-source.Data %} {% when "alternates" %} - {% assign committee_members = site.data[data-source].Data | where:'VotingStatus', 'Alternate Voting Rep' %} + {% assign committee_members = data-source.Data | where:'VotingStatus', 'Alternate Voting Rep' %} {% when "voting-and-alternates" %} - {% assign committee_members = site.data[data-source].Data | where_exp:"Item", "Item.VotingStatus == 'Voting Rep' or Item.VotingStatus == 'Alternate Voting Rep'" %} + {% assign committee_members = data-source.Data | where_exp:"Item", "Item.VotingStatus == 'Voting Rep' or Item.VotingStatus == 'Alternate Voting Rep'" %} {% when "staff" %} - {% assign committee_members = site.data[data-source].Data | where:'Role', 'LF Staff' %} + {% assign committee_members = data-source.Data | where:'Role', 'LF Staff' %} {% when "voting" %} - {% assign committee_members = site.data[data-source].Data | where:'VotingStatus', 'Voting Rep' %} + {% assign committee_members = data-source.Data | where:'VotingStatus', 'Voting Rep' %} {% else %} - {% assign committee_members = site.data[data-source].Data | where:'VotingStatus', 'Voting Rep' %} + {% assign committee_members = data-source.Data | where:'VotingStatus', 'Voting Rep' %} {% endcase %} {% if jekyll.environment == "development" %}