diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-07-14 18:38:30 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-07-14 18:50:29 -0700 |
commit | 8bf05b624c228944c4337ce57d0efa9c5ff82dcf (patch) | |
tree | e9e35891fc2735565459e5c1a0703b1d70c3a6e2 | |
parent | b53ea00def23fcff27d0bffa8e94376a56538b97 (diff) | |
download | fatcat-8bf05b624c228944c4337ce57d0efa9c5ff82dcf.tar.gz fatcat-8bf05b624c228944c4337ce57d0efa9c5ff82dcf.zip |
insert camp-local PDF URL in release entity
-rw-r--r-- | python/fatcat_web/entity_helpers.py | 6 | ||||
-rw-r--r-- | python/fatcat_web/templates/release_view.html | 4 | ||||
-rw-r--r-- | python/fatcat_web/web_config.py | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/python/fatcat_web/entity_helpers.py b/python/fatcat_web/entity_helpers.py index ab5eaea8..0a6b97f2 100644 --- a/python/fatcat_web/entity_helpers.py +++ b/python/fatcat_web/entity_helpers.py @@ -4,7 +4,7 @@ from fatcat_client.rest import ApiException from fatcat_tools.transforms import * from fatcat_web import app, api from fatcat_web.search import get_elastic_container_stats -from fatcat_web.hacks import strip_extlink_xml, wayback_suffix +from fatcat_web.hacks import strip_extlink_xml, wayback_suffix, get_camp_pdf_path def enrich_container_entity(entity): if entity.state in ('redirect', 'deleted'): @@ -75,6 +75,10 @@ def enrich_release_entity(entity): if entity.abstracts: if 'latex' in entity.abstracts[0].mimetype: entity.abstracts.reverse() + if entity.files: + camp_pdf_path = get_camp_pdf_path(entity) + if camp_pdf_path: + entity.camp_pdf_url = app.config['CAMP_PDF_URI'] + camp_pdf_path return entity def enrich_work_entity(entity): diff --git a/python/fatcat_web/templates/release_view.html b/python/fatcat_web/templates/release_view.html index 52f32fdc..fdb9cadc 100644 --- a/python/fatcat_web/templates/release_view.html +++ b/python/fatcat_web/templates/release_view.html @@ -250,6 +250,10 @@ <span class="ui top attached fluid huge grey button"><i class="file cross icon"></i>No Full Text Available</span> {% endif %} +{% if entity.camp_pdf_url %} + <a href="{{ entity.camp_pdf_url }}" class="ui top attached fluid huge yellow button"><i class="tree icon"></i>Local Copy</a> +{% endif %} + {% if release.release_type or release.release_stage or release.release_year %} <div class="ui segment attached"> <b>Type</b> <code>{{ release.release_type or 'unknown' }}</code><br> diff --git a/python/fatcat_web/web_config.py b/python/fatcat_web/web_config.py index e681b397..22998de3 100644 --- a/python/fatcat_web/web_config.py +++ b/python/fatcat_web/web_config.py @@ -65,6 +65,8 @@ class Config(object): SESSION_COOKIE_SAMESITE = 'Lax' PERMANENT_SESSION_LIFETIME = 2678400 # 31 days, in seconds + CAMP_PDF_URI = os.environ.get("CAMP_PDF_URI", default='http://localhost') + try: GIT_RELEASE = raven.fetch_git_sha('..') except Exception as e: |