mirror of
https://github.com/anuraghazra/github-readme-stats.git
synced 2024-12-15 06:04:17 +08:00
f1df178643
* Add Card Translations
* Add tests and documentation for `?lang` option
* Card Translations: update Italian
* Run Prettier
* Correct German Translations.
Co-authored-by: schmelto <30869493+schmelto@users.noreply.github.com>
* refactor: added i18n class to manage translation logic & improved code
* Make the new src/translations.js more concise
* Update translations.js
Co-authored-by: schmelto <30869493+schmelto@users.noreply.github.com>
* Revert 4175484d69
* fix: overlap because of language length
Co-authored-by: lrusso96 <russo.1699981@studenti.uniroma1.it>
Co-authored-by: schmelto <30869493+schmelto@users.noreply.github.com>
Co-authored-by: Anurag <hazru.anurag@gmail.com>
69 lines
1.5 KiB
JavaScript
69 lines
1.5 KiB
JavaScript
require("dotenv").config();
|
|
const {
|
|
renderError,
|
|
parseBoolean,
|
|
clampValue,
|
|
CONSTANTS,
|
|
isLocaleAvailable,
|
|
} = require("../src/common/utils");
|
|
const { fetchLast7Days } = require("../src/fetchers/wakatime-fetcher");
|
|
const wakatimeCard = require("../src/cards/wakatime-card");
|
|
|
|
module.exports = async (req, res) => {
|
|
const {
|
|
username,
|
|
title_color,
|
|
icon_color,
|
|
hide_border,
|
|
line_height,
|
|
text_color,
|
|
bg_color,
|
|
theme,
|
|
cache_seconds,
|
|
hide_title,
|
|
hide_progress,
|
|
custom_title,
|
|
locale,
|
|
} = req.query;
|
|
|
|
res.setHeader("Content-Type", "image/svg+xml");
|
|
|
|
if (locale && !isLocaleAvailable(locale)) {
|
|
return res.send(renderError("Something went wrong", "Language not found"));
|
|
}
|
|
|
|
try {
|
|
const last7Days = await fetchLast7Days({ username });
|
|
|
|
let cacheSeconds = clampValue(
|
|
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
|
|
CONSTANTS.TWO_HOURS,
|
|
CONSTANTS.ONE_DAY,
|
|
);
|
|
|
|
if (!cache_seconds) {
|
|
cacheSeconds = CONSTANTS.FOUR_HOURS;
|
|
}
|
|
|
|
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
|
|
|
|
return res.send(
|
|
wakatimeCard(last7Days, {
|
|
custom_title,
|
|
hide_title: parseBoolean(hide_title),
|
|
hide_border: parseBoolean(hide_border),
|
|
line_height,
|
|
title_color,
|
|
icon_color,
|
|
text_color,
|
|
bg_color,
|
|
theme,
|
|
hide_progress,
|
|
locale: locale ? locale.toLowerCase() : null,
|
|
}),
|
|
);
|
|
} catch (err) {
|
|
return res.send(renderError(err.message, err.secondaryMessage));
|
|
}
|
|
};
|