oarepo_config.ui
oarepo_config.ui
Configuration for the repository UI.
CSP
dataclass
Content Security Policy configuration.
Source code in oarepo_config/ui.py
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 | |
default_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Fallback for any directive below that is left unset.
script_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for JavaScript.
script_src_elem: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for <script> elements. Falls back to script_src.
script_src_attr: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for inline event handler attributes. Falls back to script_src.
style_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for CSS.
style_src_elem: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for <style> elements. Falls back to style_src.
style_src_attr: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for inline style attributes. Falls back to style_src.
img_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for images.
font_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for fonts.
connect_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for fetch/XHR/WebSocket/EventSource calls (e.g. REST API endpoints).
object_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for <object>, <embed> and <applet> plugins.
media_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for <audio>, <video> and <embed> media.
frame_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for nested browsing contexts (<iframe>).
frame_ancestors: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Sources allowed to embed this page; the modern replacement for X-Frame-Options.
child_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for nested browsing contexts and workers.
worker_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for Web Workers.
manifest_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for the application manifest.
prefetch_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources that may be prefetched.
form_action: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid targets for <form> submissions.
base_uri: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for the document's <base> element.
report_to: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Report-To group name(s) to send CSP reports to; the modern replacement for report_uri.
report_uri: str | None = None
class-attribute
instance-attribute
URL to send CSP violation reports to.
report_only: bool = False
class-attribute
instance-attribute
Report violations without enforcing the policy. Requires report_uri.
apply_defaults(headers: dict[str, Any]) -> dict[str, Any]
Resolve this policy against the content_security_policy already in headers.
Directives set here are merged with the sources already configured for
them (or, lacking those, with the sources of the directive they'd fall
back to, e.g. default-src for connect_src), so that setting one
directive doesn't silently drop defaults the app still needs. Unset
directives keep the configured value as-is. Same for report_uri,
report_only.
The result replaces the CSP keys in headers rather than merging into
them: headers.update(csp.apply_defaults(headers)).
Raises:
| Type | Description |
|---|---|
ValueError
|
If report-only mode ends up enabled without any
|
Source code in oarepo_config/ui.py
configure_ui(code: str = 'myrepo', name: str | Any = 'My Repository', subtitle: str = '', description: str = '', support_contact: str = '', keywords: str = '', use_default_frontpage: bool = False, show_frontpage_intro: bool = True, analytics: str | bool = False, languages: tuple[tuple[str, str], ...] = (('en', 'English'),), csp: CSP | None = None) -> None
Set up the repository's branding, name and general look-and-feel.
Configures what visitors see: the repository's name and description shown in the browser tab/search results/front page, the theme, the page layout templates, and (optionally) analytics tracking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
A short, technical, all-lowercase identifier for this
repository (e.g. |
'myrepo'
|
name
|
str | Any
|
The repository's display name, shown in the browser title
and on the front page, e.g. |
'My Repository'
|
subtitle
|
str
|
A short subtitle/tagline shown next to the name. |
''
|
description
|
str
|
A longer description of the repository, used for SEO and on the front page. |
''
|
support_contact
|
str
|
Contact information (e.g. an e-mail address) shown to users who need help. |
''
|
keywords
|
str
|
Keywords describing the repository's content, used for SEO. |
''
|
use_default_frontpage
|
bool
|
Whether to use Invenio's generic front
page. Most repositories provide a custom front page, so this
defaults to |
False
|
show_frontpage_intro
|
bool
|
Whether to show the introductory text section on the front page. |
True
|
analytics
|
str | bool
|
Set to |
False
|
languages
|
tuple[tuple[str, str], ...]
|
Extra UI languages to offer, as a tuple of
|
(('en', 'English'),)
|
csp
|
CSP | None
|
Content Security Policy configuration. Only the sources passed
here are recorded; the ones the deployment already allows (set up
by |
None
|
Should be called after configure_generic_parameters (it
builds on settings that function prepares) and before
configure_oai (which needs the repository name set here).
Example
Invenio configuration variables set, grouped by area:
Versioning
* DEPLOYMENT_VERSION
Theme & security
* APP_THEME
* APP_DEFAULT_SECURE_HEADERS - extends the value prepared by
configure_generic_parameters.
Page layout templates
* INSTANCE_THEME_FILE
* BASE_TEMPLATE, ADMINISTRATION_THEME_BASE_TEMPLATE,
COVER_TEMPLATE
* THEME_CSS_TEMPLATE, THEME_JAVASCRIPT_TEMPLATE
* HEADER_TEMPLATE, THEME_HEADER_TEMPLATE,
THEME_HEADER_LOGIN_TEMPLATE, THEME_FOOTER_TEMPLATE
* THEME_TRACKINGCODE_TEMPLATE, THEME_FRONTPAGE_TEMPLATE
* SETTINGS_TEMPLATE, SEARCH_UI_SEARCH_TEMPLATE
Analytics
* MATOMO_ANALYTICS_TEMPLATE, MATOMO_ANALYTICS_URL,
MATOMO_ANALYTICS_SITE_ID - only if analytics="matomo"
and this is not a local-development deployment.
Branding
* THEME_FRONTPAGE, THEME_LOGO, THEME_FRONTPAGE_LOGO
* THEME_SITENAME, THEME_FRONTPAGE_TITLE,
THEME_SHOW_FRONTPAGE_INTRO_SECTION
Repository metadata (SEO & front page)
* REPOSITORY_NAME, REPOSITORY_DESCRIPTION,
REPOSITORY_SUPPORT_CONTACT, REPOSITORY_SUBTITLE,
REPOSITORY_KEYWORDS
Build pipeline
* JAVASCRIPT_PACKAGES_MANAGER, ASSETS_BUILDER,
WEBPACKEXT_NPM_PKG_CLS, WEBPACKEXT_PROJECT
Records & deposit UI
* RECORDS_UI_ENDPOINTS,
APP_RDM_DEPOSIT_NG_FILES_UI_ENABLED,
DASHBOARD_RECORD_CREATE_URL
* APP_RDM_DETAIL_SIDE_BAR_TEMPLATES
Search UI
* THEME_SEARCH_ENDPOINT, SEARCH_UI_SEARCH_VIEW
Source code in oarepo_config/ui.py
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 | |