diff options
Diffstat (limited to 'python/fatcat_web')
-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 |
13 files changed, 70 insertions, 34 deletions
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) |