Skip to content

Commit 78af342

Browse files
committed
Various fixes to bibtex generation and timelines.
- Legacy-Id: 9965
1 parent ff90994 commit 78af342

3 files changed

Lines changed: 26 additions & 8 deletions

File tree

ietf/doc/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
url(r'^select2search/(?P<model_name>(document|docalias))/(?P<doc_type>draft)/$', views_search.ajax_select2_search_docs, name="ajax_select2_search_docs"),
5454

5555
url(r'^(?P<name>[A-Za-z0-9._+-]+)/(?:(?P<rev>[0-9-]+)/)?$', views_doc.document_main, name="doc_view"),
56-
url(r'^(?P<name>[A-Za-z0-9._+-]+)/bibtex/$', views_doc.document_bibtex, name="doc_bibtex"),
56+
url(r'^(?P<name>[A-Za-z0-9._+-]+)/(?:(?P<rev>[0-9-]+)/)?bibtex/$', views_doc.document_bibtex, name="doc_bibtex"),
5757
url(r'^(?P<name>[A-Za-z0-9._+-]+)/history/$', views_doc.document_history, name="doc_history"),
5858
url(r'^(?P<name>[A-Za-z0-9._+-]+)/writeup/$', views_doc.document_writeup, name="doc_writeup"),
5959
url(r'^(?P<name>[A-Za-z0-9._+-]+)/shepherdwriteup/$', views_doc.document_shepherd_writeup, name="doc_shepherd_writeup"),

ietf/doc/views_doc.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def document_main(request, name, rev=None):
417417
search_archive=search_archive,
418418
actions=actions,
419419
tracking_document=tracking_document,
420-
rev_history=crawl_history(latest_revision.doc),
420+
rev_history=crawl_history(latest_revision.doc if latest_revision else doc),
421421
),
422422
context_instance=RequestContext(request))
423423

@@ -457,7 +457,7 @@ def document_main(request, name, rev=None):
457457
group=group,
458458
milestones=milestones,
459459
can_manage=can_manage,
460-
rev_history=crawl_history(latest_revision.doc),
460+
rev_history=crawl_history(latest_revision.doc if latest_revision else doc),
461461
),
462462
context_instance=RequestContext(request))
463463

@@ -486,7 +486,7 @@ def document_main(request, name, rev=None):
486486
conflictdoc=conflictdoc,
487487
ballot_summary=ballot_summary,
488488
approved_states=('appr-reqnopub-pend','appr-reqnopub-sent','appr-noprob-pend','appr-noprob-sent'),
489-
rev_history=crawl_history(latest_revision.doc),
489+
rev_history=crawl_history(latest_revision.doc if latest_revision else doc),
490490
),
491491
context_instance=RequestContext(request))
492492

@@ -522,7 +522,7 @@ def document_main(request, name, rev=None):
522522
ballot_summary=ballot_summary,
523523
approved_states=('appr-pend','appr-sent'),
524524
sorted_relations=sorted_relations,
525-
rev_history=crawl_history(latest_revision.doc),
525+
rev_history=crawl_history(latest_revision.doc if latest_revision else doc),
526526
),
527527
context_instance=RequestContext(request))
528528

@@ -635,11 +635,27 @@ def document_history(request, name):
635635
context_instance=RequestContext(request))
636636

637637

638-
def document_bibtex(request, name):
638+
def document_bibtex(request, name, rev=None):
639639
doc = get_object_or_404(Document, docalias__name=name)
640640

641+
latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision")
642+
replaced_by = [d.name for d in doc.related_that("replaces")]
643+
published = doc.latest_event(type="published_rfc")
644+
rfc = latest_revision.doc if latest_revision.doc.get_state_slug() == "rfc" else None
645+
646+
if rev != None and rev != doc.rev:
647+
# find the entry in the history
648+
for h in doc.history_set.order_by("-time"):
649+
if rev == h.rev:
650+
doc = h
651+
break
652+
641653
return render_to_response("doc/document_bibtex.bib",
642-
dict(doc=doc),
654+
dict(doc=doc,
655+
replaced_by=replaced_by,
656+
published=published,
657+
rfc=rfc,
658+
latest_revision=latest_revision),
643659
content_type="text/plain; charset=utf-8",
644660
context_instance=RequestContext(request))
645661

ietf/templates/doc/document_bibtex.bib

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ @misc{
1010
publisher = {RFC Editor},
1111
doi = {% templatetag openbrace %}10.17487/rfc{{ doc.rfc_number }}{% templatetag closebrace %},
1212
url = {https://rfc-editor.org/rfc/rfc{{ doc.rfc_number }}.txt},{% else %}
13+
{% if published %}%% You should probably cite rfc{{ latest_revision.doc.rfc_number }} instead of this I-D.{% else %}{% if replaced_by %}%% You should probably cite {{replaced_by|join:" or "}} instead of this I-D.{% else %}
14+
{% if doc.rev != latest_revision.rev %}%% You should probably cite {{latest_revision.doc.name}}-{{latest_revision.rev}} instead of this revision.{%endif%}{% endif %}{% endif %}
1315
@techreport{% templatetag openbrace %}{{doc.name|slice:"6:"}}-{{doc.rev}},
14-
number= {% templatetag openbrace %}draft-ietf-tsvwg-rfc5405bis-05{% templatetag closebrace %},
16+
number= {% templatetag openbrace %}{{doc.name}}-{{doc.rev}}{% templatetag closebrace %},
1517
type = {% templatetag openbrace %}Internet-Draft{% templatetag closebrace %},
1618
institution = {% templatetag openbrace %}Internet Engineering Task Force{% templatetag closebrace %},
1719
publisher = {% templatetag openbrace %}Internet Engineering Task Force{% templatetag closebrace %},

0 commit comments

Comments
 (0)