Skip to content

Commit

Permalink
feat: Use idnits3 for post submission nits check
Browse files Browse the repository at this point in the history
  • Loading branch information
kesara committed Nov 6, 2024
1 parent 701e8a5 commit d8192fa
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
18 changes: 18 additions & 0 deletions ietf/doc/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2996,6 +2996,24 @@ def test_raw_id(self):
self.should_succeed(dict(name=draft.name, rev='00',ext='txt'))
self.should_404(dict(name=draft.name, rev='00',ext='html'))

@override_settings(IDNITS3_BASE_URL="https://example.org/idnits3")
def test_nits_url(self):
draft = WgDraftFactory(name="draft-ietf-moon-test",rev="01", create_revisions=range(0,2))

dir = settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR
(Path(dir) / f"{draft.name}-01.xml").touch()
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=draft.name)))
self.assertContains(r, settings.IDNITS3_BASE_URL)

@override_settings(IDNITS_BASE_URL="https://example.org/nits")
def test_nits_url_txt_only(self):
draft = WgDraftFactory(name="draft-ietf-moon-test",rev="01", create_revisions=range(0,2))

dir = settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR
(Path(dir) / f"{draft.name}-01.txt").touch()
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=draft.name)))
self.assertContains(r, settings.IDNITS_BASE_URL)

# test_raw_id_rfc intentionally removed
# an rfc is no longer a pseudo-version of a draft.

Expand Down
11 changes: 10 additions & 1 deletion ietf/doc/views_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,14 @@ def document_main(request, name, rev=None, document_html=False):
# Stream description and name passing test
stream = ("draft-stream-" + doc.stream.slug) if doc.stream != None else "(None)"

# Nits URL
nits_url = ''
if 'xml' in found_types:
nits_url = f"{settings.IDNITS3_BASE_URL}?url={[fu[1] for fu in file_urls if fu[0] == 'xml'][0]}"
elif 'txt' in found_types:
nits_url = f"{settings.IDNITS_BASE_URL}?url={[fu[1] for fu in file_urls if fu[0] == 'plain text'][0]}"


html = None
js = None
css = None
Expand Down Expand Up @@ -711,7 +719,8 @@ def document_main(request, name, rev=None, document_html=False):
review_requests=review_requests,
no_review_from_teams=no_review_from_teams,
due_date=due_date,
diff_revisions=diff_revisions
diff_revisions=diff_revisions,
nits_url=nits_url
))

elif doc.type_id == "charter":
Expand Down
1 change: 1 addition & 0 deletions ietf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ def skip_unreadable_post(record):
IDTRACKER_BASE_URL = "https://datatracker.ietf.org"
RFCDIFF_BASE_URL = "https://author-tools.ietf.org/iddiff"
IDNITS_BASE_URL = "https://author-tools.ietf.org/api/idnits"
IDNITS3_BASE_URL = "https://author-tools.ietf.org/api/idnits3"
IDNITS_SERVICE_URL = "https://author-tools.ietf.org/idnits"

# Content security policy configuration (django-csp)
Expand Down
4 changes: 3 additions & 1 deletion ietf/templates/doc/document_draft.html
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,16 @@
</i>
Referenced by
</a>
{% if nits_url %}
<a class="btn btn-primary btn-sm"
href="{{ settings.IDNITS_BASE_URL }}?url=https://www.ietf.org/archive/id/{{ doc.filename_with_rev }}"
href="{{ nits_url }}"
rel="nofollow"
target="_blank">
<i class="bi bi-exclamation">
</i>
Nits
</a>
{% endif %}
<a class="btn btn-primary btn-sm"
href="https://mailarchive.ietf.org/arch/search/?q=%22{{ doc.name }}%22"
rel="nofollow"
Expand Down

0 comments on commit d8192fa

Please sign in to comment.