Files
computer-playbook/roles/web-svc-simpleicons/templates/server.js.j2
kevinveenbirkenbachandClaude Opus 4.7 177f039b11 refactor(web-app-zammad): rename basic_auth_password → api_bot_password + SPOTs
- Rename credential basic_auth_password → api_bot_password and var
  ZAMMAD_ADMINISTRATOR_PASSWORD → ZAMMAD_API_BOT_PASSWORD to reflect
  that the value is the role-internal bot's local password, not the
  administrator's (reused for the wizard-bypass admin only because both
  need the same shell-safe alphanumeric form).
- Introduce ORGANIZATION constant (defaults to SOFTWARE_NAME) and migrate
  organization-string consumers (mattermost team, shopware shop title,
  dashboard login/logout descriptions, simpleicons "provided by",
  user-administrator description/lastname).
- Add HOST_LL_CC_TAG (BCP-47 form, e.g. en-gb) and use in auto_wizard.
- Add NETWORK_TRUSTED_PROXY_CIDRS SPOT and consume from suitecrm,
  shopware and zammad reverse-proxy configs.
- Extract ZAMMAD_WEB_PROTOCOL via lookup('tls', …, 'protocols.web')
  instead of inline 'https' if … else 'http'.
- Use database_query for CREATEDB grant so it works on shared+non-shared
  databases; back the SQL with files/sql/grant_createdb.sql SPOT.
- Read administrator firstname/lastname from users lookup in
  auto_wizard.json.j2 instead of hardcoding.
- Drop redundant elasticsearch: block from web-app-zammad services.yml
  (no consumer reads it).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 00:03:15 +02:00

73 lines
1.8 KiB
Django/Jinja

import express from 'express';
import * as icons from 'simple-icons';
import sharp from 'sharp';
const app = express();
const port = {{ container_port }};
// Helper: convert 'nextcloud' → 'siNextcloud'
function getExportName(slug) {
return 'si' + slug
.split('-')
.map(part => part[0].toUpperCase() + part.slice(1))
.join('');
}
// Root: redirect to documentation (only if web-app-sphinx is available)
app.get('/', (req, res) => {
{% if 'web-app-sphinx' in group_names %}
res.redirect('{{ lookup("tls", "web-app-sphinx", "url.base") }}{{ application_id | rel_role_path_by_application_id }}/README.html');
{% else %}
res
.status(200)
.type('text/plain; charset=utf-8')
.send(
`simpleicons.org\n` +
`provided by {{ ORGANIZATION }}\n`
);
{% endif %}
});
// GET /:slug.svg
app.get('/:slug.svg', (req, res) => {
const slug = req.params.slug.toLowerCase();
const exportName = getExportName(slug);
const icon = icons[exportName];
if (!icon) {
return res.status(404).send('Icon not found');
}
res.type('image/svg+xml');
res.send(icon.svg);
});
// GET /:slug.png?size=...
app.get('/:slug.png', async (req, res) => {
const slug = req.params.slug.toLowerCase();
const size = parseInt(req.query.size, 10) || 128;
const exportName = getExportName(slug);
const icon = icons[exportName];
if (!icon) {
return res.status(404).send('Icon not found');
}
try {
const pngBuffer = await sharp(Buffer.from(icon.svg))
.resize(size, size)
.png()
.toBuffer();
res.type('image/png');
res.send(pngBuffer);
} catch (err) {
console.error('PNG generation error:', err);
res.status(500).send('PNG generation error');
}
});
app.listen(port, () => {
console.log(`Simple-Icons server listening at http://0.0.0.0:${port}`);
});