-
Notifications
You must be signed in to change notification settings - Fork 1
/
invenio.cfg
578 lines (504 loc) · 18.8 KB
/
invenio.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
"""
InvenioRDM settings for CaltechAUTHORS project.
This file was automatically generated by 'invenio-cli init'.
For the full list of settings and their values, see
https://inveniordm.docs.cern.ch/reference/configuration/.
"""
from datetime import datetime
import idutils
def _(x): # needed to avoid start time failure with lazy strings
return x
RATELIMIT_ENABLED = True
RATELIMIT_AUTHENTICATED_USER = "50000 per hour;900 per minute"
RATELIMIT_GUEST_USER = "30000 per hour;500 per minute"
# Flask
# =====
# See https://flask.palletsprojects.com/en/1.1.x/config/
# Define the value of the cache control header `max-age` returned by the server when serving
# public files. Files will be cached by the browser for the provided number of seconds.
# See flask documentation for more information:
# https://flask.palletsprojects.com/en/2.1.x/config/#SEND_FILE_MAX_AGE_DEFAULT
SEND_FILE_MAX_AGE_DEFAULT = 300
# Since HAProxy and Nginx route all requests no matter the host header
# provided, the allowed hosts variable is set to localhost. In production it
# should be set to the correct host and it is strongly recommended to only
# route correct hosts to the application.
APP_ALLOWED_HOSTS = ["authors.library.caltech.edu", "0.0.0.0", "localhost", "127.0.0.1"]
# Flask-SQLAlchemy
# ================
# See https://flask-sqlalchemy.palletsprojects.com/en/2.x/config/
# TODO: Set
SQLALCHEMY_DATABASE_URI = (
"postgresql+psycopg2://caltechauthors:caltechauthors@localhost/caltechauthors"
)
# Invenio-App
# ===========
# See https://invenio-app.readthedocs.io/en/latest/configuration.html
APP_DEFAULT_SECURE_HEADERS = {
"content_security_policy": {
"default-src": [
"'self'",
"data:", # for fonts
"'unsafe-inline'", # for inline scripts and styles
"blob:", # for pdf preview
# Add your own policies here (e.g. analytics)
],
},
"content_security_policy_report_only": False,
"content_security_policy_report_uri": None,
"force_file_save": False,
"force_https": True,
"force_https_permanent": False,
"frame_options": "sameorigin",
"frame_options_allow_from": None,
"session_cookie_http_only": True,
"session_cookie_secure": True,
"strict_transport_security": True,
"strict_transport_security_include_subdomains": True,
"strict_transport_security_max_age": 31556926, # One year in seconds
"strict_transport_security_preload": False,
}
# Flask-Babel
# ===========
# See https://python-babel.github.io/flask-babel/#configuration
# Default locale (language)
BABEL_DEFAULT_LOCALE = "en"
# Default time zone
BABEL_DEFAULT_TIMEZONE = "UTC"
# Invenio-I18N
# ============
# See https://invenio-i18n.readthedocs.io/en/latest/configuration.html
# Other supported languages (do not include BABEL_DEFAULT_LOCALE in list).
I18N_LANGUAGES = [
# ('de', _('German')),
# ('tr', _('Turkish')),
]
# Invenio-Theme
# =============
# See https://invenio-theme.readthedocs.io/en/latest/configuration.html
THEME_SITENAME = "CaltechAUTHORS"
# Frontpage title
THEME_FRONTPAGE_TITLE = "CaltechAUTHORS"
# Header logo
THEME_LOGO = "images/CaltechAUTHORS-by-Caltech-Library-blue-with-padding.svg"
THEME_TRACKINGCODE_TEMPLATE = './invenio_theme/trackingcode.html'
# Allow matomo endpoint in the CSP rules
APP_DEFAULT_SECURE_HEADERS['content_security_policy']['default-src'].append(
'https://cdn.matomo.cloud'
)
APP_DEFAULT_SECURE_HEADERS['content_security_policy']['default-src'].append(
'https://caltechlibrary.matomo.cloud'
)
# Includes Caltech Library and RAMP
THEME_GOOGLE_SITE_VERIFICATION = ['S9ahhSTJNJrGXH8CLzN9O29lYE5sbaFyCLkdCXHU24U','UqdiAS4yhbCtENKZBNgS0WPiAcMQFShAEjOhMChYmdM']
# Invenio-App-RDM
# ===============
# See https://invenio-app-rdm.readthedocs.io/en/latest/configuration.html
# Instance's theme entrypoint file. Path relative to the ``assets/`` folder.
INSTANCE_THEME_FILE = "./less/theme.less"
# Invenio-Files-Rest
# ==================
FILES_REST_STORAGE_FACTORY = "invenio_s3.s3fs_storage_factory"
# Invenio-S3
# ==========
S3_ENDPOINT_URL = "https://s3.us-west-2.amazonaws.com/"
S3_REGION_NAME = "us-west-2"
# Allow S3 endpoint in the CSP rules
APP_DEFAULT_SECURE_HEADERS["content_security_policy"]["default-src"].append(
S3_ENDPOINT_URL
)
# Invenio-Records-Resources
# =========================
# See https://github.com/inveniosoftware/invenio-records-resources/blob/master/invenio_records_resources/config.py
SITE_UI_URL = "https://authors.library.caltech.edu"
SITE_API_URL = "https://authors.library.caltech.edu/api"
APP_RDM_DEPOSIT_FORM_DEFAULTS = {
"publication_date": lambda: datetime.now().strftime("%Y-%m-%d"),
"rights": [
{
"id": "default",
"title": "No commercial reproduction, distribution, display or performance rights in this work are provided.",
}
],
"publisher": "Caltech Library",
"resource_type": {
"title": {"de": "Zeitschriftenartikel", "en": "Journal Article"},
"id": "publication-article",
},
"languages": [{"id": "eng"}],
}
# See https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/config.py
APP_RDM_DEPOSIT_FORM_AUTOCOMPLETE_NAMES = "search" # "search_only" or "off"
RDM_CITATION_STYLES = [
("chicago-author-date", _("Chicago")),
("modern-language-association", _("MLA")),
("ieee", _("IEEE")),
("apa", _("APA")),
("american-chemical-society", _("ACS")),
("science", _("Science")),
("bibtex", _("Bibtex")),
]
RDM_CITATION_STYLES_DEFAULT = "chicago-author-date"
# Invenio-RDM-Records
# ===================
# See https://inveniordm.docs.cern.ch/customize/dois/
DATACITE_ENABLED = True
DATACITE_USERNAME = "CALTECH.LIBRARY"
DATACITE_PREFIX = "10.7907"
DATACITE_TEST_MODE = False
DATACITE_DATACENTER_SYMBOL = ""
RDM_PERSISTENT_IDENTIFIERS = {
# DOI automatically removed if DATACITE_ENABLED is False.
"doi": {
"providers": ["datacite", "external"],
"required": False,
"label": _("DOI"),
"validator": idutils.is_doi,
"normalizer": idutils.normalize_doi,
},
"oai": {
"providers": ["oai"],
"required": True,
"label": _("OAI"),
},
}
"""The configured persistent identifiers for records."""
# Authentication - Invenio-Accounts and Invenio-OAuthclient
# =========================================================
# See: https://inveniordm.docs.cern.ch/customize/authentication/
# Invenio-Accounts
# ----------------
# See https://github.com/inveniosoftware/invenio-accounts/blob/master/invenio_accounts/config.py
ACCOUNTS_LOCAL_LOGIN_ENABLED = True # enable local login
SECURITY_REGISTERABLE = False # local login: allow users to register
SECURITY_RECOVERABLE = True # local login: allow users to reset the password
SECURITY_CHANGEABLE = True # local login: allow users to change psw
SECURITY_CONFIRMABLE = True # local login: users can confirm e-mail address
SECURITY_LOGIN_WITHOUT_CONFIRMATION = (
False # require users to confirm email before being able to login
)
ACCOUNTS_DEFAULT_EMAIL_VISIBILITY= "public"
ACCOUNTS_DEFAULT_USER_VISIBILITY = "public"
# Invenio-OAuthclient
# -------------------
# See https://github.com/inveniosoftware/invenio-oauthclient/blob/master/invenio_oauthclient/config.py
OAUTHCLIENT_REMOTE_APPS = {} # configure external login providers
from invenio_oauthclient.views.client import auto_redirect_login
ACCOUNTS_LOGIN_VIEW_FUNCTION = (
auto_redirect_login # autoredirect to external login if enabled
)
OAUTHCLIENT_AUTO_REDIRECT_TO_EXTERNAL_LOGIN = False # autoredirect to external login
# Invenio-UserProfiles
# --------------------
USERPROFILES_READ_ONLY = (
False # allow users to change profile info (name, email, etc...)
)
# OAI-PMH
# =======
# See https://github.com/inveniosoftware/invenio-oaiserver/blob/master/invenio_oaiserver/config.py
OAISERVER_ID_PREFIX = "authors.library.caltech.edu"
"""The prefix that will be applied to the generated OAI-PMH ids."""
# Invenio-Search
# --------------
SEARCH_INDEX_PREFIX = "caltechauthors-"
from invenio_rdm_records.config import RDM_SORT_OPTIONS
RDM_SORT_OPTIONS.update({
"publication": dict(
title=_('Publication date'),
fields=['-metadata.publication_date'],
),
"newest": dict(
title=_("Recently added"),
fields=["-created"],
),
})
RDM_SEARCH = {
"facets": ["resource_type", "subject", "access_status", "file_type" ],
"sort": [
"bestmatch",
"newest",
"publication",
"version",
"mostviewed",
"mostdownloaded",
],
}
SECURITY_EMAIL_SENDER = "repositories@library.caltech.edu"
MAIL_SERVER = "smtp.gmail.com"
MAIL_USERNAME = "repositories@library.caltech.edu"
MAIL_USE_SSL = True
MAIL_PORT = 465
SECURITY_EMAIL_SUBJECT_PASSWORD_RESET = "Reset your password for CaltechAUTHORS"
"""Email subject for account registration emails."""
APP_RDM_ADMIN_EMAIL_RECIPIENT = "dld-dev@library.caltech.edu"
MAIL_SUPPRESS_SEND = False
# Customize identifiers
# --------------------
def always_valid(identifier):
"""Gives every identifier as valid."""
return True
RDM_RECORDS_IDENTIFIERS_SCHEMES = {
"ark": {"label": _("ARK"), "validator": idutils.is_ark, "datacite": "ARK"},
"arxiv": {"label": _("arXiv"), "validator": idutils.is_arxiv, "datacite": "arXiv"},
"bibcode": {
"label": _("Bibcode"),
"validator": idutils.is_ads,
"datacite": "bibcode",
},
"doi": {"label": _("DOI"), "validator": idutils.is_doi, "datacite": "DOI"},
"ean13": {"label": _("EAN13"), "validator": idutils.is_ean13, "datacite": "EAN13"},
"eissn": {"label": _("EISSN"), "validator": idutils.is_issn, "datacite": "EISSN"},
"handle": {
"label": _("Handle"),
"validator": idutils.is_handle,
"datacite": "Handle",
},
"igsn": {"label": _("IGSN"), "validator": always_valid, "datacite": "IGSN"},
"isbn": {"label": _("ISBN"), "validator": idutils.is_isbn, "datacite": "ISBN"},
"issn": {"label": _("ISSN"), "validator": idutils.is_issn, "datacite": "ISSN"},
"istc": {"label": _("ISTC"), "validator": idutils.is_istc, "datacite": "ISTC"},
"lissn": {"label": _("LISSN"), "validator": idutils.is_issn, "datacite": "LISSN"},
"lsid": {"label": _("LSID"), "validator": idutils.is_lsid, "datacite": "LSID"},
"pmcid": {"label": _("PMCID"), "validator": idutils.is_pmcid, "datacite": "PMID"},
"pmid": {"label": _("PMID"), "validator": idutils.is_pmid, "datacite": "PMID"},
"purl": {"label": _("PURL"), "validator": idutils.is_purl, "datacite": "PURL"},
"upc": {"label": _("UPC"), "validator": always_valid, "datacite": "UPC"},
"url": {"label": _("URL"), "validator": idutils.is_url, "datacite": "URL"},
"urn": {"label": _("URN"), "validator": idutils.is_urn, "datacite": "URN"},
"w3id": {"label": _("W3ID"), "validator": always_valid, "datacite": "w3id"},
"eprintid": {
"label": _("Eprint ID"),
"validator": always_valid,
"datacite": "Eprint ID",
},
"resolverid": {
"label": _("Resolver ID"),
"validator": always_valid,
"datacite": "Resolver ID",
},
"patentnumber": {
"label": _("Patent Number"),
"validator": always_valid,
"datacite": "Patent Number",
},
"patentnumber": {
"label": _("Patent Number"),
"validator": always_valid,
"datacite": "Patent Number",
},
"ostiid": {
"label": _("OSTI ID"),
"validator": idutils.is_pmid,
"datacite": "OSTI ID",
},
}
"""These are used for main, alternate and related identifiers."""
RDM_RECORDS_PERSONORG_SCHEMES = {
"orcid": {"label": _("ORCID"), "validator": idutils.is_orcid, "datacite": "ORCID"},
"isni": {"label": _("ISNI"), "validator": idutils.is_isni, "datacite": "ISNI"},
"gnd": {"label": _("GND"), "validator": idutils.is_gnd, "datacite": "GND"},
"ror": {"label": _("ROR"), "validator": idutils.is_ror, "datacite": "ROR"},
"clpid": {
"label": _("Caltech Library Person ID"),
"validator": idutils.is_clpid,
"datacite": "CLPID",
},
}
VOCABULARIES_NAMES_SCHEMES = {
"orcid": {"label": _("ORCID"), "validator": idutils.is_orcid, "datacite": "ORCID"},
"isni": {"label": _("ISNI"), "validator": idutils.is_isni, "datacite": "ISNI"},
"gnd": {"label": _("GND"), "validator": idutils.is_gnd, "datacite": "GND"},
"ror": {"label": _("ROR"), "validator": idutils.is_ror, "datacite": "ROR"},
"clpid": {
"label": _("Caltech Library Person ID"),
"validator": idutils.is_clpid,
"datacite": "CLPID",
},
}
# Enable featured communities
COMMUNITIES_ADMINISTRATION_DISABLED = False
# Basic homepage customization
THEME_SHOW_FRONTPAGE_INTRO_SECTION = False
from invenio_i18n import lazy_gettext as _
from invenio_rdm_records.contrib.imprint import (
IMPRINT_CUSTOM_FIELDS,
IMPRINT_CUSTOM_FIELDS_UI,
IMPRINT_NAMESPACE,
)
from invenio_rdm_records.contrib.journal import (
JOURNAL_CUSTOM_FIELDS,
JOURNAL_CUSTOM_FIELDS_UI,
JOURNAL_NAMESPACE,
)
from invenio_rdm_records.contrib.thesis import (
THESIS_CUSTOM_FIELDS,
THESIS_CUSTOM_FIELDS_UI,
THESIS_NAMESPACE,
)
from invenio_rdm_records.contrib.meeting import (
MEETING_CUSTOM_FIELDS,
MEETING_CUSTOM_FIELDS_UI,
MEETING_NAMESPACE,
)
from invenio_vocabularies.services.custom_fields import VocabularyCF
from invenio_records_resources.services.custom_fields import TextCF
RDM_NAMESPACES = {
**JOURNAL_NAMESPACE,
**IMPRINT_NAMESPACE,
**THESIS_NAMESPACE,
**MEETING_NAMESPACE,
"caltech": "https://library.caltech.edu",
}
# Combine custom fields
RDM_CUSTOM_FIELDS = [
# journal
*JOURNAL_CUSTOM_FIELDS,
# meeting
*MEETING_CUSTOM_FIELDS,
# imprint
*IMPRINT_CUSTOM_FIELDS,
# thesis
*THESIS_CUSTOM_FIELDS,
# caltech groups
VocabularyCF(
name="caltech:groups",
dump_options=True,
vocabulary_id="caltechgroups",
multiple=True,
),
# Custom series and volume/issue
TextCF(name="caltech:series"),
TextCF(name="caltech:series_number"),
TextCF(name="caltech:other_num_name"),
TextCF(name="caltech:other_num_id"),
# caltech journal list
VocabularyCF(
name="caltech:journals", dump_options=False, vocabulary_id="caltechjournals"
),
VocabularyCF(
name="caltech:publication_status", dump_options=True, vocabulary_id="publicationstatus",multiple=True
),
]
# Hide "meeting" section in the landing page
MEETING_CUSTOM_FIELDS_UI["hide_from_landing_page"] = True
# Create a "Publishing Information" section in the deposit form and add multiple fields
RDM_CUSTOM_FIELDS_UI = [
{
"section": _("Publishing information"),
"hide_from_landing_page": True,
"fields": [
# journal
*JOURNAL_CUSTOM_FIELDS_UI["fields"],
# imprint
*IMPRINT_CUSTOM_FIELDS_UI["fields"],
# thesis
*THESIS_CUSTOM_FIELDS_UI["fields"],
],
},
{
"section": _("Caltech Custom Metadata"),
"fields": [
dict(
field="caltech:groups",
ui_widget="Dropdown",
props=dict(
label="Caltech groups",
placeholder="Search for a Caltech group by name or identifier...",
icon="users",
description="The group or groups associated with record.",
autocompleteFrom="/api/vocabularies/caltechgroups",
search=True,
multiple=True,
clearable=True,
),
),
dict(
field="caltech:series",
ui_widget="Input",
props=dict(
label="Series Name",
placeholder="Technical Report Series",
icon="archive",
description="The name of a series.",
),
),
dict(
field="caltech:series_number",
ui_widget="Input",
props=dict(
label="Series Volume or Issue Number",
placeholder="5",
description="The volume or issue number in a series.",
),
),
dict(
field="caltech:other_num_name",
ui_widget="Input",
props=dict(
label="Other Numbering System Name",
placeholder="LIGO",
icon="calculator",
description="A author-assigned or other numbering system used for the item.",
),
),
dict(
field="caltech:other_num_id",
ui_widget="Input",
props=dict(
label="Other Numbering System Identifier",
placeholder="L123-456",
description="The identifier of this item in an author-assigned or other numbering system.",
),
),
dict(
field="caltech:journals",
ui_widget="AutocompleteDropdown",
props=dict(
label="Journal name",
placeholder="Search for a Journal on the CaltechAUTHORS journal list...",
icon="address book",
description="If you select a journal listed here, you do not need to complete the Journal, ISSN, and Publisher fields.",
autocompleteFrom="/api/vocabularies/caltechjournals",
search=True,
multiple=False,
clearable=True,
),
),
dict(
field="caltech:publication_status",
ui_widget="Dropdown",
props=dict(
label="Publication Status",
placeholder="Add publication status tags...",
icon="address book",
autocompleteFrom="/api/vocabularies/publicationstatus",
search=True,
multiple=True,
clearable=True,
),
),
],
},
# meeting
MEETING_CUSTOM_FIELDS_UI,
]
import sentry_sdk
from flask import Flask
from sentry_sdk.integrations.flask import FlaskIntegration
sentry_sdk.init(
dsn="https://62229a4fbf83a2bd327820cd1c9fffe2@o4505830343245824.ingest.sentry.io/4505830344818688",
integrations=[FlaskIntegration()],
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production.
traces_sample_rate=0.01,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=0.01,
)
OAISERVER_RESUMPTION_TOKEN_EXPIRE_TIME = 1 * 120
OAISERVER_PAGE_SIZE = 100
OAISERVER_ADMIN_EMAILS = [
"coda@library.caltech.edu",
]