Skip to content

Commit 0737b0f

Browse files
committed
Better journal handling
1 parent 4febaf0 commit 0737b0f

9 files changed

Lines changed: 29 additions & 10 deletions

File tree

‎_content/articles/narratives-of-buddhist-relics-and-images_berkwitz-s.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ external_url: "https://www.academia.edu/39327120/_Narratives_of_Buddhist_Relics_
66
source_url: "https://doi.org/10.1093/acrefore/9780199340378.013.587"
77
year: 2019
88
month: may
9-
journal: "Oxford Research Encyclopedia of Religion"
9+
journal: orer
1010
publisher: oxford
1111
course: form
1212
tags:

‎_includes/content.bibtex.liquid‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{%- if include.content.from_book -%}{%- assign book = site.content | where: "slug", include.content.from_book | where: "category", "monographs" | first -%}{%- else -%}{%- assign book = nil -%}{%- endif -%}
22
{%- assign series = site.series | find: "slug", include.content.series -%}
3-
{%- assign publisher = include.content.publisher | default: book.publisher | default: series.publisher -%}{%- assign publisher = site.publishers | find: "slug", publisher | default: publisher -%}
3+
{%- assign journal = site.journals | find: "slug", include.content.journal -%}
4+
{%- assign publisher = include.content.publisher | default: book.publisher | default: series.publisher | default: journal.publisher -%}{%- assign publisher = site.publishers | find: "slug", publisher | default: publisher -%}
45
{%- assign author = nil -%}
56
{%- assign curlyspace = "} " -%}
67
{%- assign curly = "}" -%}
@@ -17,10 +18,10 @@
1718
{% endif %}{% if include.content.editor %} editor={% assign editors = include.content.editor | split: " and " %}{% if include.useslugs %}{% for t in editors %}{% if t contains " " %}"{{ t }}"{% else %}{{ t }}{% endif %}{% unless forloop.last %} # " and " # {% endunless %}{% endfor %}{% else %}{% raw %}{{% endraw %}{% capture t %}{% include_cached content_authors_string.html authors=editors %}{% endcapture %}{{ t | strip | replace: ", and ", " and " | replace: ", ", " and " }}}{% endif %},
1819
{% endif %}{% if include.content.publisher or publisher %} publisher={% raw %}{{% endraw %}{% if publisher %}{{ publisher.title | default: publisher | replace: "&", escand }}{% else %}{{ include.content.publisher | replace: "&", escand }}{% endif %}},
1920
{% endif %}{% if include.content.school %} school={% raw %}{{% endraw %}{{ include.content.school }}},
20-
{% endif %}{% if include.content.address or publisher.address %} address={% raw %}{{% endraw %}{{ include.content.address | default: publisher.address }}},
21+
{% endif %}{% if include.content.address or publisher.address or journal.address %} address={% raw %}{{% endraw %}{{ include.content.address | default: journal.address | default: publisher.address }}},
2122
{% endif %}{% if include.content.year %} year={{ include.content.year }},
2223
{% endif %}{% if include.content.month %} month={{ include.content.month }},
23-
{% endif %}{% if include.content.journal %} journal={% raw %}{{% endraw %}{% assign journal = site.journals | find: "slug", include.content.journal %}{% if journal %}{{ journal.title | replace: "&", escand }}{% else %}{{ include.content.journal | replace: "&", escand }}{% endif %}},
24+
{% endif %}{% if include.content.journal %} journal={% raw %}{{% endraw %}{% if journal %}{{ journal.title | replace: "&", escand }}{% else %}{{ include.content.journal | replace: "&", escand }}{% endif %}},
2425
{% endif %}{% if include.content.volume %} volume={{ include.content.volume }},
2526
{% endif %}{% if include.content.series %} series={% raw %}{{% endraw %}{% if series %}{{ series.title }}{% else %}{{ include.content.series }}{% endif %}},
2627
{% endif %}{% if include.content.number %} number={{ include.content.number }},

‎_journals/daedalus.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: "Dædalus"
33
external_url: "https://direct.mit.edu/daed"
4+
publisher: mit
45
---
56

