diff options
-rw-r--r-- | extra/collectd_statsd.conf | 2 | ||||
-rw-r--r-- | python/example.env | 1 | ||||
-rw-r--r-- | python/fatcat_tools/transforms/csl.py | 6 | ||||
-rw-r--r-- | python/fatcat_tools/transforms/elasticsearch.py | 5 | ||||
-rw-r--r-- | python/fatcat_web/templates/base.html | 10 | ||||
-rw-r--r-- | python/fatcat_web/templates/changelog.html | 6 | ||||
-rw-r--r-- | python/fatcat_web/templates/container_view.html | 32 | ||||
-rw-r--r-- | python/fatcat_web/templates/editgroup_view.html | 2 | ||||
-rw-r--r-- | python/fatcat_web/templates/entity_base.html | 4 | ||||
-rw-r--r-- | python/fatcat_web/templates/entity_history.html | 2 | ||||
-rw-r--r-- | python/fatcat_web/templates/entity_macros.html | 7 | ||||
-rw-r--r-- | python/fatcat_web/templates/entity_view_metadata.html | 2 | ||||
-rw-r--r-- | python/fatcat_web/templates/file_view.html | 5 | ||||
-rw-r--r-- | python/fatcat_web/templates/release_save.html | 10 | ||||
-rw-r--r-- | python/fatcat_web/templates/release_view.html | 4 | ||||
-rw-r--r-- | python/fatcat_web/templates/release_view_contribs.html | 11 | ||||
-rw-r--r-- | python/fatcat_web/web_config.py | 9 | ||||
-rw-r--r-- | python/tests/import_dblp.py | 13 |
18 files changed, 90 insertions, 41 deletions
diff --git a/extra/collectd_statsd.conf b/extra/collectd_statsd.conf index 53419be2..a434ed9f 100644 --- a/extra/collectd_statsd.conf +++ b/extra/collectd_statsd.conf @@ -4,7 +4,7 @@ # eg, kcollectd, which is helpful for basic debugging of metrics. # # To use, copy this file to, eg: /etc/collectd/collectd.conf.d/fatcat_statsd.conf -# then restart colectd: sudo service collectd restart +# then restart collectd: sudo service collectd restart LoadPlugin statsd diff --git a/python/example.env b/python/example.env index 120c9e6e..3a83d5b3 100644 --- a/python/example.env +++ b/python/example.env @@ -15,6 +15,7 @@ GITLAB_CLIENT_SECRET="" IA_XAUTH_CLIENT_ID="" IA_XAUTH_CLIENT_SECRET="" SENTRY_DSN="" +ENABLE_GOATCOUNTER="" # These auth keys only for workers/importers; locally will fall back to # FATCAT_API_AUTH_TOKEN diff --git a/python/fatcat_tools/transforms/csl.py b/python/fatcat_tools/transforms/csl.py index ba199efb..15bb369f 100644 --- a/python/fatcat_tools/transforms/csl.py +++ b/python/fatcat_tools/transforms/csl.py @@ -33,19 +33,19 @@ def release_to_csl(entity): if contrib.creator: # Default to "local" (publication-specific) metadata; fall back to # creator-level - family = contrib.surname or contrib.creator.surname or (contrib.raw_name and contrib.raw_name.split()[-1]) + family = contrib.creator.surname or contrib.surname or (contrib.raw_name and contrib.raw_name.split()[-1]) if not family: # CSL requires some surname (family name) continue c = dict( family=family, - given=contrib.given_name or contrib.creator.given_name, + given=contrib.creator.given_name or contrib.given_name, #dropping-particle #non-dropping-particle #suffix #comma-suffix #static-ordering - literal=contrib.raw_name or contrib.creator.display_name, + literal=contrib.creator.display_name or contrib.raw_name, #parse-names, # role must be defined; default to author role=contrib.role or 'author', diff --git a/python/fatcat_tools/transforms/elasticsearch.py b/python/fatcat_tools/transforms/elasticsearch.py index 4bf9091a..331ca4e7 100644 --- a/python/fatcat_tools/transforms/elasticsearch.py +++ b/python/fatcat_tools/transforms/elasticsearch.py @@ -113,10 +113,13 @@ def release_to_elasticsearch(entity: ReleaseEntity, force_bool: bool = True) -> contrib_affiliations = [] creator_ids = [] for c in (release.contribs or []): - if c.raw_name: + if c.creator and c.creator.display_ame: + contrib_names.append(c.creator.display_ame) + elif c.raw_name: contrib_names.append(c.raw_name) elif c.surname: contrib_names.append(c.surname) + if c.creator_id: creator_ids.append(c.creator_id) if c.raw_affiliation: diff --git a/python/fatcat_web/templates/base.html b/python/fatcat_web/templates/base.html index 73f33d0d..5f507082 100644 --- a/python/fatcat_web/templates/base.html +++ b/python/fatcat_web/templates/base.html @@ -153,6 +153,16 @@ integrity="sha256-9H3HWYnPJ2bEHgkOrw+48KheOqYzTvJd1hbeU9sEDFk=" crossorigin="anonymous"> </script> +{% if config.ENABLE_GOATCOUNTER -%} + <script> + window.goatcounter = { + /* title leaks search query, so don't report it */ + title: "", + {# to allow localhost connections (dev) to be collected, set: allow_local: true #} + }; + </script> + <script data-goatcounter="{{ config.GOATCOUNTER_ENDPOINT }}" async src="{{ config.GOATCOUNTER_SCRIPT_URL }}"></script> +{%- endif %} {% block postscript %}{% endblock %} </body> diff --git a/python/fatcat_web/templates/changelog.html b/python/fatcat_web/templates/changelog.html index 3ad01d63..59630666 100644 --- a/python/fatcat_web/templates/changelog.html +++ b/python/fatcat_web/templates/changelog.html @@ -37,11 +37,7 @@ inspect every change all the way back to the start. </table> <div style="float: right; font-size: smaller;"> - {% if config.FATCAT_DOMAIN == "fatcat.wiki" %} - <a href="https://api.fatcat.wiki/v0/changelog">As JSON via API</a> - {% else %} - <a href="{{ config.FATCAT_API_HOST }}/changelog">As JSON via API</a> - {% endif %} + <a href="{{ config.FATCAT_PUBLIC_API_HOST }}/changelog">As JSON via API</a> </div> {% endblock %} diff --git a/python/fatcat_web/templates/container_view.html b/python/fatcat_web/templates/container_view.html index 6ec705b4..0d572c63 100644 --- a/python/fatcat_web/templates/container_view.html +++ b/python/fatcat_web/templates/container_view.html @@ -91,7 +91,7 @@ {% if container.issnl != None or container.wikidata_qid != None %} <div class="ui segment attached"> {% if container.issnl != None %} - <b>ISSN-L<sup><a href="https://en.wikipedia.org/wiki/International_Standard_Serial_Number#Linking_ISSN">?</a></sup></b> + <b>ISSN-L<sup><a href="https://en.wikipedia.org/wiki/International_Standard_Serial_Number#Linking_ISSN">?</a></sup></b> <code>{{ container.issnl }}</code> {% endif %} {% if container.extra != None and container.extra.issnp != None and (container.extra.issnp|length > 0) %} @@ -135,22 +135,34 @@ </div> {% endif %} +{%- if container.extra and container.extra.kbart %} <div class="ui segment attached"> <b>Preservation Holdings</b><br> -{%- if container.extra and container.extra.kbart %} {% for k, v in container.extra.kbart.items() %} - <br><span style="text-transform: uppercase;">{{ k }}:</span> + {% if k == "lockss" %} + <a href="https://www.lockss.org/">LOCKSS</a>: + {% elif k == "clockss" %} + <a href="https://clockss.org/">CLOCKSS</a>: + {% elif k == "hathitrust" and container.issnl %} + <a href="https://catalog.hathitrust.org/Search/Home?lookfor={{ container.issnl }}&searchtype=isn&ft=&setft=false">HathiTrust</a>: + {% elif k == "portico" and container.issnl %} + <a href="https://www.portico.org/coverage/titles/?keyword={{ container.issnl }}">Portico</a>: + {% else %} + <span style="text-transform: uppercase;">{{ k }}:</span> + {% endif %} + years {% for span in v.year_spans %} - {% if span|length >= 2 %} - {{ span[0] }}-{{ span[1] }} - {% elif span|length == 1 %} - {{ span[0] }} - {% endif %} - {{ ", " if not loop.last }} + {% if span|length >= 2 -%} + {{ span[0] }}-{{ span[1] -}} + {% elif span|length == 1 -%} + {{ span[0] -}} + {% endif -%} + {{- ", " if not loop.last }} {% endfor %} + <br> {% endfor %} -{% endif %} </div> +{% endif %} <div class="ui segment attached accordion"> <div class="title" style="padding: 0px;"><i class="dropdown icon"></i><b>Lookup Links</b></div> diff --git a/python/fatcat_web/templates/editgroup_view.html b/python/fatcat_web/templates/editgroup_view.html index 6a9793f7..e1af719d 100644 --- a/python/fatcat_web/templates/editgroup_view.html +++ b/python/fatcat_web/templates/editgroup_view.html @@ -181,7 +181,7 @@ {{ edit_list(auth_to, editgroup, editgroup.edits.webcaptures, "webcapture", "Web Capture") }} </div> <div style="float: right; font-size: smaller;"> - <a href="{{ config.FATCAT_API_HOST }}/editgroup/{{ editgroup.editgroup_id }}">As JSON via API</a> + <a href="{{ config.FATCAT_PUBLIC_API_HOST }}/editgroup/{{ editgroup.editgroup_id }}">As JSON via API</a> </div> <br> diff --git a/python/fatcat_web/templates/entity_base.html b/python/fatcat_web/templates/entity_base.html index f30df0da..36280f5d 100644 --- a/python/fatcat_web/templates/entity_base.html +++ b/python/fatcat_web/templates/entity_base.html @@ -65,8 +65,8 @@ <p style="font-size: larger;"> {% if entity._authors and entity._authors != [] %} by {% for contrib in entity._authors[:12] %} - {% if contrib.creator_id %} - <b><a href="/creator/{{contrib.creator_id}}">{{ contrib.raw_name }}</a></b>{% if not loop.last %}, {% endif %} + {% if contrib.creator_id and contrib.creator and contrib.creator.display_name %} + <b><a href="/creator/{{contrib.creator_id}}">{{ contrib.creator.display_name }}</a></b>{% if not loop.last %}, {% endif %} {% else %} {% if contrib.raw_name != None %}{{ contrib.raw_name }}{% else %}<i>Unknown</i>{% endif %}{% if not loop.last %}, {% endif %} {% endif %} diff --git a/python/fatcat_web/templates/entity_history.html b/python/fatcat_web/templates/entity_history.html index 0115b845..05fae0c3 100644 --- a/python/fatcat_web/templates/entity_history.html +++ b/python/fatcat_web/templates/entity_history.html @@ -35,7 +35,7 @@ This table only shows <i>accepted</i> edits included in the catalog, not any wor {% endfor %} </table> <div style="float: right; font-size: smaller;"> - <a href="{{ config.FATCAT_API_HOST }}/{{ entity_type }}/{{ entity.ident }}/history">As JSON via API</a> + <a href="{{ config.FATCAT_PUBLIC_API_HOST }}/{{ entity_type }}/{{ entity.ident }}/history">As JSON via API</a> </div> diff --git a/python/fatcat_web/templates/entity_macros.html b/python/fatcat_web/templates/entity_macros.html index 9207bd48..4b0635e5 100644 --- a/python/fatcat_web/templates/entity_macros.html +++ b/python/fatcat_web/templates/entity_macros.html @@ -36,12 +36,7 @@ <br>Revision: <small><code><a href="/{{ entity_type }}/rev/{{ entity.revision }}">{{ entity.revision }}</a></code></small> {% endif %} <br>API URL: <a href=" - {%- if config.FATCAT_DOMAIN == 'dev.fatcat.wiki' -%} - http://localhost:9411 - {%- else -%} - https://api.{{ config.FATCAT_DOMAIN }} - {%- endif -%} - /v0 + {{ config.FATCAT_PUBLIC_API_HOST -}} {%- if editgroup and entity.ident -%} /editgroup/{{ editgroup.editgroup_id }}{# /{{ entity_type }}/{{ entity.ident }} #} {%- elif entity.ident -%} diff --git a/python/fatcat_web/templates/entity_view_metadata.html b/python/fatcat_web/templates/entity_view_metadata.html index 90ce25d9..d1bd3c30 100644 --- a/python/fatcat_web/templates/entity_view_metadata.html +++ b/python/fatcat_web/templates/entity_view_metadata.html @@ -7,7 +7,7 @@ <h3>Entity Metadata (schema)</h3> {{ entity_macros.extra_metadata(entity._metadata) }} <div style="float: right;"> - <a href="{{ config.FATCAT_API_HOST }}/{{ entity_type }}/{{ entity.ident }}">As JSON via API</a> + <a href="{{ config.FATCAT_PUBLIC_API_HOST }}/{{ entity_type }}/{{ entity.ident }}">As JSON via API</a> </div> {% if entity.extra %} diff --git a/python/fatcat_web/templates/file_view.html b/python/fatcat_web/templates/file_view.html index 0f5a5fc6..3afd0099 100644 --- a/python/fatcat_web/templates/file_view.html +++ b/python/fatcat_web/templates/file_view.html @@ -55,11 +55,12 @@ No known archives or mirrors of this file. No Public URL </span> {% endif %} -<br> -<div class="ui top segment attached"> +<div class="ui top attached segment"> {% if file.size != None %} <b>Size</b> {{ file.size|filesizeformat }}<br> + {% else %} + <b>Size</b> <i>(unknown)</i><br> {% endif %} {% if file.mimetype != None %} <b>MIME Type</b> <code>{{ file.mimetype }}</code><br> diff --git a/python/fatcat_web/templates/release_save.html b/python/fatcat_web/templates/release_save.html index 7dd01fc0..c78d0066 100644 --- a/python/fatcat_web/templates/release_save.html +++ b/python/fatcat_web/templates/release_save.html @@ -46,11 +46,17 @@ we will attempt to crawl, process, and verify the content and add it to the catalog. + {% if release and release.ext_ids.doi %} + {% set syp_suffix = release.ext_ids.doi %} + {% else %} + {% set syp_suffix = "" %} + {% endif %} + <p style="margin-top: 1em; margin-bottom: 1em;">If you are the author of this work, and the published version is not publicly available, another option is to upload an version to an institutional or discipline repository. The - <a href="https://shareyourpaper.org/">Share Your Paper</a> tool can help with - this process. + <a href="https://shareyourpaper.org/{{ syp_suffix }}">Share Your Paper</a> + tool can help with this process. <p style="margin-top: 1em; margin-bottom: 1em;"><b>Important:</b> double-check the publication stage of the file you are submitting. We diff --git a/python/fatcat_web/templates/release_view.html b/python/fatcat_web/templates/release_view.html index 898cd369..90ea6592 100644 --- a/python/fatcat_web/templates/release_view.html +++ b/python/fatcat_web/templates/release_view.html @@ -203,7 +203,7 @@ accessible version. <div class="column" style="flex: 0 0 24em;"> {% if entity.state == 'active' and entity._es and entity._es.ia_pdf_url %} - <a href="{{ entity._es.ia_pdf_url }}" class="ui top attached fluid huge black button" style="text-decoration: underline;"> + <a href="{{ entity._es.ia_pdf_url }}" class="ui fluid huge black button" style="text-decoration: underline;"> <i class="file pdf outline icon"></i>Read Archived PDF </a> {% elif entity.state == 'active' and entity.webcaptures != [] and entity.webcaptures[0].archive_urls != [] and entity.webcaptures[0].archive_urls[0].rel == "wayback" %} @@ -225,7 +225,9 @@ accessible version. <div class="ui top attached fluid large red inverted center aligned segment" style="padding: 0.5em; border-color: #5550; background-color: #b71818;"> <b>Not Preserved</b> </div> + {% endif %} + {% if entity._es.preservation != 'bright' %} <div class="ui segment attached"> <a href="/release/{{ release.ident }}/save"> <b><i class="cloud download icon"></i>Save Paper Now!</b> diff --git a/python/fatcat_web/templates/release_view_contribs.html b/python/fatcat_web/templates/release_view_contribs.html index 55cdf133..f4969e32 100644 --- a/python/fatcat_web/templates/release_view_contribs.html +++ b/python/fatcat_web/templates/release_view_contribs.html @@ -12,12 +12,17 @@ {% for contrib in release.contribs %} <tr><td class="collapsing">{% if contrib.index or contrib.index == 0 %} {{ contrib.index + 1 }}{% endif %} <td><span itemprop="author"> - {% if contrib.creator_id %} - <a href="/creator/{{contrib.creator_id}}">{{ contrib.raw_name or 'unknown' }}</a> + {% if contrib.creator_id and contrib.creator and contrib.creator.display_name %} + <a href="/creator/{{contrib.creator_id}}">{{ contrib.creator.display_name }}</a> {% else %} {{ contrib.raw_name or '' }} {% endif %} - {% if contrib.surname %} + + {% if contrib.creator and contrib.creator.surname %} + <code> + ({{ contrib.creator.surname }}{% if contrib.creator.given_name %}, {{ contrib.creator.given_name }}{% endif %}) + </code> + {% elif contrib.surname %} <code> ({{ contrib.surname }}{% if contrib.given_name %}, {{ contrib.given_name }}{% endif %}) </code> diff --git a/python/fatcat_web/web_config.py b/python/fatcat_web/web_config.py index 5d2da830..3dba933d 100644 --- a/python/fatcat_web/web_config.py +++ b/python/fatcat_web/web_config.py @@ -22,6 +22,10 @@ class Config(object): FATCAT_DOMAIN = os.environ.get("FATCAT_DOMAIN", default="dev.fatcat.wiki") FATCAT_API_AUTH_TOKEN = os.environ.get("FATCAT_API_AUTH_TOKEN", default=None) FATCAT_API_HOST = os.environ.get("FATCAT_API_HOST", default="https://{}/v0".format(FATCAT_DOMAIN)) + public_host_default = f"https://{FATCAT_DOMAIN}/v0" + if FATCAT_DOMAIN == "dev.fatcat.wiki": + public_host_default = FATCAT_API_HOST + FATCAT_PUBLIC_API_HOST = os.environ.get("FATCAT_PUBLIC_API_HOST", default=public_host_default) # can set this to https://search.fatcat.wiki for some experimentation ELASTICSEARCH_BACKEND = os.environ.get("ELASTICSEARCH_BACKEND", default="http://localhost:9200") @@ -52,6 +56,11 @@ class Config(object): IA_XAUTH_CLIENT_ID = os.environ.get("IA_XAUTH_CLIENT_ID", default=None) IA_XAUTH_CLIENT_SECRET = os.environ.get("IA_XAUTH_CLIENT_SECRET", default=None) + # analytics; used in production + ENABLE_GOATCOUNTER = bool(os.environ.get("ENABLE_GOATCOUNTER", default=False)) + GOATCOUNTER_ENDPOINT = os.environ.get("GOATCOUNTER_ENDPOINT", default="https://goatcounter.fatcat.wiki/count") + GOATCOUNTER_SCRIPT_URL = os.environ.get("GOATCOUNTER_SCRIPT_URL", default="https://goatcounter.fatcat.wiki/count.js") + # controls granularity of "shadow_only" preservation category FATCAT_MERGE_SHADOW_PRESERVATION = os.environ.get("FATCAT_MERGE_SHADOW_PRESERVATION", default=False) diff --git a/python/tests/import_dblp.py b/python/tests/import_dblp.py index d6b5878d..340e6237 100644 --- a/python/tests/import_dblp.py +++ b/python/tests/import_dblp.py @@ -44,6 +44,12 @@ def test_dblp_importer(dblp_importer): # check that entity name mangling was fixed on import eg = dblp_importer.api.get_editgroup(eg.editgroup_id) release = dblp_importer.api.get_release(eg.edits.releases[0].ident) + for r_edit in eg.edits.releases: + release = dblp_importer.api.get_release(r_edit.ident) + #print(release.ext_ids.dblp) + if release.ext_ids.dblp == "conf/er/Norrie08": + break + assert release.ext_ids.dblp == "conf/er/Norrie08" assert release.contribs[0].raw_name == "Moira C. Norrie" assert release.contribs[1].raw_name == "Michael H. Böhlen" @@ -79,7 +85,10 @@ def test_dblp_container_importer(dblp_container_importer): # check that entity name mangling was fixed on import eg = dblp_container_importer.api.get_editgroup(eg.editgroup_id) - container = dblp_container_importer.api.get_container(eg.edits.containers[0].ident) + for c_edit in eg.edits.containers: + container = dblp_container_importer.api.get_container(c_edit.ident) + if container.issnl == "1877-3273": + break assert container.name == "Atlantis Thinking Machines" assert container.issnl == "1877-3273" assert container.container_type == "book-series" @@ -88,7 +97,7 @@ def test_dblp_container_importer(dblp_container_importer): last_index = dblp_container_importer.api.get_changelog(limit=1)[0].index output_tsv_map.seek(0) - print(output_tsv_map.read()) + #print(output_tsv_map.read()) output_tsv_map.seek(0) with open('tests/files/example_dblp_containers.json', 'r') as f: dblp_container_importer.reset() |