Skip to content

Commit 6e4d27c

Browse files
committed
Added a management command to generate bibxml files for drafts. It's not fully cooked yet, as it needs to differentiate between documents which are currently drafts, and those that have been published as RFCs, but the basics are there.
- Legacy-Id: 4953
1 parent 3ec8ec4 commit 6e4d27c

5 files changed

Lines changed: 59 additions & 0 deletions

File tree

ietf/doc/management/__init__.py

Whitespace-only changes.

ietf/doc/management/commands/__init__.py

Whitespace-only changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import sys
2+
import os
3+
4+
from django.core.management.base import BaseCommand
5+
from django.db.models import Q
6+
from django.conf import settings
7+
from django.template.loader import render_to_string
8+
9+
from ietf.doc.models import Document
10+
11+
def write(fn, new):
12+
try:
13+
f = open(fn)
14+
old = f.read().decode('utf-8')
15+
f.close
16+
except IOError:
17+
old = ""
18+
if old.strip() != new.strip():
19+
sys.stdout.write(os.path.basename(fn)+'\n')
20+
f = open(fn, "wb")
21+
f.write(new.encode('utf-8'))
22+
f.close()
23+
24+
class Command(BaseCommand):
25+
help = (u'Generate draft bibxml files, for xml2rfc references')
26+
27+
def handle(self, *args, **options):
28+
documents = Document.objects.filter(type__slug='draft')
29+
bibxmldir = os.path.join(settings.BIBXML_BASE_PATH, 'bibxml3')
30+
if not os.path.exists(bibxmldir):
31+
os.makedirs(bibxmldir)
32+
for doc in documents:
33+
ref_text = render_to_string('doc/bibxml.xml', {'doc': doc, 'doc_bibtype':'I-D'})
34+
ref_file_name = os.path.join(bibxmldir, 'reference.I-D.%s.xml' % (doc.name, ))
35+
ref_rev_file_name = os.path.join(bibxmldir, 'reference.I-D.%s-%s.xml' % (doc.name, doc.rev))
36+
write(ref_file_name, ref_text)
37+
write(ref_rev_file_name, ref_text)
38+

ietf/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@
294294

295295
SOUTH_TESTS_MIGRATE = False
296296

297+
# Generation of bibxml files for xml2rfc
298+
BIBXML_BASE_PATH = '/a/www/ietf-ftp/xml2rfc'
299+
300+
# Timezone files for iCalendar
301+
TZDATA_ICS_PATH = '/www/ietf-datatracker/tz/ics/'
302+
297303
# Put SECRET_KEY in here, or any other sensitive or site-specific
298304
# changes. DO NOT commit settings_local.py to svn.
299305
from settings_local import *

ietf/templates/doc/bibxml.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<reference anchor='{{doc_bibtype}}.{{doc.name|slice:"6:"}}'>
3+
<front>
4+
<title>{{doc.title}}</title>
5+
{% for entry in doc.authors.all %}{% with entry.address as email %}{% with entry.person as author %}
6+
<author initials='{{author.initials}}' surname='{{author.last_name}}' fullname='{{author.name}}'>
7+
<organization>{{author.affiliation}}</organization>
8+
</author>
9+
{% endwith %}{% endwith %}{% endfor %}
10+
<date month='{{doc.time|date:"F"}}' day='{{doc.time.day}}' year='{{doc.time.year}}' />
11+
<abstract><t>{{doc.abstract}}</t></abstract>
12+
</front>
13+
<seriesInfo name='Internet-Draft' value='{{doc.name}}-{{doc.rev}}' />
14+
<format type='TXT' target='http://www.ietf.org/internet-drafts/{{doc.name}}-{{doc.rev}}.txt' />
15+
</reference>

0 commit comments

Comments
 (0)