meteor3: re-enable fixtures and sitemaps with async/Meteor-3 implementations

fixtures: drop @cleverbeagle/seeder (sync Mongo, unmaintained) for a small
idempotent async seeder (same dev accounts). sitemaps: drop dead
gadicohen:sitemaps for a WebApp.connectHandlers /sitemap.xml with the same
static page list (the per-fire section was already disabled). Verified on
dev boot: 6 users ensured, sitemap serving; REST smoke byte-identical.
This commit is contained in:
vjrj 2026-07-14 07:06:07 +02:00
parent 66bab7a43b
commit 0ff9848cd4
8 changed files with 20493 additions and 15709 deletions

View file

@ -1,44 +1,37 @@
/* global sitemaps */
/* eslint-disable import/no-absolute-path */
import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
import Fires from '/imports/api/Fires/Fires';
import Comments from '/imports/api/Comments/Comments';
/*
* /sitemap.xml own implementation replacing gadicohen:sitemaps (pre-0.9
* package API, dead on Meteor 3). Static pages only: the per-fire section of
* the old handler was behind `firesMapEnabled = false` (dead code) and was
* dropped; see git history if it's ever wanted back.
*/
const firesMapEnabled = false;
const PAGES = [
'/fires',
'/login',
'/signup',
'/recover-password',
'/credits',
'/terms',
'/license',
'/privacy',
'/about'
];
sitemaps.add('/sitemap.xml', () => {
const today = new Date();
function xmlEscape(s) {
return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
const out = [];
out.push({ page: '/fires', lastmod: today });
out.push({ page: '/login', lastmod: today });
out.push({ page: '/signup', lastmod: today });
out.push({ page: '/recover-password', lastmod: today });
out.push({ page: '/credits', lastmod: today });
out.push({ page: '/terms', lastmod: today });
out.push({ page: '/license', lastmod: today });
out.push({ page: '/privacy', lastmod: today });
out.push({ page: '/about', lastmod: today });
// When user has public page
/* const users = Meteor.users.find().fetch();
_.each(users, function(user) {
out.push({
page: '/persona/' + user.username,
lastmod: user.updatedAt
});
}); */
if (firesMapEnabled) {
Fires.find({}, { limit: 100, sort: { createdAt: -1 } }).fetch().forEach((fire) => {
// Search the last comment of tha fire
const lastComment = Comments.findOne({ referenceId: `fire-${fire._id}` }, { sort: { createdAt: -1 } });
out.push({
page: `/fire/archive/${fire._id._str}`,
lastmod: lastComment ? lastComment.createdAt : fire.updatedAt
});
});
}
return out;
WebApp.connectHandlers.use('/sitemap.xml', (req, res) => {
const lastmod = new Date().toISOString().slice(0, 10);
const urls = PAGES.map((page) => {
const loc = xmlEscape(Meteor.absoluteUrl(page.replace(/^\//, '')));
return ` <url>\n <loc>${loc}</loc>\n <lastmod>${lastmod}</lastmod>\n </url>`;
}).join('\n');
const body = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls}\n</urlset>\n`;
res.writeHead(200, { 'Content-Type': 'application/xml; charset=utf-8' });
res.end(body);
});