Skip to content

Commit

Permalink
Add XMPP RFCs page
Browse files Browse the repository at this point in the history
  • Loading branch information
cal0pteryx committed Sep 29, 2021
1 parent 73f7737 commit a57291f
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 0 deletions.
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)')

0 comments on commit a57291f

Please sign in to comment.