Skip to content

Commit

Permalink
Preparing for when www goes to TheOrg for the team pages
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSeccubus committed Nov 23, 2022
1 parent 702e39f commit 4ebd435
Show file tree
Hide file tree
Showing 18 changed files with 117 additions and 38 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
Gemfile.lock
_site/
.env
_team/
_teams/
_people/
_reports/
www.divd.nl/
*.bak
Expand Down
8 changes: 4 additions & 4 deletions _layouts/case.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1>{{ page.title | escape }}</h1>
</tr><tr>
<td> Case lead </td><td>
{%- if team contains lead -%}
<a href='https://www.divd.nl/team/{{ lead | uri_escape }}/'>{{ lead }}</a>
<a href='https://www.divd.nl/people/{{ lead | uri_escape }}/'>{{ lead }}</a>
{%- else -%}
{{ lead }}
{%- endif -%}
Expand All @@ -28,7 +28,7 @@ <h1>{{ page.title | escape }}</h1>
{%- for author in page.author -%}
<li>
{%- if team contains author -%}
<a href='https://www.divd.nl/team/{{ author | uri_escape }}/'>{{ author }}</a>
<a href='https://www.divd.nl/people/{{ author | uri_escape }}/'>{{ author }}</a>
{%- else -%}
{{ author }}
{%- endif -%}
Expand All @@ -37,7 +37,7 @@ <h1>{{ page.title | escape }}</h1>
</ul>
{%- else -%}
{%- if team contains page.author -%}
<a href='https://www.divd.nl/team/{{ page.author | uri_escape }}/'>{{ page.author }}</a>
<a href='https://www.divd.nl/people/{{ page.author | uri_escape }}/'>{{ page.author }}</a>
{%- else -%}
{{ page.author }}
{%- endif -%}
Expand All @@ -53,7 +53,7 @@ <h1>{{ page.title | escape }}</h1>
{%- for r in page.researchers -%}
<li>
{%- if team contains r -%}
<a href='https://www.divd.nl/team/{{ r | uri_escape }}/'>{{ r }}</a>
<a href='https://www.divd.nl/people/{{ r | uri_escape }}/'>{{ r }}</a>
{%- else -%}
{{ r }}
{%- endif -%}
Expand Down
10 changes: 5 additions & 5 deletions _layouts/cve-json-40.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h1>{{ page.cve | escape }} - {{ page.title | escape }}</h1>
{% for r in page.discovered_by -%}
<li>
{% if team contains r %}
<a href='https://www.divd.nl/team/{{ r | uri_escape }}/'>{{ r }}</a>
<a href='https://www.divd.nl/people/{{ r | uri_escape }}/'>{{ r }}</a>
{% else %}
{{ r }}
{% endif %}
Expand All @@ -59,11 +59,11 @@ <h1>{{ page.cve | escape }} - {{ page.title | escape }}</h1>
{% assign line = r.value %}
{% for name in team %}
{% if name == line %}
{% capture line %}<a href='https://www.divd.nl/team/{{ line | uri_escape }}/'>{{ line }}</a>{% endcapture %}
{% capture line %}<a href='https://www.divd.nl/people/{{ line | uri_escape }}/'>{{ line }}</a>{% endcapture %}
{% else %}
{% if line contains name %}
{% capture linkleft %} <a href='https://www.divd.nl/team/{{ name | uri_escape }}/'>{{ name }}</a>{% endcapture %}
{% capture linkright %}<a href='https://www.divd.nl/team/{{ name | uri_escape }}/'>{{ name }}</a> {% endcapture %}
{% capture linkleft %} <a href='https://www.divd.nl/people/{{ name | uri_escape }}/'>{{ name }}</a>{% endcapture %}
{% capture linkright %}<a href='https://www.divd.nl/people/{{ name | uri_escape }}/'>{{ name }}</a> {% endcapture %}
{% capture nameleft %} {{ name }}{% endcapture %}
{% capture nameright %}{{ name }} {% endcapture %}
{% assign line = line | replace: nameleft, linkleft %}
Expand Down Expand Up @@ -138,7 +138,7 @@ <h1>{{ page.cve | escape }} - {{ page.title | escape }}</h1>
<td> Page author </td>
<td>
{% if team contains page.author %}
<a href='https://www.divd.nl/team/{{ page.author | uri_escape }}/'>{{ page.author }}</a>
<a href='https://www.divd.nl/people/{{ page.author | uri_escape }}/'>{{ page.author }}</a>
{% else %}
{{ page.author }}
{% endif %}
Expand Down
10 changes: 5 additions & 5 deletions _layouts/cve-json-50.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h1>{{ page.cve | escape }} - {{ page.title | escape }}</h1>
{% for r in page.discovered_by -%}
<li>
{% if team contains r %}
<a href='https://www.divd.nl/team/{{ r | uri_escape }}/'>{{ r }}</a>
<a href='https://www.divd.nl/people/{{ r | uri_escape }}/'>{{ r }}</a>
{% else %}
{{ r }}
{% endif %}
Expand All @@ -68,11 +68,11 @@ <h1>{{ page.cve | escape }} - {{ page.title | escape }}</h1>
{% assign line = r.value %}
{% for name in team %}
{% if name == line %}
{% capture line %}<a href='https://www.divd.nl/team/{{ line | uri_escape }}/'>{{ line }}</a>{% endcapture %}
{% capture line %}<a href='https://www.divd.nl/people/{{ line | uri_escape }}/'>{{ line }}</a>{% endcapture %}
{% else %}
{% if line contains name %}
{% capture linkleft %} <a href='https://www.divd.nl/team/{{ name | uri_escape }}/'>{{ name }}</a>{% endcapture %}
{% capture linkright %}<a href='https://www.divd.nl/team/{{ name | uri_escape }}/'>{{ name }}</a> {% endcapture %}
{% capture linkleft %} <a href='https://www.divd.nl/people/{{ name | uri_escape }}/'>{{ name }}</a>{% endcapture %}
{% capture linkright %}<a href='https://www.divd.nl/people/{{ name | uri_escape }}/'>{{ name }}</a> {% endcapture %}
{% capture nameleft %} {{ name }}{% endcapture %}
{% capture nameright %}{{ name }} {% endcapture %}
{% assign line = line | replace: nameleft, linkleft %}
Expand Down Expand Up @@ -193,7 +193,7 @@ <h1>{{ page.cve | escape }} - {{ page.title | escape }}</h1>
<td> Page author </td>
<td>
{% if team contains page.author %}
<a href='https://www.divd.nl/team/{{ page.author | uri_escape }}/'>{{ page.author }}</a>
<a href='https://www.divd.nl/people/{{ page.author | uri_escape }}/'>{{ page.author }}</a>
{% else %}
{{ page.author }}
{% endif %}
Expand Down
6 changes: 3 additions & 3 deletions _layouts/cve.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1>{{ page.cve | escape }} - {{ page.title | escape }}</h1>
{% for r in page.discovered_by -%}
<li>
{% if team contains r %}
<a href='https://www.divd.nl/team/{{ r | uri_escape }}/'>{{ r }}</a>
<a href='https://www.divd.nl/people/{{ r | uri_escape }}/'>{{ r }}</a>
{% else %}
{{ r }}
{% endif %}
Expand All @@ -34,7 +34,7 @@ <h1>{{ page.cve | escape }} - {{ page.title | escape }}</h1>
{% for r in page.researchers -%}
<li>
{% if team contains r %}
<a href='https://www.divd.nl/team/{{ r | uri_escape }}/'>{{ r }}</a>
<a href='https://www.divd.nl/people/{{ r | uri_escape }}/'>{{ r }}</a>
{% else %}
{{ r }}
{% endif %}
Expand Down Expand Up @@ -83,7 +83,7 @@ <h1>{{ page.cve | escape }} - {{ page.title | escape }}</h1>
<td> Page author </td>
<td>
{% if team contains page.author %}
<a href='https://www.divd.nl/team/{{ page.author | uri_escape }}/'>{{ page.author }}</a>
<a href='https://www.divd.nl/people/{{ page.author | uri_escape }}/'>{{ page.author }}</a>
{% else %}
{{ page.author }}
{% endif %}
Expand Down
Empty file added _layouts/person.html
Empty file.
4 changes: 2 additions & 2 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ <h1>{{ page.title }}</h1>
{% endif %}
{% assign page_author = a | default: "anonymous" %}
{% if team contains page_author %}
<a href='https://www.divd.nl/team/{{ page_author }}/'>{{ page_author }}</a>
<a href='https://www.divd.nl/people/{{ page_author | url_encode }}/'>{{ page_author }} </a>
{% else %}
{{ page_author }}
{% endif %}
{% endfor %}
{% else %}
{% assign page_author = page.author | default: "anonymous" %}
{% if team contains page_author %}
<a href='https://www.divd.nl/team/{{ page_author }}/'>{{ page_author }}</a>
<a href='https://www.divd.nl/people/{{ page_author | url_encode }}/'>{{ page_author }}</a>
{% else %}
{{ page_author }}
{% endif %}
Expand Down
Empty file added _teams/.keep
Empty file.
4 changes: 2 additions & 2 deletions blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ <h3>
,
{%- endif -%}
{%- if team contains post_author -%}
<a href='https://www.divd.nl/team/{{ post_author | uri_escape }}/'>{{ post_author }}</a>
<a href='https://www.divd.nl/people/{{ post_author | uri_escape }}/'>{{ post_author }}</a>
{%- else -%}
{{ post_author }}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- assign post_author = post.author | default: "anonymous" -%}
{%- if team contains post_author -%}
<a href='https://www.divd.nl/team/{{ post_author | uri_escape }}/'>{{ post_author }}</a>
<a href='https://www.divd.nl/people/{{ post_author | uri_escape }}/'>{{ post_author }}</a>
{%- else -%}
{{ post_author }}
{%- endif -%}
Expand Down
8 changes: 4 additions & 4 deletions cases.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ <h3><a href="{{ p.url }}">{{ p.title }}</a><em>
,
{%- endif -%}
{%- if team contains case_author -%}
<a href='https://www.divd.nl/team/{{ case_author | uri_escape }}'>{{ case_author }}</a>
<a href='https://www.divd.nl/people/{{ case_author | uri_escape }}'>{{ case_author }}</a>
{%- else -%}
{{ case_author }}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- assign case_author = p.author | default: "anonymous" -%}
{%- if team contains case_author -%}
<a href='https://www.divd.nl/team/{{ case_author | uri_escape }}'>{{ case_author }}</a>
<a href='https://www.divd.nl/people/{{ case_author | uri_escape }}'>{{ case_author }}</a>
{%- else -%}
{{ case_author }}
{%- endif -%}
Expand Down Expand Up @@ -91,15 +91,15 @@ <h3><a href="{{ p.url }}">{{ p.title }}</a><em>
,
{%- endif -%}
{%- if team contains case_author -%}
<a href='https://www.divd.nl/team/{{ case_author | uri_escape }}'>{{ case_author }}</a>
<a href='https://www.divd.nl/people/{{ case_author | uri_escape }}'>{{ case_author }}</a>
{%- else -%}
{{ case_author }}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- assign case_author = p.author | default: "anonymous" -%}
{%- if team contains case_author -%}
<a href='https://www.divd.nl/team/{{ case_author | uri_escape }}'>{{ case_author }}</a>
<a href='https://www.divd.nl/people/{{ case_author | uri_escape }}'>{{ case_author }}</a>
{%- else -%}
{{ case_author }}
{%- endif -%}
Expand Down
1 change: 0 additions & 1 deletion cves.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: CVEs
---
{% assign cvepages = site.cves |reverse %}
{% assign team = site.team | map: "name" %}
{% for p in cvepages %}
<div class="caseitem">
<h3><a href="{{ p.url }}">{{ p.cve | escape }} - {{ p.title | escape }}</a></h3>
Expand Down
1 change: 0 additions & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Last 10 posts ...

