A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
1
import {state} from '../main.js';3
export default {4
props: ['id', 'tab'],5
watch: {
8
}9
},10
template: `9
<div v-if="id === tab" class="flex flex-col gap-6 sm:gap-12">11
<div class="flex flex-col gap-6 sm:gap-12 min-w-full overflow-y-auto">12
<slot></slot>13
</div>14
`
9
export const state = {10
app: null,11
tab: 'search',12
tabs: ['search', 'favorites', 'account'],13
account: null,14
station: null,15
authenticated: false
21
new Vue({22
el: '#app',23
data: {23
state24
state,25
touch: null26
},27
components: {28
VMenu,
96
}97
}98
}99
},100
onTouchStart(event) {101
this.touch = event.changedTouches[0];102
},103
onTouchEnd(event) {104
const touch = event.changedTouches[0];105
const diff = {106
x: touch.pageX - this.touch.pageX,107
y: touch.pageY - this.touch.pageY108
};109
const angle = Math.atan(diff.x / diff.y) * (180 / Math.PI);110
const index = state.tabs.indexOf(state.tab);111
if(Math.abs(diff.x) > window.innerWidth / 4) {112
if(diff.x > 0 && index > 0 && (angle <= -60 || angle >= 60)) {113
state.tab = state.tabs[index - 1];114
}115
if(diff.x < 0 && index < state.tabs.length - 1 && (angle <= -60 || angle >= 60)) {116
state.tab = state.tabs[index + 1];117
}118
}119
}120
},121
computed: {122
styles() {123
const index = state.tabs.indexOf(state.tab);124
const offset = window.innerWidth <= 640125
? `${index * -100}vw`126
: `${index * -1200}px`;127
return {128
'transform': `translate(${offset}, 0)`129
};130
}131
},132
template: `100
<div class="px-4 sm:px-10 pb-8 sm:pb-[100px] max-w-[1200px] mx-auto flex flex-col">133
<div134
@touchstart="onTouchStart"135
@touchend="onTouchEnd"136
class="px-4 sm:px-10 max-w-[1200px] mx-auto flex flex-col min-h-[100vh] max-h-[100vh] overflow-hidden"137
>138
<v-menu :state="state"></v-menu>139
<v-player v-if="state.authenticated" :station="state.station"></v-player>103
<v-search v-if="state.authenticated" ref="search" :state="state"></v-search>104
<v-favorites v-if="state.authenticated" ref="favorites" :state="state"></v-favorites>105
<v-account v-if"state.authenticated" :state="state"></v-account>140
<div class="flex flex-1 gap-[32px] sm:gap-[5rem] overflow-y-clip transition-transform" :style="styles">141
<v-search v-if="state.authenticated" ref="search" :state="state"></v-search>142
<v-favorites v-if="state.authenticated" ref="favorites" :state="state"></v-favorites>143
<v-account v-if="state.authenticated" :state="state"></v-account>144
</div>145
<v-popup ref="popup"></v-popup>146
</div>147
`
31
},32
template: `33
<v-tab id="favorites" :tab="state.tab">34
<ul class="flex flex-col">35
<li36
:key="station.id"37
v-for="station in results"38
class="border-t sm:border-t-2 first:border-none border-zinc-900 py-4 first:pt-0"34
<div class="pb-8 sm:pb-[100px]">35
<ul class="flex flex-col">36
<li37
:key="station.id"38
v-for="station in results"39
class="border-t sm:border-t-2 first:border-none border-zinc-900 py-4 first:pt-0"40
>41
<v-station :station="station"></v-station>42
</li>43
</ul>44
<div45
v-show="loading"46
class="w-[60px] h-[60px] select-none pointer-events-none mx-auto"47
>40
<v-station :station="station"></v-station>41
</li>42
</ul>43
<div44
v-show="loading"45
class="w-[60px] h-[60px] select-none pointer-events-none mx-auto"46
>47
<v-icon48
id="loader"49
class="text-gray-400 animate-spin"50
style="animation-duration: 2s;"51
size="44px"52
></v-icon>48
<v-icon49
id="loader"50
class="text-gray-400 animate-spin"51
style="animation-duration: 2s;"52
size="44px"53
></v-icon>54
</div>55
</div>56
</v-tab>57
`
85
},86
template: `87
<v-tab id="search" :tab="state.tab">88
<div class="flex flex-wrap rounded-md overflow-hidden bg-zinc-900">89
<div class="relative before:absolute before:w-full before:bottom-0 before:border-b md:before:border-none before:border-zinc-800 flex-1">90
<input91
v-model="query.name"92
@change="doSearch"93
type="text"94
:placeholder="$lang('search.input.placeholder')"95
class="w-full h-[56px] px-5 text-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none"96
spellcheck="false"97
autocomplete="off"98
>99
</div>100
<div class="flex w-full md:w-[300px]">101
<div class="flex relative before:absolute before:h-[36px] before:top-[10px] before:border-l-none md:before:border-l before:border-zinc-800 w-6/12">102
<v-icon103
id="map-pin"104
size="20px"105
class="text-gray-400 select-none pointer-events-none before:left-[24px] min-w-[0px]"106
>107
</v-icon>108
<select109
v-model="query.country"88
<div class="flex flex-col flex-1 gap-[32px] pb-8 sm:pb-[100px]">89
<div class="flex flex-wrap rounded-md overflow-hidden bg-zinc-900">90
<div class="relative before:absolute before:w-full before:bottom-0 before:border-b md:before:border-none before:border-zinc-800 flex-1">91
<input92
v-model="query.name"93
@change="doSearch"111
class="w-full h-[56px] px-5 pl-11 text-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none cursor-pointer appearance-none"94
type="text"95
:placeholder="$lang('search.input.placeholder')"96
class="w-full h-[56px] px-5 text-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none"97
spellcheck="false"98
autocomplete="off"99
>113
<option value="" selected>All</option>114
<option v-for="country in countries" :value="country">{{country}}</option>115
</select>100
</div>117
<div class="flex relative before:absolute before:h-[36px] before:top-[10px] before:border-l before:border-zinc-800 w-6/12">118
<v-icon119
id="world"120
size="20px"121
class="text-gray-400 select-none pointer-events-none before:left-[24px] min-w-[0px]"122
>123
</v-icon>124
<select125
v-model="query.language"126
@change="doSearch"127
class="w-full h-[56px] px-5 pl-11 text-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none cursor-pointer appearance-none"128
>129
<option value="">All</option>130
<option v-for="language in languages" :value="language">{{language}}</option>131
</select>101
<div class="flex w-full md:w-[300px]">102
<div class="flex relative before:absolute before:h-[36px] before:top-[10px] before:border-l-none md:before:border-l before:border-zinc-800 w-6/12">103
<v-icon104
id="map-pin"105
size="20px"106
class="text-gray-400 select-none pointer-events-none before:left-[24px] min-w-[0px]"107
>108
</v-icon>109
<select110
v-model="query.country"111
@change="doSearch"112
class="w-full h-[56px] px-5 pl-11 text-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none cursor-pointer appearance-none"113
>114
<option value="" selected>All</option>115
<option v-for="country in countries" :value="country">{{country}}</option>116
</select>117
</div>118
<div class="flex relative before:absolute before:h-[36px] before:top-[10px] before:border-l before:border-zinc-800 w-6/12">119
<v-icon120
id="world"121
size="20px"122
class="text-gray-400 select-none pointer-events-none before:left-[24px] min-w-[0px]"123
>124
</v-icon>125
<select126
v-model="query.language"127
@change="doSearch"128
class="w-full h-[56px] px-5 pl-11 text-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none cursor-pointer appearance-none"129
>130
<option value="">All</option>131
<option v-for="language in languages" :value="language">{{language}}</option>132
</select>133
</div>134
</div>135
</div>134
</div>135
<ul v-if="searching" class="flex flex-col">136
<li137
:key="station.id"138
v-for="station in results"139
class="border-t sm:border-t-2 first:border-none border-zinc-900 py-5 first:pt-0"140
>141
<v-station :station="station"></v-station>142
</li>143
</ul>144
<div v-else>145
<h3 class="text-white text-[24px] font-bold pb-8 pt-4 sm:pt-0">{{$lang('search.recommended')}}</h3>146
<ul class="flex flex-col">136
<ul v-if="searching" class="flex flex-col">137
<li138
:key="station.id"149
v-for="station in recommended"150
class="border-t sm:border-t-2 first:border-none border-zinc-900 py-4 first:pt-0"139
v-for="station in results"140
class="border-t sm:border-t-2 first:border-none border-zinc-900 py-5 first:pt-0"141
>142
<v-station :station="station"></v-station>143
</li>144
</ul>155
</div>156
<div157
v-show="loading"158
class="w-[60px] h-[60px] select-none pointer-events-none mx-auto"159
>160
<v-icon161
id="loader"162
class="text-gray-400 animate-spin"163
style="animation-duration: 2s;"164
size="44px"165
></v-icon>166
</div>167
<div168
v-if="searching && !more && results.length > 0"169
class="text-zinc-400 text-md mx-auto pb-6"170
>171
{{$lang('search.list.end')}}172
</div>173
<div174
v-if="searching && !loading && results.length == 0"175
class="text-zinc-400 text-md mx-auto pb-6"176
>177
{{$lang('search.list.empty')}}145
<div v-else>146
<h3 class="text-white text-[24px] font-bold pb-8 pt-4 sm:pt-0">{{$lang('search.recommended')}}</h3>147
<ul class="flex flex-col">148
<li149
:key="station.id"150
v-for="station in recommended"151
class="border-t sm:border-t-2 first:border-none border-zinc-900 py-4 first:pt-0"152
>153
<v-station :station="station"></v-station>154
</li>155
</ul>156
</div>157
<div158
v-show="loading"159
class="w-[60px] h-[60px] select-none pointer-events-none mx-auto"160
>161
<v-icon162
id="loader"163
class="text-gray-400 animate-spin"164
style="animation-duration: 2s;"165
size="44px"166
></v-icon>167
</div>168
<div169
v-if="searching && !more && results.length > 0"170
class="text-zinc-400 text-md mx-auto pb-6"171
>172
{{$lang('search.list.end')}}173
</div>174
<div175
v-if="searching && !loading && results.length == 0"176
class="text-zinc-400 text-md mx-auto pb-6"177
>178
{{$lang('search.list.empty')}}179
</div>180
</div>181
</v-tab>182
`
242
UNNEST(tags) AS tag243
FROM station244
GROUP BY UNNEST(tags)245
ORDER BY COUNT(*) DESC;245
ORDER BY COUNT(*) DESC246
LIMIT 100;247
"#248
.to_string();249
let mut conn = req.sqlx_conn::<Postgres>().await;