Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 12 additions & 8 deletions backend/handlers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ export function handleGeocodeAddress(requestUrl, res) {

console.log(`[Geocode] Address lookup: ${q}`);

https.get({ hostname: 'nominatim.openstreetmap.org', path: `/search?${target.searchParams}`, headers: {
'Accept-Language': 'fr,en',
'User-Agent': 'CommunautoFlexWebNotifier/1.0 (https://github.com/jeromelefeuvre/communauto-flex-webnotifier)'
}}, (proxyRes) => {
https.get({
hostname: 'nominatim.openstreetmap.org', path: `/search?${target.searchParams}`, headers: {
'Accept-Language': 'fr,en',
'User-Agent': 'CommunautoFlexWebNotifier/1.0 (https://github.com/jeromelefeuvre/communauto-flex-webnotifier)'
}
}, (proxyRes) => {
res.writeHead(proxyRes.statusCode, { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' });
proxyRes.pipe(res);
}).on('error', (err) => {
Expand All @@ -86,9 +88,11 @@ export function handleGeocodePostal(requestUrl, res) {

console.log(`[Geocode] Postal code lookup: ${q}`);

https.get({ hostname: 'geocoder.ca', path: `/?locate=${encodeURIComponent(q)}&geoit=XML&json=1`, headers: {
'User-Agent': 'CommunautoFlexWebNotifier/1.0'
}}, (proxyRes) => {
https.get({
hostname: 'geocoder.ca', path: `/?locate=${encodeURIComponent(q)}&geoit=XML&json=1`, headers: {
'User-Agent': 'CommunautoFlexWebNotifier/1.0'
}
}, (proxyRes) => {
res.writeHead(proxyRes.statusCode, { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' });
proxyRes.pipe(res);
}).on('error', (err) => {
Expand Down Expand Up @@ -165,7 +169,7 @@ export function handleStaticFiles(requestUrl, res) {
} catch (e) { }

// Dynamically cache-bust main static assets based on package version
text = text.replace(/href="static\/css\/style\.css"/g, `href="static/css/style.css?v=${version}"`);
text = text.replace(/href="static\/css\/([^"]+)\.css"/g, `href="static/css/$1.css?v=${version}"`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This is a great improvement for cache-busting CSS files. You could apply a similar pattern for the JavaScript files below. This would make the code more maintainable and also fix a bug where location.js is not being cache-busted.

I recommend replacing all the individual text.replace calls for JS files (lines 173-177) with a single, more robust line:

text = text.replace(/src="static\/js\/([^\"]+)\.js"/g, `src="static/js/$1.js?v=${version}"`);

text = text.replace(/src="static\/js\/config\.js"/g, `src="static/js/config.js?v=${version}"`);
text = text.replace(/src="static\/js\/utils\.js"/g, `src="static/js/utils.js?v=${version}"`);
text = text.replace(/src="static\/js\/ui\.js"/g, `src="static/js/ui.js?v=${version}"`);
Expand Down
26 changes: 26 additions & 0 deletions frontend/static/css/responsive.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,32 @@
padding: 8px 16px;
}

header {
text-align: left;
min-width: 0; /* Allows text truncation in flex container */
flex-shrink: 1; /* Allows header to shrink */
margin-right: 12px;
}

header h1 {
font-size: 18px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.subtitle {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.btn-install-header {
flex-shrink: 0; /* Ensure the button never shrinks and gets cut off */
padding: 6px 12px;
font-size: 12px;
}

.map-container {
border-radius: 0;
border: none;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "communauto-flex-webnotifier",
"version": "1.12.0",
"version": "1.12.1",
"description": "Look for close-by Communauto flex cars and get an alert ========================================================",
"main": "app.js",
"scripts": {
Expand Down
Loading