diff --git a/front/config/prod.env.js b/front/config/prod.env.js index decfe36154adc59fbf4a432cecac77119bbcdbf7..773d263d31260be27d2d7e3fbaa5c17ae4e732f6 100644 --- a/front/config/prod.env.js +++ b/front/config/prod.env.js @@ -1,4 +1,3 @@ module.exports = { - NODE_ENV: '"production"', - BACKEND_URL: '"/"' + NODE_ENV: '"production"' } diff --git a/front/src/App.vue b/front/src/App.vue index 73e46328a218106b801d7d94fb7f55ff1bca23f9..56dbe0aad41f7af3d382202832ab6828bb431837 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -39,7 +39,13 @@ <template v-else>{{ $t('Source code') }}</template> </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 class="ten wide column"> diff --git a/front/src/audio/backend.js b/front/src/audio/backend.js index 619f3cefdbd7b08f9879be343ce246e41e86de0d..5a82719a3a0d403ce6ee264eed47e2f5926068f0 100644 --- a/front/src/audio/backend.js +++ b/front/src/audio/backend.js @@ -1,5 +1,3 @@ -import config from '@/config' - var Album = { clean (album) { // we manually rebind the album and artist to each child track @@ -21,21 +19,6 @@ var Artist = { } } 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, Album: Album - } diff --git a/front/src/audio/track.js b/front/src/audio/track.js deleted file mode 100644 index 9873b74ec5405bd941999df63e6071a3ac8056d3..0000000000000000000000000000000000000000 --- a/front/src/audio/track.js +++ /dev/null @@ -1,7 +0,0 @@ -import backend from './backend' - -export default { - getCover (track) { - return backend.absoluteUrl(track.album.cover) - } -} diff --git a/front/src/components/Sidebar.vue b/front/src/components/Sidebar.vue index 87c374a336780d1e2623f85685e581abbabab347..de018907b65d7763deecf67dbefa73ba24dab428 100644 --- a/front/src/components/Sidebar.vue +++ b/front/src/components/Sidebar.vue @@ -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}]"> <td class="right aligned">{{ index + 1}}</td> <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"> </td> <td colspan="4"> diff --git a/front/src/components/audio/Player.vue b/front/src/components/audio/Player.vue index 3c922e14ad323d75413d969ba7c033add19e92e0..1cc27970b47aabc5571047713d1ee45e3f7b853a 100644 --- a/front/src/components/audio/Player.vue +++ b/front/src/components/audio/Player.vue @@ -14,7 +14,7 @@ <div v-if="currentTrack" class="track-area ui unstackable items"> <div class="ui inverted item"> <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"> </div> <div class="middle aligned content"> @@ -143,7 +143,6 @@ import {mapState, mapGetters, mapActions} from 'vuex' import GlobalEvents from '@/components/utils/global-events' import ColorThief from '@/vendor/color-thief' -import Track from '@/audio/track' import AudioTrack from '@/components/audio/Track' import TrackFavoriteIcon from '@/components/favorites/TrackFavoriteIcon' import TrackPlaylistIcon from '@/components/playlists/TrackPlaylistIcon' @@ -162,7 +161,6 @@ export default { isShuffling: false, renderAudio: true, sliderVolume: this.volume, - Track: Track, defaultAmbiantColors: defaultAmbiantColors, ambiantColors: defaultAmbiantColors } diff --git a/front/src/components/audio/SearchBar.vue b/front/src/components/audio/SearchBar.vue index 99896d04beda7bc51a559fb10b8205a45e254610..9b6dc50e2343cf514fced16d4b46d9431494b6db 100644 --- a/front/src/components/audio/SearchBar.vue +++ b/front/src/components/audio/SearchBar.vue @@ -11,11 +11,8 @@ <script> import jQuery from 'jquery' -import config from '@/config' import router from '@/router' -const SEARCH_URL = config.API_URL + 'search?query={query}' - export default { mounted () { let self = this @@ -94,7 +91,7 @@ export default { }) return {results: results} }, - url: SEARCH_URL + url: this.$store.getters['instance/absoluteUrl']('search?query={query}') } }) } diff --git a/front/src/components/audio/Track.vue b/front/src/components/audio/Track.vue index 366f104f1fc021fbe5478346439e94034b345e2a..2ded7cb0076f29b2f78956aae2ff8703fb2da9c8 100644 --- a/front/src/components/audio/Track.vue +++ b/front/src/components/audio/Track.vue @@ -49,7 +49,7 @@ export default { return [] } 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) { // we need to send the token directly in url diff --git a/front/src/components/audio/album/Card.vue b/front/src/components/audio/album/Card.vue index 6742dca4f9b94e88983ad6ec6d4396b11dc14648..3782771803edce6432a125957e9d10346b073fbd 100644 --- a/front/src/components/audio/album/Card.vue +++ b/front/src/components/audio/album/Card.vue @@ -2,7 +2,7 @@ <div class="ui card"> <div class="content"> <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"> </div> <div class="header"> diff --git a/front/src/components/audio/artist/Card.vue b/front/src/components/audio/artist/Card.vue index a46506791e083eb5cc750c8f84918a6bc1fb2318..b19c5e12d727b6a32c6a57c04e9dab4b0b9c3134 100644 --- a/front/src/components/audio/artist/Card.vue +++ b/front/src/components/audio/artist/Card.vue @@ -11,7 +11,7 @@ <tbody> <tr v-for="album in albums"> <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"> </td> <td colspan="4"> diff --git a/front/src/components/audio/track/Row.vue b/front/src/components/audio/track/Row.vue index 8310e89c4a4ad6ab749f2386003f1c59ae7dccea..bd3ceb2aaa869350fa013ca36c709f16cc97cdbc 100644 --- a/front/src/components/audio/track/Row.vue +++ b/front/src/components/audio/track/Row.vue @@ -4,7 +4,7 @@ <play-button class="basic icon" :discrete="true" :track="track"></play-button> </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"> </td> <td colspan="6"> diff --git a/front/src/components/audio/track/Table.vue b/front/src/components/audio/track/Table.vue index 4559b3c41b59ccf798eec071b97c1ab55a81dceb..81869ff564af2f8b5ee5260535b7fda5f95f924e 100644 --- a/front/src/components/audio/track/Table.vue +++ b/front/src/components/audio/track/Table.vue @@ -35,7 +35,7 @@ <pre> export PRIVATE_TOKEN="{{ $store.state.auth.token }}" <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> </div> </div> diff --git a/front/src/components/library/Album.vue b/front/src/components/library/Album.vue index 1681d46e3b44466f022f18d22ffa3ba78e1643b7..9a4288b8ac46a8e584fa8dbf23bae3a96fa4e5cc 100644 --- a/front/src/components/library/Album.vue +++ b/front/src/components/library/Album.vue @@ -87,7 +87,7 @@ export default { if (!this.album.cover) { return '' } - return 'background-image: url(' + backend.absoluteUrl(this.album.cover) + ')' + return 'background-image: url(' + this.$store.getters['instance/absoluteUrl'](this.album.cover) + ')' } }, watch: { diff --git a/front/src/components/library/Artist.vue b/front/src/components/library/Artist.vue index 7d0a41d8988055316ecb4773103e129e970f92c7..171b80e8b7b1f9a2ad8c7a65e9dc3c227e6e1b5a 100644 --- a/front/src/components/library/Artist.vue +++ b/front/src/components/library/Artist.vue @@ -127,7 +127,7 @@ export default { if (!this.cover) { return '' } - return 'background-image: url(' + backend.absoluteUrl(this.cover) + ')' + return 'background-image: url(' + this.$store.getters['instance/absoluteUrl'](this.cover) + ')' } }, watch: { diff --git a/front/src/components/library/Track.vue b/front/src/components/library/Track.vue index 24acca75b809445ce711f9fb90e38a65f7c974dd..af364e94d6af39e4d459e1cbdc9ab105560d2f5f 100644 --- a/front/src/components/library/Track.vue +++ b/front/src/components/library/Track.vue @@ -108,7 +108,6 @@ import time from '@/utils/time' import axios from 'axios' import url from '@/utils/url' import logger from '@/logging' -import backend from '@/audio/backend' import PlayButton from '@/components/audio/PlayButton' import TrackFavoriteIcon from '@/components/favorites/TrackFavoriteIcon' import TrackPlaylistIcon from '@/components/playlists/TrackPlaylistIcon' @@ -169,7 +168,7 @@ export default { }, downloadUrl () { 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) { u = url.updateQueryString(u, 'jwt', this.$store.state.auth.token) } @@ -191,7 +190,7 @@ export default { if (!this.cover) { return '' } - return 'background-image: url(' + backend.absoluteUrl(this.cover) + ')' + return 'background-image: url(' + this.$store.getters['instance/absoluteUrl'](this.cover) + ')' } }, watch: { diff --git a/front/src/components/library/radios/Filter.vue b/front/src/components/library/radios/Filter.vue index b27c36077c113b801bf842f84ad868cfecc87542..0d268dc60faad8355650aed431ad4174d22ce464 100644 --- a/front/src/components/library/radios/Filter.vue +++ b/front/src/components/library/radios/Filter.vue @@ -63,7 +63,6 @@ </template> <script> import axios from 'axios' -import config from '@/config' import $ from 'jquery' import _ from 'lodash' @@ -86,7 +85,7 @@ export default { return { checkResult: null, showCandidadesModal: false, - exclude: config.not + exclude: this.config.not } }, mounted: function () { diff --git a/front/src/components/manage/users/InvitationForm.vue b/front/src/components/manage/users/InvitationForm.vue index 9429c1ae16294c49b91aa5a6ee43780a7b596c90..d9f0969e67853c841cbb0a10ebd9735792723d97 100644 --- a/front/src/components/manage/users/InvitationForm.vue +++ b/front/src/components/manage/users/InvitationForm.vue @@ -43,8 +43,6 @@ <script> import axios from 'axios' -import backend from '@/audio/backend' - export default { data () { return { @@ -72,7 +70,7 @@ export default { }) }, 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) } } } diff --git a/front/src/components/metadata/Search.vue b/front/src/components/metadata/Search.vue index 305aa7a3d6b3aa7e695c9613f566946c3e7be805..0379cb188ae7e8739ca8c2e5247856f9110dbfe7 100644 --- a/front/src/components/metadata/Search.vue +++ b/front/src/components/metadata/Search.vue @@ -22,7 +22,6 @@ <script> import jQuery from 'jquery' -import config from '@/config' export default { props: { @@ -117,7 +116,7 @@ export default { })[0] }, 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 () { return [ diff --git a/front/src/config.js b/front/src/config.js deleted file mode 100644 index 47d9d7b8b2cdc83ded7330e2400c48d4b72b8e2e..0000000000000000000000000000000000000000 --- a/front/src/config.js +++ /dev/null @@ -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() diff --git a/front/src/store/instance.js b/front/src/store/instance.js index 555bd82391fe56a4ec5d18baa71e0e64dceabf35..ba069ac4ccd5bc5db427626fcb87f36913ffd055 100644 --- a/front/src/store/instance.js +++ b/front/src/store/instance.js @@ -6,7 +6,7 @@ export default { namespaced: true, state: { maxEvents: 200, - instanceUrl: process.env.INSTANCE_URL, + instanceUrl: '/', events: [], settings: { instance: {