forked from MapComplete/MapComplete
		
	Add link to wikipedia-image in the attribution box, fix #1049
This commit is contained in:
		
							parent
							
								
									efd1f5467b
								
							
						
					
					
						commit
						c09b437d9a
					
				
					 3 changed files with 16 additions and 3 deletions
				
			
		|  | @ -8,4 +8,5 @@ export class LicenseInfo { | |||
|     copyrighted: boolean = false; | ||||
|     credit: string = ""; | ||||
|     description: string = ""; | ||||
|     informationLocation: URL = undefined | ||||
| } | ||||
|  | @ -153,6 +153,7 @@ export class WikimediaImageProvider extends ImageProvider { | |||
|         licenseInfo.licenseShortName = license.LicenseShortName?.value; | ||||
|         licenseInfo.credit = license.Credit?.value; | ||||
|         licenseInfo.description = license.ImageDescription?.value; | ||||
|         licenseInfo.informationLocation = new URL("https://en.wikipedia.org/wiki/"+pageInfo.title) | ||||
|         return licenseInfo; | ||||
| 
 | ||||
|     } | ||||
|  |  | |||
|  | @ -2,10 +2,14 @@ import Combine from "../Base/Combine"; | |||
| import Translations from "../i18n/Translations"; | ||||
| import BaseUIElement from "../BaseUIElement"; | ||||
| import {VariableUiElement} from "../Base/VariableUIElement"; | ||||
| import {Store, UIEventSource} from "../../Logic/UIEventSource"; | ||||
| import {Store} from "../../Logic/UIEventSource"; | ||||
| import {LicenseInfo} from "../../Logic/ImageProviders/LicenseInfo"; | ||||
| import {FixedUiElement} from "../Base/FixedUiElement"; | ||||
| import Link from "../Base/Link"; | ||||
| 
 | ||||
| /** | ||||
|  * Small box in the bottom left of an image, e.g. the image in a popup | ||||
|  */ | ||||
| export default class Attribution extends VariableUiElement { | ||||
| 
 | ||||
|     constructor(license: Store<LicenseInfo>, icon: BaseUIElement, date?: Date) { | ||||
|  | @ -18,11 +22,18 @@ export default class Attribution extends VariableUiElement { | |||
|                     return undefined | ||||
|                 } | ||||
| 
 | ||||
|                 let title = undefined; | ||||
|                 if (license?.title) { | ||||
|                     title = Translations.W(license?.title).SetClass("block") | ||||
|                     if (license.informationLocation) { | ||||
|                         title = new Link(title, license.informationLocation.href, true) | ||||
|                     } | ||||
|                 } | ||||
|                 return new Combine([ | ||||
|                     icon?.SetClass("block left").SetStyle("height: 2em; width: 2em; padding-right: 0.5em;"), | ||||
| 
 | ||||
|                     new Combine([ | ||||
|                         Translations.W(license?.title).SetClass("block"), | ||||
|                         title, | ||||
|                         Translations.W(license?.artist ?? "").SetClass("block font-bold"), | ||||
|                         Translations.W(license?.license ?? license?.licenseShortName), | ||||
|                         date === undefined ? undefined : new FixedUiElement(date.toLocaleDateString()) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue