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
This commit is contained in:
Henrik Levkowetz 2012-10-25 21:18:06 +00:00
parent 3ec8ec4803
commit 6e4d27ca5b
5 changed files with 59 additions and 0 deletions

View file

View file

View file

@ -0,0 +1,38 @@
import sys
import os
from django.core.management.base import BaseCommand
from django.db.models import Q
from django.conf import settings
from django.template.loader import render_to_string
from ietf.doc.models import Document
def write(fn, new):
try:
f = open(fn)
old = f.read().decode('utf-8')
f.close
except IOError:
old = ""
if old.strip() != new.strip():
sys.stdout.write(os.path.basename(fn)+'\n')
f = open(fn, "wb")
f.write(new.encode('utf-8'))
f.close()
class Command(BaseCommand):
help = (u'Generate draft bibxml files, for xml2rfc references')
def handle(self, *args, **options):
documents = Document.objects.filter(type__slug='draft')
bibxmldir = os.path.join(settings.BIBXML_BASE_PATH, 'bibxml3')
if not os.path.exists(bibxmldir):
os.makedirs(bibxmldir)
for doc in documents:
ref_text = render_to_string('doc/bibxml.xml', {'doc': doc, 'doc_bibtype':'I-D'})
ref_file_name = os.path.join(bibxmldir, 'reference.I-D.%s.xml' % (doc.name, ))
ref_rev_file_name = os.path.join(bibxmldir, 'reference.I-D.%s-%s.xml' % (doc.name, doc.rev))
write(ref_file_name, ref_text)
write(ref_rev_file_name, ref_text)

View file

@ -294,6 +294,12 @@ USE_DB_REDESIGN_PROXY_CLASSES = True
SOUTH_TESTS_MIGRATE = False
# Generation of bibxml files for xml2rfc
BIBXML_BASE_PATH = '/a/www/ietf-ftp/xml2rfc'
# Timezone files for iCalendar
TZDATA_ICS_PATH = '/www/ietf-datatracker/tz/ics/'
# Put SECRET_KEY in here, or any other sensitive or site-specific
# changes. DO NOT commit settings_local.py to svn.
from settings_local import *

View file

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<reference anchor='{{doc_bibtype}}.{{doc.name|slice:"6:"}}'>
<front>
<title>{{doc.title}}</title>
{% for entry in doc.authors.all %}{% with entry.address as email %}{% with entry.person as author %}
<author initials='{{author.initials}}' surname='{{author.last_name}}' fullname='{{author.name}}'>
<organization>{{author.affiliation}}</organization>
</author>
{% endwith %}{% endwith %}{% endfor %}
<date month='{{doc.time|date:"F"}}' day='{{doc.time.day}}' year='{{doc.time.year}}' />
<abstract><t>{{doc.abstract}}</t></abstract>
</front>
<seriesInfo name='Internet-Draft' value='{{doc.name}}-{{doc.rev}}' />
<format type='TXT' target='http://www.ietf.org/internet-drafts/{{doc.name}}-{{doc.rev}}.txt' />
</reference>