From 9df558c5299f6050f71332f1b88f8a2ce509133d Mon Sep 17 00:00:00 2001 From: Alexander Heimbuch Date: Fri, 5 May 2017 20:44:37 +0200 Subject: [PATCH] feat(deep-linking): Use podlove deep linking format --- src/components/tabs/share/ShareEmbed.vue | 2 +- src/components/tabs/share/ShareLink.vue | 2 +- src/embed/embed.js | 4 ++-- src/embed/share.js | 6 +++--- src/utils/url.js | 18 +++++++++++------- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/components/tabs/share/ShareEmbed.vue b/src/components/tabs/share/ShareEmbed.vue index 39c47b5d6..324669745 100644 --- a/src/components/tabs/share/ShareEmbed.vue +++ b/src/components/tabs/share/ShareEmbed.vue @@ -51,7 +51,7 @@ } if (embed.start) { - parameters.playtime = secondsToTime(embed.starttime) + parameters.t = secondsToTime(embed.starttime) } return `` diff --git a/src/components/tabs/share/ShareLink.vue b/src/components/tabs/share/ShareLink.vue index 27b968945..aae9dcea0 100644 --- a/src/components/tabs/share/ShareLink.vue +++ b/src/components/tabs/share/ShareLink.vue @@ -34,7 +34,7 @@ const parameters = {} if (link.start) { - parameters.playtime = secondsToTime(link.starttime) + parameters.t = secondsToTime(link.starttime) } return addQueryParameter(reference.origin, parameters) diff --git a/src/embed/embed.js b/src/embed/embed.js index b8a9fb93b..2f4401305 100644 --- a/src/embed/embed.js +++ b/src/embed/embed.js @@ -3,7 +3,7 @@ import Bluebird from 'bluebird' import { findNode, createNode, appendNode, tag } from 'utils/dom' import requestConfig from 'utils/request' -import { params as urlConfig } from 'utils/url' +import { params } from 'utils/url' import { iframeResizer } from 'iframe-resizer' import iframeResizerContentWindow from 'raw-loader!iframe-resizer/js/iframeResizer.contentWindow.min.js' @@ -80,7 +80,7 @@ const configNode = (config = {}) => // If the config is a string, lets assume that this will point to the remote config json .then(config => isString(config) ? requestConfig(config) : config) // Load parameters from url - .then(config => Object.assign({}, config, urlConfig)) + .then(config => Object.assign({}, config, params)) // Finally return the node .then(config => tag('script', `window.PODLOVE = ${JSON.stringify(config)}`)) diff --git a/src/embed/share.js b/src/embed/share.js index 16d0c09c4..353087a4c 100644 --- a/src/embed/share.js +++ b/src/embed/share.js @@ -1,9 +1,9 @@ -import { aprams as urlConfig } from 'utils/url' +import { params } from 'utils/url' import remoteConfig from 'utils/request' import app from '../app' -remoteConfig(urlConfig.episode) - .then(config => Object.assign({}, config, urlConfig)) +remoteConfig(params.episode) + .then(config => Object.assign({}, config, params)) .then(config => Object.assign({}, config, {mode: 'share'})) .then(app) diff --git a/src/utils/url.js b/src/utils/url.js index 50cead6dc..f26de6ce8 100644 --- a/src/utils/url.js +++ b/src/utils/url.js @@ -3,17 +3,21 @@ import { timeToSeconds } from 'utils/time' const locationParams = queryString.parse(window.location.search) -const parsePlaytime = parameters => { - if (parameters.playtime) { - return { - playtime: timeToSeconds(parameters.playtime) - } +const parseParameters = parameters => { + const parsed = {} + + if (parameters.t) { + parsed.playtime = timeToSeconds(parameters.t) + } + + if (parameters.episode) { + parsed.episode = parameters.episode } - return {} + return parsed } -export const params = Object.assign({}, params, parsePlaytime(locationParams)) +export const params = Object.assign({}, parseParameters(locationParams)) export const addQueryParameter = (url, additionalParameters = {}) => { const parser = document.createElement('a')