diff --git a/src/component/AttributionComponent.ts b/src/component/AttributionComponent.ts index 5875a40d..7fc483b9 100644 --- a/src/component/AttributionComponent.ts +++ b/src/component/AttributionComponent.ts @@ -4,11 +4,18 @@ import * as vd from "virtual-dom"; import {Subscription} from "rxjs/Subscription"; -import {Container, Navigator} from "../Viewer"; +import { + ComponentService, + Component, + IComponentConfiguration, +} from "../Component"; import {Node} from "../Graph"; - -import {ComponentService, Component, IComponentConfiguration} from "../Component"; import {IVNodeHash} from "../Render"; +import {Urls} from "../Utils"; +import { + Container, + Navigator, +} from "../Viewer"; export class AttributionComponent extends Component { public static componentName: string = "attribution"; @@ -37,13 +44,13 @@ export class AttributionComponent extends Component { private _getAttributionNode(username: string, key: string): vd.VNode { return vd.h("div.Attribution", {}, [ - vd.h("a", {href: `https://www.mapillary.com/app/user/${username}`, + vd.h("a", {href: Urls.exporeUser(username), target: "_blank", textContent: `@${username}`, }, []), vd.h("span", {textContent: "|"}, []), - vd.h("a", {href: `https://www.mapillary.com/app/?pKey=${key}&focus=photo`, + vd.h("a", {href: Urls.exporeImage(key), target: "_blank", textContent: "mapillary.com", }, diff --git a/src/component/CoverComponent.ts b/src/component/CoverComponent.ts index 92ce7235..1da37b44 100644 --- a/src/component/CoverComponent.ts +++ b/src/component/CoverComponent.ts @@ -8,19 +8,20 @@ import "rxjs/add/operator/filter"; import "rxjs/add/operator/map"; import "rxjs/add/operator/withLatestFrom"; -import {Node} from "../Graph"; -import { - Container, - Navigator, -} from "../Viewer"; import { CoverState, ICoverConfiguration, ComponentService, Component, } from "../Component"; - +import {Node} from "../Graph"; import {IVNodeHash} from "../Render"; +import {Urls} from "../Utils"; +import { + Container, + ImageSize, + Navigator, +} from "../Viewer"; export class CoverComponent extends Component { public static componentName: string = "cover"; @@ -81,14 +82,13 @@ export class CoverComponent extends Component { return vd.h(cover, [ this._getCoverBackgroundVNode(conf), vd.h("button.CoverButton", { onclick: (): void => { this.configure({ state: CoverState.Loading }); } }, ["Explore"]), - vd.h("a.CoverLogo", {href: `https://www.mapillary.com`, target: "_blank"}, []), + vd.h("a.CoverLogo", {href: Urls.explore, target: "_blank"}, []), ]); } private _getCoverBackgroundVNode(conf: ICoverConfiguration): vd.VNode { let url: string = conf.src != null ? - `url(${conf.src})` : - `url(https://d1cuyjsrcm0gby.cloudfront.net/${conf.key}/thumb-640.jpg)`; + `url(${conf.src})` : Urls.thumbnail(conf.key, ImageSize.Size640); let properties: vd.createProperties = { style: { backgroundImage: url } }; diff --git a/src/graph/NodeCache.ts b/src/graph/NodeCache.ts index 467a5526..a657515f 100644 --- a/src/graph/NodeCache.ts +++ b/src/graph/NodeCache.ts @@ -317,7 +317,7 @@ export class NodeCache { return Observable.create( (subscriber: Subscriber>): void => { let xmlHTTP: XMLHttpRequest = new XMLHttpRequest(); - xmlHTTP.open("GET", Urls.thumbnail(key, imageSize), true); + xmlHTTP.open("GET", Urls.thumbnail(key, imageSize, Urls.origin), true); xmlHTTP.responseType = "arraybuffer"; xmlHTTP.timeout = 15000; diff --git a/src/utils/Urls.ts b/src/utils/Urls.ts index 398e9625..0148c85b 100644 --- a/src/utils/Urls.ts +++ b/src/utils/Urls.ts @@ -41,8 +41,10 @@ export class Urls { return `${Urls._scheme}://${Urls._meshHost}/v2/mesh/${key}`; } - public static thumbnail(key: string, size: number): string { - return `${Urls._scheme}://${Urls._imageHost}/${key}/thumb-${size}.jpg?origin=${Urls.origin}`; + public static thumbnail(key: string, size: number, origin?: string): string { + const query: string = !!origin ? `?origin=${origin}` : ""; + + return `${Urls._scheme}://${Urls._imageHost}/${key}/thumb-${size}.jpg${query}`; } public static setOptions(options: IUrlOptions): void {