67
An interdisciplinary journal published by [MIT](/publishers/mit) on behalf of the [American Academy of Arts and Sciences](https://www.amacad.org/), each quarterly issue invites a number of prominent writers addressing a particular theme.

‎_journals/pnas.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "The Proceedings of the National Academy of Sciences"
3-
publisher: "The National Academy of Sciences of the United States of America"
3+
publisher: nap
44
address: "Washington D.C."
55
external_url: "https://www.pnas.org/"
66
openalexid: S125754415

‎_layouts/content.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ <h2 class="author">Read by {% if reader %}<a href="{{ reader.url }}">{{ reader.t
6969
{%- endif -%}
7070
{% if page.series %}{% assign series = site.series | find: "slug", page.series %}{% else %}{% assign series = nil %}{% endif %}
7171
{% if page.journal %}{% assign journal = site.journals | find: "slug", page.journal %}{% endif %}
72-
{% if page.publisher or series %}{% assign publisher = page.publisher | default: series.publisher %}{% assign publisher = site.publishers | find: "slug", publisher | default: publisher %}{% else %}{% assign publisher = nil %}{% endif %}
72+
{% if page.publisher or series or journal %}{% assign publisher = page.publisher | default: series.publisher | default: journal.publisher %}{% assign publisher = site.publishers | find: "slug", publisher | default: publisher %}{% else %}{% assign publisher = nil %}{% endif %}
7373

7474
{% if tags.size > 0 %}<p class="star_desc">
7575
About: {{ tags }}
@@ -90,7 +90,7 @@ <h2 class="author">Read by {% if reader %}<a href="{{ reader.url }}">{{ reader.t
9090
{% endif %}
9191
<p class="pub_desc"><i>
9292
{%- if page.translator -%}Translated by {% assign translators = page.translator | split: " and " %}{% include_cached content_authors_string.html authors=translators link=true %}.{% endif %}
93-
{% if page.year or publisher or booktitle or page.journal or page.series %}Published{% if page.year %} in {{ page.year }}{% endif %}{% if page.journal %} in {% if journal %}<a href="{{ journal.url }}">{{ journal.title }}</a>{% else %}{{ page.journal }}{% endif %}{% endif %}{% if booktitle %} in “{{ booktitle }}”{% endif %}{% if page.editor %} ({% assign editors = page.editor | split: " and " %}{% include_cached content_authors_string.html authors=editors link=true %} ed.){% endif %}{% if publisher %} by {% if publisher.title %}<a href="{{ publisher.url }}">{{ publisher.title }}</a>{% else %}{{ publisher }}{% endif %}{% if page.address or publisher.address or series.address %}, {{ page.address | default: series.address | default: publisher.address }}{% endif %}{% endif %}{% if page.series %} {% if page.number %}as{% else %}in{% endif %} {% if series %}<a href="{{ series.url }}">{{ series.title }}</a>{% else %}"{{ page.series }}"{% endif %}{% if page.number %} number {{ page.number }}{% endif %}{% endif %}.{% endif %}
93+
{% if page.year or publisher or booktitle or page.journal or page.series %}Published{% if page.year %} in {{ page.year }}{% endif %}{% if page.journal %} in {% if journal %}<a href="{{ journal.url }}">{{ journal.title }}</a>{% else %}{{ page.journal }}{% endif %}{% endif %}{% if booktitle %} in “{{ booktitle }}”{% endif %}{% if page.editor %} ({% assign editors = page.editor | split: " and " %}{% include_cached content_authors_string.html authors=editors link=true %} ed.){% endif %}{% if publisher %} by {% if publisher.title %}<a href="{{ publisher.url }}">{{ publisher.title }}</a>{% else %}{{ publisher }}{% endif %}{% if page.address or publisher.address or series.address %}, {{ page.address | default: series.address | default: journal.address | default: publisher.address }}{% endif %}{% endif %}{% if page.series %} {% if page.number %}as{% else %}in{% endif %} {% if series %}<a href="{{ series.url }}">{{ series.title }}</a>{% else %}"{{ page.series }}"{% endif %}{% if page.number %} number {{ page.number }}{% endif %}{% endif %}.{% endif %}
9494

9595
</i></p>
9696

‎_layouts/publisher.html‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@ <h3><a target="_blank" href="{{ page.external_url }}">Online here</a></h3>
1515
<div class="post-content">
1616
{{ content }}
1717

18+
{% assign journals = site.journals | where: "publisher", page.slug %}
19+
{% assign journalslugs = journals | map: "slug" %}
20+
{% if journals.size > 0 %}<h4>Featured Journals</h4>
21+
{% for journal in journals %}
22+
<div><i class="far fa-newspaper"></i> <a href="{{ journal.url }}">{{ journal.title }}</a></div>
23+
{% endfor %}
24+
{% endif %}
1825
{% assign series = site.series | where: "publisher", page.slug %}
1926
{% assign seriesslugs = series | map: "slug" %}
2027
{% if series.size > 0 %}<h4>Featured Series</h4>
2128
{% include content_list.html contents=series keep_rejects="true" %}
2229
{% endif %}
2330
{% assign allworks = site.content | where: "publisher", page.slug %}
2431
{% assign filtered = '' | split: '' %}
25-
{% for c in allworks %}{% unless seriesslugs contains c.series %}{% assign filtered = filtered | push: c %}{% endunless %}{% endfor %}
32+
{% for c in allworks %}{% unless seriesslugs contains c.series or journalslugs contains c.journal %}{% assign filtered = filtered | push: c %}{% endunless %}{% endfor %}
2633
{% if filtered.size > 0 %}<h4>Featured Publications:</h4>
2734
{% include content_list.html contents=filtered keep_rejects="true" %}
2835
{% endif %}

‎_tests/bibtex.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ Bibtex pulls the address from the publisher: {% if bib contains "address={" %}Pa
3737

3838
Test is valid (piece has doi source): {% if testc.source_url contains "doi.org" %}Pass ✅{% else %}FAIL ❌{% endif %}
3939
Bibtex pulls doi from source: {% if bib contains "doi={" %}Pass ✅{% else %}FAIL ❌{% endif %}
40+
41+
{% assign testc = site.content | find: "url", "/content/articles/notes-on-visuddhimagga-9_gombrich" %}
42+
```
43+
{% capture bib %}{% include content.bibtex.liquid content=testc %}{% endcapture %}{{ bib }}
44+
```
45+
46+
Test is valid (piece has journal but no publisher or address): {% if testc.address or testc.publisher %}FAIL ❌{% else %}{% if testc.journal == 'jpts' %}Pass ✅{% else %}FAIL ❌{% endif %}{% endif %}
47+
Bibtex pulls publisher from the journal: {% if bib contains "publisher=" %}Pass ✅{% else %}FAIL ❌{% endif %}
48+
Bibtex pulls address from the publisher: {% if bib contains "address=" %}Pass ✅{% else %}FAIL ❌{% endif %}

‎_tests/content.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ A series of tests checking the integrity of the _content data
2121
| Unlinked Authors | {% assign authors = site.authors | map: "title" %}{% assign dupes = '' | split: '' %}{% for cont in site.content %}{% for auth in cont.authors %}{% if authors contains auth %}{% assign dupes = dupes | push: cont %}{% break %}{% endif %}{% endfor %}{% endfor %}{% if dupes.size == 0 %}Pass ✅{% else %}FAIL ❌{% endif %} | Found {{ dupes.size }} works with unlinked authors{% if dupes.size > 0 %}: {{ dupes | map: "url" | array_to_sentence_string }}{% endif %}
2222
| Dangling Authors | {% assign authors = site.authors | map: "slug" %}{% for auth in found %}{% assign authors = authors | where_exp: "a", "a != auth" %}{% endfor %}{% assign unfound = '' | split: '' %}{% for auth in authors %}{% assign c = site.content | where: "translator", auth | size %}{% if c > 0 %}{% continue %}{% endif %}{% assign c = site.content | where: "editor", auth | size %}{% if c > 0 %}{% continue %}{% endif %}{% assign c = site.content | where: "reader", auth | size %}{% if c == 0 %}{% assign unfound = unfound | push: auth %}{% endif %}{% endfor %}{% if unfound.size == 0 %}Pass ✅{% else %}FAIL ❌{% endif %} | There are {{ unfound.size }} authors with no works attributed to them{% if unfound.size == 0 %}.{% else %}: {{ unfound | array_to_sentence_string }}.{% endif %}
2323
| Content unexpectedly missing links | {% assign failures = site.content | where_exp: "c", "c.external_url == nil" | where_exp: "c", "c.drive_links == nil" | where_exp: "c", "c.source_url == nil" | where_exp: "c", "c.file_links == nil" | where_exp: "c", "c.category != 'monographs'" | where_exp: "c", "c.status != 'rejected'" | where_exp: "c", "c.slug != 'historical-dictionary-of-chan_wang-youru'" | where_exp: "c", "c.subcat != 'film'" %}{% if failures.size == 0 %}Pass ✅{% else %}FAIL ❌{% endif %} | There are {{ failures.size }} missing links{% if failures.size >0 %}: {{ failures | map: "slug" | array_to_sentence_string }}{% endif %}.
24+
| Films have video files | {% assign failures = site.content | where: "subcat", "film" | where_exp: "c", "c.drive_links[0]" | where: "formats[0]", "mp3" %}{% if failures.size == 0 %}Pass ✅{% else %}FAIL ❌{% endif %} | There are {{ failures.size }} films with mp3s{% if failures.size > 0 %}: {{ failures | map: "slug" | array_to_sentence_string }}{% endif %}.
2425
| https error | {% assign ec = site.content | where_exp: "c", "c.external_url contains 'http://'" %}{% assign ed = "" | split: "" %}{% for c in ec %}{% unless c.external_url contains "https://" %}{% assign ed = ed | push: c %}{% endunless %}{% endfor %}{% assign failures = ed | where_exp: "c", "c.external_url contains '.pdf'" %}{% assign ec = ed | where_exp: "c", "c.external_url contains '/article/download/'" %}{% assign failures = failures | concat: ec %}{% if failures.size == 0 %}Pass ✅{% else %}FAIL ❌{% endif %} | There are {{ failures.size }} links that need to be https{% if failures.size >0 %}: {{ failures | map: "slug" | array_to_sentence_string }}{% endif %}.
2526
| Content missing year | {% assign failures = site.content | where_exp: "c", "c.year == nil" %}{% if failures.size == 0 %}Pass ✅{% else %}FAIL ❌{% endif %} | There are {{ failures.size }} missing years{% if failures.size >0 %}: {{ failures | map: "slug" | array_to_sentence_string }}{% endif %}.
2627
| Invalid months | {% assign failures = "" | split: "" %}{% for cont in site.content %}{% if cont.month %}{% unless site.data.bibtex.months contains cont.month %}{% assign failures = failures | push: cont.path %}{% endunless %}{% endif %}{% endfor %}{% if failures.size == 0 %}Pass ✅{% else %}FAIL ❌{% endif %} | {{ failures.size }} bad months found{% if failures.size >0 %}: {{ failures | array_to_sentence_string }}{% endif %}

‎scripts/gdrive.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
DOC_LINK = 'https://docs.google.com/document/d/{}/edit?usp=drivesdk'
4141

4242
def link_to_id(link):
43-
ret = re.search(r'/d/([a-zA-Z0-9_-]{33}|[a-zA-Z0-9_-]{44})/?(edit|view)?(\?usp=)?(sharing|drivesdk)?$', link)
43+
ret = re.search(r'/d/([a-zA-Z0-9_-]{33}|[a-zA-Z0-9_-]{44})/?(edit|view)?(\?usp=)?(sharing|drivesdk|drive_link)?$', link)
4444
return ret.groups()[0] if ret else None
4545

4646
def folderlink_to_id(link):
@@ -102,7 +102,7 @@ def google_credentials():
102102
creds.refresh(Request())
103103
else:
104104
if not os.path.exists(CLIENTSECRETS):
105-
raise RuntimeError(f"{CLIENTSECRETS} does not exist.")
105+
raise RuntimeError(f"{CLIENTSECRETS} does not exist.\nDownload it at https://console.developers.google.com/apis/credentials")
106106
flow = InstalledAppFlow.from_client_secrets_file(
107107
CLIENTSECRETS, SCOPES)
108108
creds = flow.run_local_server(port=0)

0 commit comments

Comments
 (0)