Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RFC overview page #975

Merged
merged 4 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
include:
- stage: Prepare XEP list
script: python3 ./tools/prepare_xep_list.py
- stage: Prepare RFC list
script: python3 ./tools/prepare_rfc_list.py
- stage: Software list linting
script: python3 ./tools/lint-list.py clients.json && python3 ./tools/lint-list.py servers.json && python3 ./tools/lint-list.py libraries.json
- stage: Generate pages
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,19 @@ clean:

serve:
$(PY) $(TOOLSDIR)/prepare_xep_list.py
$(PY) $(TOOLSDIR)/prepare_rfc_list.py
$(HUGO) version
$(HUGO) server --bind=0.0.0.0 --baseURL="http://localhost/"

prepare_docker:
$(PY) $(TOOLSDIR)/prepare_xep_list.py
$(PY) $(TOOLSDIR)/prepare_rfc_list.py
$(HUGO) version
$(HUGO) --baseURL="http://localhost/"

publish:
$(PY) $(TOOLSDIR)/prepare_xep_list.py
$(PY) $(TOOLSDIR)/prepare_rfc_list.py
$(PY) $(TOOLSDIR)/lint-list.py clients.json
$(PY) $(TOOLSDIR)/lint-list.py servers.json
$(PY) $(TOOLSDIR)/lint-list.py libraries.json
Expand Down
1 change: 1 addition & 0 deletions content/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ aliases:
- [RFC 7622](https://datatracker.ietf.org/doc/rfc7622/) XMPP Address Format
- [RFC 7590](https://datatracker.ietf.org/doc/rfc7590/) Use of TLS in XMPP
- [RFC 7395](https://datatracker.ietf.org/doc/rfc7395/) XMPP over WebSockets
- [View all XMPP RFCs](/rfcs)

{{< /col >}}

Expand Down
9 changes: 9 additions & 0 deletions content/rfcs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: XMPP RFCs
layout: "extensions"
---
The core specifications for XMPP are developed at the [Internet Engineering Task Force (IETF)](https://ietf.org). The XMPP Standards Foundation develops extensions to XMPP in its [XEP series](/extensions).

Good places for developers to start are the [compliance suites](https://xmpp.org/about/compliance-suites-current), as well as the [technology overview pages](https://xmpp.org/about-xmpp/technology-overview/).

{{< rfc-list >}}
1 change: 1 addition & 0 deletions data/rfc_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
59 changes: 59 additions & 0 deletions themes/xmpp.org/layouts/shortcodes/rfc-list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<h3>Basic XMPP RFCs</h3>
<ul>
{{ range sort .Site.Data.rfc_list ".number" }}
{{ if .basic }}
<li><a href="#{{ .number }}">RFC {{ .number }}:</a> {{ .title }}</li>
{{ end }}
{{ end }}
</ul>

<h3>Further XMPP RFCs</h3>
<ul>
{{ range sort .Site.Data.rfc_list ".number" }}
{{ if and (not .basic) (not .obsoleted_by) }}
<li><a href="#{{ .number }}">RFC {{ .number }}:</a> {{ .title }}</li>
{{ end }}
{{ end }}
</ul>

<h3>Obsoleted</h3>
<ul>
{{ range sort .Site.Data.rfc_list ".number" }}
{{ if .obsoleted_by }}
<li><a href="#{{ .number }}">RFC {{ .number }}:</a> {{ .title }}</li>
{{ end }}
{{ end }}
</ul>

<h3>All XMPP RFCs</h3>
{{ range sort .Site.Data.rfc_list ".number" }}
<div class="card">
<div class="card-header">
<a id="{{ .number }}"><h5 class="card-title">RFC {{ .number }}: {{ .title }}</h5></a>
<p class="card-subtitle text-muted"><small>{{ .authors }} ({{ .date }})</small></p>
</div>
<div class="card-body">
<p class="card-text">{{ .abstract }}</p>
{{ if .obsoletes }}
<p><small>This RFC obsoletes <a href="#{{ .obsoletes }}">RFC {{ .obsoletes }}.</a></small></p>
{{ end }}
{{ if .obsoleted_by }}
<p><small>This RFC is obsoleted by <a href="#{{ .obsoleted_by }}">RFC {{ .obsoleted_by }}.</a></small></p>
{{ end }}
{{ if .selfhosted }}
<div>
<a class="btn btn-outline-secondary btn-sm mb-1" role="button" href="https://datatracker.ietf.org/doc/rfc{{ .number}}" title="RFC {{ .number }} at datatracker.ietf.org" target="_blank"><i class="fas fa-external-link-alt"></i> RFC {{ .number }}</a>
<p class="mb-1"><small>The XSF hosts this document:</small></p>
<a class="btn btn-outline-secondary btn-sm" role="button" href="/rfcs/rfc{{ .number }}.html" title="RFC {{ .number }} - HTML" target="_blank"><i class="far fa-file-alt"></i> HTML</a>
<a class="btn btn-outline-secondary btn-sm" role="button" href="/rfcs/rfc{{ .number }}.txt" title="RFC {{ .number }} - TXT file" target="_blank"><i class="far fa-file"></i> TXT File</a>
<a class="btn btn-outline-secondary btn-sm" role="button" href="/rfcs/rfc{{ .number }}.xml" title="RFC {{ .number }} - XML source" target="_blank"><i class="far fa-file-code"> XML Source</i></a>
</div>
{{ else }}
<div>
<a class="btn btn-outline-secondary btn-sm" role="button" href="https://datatracker.ietf.org/doc/rfc{{ .number}}" title="RFC {{ .number }} at datatracker.ietf.org" target="_blank"><i class="fas fa-external-link-alt"></i> RFC {{ .number }}</a>
</div>
{{ end }}
</div>
</div>
<br>
{{ end }}
146 changes: 146 additions & 0 deletions tools/prepare_rfc_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# This file is used to download RFC references and convert them to
# a single JSON file
import sys
import os
import json
import requests
import xml.etree.ElementTree as ET


def status_ok(status_code):
# Status codes ranging from 200 (OK) to 300 (redirects) are okay
if status_code >= 200 and status_code < 400:
return True
return False


rfc_numbers = [
3920,
3921,
3922,
3923,
4622,
4854,
4979,
5122,
5437,
6120, #
6121, #
7081,
7165,
7247,
7248,
7259,
7395, #
7572,
7573,
7590, #
7622, #
7700,
7702,
7712,
8084,
8266,
8284,
8600
]

basic_rfc_numbers = [
6120,
6121,
7395,
7590,
7622
]

selfhosted_rfcs = [
3920,
3921,
3922,
3923,
4622,
4854,
5122,
6120,
6121,
6122
]

bibxmlpath = 'https://xml2rfc.tools.ietf.org/public/rfc/bibxml'

rfcs = []

print('Start preparing RFC list')

for number in rfc_numbers:
request = requests.get(f'{bibxmlpath}/reference.RFC.{number}.xml')
if not status_ok(request.status_code):
quit(f'Error while downloading reference for '
f'RFC {number} ({request.status_code})')

try:
root = ET.fromstring(request.content)
except Exception:
quit(f'Error while parsing RFC reference for RFC {number}')

authors = None
for item in root.iter():
if item.tag == 'title':
title = item.text
if item.tag == 'date':
date = item.attrib.get('year')
if item.tag == 'author':
if authors is None:
authors = item.attrib.get('fullname')
else:
authors += f", {item.attrib.get('fullname')}"
if item.tag == 'abstract':
abstract = item.find('t').text

obsoletes = None
obsoleted_by = None
if number == 3920:
obsoleted_by = '6120'
if number == 3921:
obsoleted_by = '6121'
if number == 4622:
obsoleted_by = '5122'
if number == 5122:
obsoletes = '4622'
if number == 6120:
obsoletes = '3920'
if number == 6121:
obsoletes = '3921'
if number == 7248:
obsoleted_by = '8084'
if number == 7700:
obsoleted_by = '8266'
if number == 8084:
obsoletes = '7248'
if number == 8266:
obsoletes = '7700'

basic = True if number in basic_rfc_numbers else False
selfhosted = True if number in selfhosted_rfcs else False

rfcs.append(
{
'number': number,
'title': title,
'date': date,
'authors': authors,
'abstract': abstract,
'obsoletes': obsoletes,
'obsoleted_by': obsoleted_by,
'basic': basic,
'selfhosted': selfhosted,
}
)
print(f'Added RFC {number}')

base_path = os.path.dirname(os.path.abspath(sys.argv[0]))

with open(f'{base_path}/../data/rfc_list.json', 'w') as json_file:
json.dump(rfcs, json_file, indent=4)

print(f'RFC list prepared successfully ({len(rfc_numbers)} RFCs)')