<ul>
{%- assign cases = site.cases |reverse -%}
{%- assign team = site.team | map: "name" -%}
{%- for p in cases -%}
{%- if p.status == "Open" -%}
<li>
Expand Down
6 changes: 0 additions & 6 deletions proof_html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ set -e # Need to fail on error

TIDY_OUT=/tmp/tidy_out.$$

TEAMCOUNT_HERE=$( ls _team|wc -l )
TEAMCOUNT_THERE=$( ls www.divd.nl/_team|wc -l )
if [[ $TEAMCOUNT_HERE -le 0 || $TEAMCOUNT_HERE -ne $TEAMCOUNT_THERE ]]; then
echo "_team directory is not updated, run ./update.sh"
exit 1
fi
echo "*** Internal link check ***"
export LANG=en_US.UTF-8
htmlproofer \
Expand Down
1 change: 1 addition & 0 deletions serve
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ docker run \
-ti mrseccubus/github-pages \
-c "
cd /root/project/;
pip install requests
if [[ -e Gemfile ]]; then
echo \"*** Installing Gems in Gemfile ***\"
bundle install
Expand Down
1 change: 1 addition & 0 deletions test_it.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ docker pull mrseccubus/github-pages:latest
docker run --volume="$PWD:/root/project:delegated" --entrypoint /bin/bash -ti mrseccubus/github-pages \
-c "
cd /root/project/;
pip install requests
if [[ -e Gemfile ]]; then
echo \"*** Installing Gems in Gemfile ***\"
bundle install
Expand Down
8 changes: 5 additions & 3 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ fi

