Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #380 from alexander-heimbuch/feature/podlove-deep-…
Browse files Browse the repository at this point in the history
…linking-format

feat(deep-linking): Use podlove deep linking format
  • Loading branch information
alexander-heimbuch authored May 5, 2017
2 parents 91e855c + 9df558c commit eca817d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/components/tabs/share/ShareEmbed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
}
if (embed.start) {
parameters.playtime = secondsToTime(embed.starttime)
parameters.t = secondsToTime(embed.starttime)
}
return `<iframe width="${width}" height="${height}" src="${addQueryParameter(reference.share, parameters)}" frameborder="0" scrolling="no"></iframe>`
Expand Down
2 changes: 1 addition & 1 deletion src/components/tabs/share/ShareLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
const parameters = {}
if (link.start) {
parameters.playtime = secondsToTime(link.starttime)
parameters.t = secondsToTime(link.starttime)
}
return addQueryParameter(reference.origin, parameters)
Expand Down
4 changes: 2 additions & 2 deletions src/embed/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)}`))

Expand Down
6 changes: 3 additions & 3 deletions src/embed/share.js
Original file line number Diff line number Diff line change
@@ -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)
18 changes: 11 additions & 7 deletions src/utils/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit eca817d

Please sign in to comment.