Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single page app for the calendar #860

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
93f3f31
prep: split head html and add new blocks
ionous Jan 24, 2025
21503f5
add some comments to the netlify config
ionous Jan 24, 2025
6b6fa49
wip: an initial "slim" view
ionous Jan 24, 2025
e5a3cf8
placeholder toolbar
ionous Jan 25, 2025
2eacc94
improve node endpoint configuration
ionous Jan 26, 2025
2ba9464
improve netlify comments
ionous Jan 26, 2025
52ec03b
implement "jump to date"
ionous Jan 26, 2025
933025f
bug fixes for node config changes
ionous Jan 26, 2025
f9a466d
improve menu
ionous Jan 26, 2025
3bf8318
avoid fetching data when subroutes change
ionous Jan 26, 2025
96476d3
start of pedalp data
ionous Jan 28, 2025
45919a7
rename "slim" to "events"
ionous Jan 28, 2025
38deb42
improve top banner and date navigation
ionous Feb 1, 2025
a2eb833
whitespace fix
ionous Feb 1, 2025
b2811fe
add pp before/after dividers
ionous Feb 1, 2025
a24c1a5
add/fix npm run dev paths
ionous Feb 1, 2025
ce4c0cf
use siteConfig for api endpoint; add comments.
ionous Feb 1, 2025
e3d01bb
forward / back navigation for the event list
ionous Feb 1, 2025
9d69de8
progress on single page event
ionous Feb 4, 2025
eeab48d
simplify/standardize range fetching
ionous Feb 7, 2025
25cd2a0
fix bugs with forward/back navigation
ionous Feb 7, 2025
02897f9
switch to beforeMount/beforeRouteUpdate
ionous Feb 7, 2025
a4f900c
bug fix
ionous Feb 7, 2025
cf0fd03
add some keys to v-for
ionous Feb 8, 2025
c53a4ae
add share and export links
ionous Feb 8, 2025
04a069b
contact info, and nav
ionous Feb 8, 2025
0e3b920
improve scroll into view behavior
ionous Feb 8, 2025
0453a96
add the events app to netlify
ionous Feb 8, 2025
22c9120
add doc on status and tods
ionous Feb 8, 2025
8fbc6c2
vite prep
ionous Feb 15, 2025
d2376d3
move the spa out of hugo
ionous Feb 15, 2025
7caddee
add vite to npm run dev, npm run build, etc.
ionous Feb 15, 2025
704e385
size optimization by switching to single file components
ionous Feb 15, 2025
00b44b2
experiment with netlify using npm run
ionous Feb 15, 2025
3526ee9
tell netlify to install first
ionous Feb 15, 2025
d89f489
more netlify tweaks
ionous Feb 15, 2025
d35f288
snark hunting
ionous Feb 15, 2025
8e380da
netlify debugging
ionous Feb 15, 2025
a470d6f
alright, try just plain site
ionous Feb 15, 2025
50910e6
more logging
ionous Feb 15, 2025
92fff70
fix?
ionous Feb 15, 2025
20c5f74
friendly urls, opengraph tags, cleanup query params
ionous Feb 18, 2025
e453d91
remove meta tags if content is missing
ionous Feb 25, 2025
ae9e0bf
placeholder empty component
ionous Feb 25, 2025
901d9cf
prep for search: refactor to share "chrome"
ionous Feb 25, 2025
6acbdab
fixed doubled "Shift" in title
ionous Feb 25, 2025
c021cd2
add cancelled decoration
ionous Feb 25, 2025
72db438
improve comments
ionous Feb 25, 2025
bc2091b
add featured ride
ionous Feb 26, 2025
7d47446
adds font awesome, initial styling, small fixes
ionous Feb 28, 2025
55fc653
Merge branch 'main' into slim
ionous Feb 28, 2025
faa0df6
improve wrapping of disclosure
ionous Feb 28, 2025
5fd43be
update status doc
ionous Feb 28, 2025
02dd03f
fix npm run preview
ionous Feb 28, 2025
15b9901
throw an error rather than accessing bad data
ionous Feb 28, 2025
5d93daf
don't add empty meta tags
ionous Feb 28, 2025
36e5213
wait to load banner, and better error handling
ionous Feb 28, 2025
f695534
menu tweaks
ionous Feb 28, 2025
f9d4b61
initial toolbar styles
ionous Feb 28, 2025
c15f397
Update Toolbar.vue
ionous Feb 28, 2025
82c04c0
fix subscribe button
ionous Mar 1, 2025
d5d62dc
fix bug with error not clearing when naving to a new page
ionous Mar 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ app/eventimages/*
!app/eventimages/bike-big.png
!app/eventimages/bike-bad.tiff
bin/
node_modules/
node_modules/
/frontend/.vscode
20 changes: 19 additions & 1 deletion app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const appPath = path.resolve(__dirname);
// for max file size
const bytesPerMeg = 1024*1024;

const staticFiles = env_default('SHIFT_STATIC_FILES');

const config = {
appPath,
api: {
Expand Down Expand Up @@ -46,7 +48,23 @@ const config = {
helpPage() {
return config.site.url("pages/calendar-faq/");
},
staticFiles: env_default('SHIFT_STATIC_FILES'),
staticFiles,
devEndpoints: !staticFiles ? null : [{
// ex. http://localhost:3080/addevent/edit-1-d00c888b0a1d4bab8107ba2fbe2beddf
// loads http://localhost:3080/addevent/index.html
url: "/addevent/edit-:series-:secret",
filePath: path.posix.resolve(staticFiles, 'addevent', 'index.html')
}, {
// ex. http://localhost:3080/calendar/event-201
// loads http://localhost:3080/calendar/event/index.html
url: "/calendar/event-:caldaily",
filePath: path.posix.resolve(staticFiles, 'calendar/event', 'index.html')
}, {
// ex. http://localhost:3080/events/201
// loads http://localhost:3080/events/index.html
url: "/events/:caldaily_id/:slug?",
filePath: path.posix.resolve(staticFiles, 'events', 'index.html')
}],
},
// various useful email addresses
// ( for sendConfirmationEmail() )
Expand Down
74 changes: 52 additions & 22 deletions app/facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,64 @@
// ex. npm run -w tools preview
const express = require('express');
const path = require('path');

// for these, javascript on the static page parses the url and sends backend requests.
// ngnix does this remapping when running docker locally;
// in production, its handled by netlify.
function splat(app, url, filePath) {
app.get(url, function (req, res, next) {
const parts = JSON.stringify(req.params);
console.debug(`remapping ${url} with ${parts}`);
res.sendFile(filePath);
});
}
const { createProxyMiddleware } = require('http-proxy-middleware');

// fix? might be cool to make this express "middleware"
const facade = {
// uses config for the source of the static files
// you can use "hugo --watch" to rebuild changes on demand.
serveFrontEnd(app, config) {
if (!config.site.staticFiles) {
serveWebContent(app, config) {
const { staticFiles } = config.site;
if (!staticFiles) {
throw new Error("missing static files path");
}
const staticFiles = path.resolve(config.appPath, config.site.staticFiles);
console.log("serving static files from", staticFiles);
app.use(express.static(staticFiles));

// ex. http://localhost:3080/addevent/edit-1-d00c888b0a1d4bab8107ba2fbe2beddf
splat(app,"/addevent/edit-:id-:secret",
path.posix.join(staticFiles, 'addevent', 'index.html'));
// remap any path under a url to a specific html pages.
// in production, this is done by netlify.
// running locally with docker, this is done by nginx.
// this handles local node development via "npm run dev"
config.site.devEndpoints.forEach(item => {
const { url, filePath } = item;
// when someone gets the url
app.get(url, function (req, res, next) {
// log url parts for debugging
const parts = JSON.stringify(req.params);
console.debug(`remapping ${url} with ${parts} to ${filePath}`);
// and always return the specified file
res.sendFile(filePath);
});
});
},

// ex. http://localhost:3080/calendar/event-201
splat(app,"/calendar/event-:id",
path.posix.join(staticFiles, 'calendar/event', 'index.html'));
// in production, netlify uses vite to build the frontend app
// into a single set of files embedded into events/index.html
// in development, vite runs a server to watch for source code changes
// our webpage can only talk to one server, so we make it talk to node
// and have node -- here -- send "events" requests to vite.
serveVite(app, config) {
const events = createProxyMiddleware({
logger: console,
target: 'http://localhost:5173/events/',
changeOrigin: true,
ws: true
});
app.use('/events', events);
const etc = createProxyMiddleware({
logger: console,
target: 'http://localhost:5173/',
pathFilter: [
'/@*/**', // ex. @vite/client
'/src/**',
'/node_modules/**',
// the proxy code uses micromatch, https://www.npmjs.com/package/micromatch and it doesn't allow star (*) to match dot (.)
'/node_modules/.*/**',
],
changeOrigin: true,
ws: true
});
app.use('/', etc);
},

// uses config for the image directory
Expand All @@ -54,8 +81,11 @@ const facade = {
},

makeFacade(app, config) {
facade.serveFrontEnd(app,config);
facade.serveImages(app,config);
// serve vite first so its events path will override any events folder in dist
// ( ex. if previously built with npm run build )
facade.serveVite(app, config);
facade.serveWebContent(app, config);
facade.serveImages(app, config);
}
};

Expand Down
21 changes: 21 additions & 0 deletions cal/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="robots" content="all,follow">
<meta name="googlebot" content="index,follow,snippet,archive">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Calendar - Shift</title>
<meta name="keywords" content="calendar, rides">
<meta name="description" content="Rides calendar">
<link rel="icon" href="/img/favicon.ico">
<link rel="icon" href="/img/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="/img/apple-touch-icon.png">
<!-- Verification metadata for Mastodon -->
<link href="https://pdx.social/@shift2bikes" rel="me">
</head>
<body>
<div id="app" class="c-app"></div>
<script type="module" src="/src/calMain.js"></script>
</body>
</html>
Loading