Skip to content

Commit

Permalink
Move default to having lfx_committee_url in the front matter
Browse files Browse the repository at this point in the history
Signed-off-by: John Mertic <jmertic@linuxfoundation.org>
  • Loading branch information
jmertic committed Oct 25, 2024
1 parent 1b1096f commit 1465872
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 60 deletions.
59 changes: 9 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```
<data-source>_<render>_<filter>.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: <url from LFX PCC Committee page - example https://projectadmin.lfx.linuxfoundation.org/project/a0941000002wBykAAE/collaboration/committees/40ab4fff-0c3b-4718-91e4-e76b2805f34c>
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
<div w3-include-html="https://jmertic.github.io/committee-gallery/DATA_NAME.html"></div>
<div w3-include-html="https://jmertic.github.io/committee-gallery/FILENAME.html"></div>
<script src="https://jmertic.github.io/committee-gallery/embed.js"></script>
```

`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`.
26 changes: 16 additions & 10 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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' %}
<style>
.committee_member-role { display: none !important; }
</style>
{% 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" %}
<!--
DEBUG:
data-source: {{ data-source }}
data-source: {{ data-source | inspect }}
render: {{ render }}
filter: {{ filter }}
Expand Down
26 changes: 26 additions & 0 deletions _plugins/externaljson.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'json'
require 'net/http'

module ExternalJSON
class ExternalJSON_tag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@text = text
end
def render(context)
if /(.+) from url (.+)/.match(@text)
url = context[$2] || $2
resp = Net::HTTP.get_response(URI(url.strip))
data = resp.body
context[$1] = JSON data
nil
else
# syntax error
raise ArgumentError, 'ERROR:bad_syntax'
end
end
end
end

Liquid::Template.register_tag('externalJSON', ExternalJSON::ExternalJSON_tag)

3 changes: 3 additions & 0 deletions cip-governing-board.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
lfx_committee_url: https://projectadmin.lfx.linuxfoundation.org/project/a0941000002wBz3AAE/collaboration/committees/146d2a4b-d39d-45e6-91a2-20937f4978cf
---
4 changes: 4 additions & 0 deletions openapi-governing-board.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
lfx_committee_url: https://projectadmin.lfx.linuxfoundation.org/project/a0941000002wBykAAE/collaboration/committees/40ab4fff-0c3b-4718-91e4-e76b2805f34c
---

0 comments on commit 1465872

Please sign in to comment.