A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
27
></v-button>28
</div>29
<v-button30
text="typable"30
:text="state.account.username"31
icon="user"32
:title="$lang('global.account')"33
:active="state.tab === 'account'"
44
v-else45
id="access-point"46
size="65%"47
class="bg-gray-400"48
></v-icon>49
</div>50
<div
12
$lang13
},14
template: `15
<div class="w-full py-5 gap-4 group flex items-center border-t sm:border-t-2 first:border-none border-zinc-900">15
<div class="w-full gap-4 group flex items-center">16
<div class="w-[54px] h-[54px] min-w-[54px] bg-zinc-900 rounded-lg overflow-hidden">17
<img v-if="station.favicon" :alt="station.name" :src="station.favicon" v-on:error="doHideFavicon(station)" class="w-full h-full object-contain">18
<div v-else class="w-full h-full bg-gray-400 [mask:url('https://cdn.typable.dev/tabler/access-point')]" style="-webkit-mask-repeat: no-repeat; -webkit-mask-position: center; -webkit-mask-size: 65%;"></div>17
<img18
v-if="station.favicon"19
:alt="station.name"20
:src="station.favicon"21
@error="() => station.favicon = null"22
class="w-full h-full object-contain"23
>24
<v-icon25
v-else26
id="access-point"27
size="65%"28
class="bg-gray-400"29
></v-icon>30
</div>31
<div class="flex flex-col flex-1 min-w-0">32
<p class="text-lg font-medium text-gray-100 pb-0 overflow-hidden text-ellipsis whitespace-nowrap">{{station.name}}</p>33
<span class="text-md text-gray-400 overflow-hidden flex gap-2 sm:gap-3">23
<span v-if="station.country" class="text-gray-400 inline-flex items-center gap-[5px]" v-bind:title="$('global.country')">24
<div class="w-[18px] h-[18px] min-w-[18px] inline-flex bg-gray-400 [mask:url(https://cdn.typable.dev/tabler/world)]" style="-webkit-mask-repeat: no-repeat; -webkit-mask-position: center; -webkit-mask-size: 100%;"></div>34
<span35
v-if="station.country"36
class="text-gray-400 inline-flex items-center gap-[5px]"37
:title="$lang('global.country')"38
>39
<v-icon40
id="world"41
class="w-[18px] h-[18px] !min-w-[18px] inline-flex bg-gray-400"42
size="100%"43
></v-icon>44
<p>{{station.country}}</p>45
</span>27
<span v-if="station.votes" class="text-gray-400 inline-flex items-center gap-[5px]" v-bind:title="$('global.votes')">28
<div class="w-[18px] h-[18px] inline-flex bg-gray-400 [mask:url(https://cdn.typable.dev/tabler/thumb-up)]" style="-webkit-mask-repeat: no-repeat; -webkit-mask-position: center; -webkit-mask-size: 100%;"></div>46
<span47
v-if="station.votes"48
class="text-gray-400 inline-flex items-center gap-[5px]"49
:title="$lang('global.votes')"50
>51
<v-icon52
id="thumb-up"53
class="w-[18px] h-[18px] !min-w-[18px] inline-flex bg-gray-400"54
size="100%"55
></v-icon>56
<p>{{station.votes}}</p>57
</span>31
<span v-if="station.click_trend" class="text-gray-400 hidden sm:inline-flex items-center gap-[5px]" v-bind:title="$('global.trend')">32
<div class="w-[16px] h-[16px] inline-flex bg-gray-400" v-bind:class="[ station.click_trend >= 0 ? '[mask:url(https://cdn.typable.dev/tabler/arrow-up-right)]' : '[mask:url(https://cdn.typable.dev/tabler/arrow-down-right)]' ]" style="-webkit-mask-repeat: no-repeat; -webkit-mask-position: center;"></div>58
<span59
v-if="station.click_trend"60
class="text-gray-400 hidden sm:inline-flex items-center gap-[5px]"61
:title="$lang('global.trend')"62
>63
<v-icon64
:id="[ station.click_trend >= 0 ? 'arrow-up-right' : 'arrow-down-right' ]"65
class="w-[18px] h-[18px] !min-w-[18px] inline-flex bg-gray-400"66
></v-icon>67
<p>{{Math.abs(station.click_trend) ?? 'None'}}</p>68
</span>69
</span>70
</div>37
<div class="inline-flex gap-4">38
<button v-on:click="doToggleFavorite(station, !station.is_favorite)" v-bind:title="[ station.is_favorite ? $('global.unlike') : $('global.like') ]" class="w-[46px] h-[46px] bg-zinc-900 hover:bg-white rounded-full inline-flex justify-center items-center cursor-pointer transition-colors">39
<div class="w-full h-full bg-gray-400 hover:bg-red-600 transition-colors" v-bind:class="[ station.is_favorite ? '[mask:url(https://cdn.typable.dev/tabler/heart-solid)]' : '[mask:url(https://cdn.typable.dev/tabler/heart)]' ]" style="-webkit-mask-repeat: no-repeat; -webkit-mask-position: center;"></div>40
</button>41
<button v-on:click="doPlay(station)" v-bind:title="$('global.play')" class="w-[46px] h-[46px] bg-zinc-900 hover:bg-white rounded-full inline-flex justify-center items-center cursor-pointer transition-colors">42
<div class="w-full h-full bg-gray-400 hover:bg-gray-700 transition-colors [mask:url('https://cdn.typable.dev/tabler/player-play')]" style="-webkit-mask-repeat: no-repeat; -webkit-mask-position: center;"></div>43
</button>71
<div class="inline-flex gap-3 sm:gap-4">72
<v-button73
:icon="[ station.is_favorite ? 'heart-solid' : 'heart' ]"74
:title="[ $lang(station.is_favorite ? 'global.unlike' : 'global.like') ]"75
:active="station.is_favorite"76
class="bg-zinc-900 hover:bg-white"77
></v-button>78
<v-button79
icon="player-play"80
class="bg-zinc-900 hover:bg-white"81
:title="$lang('global.play')"82
></v-button>83
</div>84
</div>85
`
18
<v-icon19
v-if="icon"20
:id="icon"21
:class="[ active ? 'bg-gray-100' : 'bg-gray-400', animation ]"21
:class="[ active ? 'bg-gray-100' : 'bg-gray-400', text ? 'group-hover:bg-gray-700' : '', animation ]"22
class="hover:bg-gray-700"23
></v-icon>24
<slot v-else></slot>25
<p
13
template: `14
<div15
:style="styles"16
class="min-w-[50px] h-full group-hover:bg-gray-700 transition-colors"16
class="min-w-[50px] h-full transition-colors"17
:class="classes"18
></div>19
`
4
import VAccount from './page/account.js';6
export const state = {7
locale: 'en',7
tab: 'search',8
account: {9
username: 'typable',10
language: 'en'11
},12
station: {13
name: 'Liquid Trap',11
favicon: 'https://cdn-images.audioaddict.com/6/b/5/b/d/6/6b5bd66a99e46fa1258cb565d988ea7c.jpg'14
favicon: 'https://cdn-images.audioaddict.com/6/b/5/b/d/6/6b5bd66a99e46fa1258cb565d988ea7c.jpg',15
is_favorite: true16
}17
};
11
},12
template: `13
<v-tab id="account" :tab="state.tab">14
<div class="sticky top-[98px] z-30 -mb-6">15
<div class="bg-gradient-to-b from-black h-2 sm:h-4"></div>16
</div>18
<!--19
<div v-if="account.settings" class="flex flex-col gap-[60px] sm:gap-[80px] pt-6 sm:pt-12">20
<div>21
<h1 class="text-white text-[28px] font-semibold pb-6 sm:pb-8">{{$('account.settings')}}</h1>22
<div class="grid grid-cols-8 gap-8 sm:gap-10 pt-8 sm:pt-12">23
<div class="flex flex-col col-span-8 sm:col-span-8">24
<p class="text-gray-300 text-[22px] font-medium pb-2 text-lg">{{$('global.account')}}</p>25
</div>26
<div class="flex flex-col col-span-8 sm:col-span-4">27
<p class="text-white font-medium pb-2 text-lg">{{$('account.username')}}</p>28
<span class="text-gray-400 pb-4 text-md flex-1">{{$('account.username.info')}}</span>29
<input v-model="account.settings.username" v-on:change="doAccountSave" type="text" class="w-full h-[54px] px-5 sm:h-[48px] sm:px-4 text-md rounded-lg bg-zinc-900 text-gray-300 disabled:text-gray-600 focus:text-gray-200 outline-none font-normal placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none">30
</div>31
<div class="flex flex-col col-span-8 sm:col-span-4">32
<p class="text-white font-medium pb-2 text-lg">{{$('account.language')}}</p>33
<span class="text-gray-400 pb-4 text-md flex-1">{{$('account.language.info')}}</span>34
<div class="flex items-center relative">35
<select v-model="account.settings.language" v-on:change="doAccountSave" type="text" class="w-full h-[54px] px-5 sm:h-[48px] sm:px-4 appearance-none text-md rounded-lg bg-zinc-900 text-gray-300 disabled:text-gray-600 focus:text-gray-200 outline-none font-normal placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none">36
<option value="en">English</option>37
<option value="de">Deutsch</option>38
</select>39
<div class="absolute right-3 pointer-events-none w-[30px] h-[30px] bg-gray-400 [mask:url(https://cdn.typable.dev/tabler/chevron-down)]" style="-webkit-mask-repeat: no-repeat; -webkit-mask-position: center;"></div>40
</div>41
</div>42
<div class="flex flex-col col-span-8 sm:col-span-8 border-t sm:border-t-2 border-zinc-800"></div>43
<div class="flex flex-col col-span-8 sm:col-span-8">44
<p class="text-gray-300 text-[22px] font-medium pb-2 text-lg">{{$('account.player')}}</p>45
</div>46
<div class="flex flex-col col-span-8 sm:col-span-4">47
<p class="text-white font-medium pb-2 text-lg">{{$('account.playback-history')}}</p>48
<span class="text-gray-400 pb-4 text-md flex-1">{{$('account.playback-history.info')}}</span>49
<div class="flex h-[54px] sm:h-[48px] items-center">50
<label for="account-playback-history" class="w-[50px] h-[20px] bg-zinc-900 rounded-full ml-[10px] relative cursor-pointer group">51
<input v-model="account.settings.is_playback_history" v-on:change="doAccountSave" type="checkbox" id="account-playback-history" class="peer opacity-0 w-0 h-0 pointer-events-none select-none outline-none">52
<div class="before:absolute before:-translate-y-[50%] before:-left-[10px] before:transition-all before:top-[10px] before:content-[''] before:z-10 before:block peer-checked:after:bg-gray-500/70 peer-checked:before:translate-x-[40px] before:w-[32px] before:h-[32px] sm:before:h-[28px] sm:before:w-[28px] before:rounded-full before:bg-zinc-400 after:content-[''] after:absolute after:block after:-left-[10px] after:rounded-full after:transition-colors after:left-0 after:top-0 after:w-full after:h-[20px] group-hover:before:bg-zinc-300 outline-none"></div>53
</label>54
</div>55
</div>56
</div>57
</div>58
<div>59
<h1 class="text-white text-[28px] font-semibold pb-6 sm:pb-8">{{$('account.devices')}}</h1>60
<div class="grid grid-cols-8 gap-8 sm:gap-10">61
<div class="flex flex-col gap-8 col-span-8 pt-8 sm:pt-12">62
<ul class="flex flex-col">63
<li v-for="device in account.settings.devices" class="flex gap-4 px-3 py-2 items-center hover:bg-zinc-800 rounded-md group transition-colors">64
<div v-bind:title="device" class="flex flex-1 min-w-0">65
<span class="text-gray-400 group-hover:text-gray-200 transition-colors overflow-hidden text-ellipsis whitespace-nowrap">{{device}}</span>66
</div>67
</li>68
</ul>69
<input v-model="account.foreign_code" type="text" maxlength="6" placeholder="------" class="w-[200px] text-center tracking-[8px] h-[56px] px-5 text-lg uppercase rounded-lg bg-zinc-900 text-white outline-none font-medium placeholder:tracking-[12px] placeholder:font-bold placeholder:normal-case placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none">70
<div class="flex gap-8 flex-col sm:flex-row w-full">71
<button v-on:click="doSync" class="flex-1 bg-zinc-900 hover:bg-zinc-100 rounded-lg px-4 h-[48px] min-h-[48px] transition-colors text-gray-200 hover:text-gray-800 text-md">Connect</button>72
<button v-on:click="doGenerate" class="flex-1 bg-zinc-900 hover:bg-zinc-100 rounded-lg px-4 h-[48px] min-h-[48px] transition-colors text-gray-200 hover:text-gray-800 text-md">Link device</button>73
</div>74
</div>75
</div>76
</div>77
<div>78
<div class="grid grid-cols-8 gap-8 sm:gap-10 pb-8">79
<div class="flex flex-col gap-1 col-span-8 pt-8 sm:pt-12">80
<p class="text-zinc-400 text-md mx-auto">Verbal</p>81
<p class="text-zinc-400 text-md mx-auto">Version: {{version}}</p>82
</div>83
</div>84
</div>85
</div>86
-->88
</v-tab>89
`90
}
1
import {$lang} from '../utils.js';1
import {$lang, http} from '../utils.js';2
import VIcon from '../element/icon.js';3
import VPlayer from '../component/player.js';4
import VTab from '../component/tab.js';5
import VStation from '../component/station.js';7
export default {8
props: ['state'],9
data() {10
return {11
results: [],12
loading: false13
};14
},15
components: {16
VIcon,17
VTab,9
VPlayer18
VPlayer,19
VStation20
},21
methods: {12
$lang22
$lang,23
async doFetch() {24
this.loading = true;25
const result = await http`get::/api/favorite`();26
this.loading = false;27
this.results = result.data;28
}29
},30
mounted() {31
this.doFetch();32
},33
template: `34
<v-tab id="favorites" :tab="state.tab">35
<v-player :station="state.station"></v-player>36
<ul class="flex flex-col">37
<li38
:key="station.id"39
v-for="station in results"40
class="border-t sm:border-t-2 first:border-none border-zinc-900 py-5 first:pt-0"41
>42
<v-station :station="station"></v-station>43
</li>44
</ul>45
<div46
v-show="loading"47
class="w-[60px] h-[60px] select-none pointer-events-none mx-auto"48
>49
<v-icon50
id="loader"51
class="bg-gray-400 animate-spin"52
style="animation-duration: 2s;"53
size="80%"54
></v-icon>55
</div>56
<!--57
<ul v-if="account.info" class="flex flex-col">58
<li v-bind:key="station.id" v-for="station in account.favorites" class="w-full py-5 gap-4 group flex items-center border-t sm:border-t-2 first:border-none border-zinc-900">
1
import {$lang} from '../utils.js';1
import {$lang, http} from '../utils.js';2
import VIcon from '../element/icon.js';3
import VPlayer from '../component/player.js';4
import VTab from '../component/tab.js';
14
},15
results: [],16
loading: false,17
more: false17
more: true18
};19
},20
components: {
24
VStation25
},26
methods: {27
$lang27
$lang,28
async doSearch() {29
this.loading = true;30
const result = await http`get::/api/search`(this.query);31
this.loading = false;32
this.results = result.data;33
}34
},35
mounted() {36
this.doSearch();37
},38
template: `39
<v-tab id="search" :tab="state.tab">
49
<li50
:key="station.id"51
v-for="station in results"52
class="border-t sm:border-t-2 first:border-none border-zinc-900 py-5 first:pt-0"53
>54
<v-station :station="station"></v-station>55
</li>
69
v-if="!more && results.length > 0"70
class="text-zinc-400 text-md mx-auto pb-6"71
>62
{{$('search.list.end')}}72
{{$lang('search.list.end')}}73
</div>74
</v-tab>75
`
13
const line = ltr(parts, values).trim();14
const regex = /^(\w+)::([\w\/.]*)$/;15
const [, method, path] = line.match(regex) ?? [];16
return (body) => {16
return (data) => {17
return new Promise(async (resolve, reject) => {18
try {19
const headers = {20
'content-type': 'application/json',21
}22
const deviceToken = localStorage.getItem('verbal.device_token');22
const deviceToken = localStorage.getItem('verbal-token');23
if(deviceToken) {24
headers['verbal-device-token'] = deviceToken;24
headers['verbal-token'] = deviceToken;25
}26
const response = await fetch(window.location.origin + path, {26
let body = null;27
let params = '';28
if(method === 'get' || method === 'head') {29
params = '?' + new URLSearchParams(data).toString();30
}31
else {32
body = JSON.stringify(data);33
}34
const response = await fetch(window.location.origin + path + params, {35
method,36
headers,29
body: JSON.stringify(body)37
body38
});39
resolve(await response.json());40
}
48
const locale = await http`get::/asset/json/locale.json`();50
export function $lang(id) {43
return locale[state.locale ?? 'en'][id];51
return locale[state.account?.language ?? 'en'][id];52
}
129
for station_id in station_ids {130
for adapter in &adapters {131
if adapter.stationuuid == station_id {132
stations.push(adapter.clone().populate(Station::default()));132
let mut station = Station::default();133
station.is_favorite = true;134
stations.push(adapter.clone().populate(station));135
}136
}137
}
188
});190
/* search */189
app.at("/api/search").get(|mut req: tide::Request<State>| async move {191
app.at("/api/search").get(|req: tide::Request<State>| async move {192
let account = match identify(&req).await {193
Ok(model) => model,194
Err(err) => return Response::throw(err),195
};194
let inner = match req.body_json::<Search>().await {196
let inner = match req.query::<Search>() {197
Ok(inner) => inner,198
Err(err) => return Response::throw(Error::new(ErrorKind::Arguments, &err.to_string())),199
};