From 9f98a70dc8635f2a29946fbb2ca399f23cfce714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20G=C3=B3mez?= Date: Thu, 10 Oct 2024 04:33:34 +0200 Subject: [PATCH] Reformat some code to ease code review --- .../item-page-cc-license-field.component.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts b/src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts index 2548443f01f..d9466ba3b17 100644 --- a/src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts +++ b/src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts @@ -38,21 +38,21 @@ export class ItemPageCcLicenseFieldComponent implements OnInit { */ @Input() item: Item; - /** - * Field name containing the CC license URI + /** + * 'full' variant shows image, a disclaimer (optional) and name (always), better for the item page content. + * 'small' variant shows image and name (optional), better for the item page sidebar */ - @Input() ccLicenseUriField?; + @Input() variant?: 'small' | 'full' = this.appConfig.ccLicense.variant; - /** + /** * Field name containing the CC license URI */ - @Input() ccLicenseNameField?; + @Input() ccLicenseUriField?; /** - * 'full' variant shows image, a disclaimer (optional) and name (always), better for the item page content. - * 'small' variant shows image and name (optional), better for the item page sidebar + * Field name containing the CC license URI */ - @Input() variant?: 'small' | 'full' = this.appConfig.ccLicense.variant; + @Input() ccLicenseNameField?; /** * Shows the CC license name with the image. Always show if image fails to load @@ -64,6 +64,11 @@ export class ItemPageCcLicenseFieldComponent implements OnInit { */ @Input() showDisclaimer? = this.appConfig.ccLicense.showDisclaimer; + /** + * Expression used to detect (and parse) whether a URI denotes a CC license + */ + public static readonly regex = /.*creativecommons.org\/(licenses|publicdomain)\/([^/]+)/gm; + uri: string; name: string; showImage = true; @@ -76,7 +81,6 @@ export class ItemPageCcLicenseFieldComponent implements OnInit { } ngOnInit() { - const regex = /.*creativecommons.org\/(licenses|publicdomain)\/([^/]+)/gm; this.configService.findByPropertyName('cc.license.uri').pipe( getFirstCompletedRemoteData(),