See #327: Cleaned now unused backend.absoluteUrl and config module

This commit is contained in:
Eliot Berriot 2018-06-23 07:25:27 +02:00
parent f3e2193782
commit 2e3a2cd6dd
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
20 changed files with 24 additions and 61 deletions

View File

@ -1,4 +1,3 @@
module.exports = { module.exports = {
NODE_ENV: '"production"', NODE_ENV: '"production"'
BACKEND_URL: '"/"'
} }

View File

@ -39,7 +39,13 @@
<template v-else>{{ $t('Source code') }}</template> <template v-else>{{ $t('Source code') }}</template>
</a> </a>
<a href="https://code.eliotberriot.com/funkwhale/funkwhale/issues" class="item" target="_blank">{{ $t('Issue tracker') }}</a> <a href="https://code.eliotberriot.com/funkwhale/funkwhale/issues" class="item" target="_blank">{{ $t('Issue tracker') }}</a>
<a @click="switchInstance" class="item" target="_blank">{{ $t('Use another instance') }}</a> <a @click="switchInstance" class="item" >
{{ $t('Use another instance') }}
<template v-if="$store.state.instance.instanceUrl !== '/'">
<br>
({{ $store.state.instance.instanceUrl }})
</template>
</a>
</div> </div>
</div> </div>
<div class="ten wide column"> <div class="ten wide column">

View File

@ -1,5 +1,3 @@
import config from '@/config'
var Album = { var Album = {
clean (album) { clean (album) {
// we manually rebind the album and artist to each child track // we manually rebind the album and artist to each child track
@ -21,21 +19,6 @@ var Artist = {
} }
} }
export default { export default {
absoluteUrl (url) {
if (url.startsWith('http')) {
return url
}
if (url.startsWith('/')) {
let rootUrl = (
window.location.protocol + '//' + window.location.hostname +
(window.location.port ? ':' + window.location.port : '')
)
return rootUrl + url
} else {
return config.BACKEND_URL + url
}
},
Artist: Artist, Artist: Artist,
Album: Album Album: Album
} }

View File

@ -1,7 +0,0 @@
import backend from './backend'
export default {
getCover (track) {
return backend.absoluteUrl(track.album.cover)
}
}

View File

@ -125,7 +125,7 @@
<tr @click="$store.dispatch('queue/currentIndex', index)" v-for="(track, index) in queue.tracks" :key="index" :class="[{'active': index === queue.currentIndex}]"> <tr @click="$store.dispatch('queue/currentIndex', index)" v-for="(track, index) in queue.tracks" :key="index" :class="[{'active': index === queue.currentIndex}]">
<td class="right aligned">{{ index + 1}}</td> <td class="right aligned">{{ index + 1}}</td>
<td class="center aligned"> <td class="center aligned">
<img class="ui mini image" v-if="track.album.cover" :src="backend.absoluteUrl(track.album.cover)"> <img class="ui mini image" v-if="track.album.cover" :src="$store.getters['instance/absoluteUrl'](track.album.cover)">
<img class="ui mini image" v-else src="../assets/audio/default-cover.png"> <img class="ui mini image" v-else src="../assets/audio/default-cover.png">
</td> </td>
<td colspan="4"> <td colspan="4">

View File

@ -14,7 +14,7 @@
<div v-if="currentTrack" class="track-area ui unstackable items"> <div v-if="currentTrack" class="track-area ui unstackable items">
<div class="ui inverted item"> <div class="ui inverted item">
<div class="ui tiny image"> <div class="ui tiny image">
<img ref="cover" @load="updateBackground" v-if="currentTrack.album.cover" :src="Track.getCover(currentTrack)"> <img ref="cover" @load="updateBackground" v-if="currentTrack.album.cover" :src="$store.getters['instance/absoluteUrl'](currentTrack.album.cover)">
<img v-else src="../../assets/audio/default-cover.png"> <img v-else src="../../assets/audio/default-cover.png">
</div> </div>
<div class="middle aligned content"> <div class="middle aligned content">
@ -143,7 +143,6 @@ import {mapState, mapGetters, mapActions} from 'vuex'
import GlobalEvents from '@/components/utils/global-events' import GlobalEvents from '@/components/utils/global-events'
import ColorThief from '@/vendor/color-thief' import ColorThief from '@/vendor/color-thief'
import Track from '@/audio/track'
import AudioTrack from '@/components/audio/Track' import AudioTrack from '@/components/audio/Track'
import TrackFavoriteIcon from '@/components/favorites/TrackFavoriteIcon' import TrackFavoriteIcon from '@/components/favorites/TrackFavoriteIcon'
import TrackPlaylistIcon from '@/components/playlists/TrackPlaylistIcon' import TrackPlaylistIcon from '@/components/playlists/TrackPlaylistIcon'
@ -162,7 +161,6 @@ export default {
isShuffling: false, isShuffling: false,
renderAudio: true, renderAudio: true,
sliderVolume: this.volume, sliderVolume: this.volume,
Track: Track,
defaultAmbiantColors: defaultAmbiantColors, defaultAmbiantColors: defaultAmbiantColors,
ambiantColors: defaultAmbiantColors ambiantColors: defaultAmbiantColors
} }

