diff --git a/src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.html b/src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.html new file mode 100644 index 0000000000..e496676847 --- /dev/null +++ b/src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.html @@ -0,0 +1,28 @@ +
+ +
+ + +
+ +
+ + +
+ + {{ variant === 'full' && showDisclaimer ? ('item.page.cc.license.disclaimer' | translate) : '' }} + {{ name }} + +
+
+
+
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 new file mode 100644 index 0000000000..5d19fe4b4e --- /dev/null +++ b/src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts @@ -0,0 +1,73 @@ +import { + NgClass, + NgIf, + NgStyle, +} from '@angular/common'; +import { + Component, + Input, + OnInit, +} from '@angular/core'; +import { TranslateModule } from '@ngx-translate/core'; +import { Item } from 'src/app/core/shared/item.model'; +import { MetadataFieldWrapperComponent } from 'src/app/shared/metadata-field-wrapper/metadata-field-wrapper.component'; + +@Component({ + selector: 'ds-item-page-cc-license-field', + templateUrl: './item-page-cc-license-field.component.html', + standalone: true, + imports: [NgIf, NgClass, NgStyle, TranslateModule, MetadataFieldWrapperComponent], +}) +/** + * Displays the item's Creative Commons license image in it's simple item page + */ +export class ItemPageCcLicenseFieldComponent implements OnInit { + /** + * The item to display the CC license image for + */ + @Input() item: Item; + + /** + * '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() variant?: 'small' | 'full' = 'small'; + + /** + * Filed name containing the CC license URI, as configured in the back-end, in the 'dspace.cfg' file, propertie + * 'cc.license.uri' + */ + @Input() ccLicenseUriField? = 'dc.rights.uri'; + + /** + * Filed name containing the CC license name, as configured in the back-end, in the 'dspace.cfg' file, propertie + * 'cc.license.name' + */ + @Input() ccLicenseNameField? = 'dc.rights'; + + /** + * Shows the CC license name with the image. Always show if image fails to load + */ + @Input() showName? = true; + + /** + * Shows the disclaimer in the 'full' variant of the component + */ + @Input() showDisclaimer? = true; + + uri: string; + name: string; + showImage = true; + imgSrc: string; + + ngOnInit() { + this.uri = this.item.firstMetadataValue(this.ccLicenseUriField); + this.name = this.item.firstMetadataValue(this.ccLicenseNameField); + + // Extracts the CC license code from the URI + const regex = /.*creativecommons.org\/(licenses|publicdomain)\/([^/]+)/gm; + const matches = regex.exec(this.uri ?? '') ?? []; + const ccCode = matches.length > 2 ? matches[2] : null; + this.imgSrc = ccCode ? `assets/images/cc-licenses/${ccCode}.png` : null; + } +} diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index e79294d4eb..864547636d 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -6657,4 +6657,8 @@ "search.filters.filter.notifyEndorsement.placeholder": "Notify Endorsement", "search.filters.filter.notifyEndorsement.label": "Search Notify Endorsement", + + "item.page.cc.license.title": "Creative Commons license", + + "item.page.cc.license.disclaimer": "Except where otherwised noted, this item's license is described as", } diff --git a/src/assets/images/cc-licenses/by-nc-nd.png b/src/assets/images/cc-licenses/by-nc-nd.png new file mode 100644 index 0000000000..5a8dbd0652 Binary files /dev/null and b/src/assets/images/cc-licenses/by-nc-nd.png differ diff --git a/src/assets/images/cc-licenses/by-nc-sa.png b/src/assets/images/cc-licenses/by-nc-sa.png new file mode 100644 index 0000000000..b9a55533c0 Binary files /dev/null and b/src/assets/images/cc-licenses/by-nc-sa.png differ diff --git a/src/assets/images/cc-licenses/by-nc.png b/src/assets/images/cc-licenses/by-nc.png new file mode 100644 index 0000000000..25e284099a Binary files /dev/null and b/src/assets/images/cc-licenses/by-nc.png differ diff --git a/src/assets/images/cc-licenses/by-nd.png b/src/assets/images/cc-licenses/by-nd.png new file mode 100644 index 0000000000..fc3d26789a Binary files /dev/null and b/src/assets/images/cc-licenses/by-nd.png differ diff --git a/src/assets/images/cc-licenses/by-sa.png b/src/assets/images/cc-licenses/by-sa.png new file mode 100644 index 0000000000..8770732928 Binary files /dev/null and b/src/assets/images/cc-licenses/by-sa.png differ diff --git a/src/assets/images/cc-licenses/by.png b/src/assets/images/cc-licenses/by.png new file mode 100644 index 0000000000..c8473a2478 Binary files /dev/null and b/src/assets/images/cc-licenses/by.png differ diff --git a/src/assets/images/cc-licenses/zero.png b/src/assets/images/cc-licenses/zero.png new file mode 100644 index 0000000000..4ff09a0bb2 Binary files /dev/null and b/src/assets/images/cc-licenses/zero.png differ