From 595d7769ec69f5cc19df39fe7c653c3ca6f28eed Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 13 Jun 2022 18:37:50 +0400 Subject: [PATCH] Template was rewritten to a form that gets pre-compiled into a Go source file. Must help to increase speed drastically. --- web/templates/index.jade | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/web/templates/index.jade b/web/templates/index.jade index 6784045..5ca6869 100644 --- a/web/templates/index.jade +++ b/web/templates/index.jade @@ -1,3 +1,7 @@ +:go:func Index(mainSite string, status *radio.IcecastStatus, songs *[]radio.Song) + +:go:import "dwelling-radio/internal/radio" + doctype html html(lang='en') head @@ -16,7 +20,7 @@ html(lang='en') text.logo Arav's dwelling text.under(y='11') Welcome to my sacred place, wanderer nav - a(href=.MainSite) Back to main website + a(href=mainSite) Back to main website h1 Radio section small.player-links @@ -31,27 +35,27 @@ html(lang='en') audio(preload='none' controls='') source(src='/live/stream.ogg' type='audio/ogg') | Your browser doesn't support an audio element, it's sad... But you always can take the #[a(href='/playlist') playlist]! - if .Status.ServerStartDate + if status.ServerStartDate != "" p#radio-status On-air since - time(datetime=.Status.ServerStartISO8601)= .Status.ServerStartDate + time(datetime=status.ServerStartISO8601)= status.ServerStartDate else p#radio-status Radio is offline. - p Now playing: #[span#radio-song #{.Status.SongName}] - p Current/peak listeners: #[span#radio-listeners #{.Status.Listeners}] / #[span#radio-listener-peak #{.Status.ListenerPeak}] + p Now playing: #[span#radio-song #{status.SongName}] + p Current/peak listeners: #[span#radio-listeners #{status.Listeners}] / #[span#radio-listener-peak #{status.ListenerPeak}] p small Notice: information updates every 45 seconds. But you can #[button(id='btn-update') update] it forcibly. - if .Songs + if len(*songs) > 0 section h2 Last 10 songs table#last-played - each s in .Songs + each song in *songs tr - td= .Time - if ne .Listeners "0" - td= .Listeners + td= song.Time + if song.Listeners != "0" + td= song.Listeners else td - td= .Song + td= song.Song section p The largest number of simultaneous listeners was #[b 7] at #[time(datetime='2022-02-19') 19 February 2022], and the song was "Röyksopp - 49 Percent". section