From ce399ce258256f1cb50ec10f97c884770f935dfd Mon Sep 17 00:00:00 2001 From: didier amyot Date: Fri, 25 Apr 2025 09:53:48 -0400 Subject: [PATCH] Fixed couple of bugs --- README.md | 20 ++-- my-template.vto | 1 - static/scripts/little-calendar.js | 148 +++++++++++++++------------- templates/home.vto | 3 +- templates/includes/home-news.vto | 2 +- templates/nouvelles.vto | 4 +- templates/partials/games-editor.vto | 2 +- 7 files changed, 98 insertions(+), 82 deletions(-) delete mode 100644 my-template.vto diff --git a/README.md b/README.md index 31d849b..a2ea44e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Site Web de Balle Phénix +# Site Web de [Balle Phénix](http://ballephenix.com) ![Image Alt](https://gitlab.com/ballephenix/website/raw/master/images/phenix_logo.png) @@ -32,11 +32,17 @@ side for The softball league 'Balle Phénix'. ## How to build - $ npm install - $ node_modules/.bin/gulp help +No build, it uses [deno](https://deno.land) -# How it is made +# How to run it -* mithril.js as client side framework -* uikit as css framework -* coffee and love +```shell +deno run -A --unstable-vk server.ts +``` + + +## How to deploy the website + +```shell +./deploy +``` diff --git a/my-template.vto b/my-template.vto deleted file mode 100644 index 3d6eca7..0000000 --- a/my-template.vto +++ /dev/null @@ -1 +0,0 @@ -hello {{ title }} diff --git a/static/scripts/little-calendar.js b/static/scripts/little-calendar.js index ebebee7..a70b805 100644 --- a/static/scripts/little-calendar.js +++ b/static/scripts/little-calendar.js @@ -1,99 +1,109 @@ // alert("ok") import * as util from "./util.js"; -import * as resultParser from './resultParser.js' -import * as teams from './teams.js' -import m from "https://esm.sh/mithril@2.2.2" -import {rainSvg} from "./images.js"; -import _ from "https://esm.sh/lodash-es@4.17.21" - -import {statsView, tabView, scheduleTeamTags } from './schedule.js' +import * as resultParser from "./resultParser.js"; +import * as teams from "./teams.js"; +import m from "https://esm.sh/mithril@2.2.2"; +import { rainSvg } from "./images.js"; +import _ from "https://esm.sh/lodash-es@4.17.21"; +import { statsView, tabView, scheduleTeamTags } from "./schedule.js"; const nextGameDaySchedule = {}; -nextGameDaySchedule._toDay = function(){ - var now = new Date(); - return new Date(now.getFullYear(), now.getMonth(), now.getDate()); +nextGameDaySchedule._toDay = function () { + var now = new Date(); + return new Date(now.getFullYear(), now.getMonth(), now.getDate()); }; -nextGameDaySchedule.oninit = async function(){ +const currentYear = new Date(); - const result = await m.request({ - method: "GET", - url: `/api/results/2024.json` - }); +nextGameDaySchedule.oninit = async function () { + const result = await m.request({ + method: "GET", + url: `/api/results/${new Date().getFullYear()}.json`, + }); const nightGames = resultParser.getNightGames(result); - nextGameDaySchedule.games = nextGameDaySchedule._getNextNightGame(nightGames, nextGameDaySchedule._toDay()); + nextGameDaySchedule.games = nextGameDaySchedule._getNextNightGame( + nightGames, + nextGameDaySchedule._toDay(), + ); }; -nextGameDaySchedule._getNextNightGame = function(games, date){ - return _(games) - .filter(g => g.jsDate.getTime() >= date.getTime()) - .last() - .games - .sort((g1, g2) => g1.jsDate - g2.jsDate); +nextGameDaySchedule._getNextNightGame = function (games, date) { + return _(games) + .filter((g) => g.jsDate.getTime() >= date.getTime()) + .last() + .games.sort((g1, g2) => g1.jsDate - g2.jsDate); }; -nextGameDaySchedule._getTableHead = function(){ - return m('thead', m('tr', [ - m('td', 'Date'), - m('td', 'Heure'), - m('td', 'Receveur'), - m('td', 'Visiteur') - ])); +nextGameDaySchedule._getTableHead = function () { + return m( + "thead", + m("tr", [ + m("td", "Date"), + m("td", "Heure"), + m("td", "Receveur"), + m("td", "Visiteur"), + ]), + ); }; -nextGameDaySchedule._responsoveText = function(largeText, smallText, game){ - var ret = []; - if(game.rain){ - ret.push(rainSvg('1.5em')); - ret.push(' '); - } else if(game.practice){ - ret.push(m('span.uk-badge.uk-badge-success', 'pratique!')); - ret.push(' '); - } - ret.push(m('span.uk-visible-large', largeText)); - ret.push(m('span.uk-hidden-large', smallText)); - return ret; +nextGameDaySchedule._responsoveText = function (largeText, smallText, game) { + var ret = []; + if (game.rain) { + ret.push(rainSvg("1.5em")); + ret.push(" "); + } else if (game.practice) { + ret.push(m("span.uk-badge.uk-badge-success", "pratique!")); + ret.push(" "); + } + ret.push(m("span.uk-visible-large", largeText)); + ret.push(m("span.uk-hidden-large", smallText)); + return ret; }; -nextGameDaySchedule._getGamesRow = function(game){ - return m('tr', [ - m('td', nextGameDaySchedule._responsoveText(util.formatDate(game.jsDate), - util.formatDateSmall(game.jsDate), - game)), - m('td', game.time), - m('td', scheduleTeamTags.getHomeTeamTag(game)), - m('td',scheduleTeamTags.getAwayTeamTag(game)) - ]); +nextGameDaySchedule._getGamesRow = function (game) { + return m("tr", [ + m( + "td", + nextGameDaySchedule._responsoveText( + util.formatDate(game.jsDate), + util.formatDateSmall(game.jsDate), + game, + ), + ), + m("td", game.time), + m("td", scheduleTeamTags.getHomeTeamTag(game)), + m("td", scheduleTeamTags.getAwayTeamTag(game)), + ]); }; -nextGameDaySchedule._getGamesRows = function(games){ - return _.map(games, nextGameDaySchedule._getGamesRow); +nextGameDaySchedule._getGamesRows = function (games) { + return _.map(games, nextGameDaySchedule._getGamesRow); }; -nextGameDaySchedule.view = function(){ - return m('table.uk-table.uk-table-hover.uk-table-striped.uk-table-condensed',[ - nextGameDaySchedule._getTableHead(), - m('tbody', - nextGameDaySchedule._getGamesRows(nextGameDaySchedule.games) - )]); +nextGameDaySchedule.view = function () { + return m( + "table.uk-table.uk-table-hover.uk-table-striped.uk-table-condensed", + [ + nextGameDaySchedule._getTableHead(), + m("tbody", nextGameDaySchedule._getGamesRows(nextGameDaySchedule.games)), + ], + ); }; +const LittleCalendar = {}; - - - -const LittleCalendar = {} - -LittleCalendar.view = function(){ +LittleCalendar.view = function () { return m(nextGameDaySchedule); -} +}; -const containerIds = ['large-mithril-container', - 'medium-mithril-container', - 'small-mithril-container'] +const containerIds = [ + "large-mithril-container", + "medium-mithril-container", + "small-mithril-container", +]; -for(const id of containerIds){ +for (const id of containerIds) { m.mount(document.getElementById(id), LittleCalendar); } diff --git a/templates/home.vto b/templates/home.vto index b2f4ee2..28359ae 100644 --- a/templates/home.vto +++ b/templates/home.vto @@ -87,7 +87,8 @@

Calendrier

-
+
+
diff --git a/templates/includes/home-news.vto b/templates/includes/home-news.vto index 09ad320..bb1c67f 100644 --- a/templates/includes/home-news.vto +++ b/templates/includes/home-news.vto @@ -1,6 +1,6 @@

-

Saison 2023

+

Saison 2025

diff --git a/templates/nouvelles.vto b/templates/nouvelles.vto index a4f9725..a16963e 100644 --- a/templates/nouvelles.vto +++ b/templates/nouvelles.vto @@ -5,10 +5,10 @@

-

Saison 2023

+

Saison 2025

Dimanche 10 Juillet 2023

+

Vendredi 25 Avril 2025

Bonne saison à tous et toutes!

N'oubliez pas de consulter la page facebook: https://www.facebook.com/SportsPhenixMtl/ pour toutes mises à jour, y compris les annulations due à la météo.

diff --git a/templates/partials/games-editor.vto b/templates/partials/games-editor.vto index a0b6ea4..4e3d092 100644 --- a/templates/partials/games-editor.vto +++ b/templates/partials/games-editor.vto @@ -30,7 +30,7 @@