From 8bf05b624c228944c4337ce57d0efa9c5ff82dcf Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 14 Jul 2019 18:38:30 -0700 Subject: insert camp-local PDF URL in release entity --- python/fatcat_web/entity_helpers.py | 6 +++++- python/fatcat_web/templates/release_view.html | 4 ++++ python/fatcat_web/web_config.py | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'python') 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 @@ No Full Text Available {% endif %} +{% if entity.camp_pdf_url %} + Local Copy +{% endif %} + {% if release.release_type or release.release_stage or release.release_year %}
Type  {{ release.release_type or 'unknown' }}
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: -- cgit v1.2.3