Skip to content

Commit

Permalink
Show better feedback for missing DOIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmccurley committed Jul 17, 2024
1 parent 9849c8f commit be02bb1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
21 changes: 16 additions & 5 deletions webapp/bibmarkup.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,22 @@ def bibtex_to_html(compilation, cite_map: OrderedDict):
if (entry.entry_type == 'article' or
entry.entry_type == 'inproceedings'):
if 'doi' not in entry.fields_dict and 'url' not in entry.fields_dict:
compilation.warning_log.append(
CompileError(error_type=ErrorType.BIBTEX_WARNING,
logline=0,
text='bibtex entry {} of type @{} should probably have a doi or url field.'.format(entry.key,
entry.entry_type)))
warning = CompileError(error_type=ErrorType.BIBTEX_WARNING,
logline=0,
text='bibtex entry {} of type @{} should probably have a doi or url field.'.format(entry.key,
entry.entry_type))
if 'title' in entry.fields_dict:
title = entry.fields_dict['title'].value
# supply better text hint with title.
warning.text = 'bibtex entry {} of type @{} with title "{}" should probably have a doi or url field.'.format(entry.key,
entry.entry_type,
title)
searchurl = '/cryptobib?' + urlencode({'textq': title})
crossrefurl = 'https://search.crossref.org/search/works?' + urlencode({'q': title,
'from_ui': 'yes'})
warning.help = '<a href="{}" target="_blank">Search cryptobib</a> or <a href="{}" target="_blank">search crossref.org</a>.'.format(searchurl,
crossrefurl)
compilation.warning_log.append(warning)
bibitemdata = {'key': entry.key,
'label': cite_map.get(entry.key, 'BUG!')}
if errors:
Expand Down
9 changes: 8 additions & 1 deletion webapp/templates/admin/copyedit.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
width: 12rem;
text-align: right !important;
}
div.BIBTEX_WARNING {
background-color: #f8e57c;
}

</style>
{# this template is used for generating notes from javascript. #}
{% raw %}
Expand Down Expand Up @@ -554,7 +558,7 @@
<div class="list-group discussionTabs">
{% if comp.warning_log %}
{% for err in comp.warning_log %}
<div id="warning-{{loop.index}}" class="alert alert-warning d-flex justify-content-between fade show"
<div id="warning-{{loop.index}}" class="alert alert-warning d-flex justify-content-between fade show {{err.error_type.name}}"
{% if err.filepath %}
{% if err.filepath.startswith('/usr/') %}
{% set filepath = err.filepath.split('/')[-1] %}
Expand Down Expand Up @@ -588,6 +592,9 @@
{% if err.filepath_line %}line {{err.filepath_line}}{% endif %}</span>{% endif %}
</div>
</div>
{% if err.help %}
<div>{{err.help|safe}}</div>
{% endif %}
</div>
<div class="ms-3 d-flex flex-column align-items-end">
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close" title="Hide"></button>
Expand Down
2 changes: 1 addition & 1 deletion webapp/templates/view_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
div.warning_log_entry {
background-color: #fef7b8; /* #fff0a8;*/
}
div.warning_log_entry.METADATA_WARNING {
div.warning_log_entry.METADATA_WARNING,div.warning_log_entry.BIBTEX_WARNING {
background-color: #ffe035;
}
div.error_log_entry {
Expand Down

0 comments on commit be02bb1

Please sign in to comment.