From 814e1315b50e4d1aec6f2002611d0446279d31a7 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Mon, 20 Mar 2017 14:08:52 +0000 Subject: [PATCH] Added a new document tab for some documents, showing htmlized drafts and RFCs using the htmlization code previously developed for tools.ietf.org. As the generation of the htmlized page is a bit too costly to do on the fly for often-referenced drafts and RFCs, the part of each page which contains the htmlized document is cached on file with a cache time of 2 weeks. Changed all links which pointed to the htmlized version on tools to instead point at the datatracker htmlized document. Tweaked some URLs which didn't permit retrieval of intermediate-rev-charters. Narrowed the pattern for document names to disallow dots in names, and instead explicitly enumerated the few historical draftw with dots in the name. Added a file-system cache for the htmlized documents, and specified a max_entries value for caches, overriding the default 300 entries. Tweaked the code for new author email entries to provide a time if missing in an updated entry. Changed links in various email templates which pointed at tools.ietf.org pages to instead point at datatracker pages, where appropriate. Changed the search result rows to provide links to both the current meta- information document pages (with a (i) info symbol) and to the new htmlized document pages. - Legacy-Id: 13040 --- ietf/doc/templatetags/ietf_filters.py | 2 +- ietf/doc/tests.py | 9 ++ ietf/doc/urls.py | 5 +- ietf/doc/urls_charter.py | 4 +- ietf/doc/utils.py | 129 ++++++++++++++++++ ietf/doc/views_doc.py | 42 +++++- ietf/settings.py | 34 ++++- ietf/settings_testcrawl.py | 13 +- ietf/static/ietf/css/ietf.css | 116 +++++++++++++++- ietf/submit/utils.py | 2 + ietf/templates/base.html | 12 +- ietf/templates/doc/document_bibtex.bib | 2 +- ietf/templates/doc/document_draft.html | 20 ++- ietf/templates/doc/document_html.html | 69 ++++++++++ ietf/templates/doc/document_top.html | 2 +- .../doc/search/search_result_row.html | 4 +- ietf/templates/group/customize_workflow.html | 2 +- .../templates/submit/announce_new_version.txt | 2 +- ietf/templates/submit/announce_to_authors.txt | 4 +- ietf/templates/submit/announce_to_lists.txt | 4 +- 20 files changed, 444 insertions(+), 33 deletions(-) create mode 100644 ietf/templates/doc/document_html.html diff --git a/ietf/doc/templatetags/ietf_filters.py b/ietf/doc/templatetags/ietf_filters.py index 1deca4466..c5ee9b15e 100644 --- a/ietf/doc/templatetags/ietf_filters.py +++ b/ietf/doc/templatetags/ietf_filters.py @@ -197,7 +197,7 @@ def rfclink(string): URL for that RFC. """ string = str(string); - return "https://tools.ietf.org/html/rfc" + string; + return "/doc/html/rfc" + string; @register.filter(name='urlize_ietf_docs', is_safe=True, needs_autoescape=True) def urlize_ietf_docs(string, autoescape=None): diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py index 81de8b8ce..a4b629620 100644 --- a/ietf/doc/tests.py +++ b/ietf/doc/tests.py @@ -493,6 +493,15 @@ Man Expires September 22, 2015 [Page 3] self.assertTrue("Show full document text" in unicontent(r)) self.assertFalse("Deimos street" in unicontent(r)) + r = self.client.get(urlreverse("ietf.doc.views_doc.document_html", kwargs=dict(name=draft.name))) + self.assertEqual(r.status_code, 200) + self.assertTrue("Versions:" in unicontent(r)) + self.assertTrue("Deimos street" in unicontent(r)) + q = PyQuery(r.content) + self.assertEqual(len(q('.rfcmarkup pre')), 4) + self.assertEqual(len(q('span.h1')), 2) + self.assertEqual(len(q('a[href]')), 116) + # expired draft draft.set_state(State.objects.get(type="draft", slug="expired")) diff --git a/ietf/doc/urls.py b/ietf/doc/urls.py index 69fa7ad55..f5ca91a87 100644 --- a/ietf/doc/urls.py +++ b/ietf/doc/urls.py @@ -59,13 +59,14 @@ urlpatterns = [ url(r'^stats/newrevisiondocevent/data/?$', views_stats.chart_data_newrevisiondocevent), url(r'^stats/person/(?P[0-9]+)/drafts/conf/?$', views_stats.chart_conf_person_drafts), url(r'^stats/person/(?P[0-9]+)/drafts/data/?$', views_stats.chart_data_person_drafts), + url(r'^html/%(name)s(?:-%(rev)s)?(\.txt|\.html)?$' % settings.URL_REGEXPS, views_doc.document_html), url(r'^all/$', views_search.index_all_drafts), url(r'^active/$', views_search.index_active_drafts), url(r'^select2search/(?P(document|docalias))/(?Pdraft)/$', views_search.ajax_select2_search_docs), - url(r'^%(name)s/(?:%(rev)s/)?$' % settings.URL_REGEXPS, views_doc.document_main), - url(r'^%(name)s/(?:%(rev)s/)?bibtex/$' % settings.URL_REGEXPS, views_doc.document_bibtex), + url(r'^%(name)s(?:/%(rev)s)?/$' % settings.URL_REGEXPS, views_doc.document_main), + url(r'^%(name)s(?:/%(rev)s)?/bibtex/$' % settings.URL_REGEXPS, views_doc.document_bibtex), url(r'^%(name)s/history/$' % settings.URL_REGEXPS, views_doc.document_history), url(r'^%(name)s/writeup/$' % settings.URL_REGEXPS, views_doc.document_writeup), url(r'^%(name)s/email/$' % settings.URL_REGEXPS, views_doc.document_email), diff --git a/ietf/doc/urls_charter.py b/ietf/doc/urls_charter.py index 5daf4092d..9e0f4bb1f 100644 --- a/ietf/doc/urls_charter.py +++ b/ietf/doc/urls_charter.py @@ -1,7 +1,5 @@ # Copyright The IETF Trust 2011, All Rights Reserved -from django.conf import settings - from ietf.doc import views_charter, views_doc from ietf.utils.urls import url @@ -17,5 +15,5 @@ urlpatterns = [ url(r'^ballotwriteupnotes/$', views_charter.ballot_writeupnotes), url(r'^approve/$', views_charter.approve), url(r'^submit/(?:(?P