View File

@ -11,11 +11,8 @@
<script> <script>
import jQuery from 'jquery' import jQuery from 'jquery'
import config from '@/config'
import router from '@/router' import router from '@/router'
const SEARCH_URL = config.API_URL + 'search?query={query}'
export default { export default {
mounted () { mounted () {
let self = this let self = this
@ -94,7 +91,7 @@ export default {
}) })
return {results: results} return {results: results}
}, },
url: SEARCH_URL url: this.$store.getters['instance/absoluteUrl']('search?query={query}')
} }
}) })
} }

View File

@ -49,7 +49,7 @@ export default {
return [] return []
} }
let sources = [ let sources = [
{type: file.mimetype, url: file.path} {type: file.mimetype, url: this.$store.getters['instance/absoluteUrl'](file.path)}
] ]
if (this.$store.state.auth.authenticated) { if (this.$store.state.auth.authenticated) {
// we need to send the token directly in url // we need to send the token directly in url

View File

@ -2,7 +2,7 @@
<div class="ui card"> <div class="ui card">
<div class="content"> <div class="content">
<div class="right floated tiny ui image"> <div class="right floated tiny ui image">
<img v-if="album.cover" v-lazy="backend.absoluteUrl(album.cover)"> <img v-if="album.cover" v-lazy="$store.getters['instance/absoluteUrl'](album.cover)">
<img v-else src="../../../assets/audio/default-cover.png"> <img v-else src="../../../assets/audio/default-cover.png">
</div> </div>
<div class="header"> <div class="header">

View File

@ -11,7 +11,7 @@
<tbody> <tbody>
<tr v-for="album in albums"> <tr v-for="album in albums">
<td> <td>
<img class="ui mini image" v-if="album.cover" :src="backend.absoluteUrl(album.cover)"> <img class="ui mini image" v-if="album.cover" :src="$store.getters['instance/absoluteUrl'](album.cover)">
<img class="ui mini image" v-else src="../../../assets/audio/default-cover.png"> <img class="ui mini image" v-else src="../../../assets/audio/default-cover.png">
</td> </td>
<td colspan="4"> <td colspan="4">

View File

@ -4,7 +4,7 @@
<play-button class="basic icon" :discrete="true" :track="track"></play-button> <play-button class="basic icon" :discrete="true" :track="track"></play-button>
</td> </td>
<td> <td>
<img class="ui mini image" v-if="track.album.cover" v-lazy="backend.absoluteUrl(track.album.cover)"> <img class="ui mini image" v-if="track.album.cover" v-lazy="$store.getters['instance/absoluteUrl'](track.album.cover)">
<img class="ui mini image" v-else src="../../..//assets/audio/default-cover.png"> <img class="ui mini image" v-else src="../../..//assets/audio/default-cover.png">
</td> </td>
<td colspan="6"> <td colspan="6">

View File

@ -35,7 +35,7 @@
<pre> <pre>
export PRIVATE_TOKEN="{{ $store.state.auth.token }}" export PRIVATE_TOKEN="{{ $store.state.auth.token }}"
<template v-for="track in tracks"><template v-if="track.files.length > 0"> <template v-for="track in tracks"><template v-if="track.files.length > 0">
curl -G -o "{{ track.files[0].filename }}" <template v-if="$store.state.auth.authenticated">--header "Authorization: JWT $PRIVATE_TOKEN"</template> "{{ backend.absoluteUrl(track.files[0].path) }}"</template></template> curl -G -o "{{ track.files[0].filename }}" <template v-if="$store.state.auth.authenticated">--header "Authorization: JWT $PRIVATE_TOKEN"</template> "{{ $store.getters['instance/absoluteUrl'](track.files[0].path) }}"</template></template>
</pre> </pre>
</div> </div>
</div> </div>

View File

@ -87,7 +87,7 @@ export default {
if (!this.album.cover) { if (!this.album.cover) {
return '' return ''
} }
return 'background-image: url(' + backend.absoluteUrl(this.album.cover) + ')' return 'background-image: url(' + this.$store.getters['instance/absoluteUrl'](this.album.cover) + ')'
} }
}, },
watch: { watch: {

View File

@ -127,7 +127,7 @@ export default {
if (!this.cover) { if (!this.cover) {
return '' return ''
} }
return 'background-image: url(' + backend.absoluteUrl(this.cover) + ')' return 'background-image: url(' + this.$store.getters['instance/absoluteUrl'](this.cover) + ')'
} }
}, },
watch: { watch: {

View File

@ -108,7 +108,6 @@ import time from '@/utils/time'
import axios from 'axios' import axios from 'axios'
import url from '@/utils/url' import url from '@/utils/url'
import logger from '@/logging' import logger from '@/logging'
import backend from '@/audio/backend'
import PlayButton from '@/components/audio/PlayButton' import PlayButton from '@/components/audio/PlayButton'
import TrackFavoriteIcon from '@/components/favorites/TrackFavoriteIcon' import TrackFavoriteIcon from '@/components/favorites/TrackFavoriteIcon'
import TrackPlaylistIcon from '@/components/playlists/TrackPlaylistIcon' import TrackPlaylistIcon from '@/components/playlists/TrackPlaylistIcon'
@ -169,7 +168,7 @@ export default {
}, },
downloadUrl () { downloadUrl () {
if (this.track.files.length > 0) { if (this.track.files.length > 0) {
let u = backend.absoluteUrl(this.track.files[0].path) let u = this.$store.getters['instance/absoluteUrl'](this.track.files[0].path)
if (this.$store.state.auth.authenticated) { if (this.$store.state.auth.authenticated) {
u = url.updateQueryString(u, 'jwt', this.$store.state.auth.token) u = url.updateQueryString(u, 'jwt', this.$store.state.auth.token)
} }
@ -191,7 +190,7 @@ export default {
if (!this.cover) { if (!this.cover) {
return '' return ''
} }
return 'background-image: url(' + backend.absoluteUrl(this.cover) + ')' return 'background-image: url(' + this.$store.getters['instance/absoluteUrl'](this.cover) + ')'
} }
}, },
watch: { watch: {

View File

@ -63,7 +63,6 @@
</template> </template>
<script> <script>
import axios from 'axios' import axios from 'axios'
import config from '@/config'
import $ from 'jquery' import $ from 'jquery'
import _ from 'lodash' import _ from 'lodash'
@ -86,7 +85,7 @@ export default {
return { return {
checkResult: null, checkResult: null,
showCandidadesModal: false, showCandidadesModal: false,
exclude: config.not exclude: this.config.not
} }
}, },
mounted: function () { mounted: function () {

View File

@ -43,8 +43,6 @@
<script> <script>
import axios from 'axios' import axios from 'axios'
import backend from '@/audio/backend'
export default { export default {
data () { data () {
return { return {
@ -72,7 +70,7 @@ export default {
}) })
}, },
getUrl (code) { getUrl (code) {
return backend.absoluteUrl(this.$router.resolve({name: 'signup', query: {invitation: code.toUpperCase()}}).href) return this.$store.getters['instance/absoluteUrl'](this.$router.resolve({name: 'signup', query: {invitation: code.toUpperCase()}}).href)
} }
} }
} }

View File

@ -22,7 +22,6 @@
<script> <script>
import jQuery from 'jquery' import jQuery from 'jquery'
import config from '@/config'
export default { export default {
props: { props: {
@ -117,7 +116,7 @@ export default {
})[0] })[0]
}, },
searchUrl: function () { searchUrl: function () {
return config.API_URL + 'providers/musicbrainz/search/' + this.currentTypeObject.value + 's/?query={query}' return this.$store.getters['instance/absoluteUrl']('providers/musicbrainz/search/' + this.currentTypeObject.value + 's/?query={query}')
}, },
types: function () { types: function () {
return [ return [

View File

@ -1,8 +0,0 @@
class Config {
constructor () {
this.BACKEND_URL = process.env.BACKEND_URL
this.API_URL = this.BACKEND_URL + 'api/v1/'
}
}
export default new Config()

View File

@ -6,7 +6,7 @@ export default {
namespaced: true, namespaced: true,
state: { state: {
maxEvents: 200, maxEvents: 200,
instanceUrl: process.env.INSTANCE_URL, instanceUrl: '/',
events: [], events: [],
settings: { settings: {
instance: { instance: {