echo "Updating team"
(
cd _team
rm -f *.html
cp ../www.divd.nl/_team/*.html .
cd _teams
rm -f *.md
cd ../_team
rm -f *.md
)
./update_org.py --team-path _teams --member-path _team

echo "Updating reports"
(
Expand Down
83 changes: 83 additions & 0 deletions update_org.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env python3

import json
import requests
import argparse

# Main

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Update team members and teams from theorg.com', allow_abbrev=False)
parser.add_argument('--member-path', type=str, metavar="<path to create team member md files>", default="", required=True, help="path of directory to create member md files")
parser.add_argument('--team-path', type=str, metavar="<path to create team md files>", default="", required=True, help="path of directory to create member md files")


args = parser.parse_args()

url = 'https://prod-graphql-api.theorg.com/graphql'
#payload = {'some': 'data'}
payload = {
"operationName": "teamsByCompany",
"variables": {
"companySlug": "dutch-institute-for-vulnerability-disclosure",
"membersLimit": 20,
"offset": 0,
"limit": 100
},
"query": 'query teamsByCompany($companySlug: String!, $limit: Int!, $offset: Int!, $membersLimit: Int!) {\n teamsByCompany(companySlug: $companySlug, limit: $limit, offset: $offset) {\n ...LightTeam\n __typename\n }\n}\n\nfragment LightTeam on Team {\n id\n slug\n name\n memberCount\n members(limit: $membersLimit) {\n ...LightPositionFragment\n __typename\n }\n __typename\n}\n\nfragment LightPositionFragment on LightPosition {\n id\n slug\n fullName\n profileImage {\n ...ImageFragment\n __typename\n }\n role\n parentPositionId\n isAdviser\n lastUpdate\n __typename\n}\n\nfragment ImageFragment on Image {\n endpoint\n ext\n placeholderDataUrl\n prevailingColor\n uri\n versions\n __typename\n}\n'
}
headers = {'content-type': 'application/json'}

r = requests.post(url, data=json.dumps(payload), headers=headers)
#r = requests.post(url, data=payload, headers=headers)

print("updating teams",end="")
for team in r.json()["data"]["teamsByCompany"] :
#print(json.dumps(team))
with open("{}/{}.md".format(args.team_path,team["slug"]), "w") as tfh :
tfh.write("---\n")
tfh.write("layout: team\n")
tfh.write("slug: {}\n".format(team["slug"]))
tfh.write("name: {}\n".format(team["name"]))
tfh.write("title: {}\n".format(team["name"]))
tfh.write("size: {}\n".format(team["memberCount"]))
tfh.write("members:\n")
for member in team["members"] :
tfh.write(" - {}\n".format(member["id"]))
tfh.write("---\n")
print(".",end="")
print("done")

payload = {
"operationName": "Company",
"variables": {
"slug": "dutch-institute-for-vulnerability-disclosure"
},
"query": "query Company($slug: String!) {\n company(slug: $slug) {\n ...FullCompany\n __typename\n }\n}\n\nfragment FullCompany on Company {\n id\n name\n slug\n extensions\n logoImage {\n ...ImageFragment\n __typename\n }\n social {\n ...CompanySocialFragment\n __typename\n }\n location {\n ...CompanyLocation\n __typename\n }\n description\n type\n industry\n status\n private\n teams {\n id\n __typename\n }\n meta {\n ...MetaFragment\n __typename\n }\n nodes {\n ...PositionNode\n __typename\n }\n stats {\n ...CompanyStats\n __typename\n }\n verification {\n verificationType\n __typename\n }\n adminLocked\n stage\n companyValues {\n ...CompanyValue\n __typename\n }\n imageGallery {\n ...ImageFragment\n __typename\n }\n testimonials {\n ...CompanyTestimonialConnection\n __typename\n }\n industries {\n ...CompanyIndustryFragment\n __typename\n }\n lastUpdate\n permissionSettings {\n companyId\n restrictMembersFromEditing\n __typename\n }\n __typename\n}\n\nfragment ImageFragment on Image {\n endpoint\n ext\n placeholderDataUrl\n prevailingColor\n uri\n versions\n __typename\n}\n\nfragment CompanySocialFragment on CompanySocial {\n twitterUrl\n linkedInUrl\n facebookUrl\n websiteUrl\n __typename\n}\n\nfragment CompanyLocation on CompanyLocation {\n id\n street\n postalCode\n city\n subLocality\n country\n countryIso\n state\n locationString\n isPrimary\n __typename\n}\n\nfragment MetaFragment on CompanyMeta {\n noIndex\n importanceScore\n tags\n __typename\n}\n\nfragment PositionNode on OrgChartStructureNode {\n id\n title\n leafMember {\n ...FlatPositionFragment\n __typename\n }\n containingNodeId\n node {\n ... on Vacant {\n job {\n id\n slug\n title\n location {\n city\n state\n country\n __typename\n }\n atsProvider {\n provider\n __typename\n }\n createdOn\n jobFunction\n remote\n manager {\n ... on ChartNodeGroup {\n positions {\n ... on PositionOrgChartPosition {\n positionId\n fullName\n profileImage {\n ...ImageFragment\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n ... on ChartNodeSingular {\n positionId\n position {\n ... on PositionOrgChartPosition {\n profileImage {\n ...ImageFragment\n __typename\n }\n fullName\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n order\n parentId\n section\n type\n __typename\n}\n\nfragment FlatPositionFragment on FlatPosition {\n id\n slug\n fullName\n role\n roleFunction\n roleAutoFunction\n description\n parentPositionId\n profileImage {\n ...ImageFragment\n __typename\n }\n social {\n ...UserSocialFragment\n __typename\n }\n isAdviser\n group {\n ...PositionGroupFragment\n __typename\n }\n companyStartDate {\n day\n month\n year\n __typename\n }\n roleStartDate {\n day\n month\n year\n __typename\n }\n location {\n ...CompanyLocation\n __typename\n }\n invitedAt\n remote\n lastUpdate\n pronoun\n invitedAt\n claimedBy\n __typename\n}\n\nfragment UserSocialFragment on UserSocial {\n twitterUrl\n linkedInUrl\n facebookUrl\n websiteUrl\n __typename\n}\n\nfragment PositionGroupFragment on PositionGroup {\n id\n name\n __typename\n}\n\nfragment CompanyStats on CompanyStats {\n tags\n employeeRange\n followerCount\n positionCount\n jobsCount\n teamsCount\n announcementsCount\n following\n promptDismissals\n latestFundingRound {\n id\n fundingType\n __typename\n }\n __typename\n}\n\nfragment CompanyValue on CompanyValue {\n id\n value\n description\n __typename\n}\n\nfragment CompanyTestimonialConnection on CompanyTestimonialConnection {\n testimonial {\n id\n question\n answer\n __typename\n }\n position {\n id\n slug\n fullName\n profileImage {\n ...ImageFragment\n __typename\n }\n role\n parentPositionId\n isAdviser\n lastUpdate\n __typename\n }\n __typename\n}\n\nfragment CompanyIndustryFragment on CompanyTag {\n id\n title\n __typename\n}\n"
}
r = requests.post(url, data=json.dumps(payload), headers=headers)

print("Updating people",end="")
for node in r.json()["data"]["company"]["nodes"] :
if node["leafMember"]["slug"] :
with open("{}/{}.md".format(args.member_path, node["leafMember"]["fullName"]), "w") as mfh :
mfh.write("---\n")
mfh.write("layout: person\n")
mfh.write("person_id: {}\n".format(node["leafMember"]["id"] or ""))
mfh.write("name: \"{}\"\n".format(node["leafMember"]["fullName"] or ""))
mfh.write("role: \"{}\"\n".format(node["leafMember"]["role"] or ""))
mfh.write("manager: {}\n".format(node["leafMember"]["parentPositionId"] or ""))
mfh.write("socials :\n")
for social in node["leafMember"]["social"] :
if not social.startswith("__"):
mfh.write(" {}: {}\n".format(social, node["leafMember"]["social"][social] or ""))
if "companyStartDate" in node["leafMember"] and node["leafMember"]["companyStartDate"] :
mfh.write("start: {:04d}-{:02d}-{:02d}\n".format(
node["leafMember"]["companyStartDate"]["year"],
node["leafMember"]["companyStartDate"]["month"],
node["leafMember"]["companyStartDate"]["day"])
)
mfh.write("---\n")
mfh.write("{}\n".format(node["leafMember"]["description"] or ""))
print(".",end="")
print("done")
Loading

0 comments on commit 4ebd435

Please sign in to comment.