Note: The stats above are just examples and not from your GitHub profile.
-
-
diff --git a/src/demo/js/script.js b/src/demo/js/script.js
index d164d463..8239318a 100644
--- a/src/demo/js/script.js
+++ b/src/demo/js/script.js
@@ -15,9 +15,11 @@ const preview = {
type: "svg",
exclude_days: "",
card_width: "495",
+ card_height: "195",
hide_total_contributions: "false",
hide_current_streak: "false",
hide_longest_streak: "false",
+ short_numbers: "false",
},
/**
@@ -43,22 +45,32 @@ const preview = {
if (params.type !== "json") {
const repoLink = "https://git.io/streak-stats";
const md = `[](${repoLink})`;
+ const html = `
`;
document.querySelector(".output img").src = demoImageURL;
document.querySelector(".md code").innerText = md;
+ document.querySelector(".html code").innerText = html;
+ document.querySelector(".copy-md").parentElement.style.display = "block";
+ document.querySelector(".copy-html").parentElement.style.display = "block";
document.querySelector(".output img").style.display = "block";
document.querySelector(".output .json").style.display = "none";
+ document.querySelector(".copy-json").parentElement.style.display = "none";
} else {
- document.querySelector(".output img").style.display = "none";
- document.querySelector(".output .json").style.display = "block";
fetch(demoImageURL)
.then((response) => response.json())
.then((data) => (document.querySelector(".output .json pre").innerText = JSON.stringify(data, null, 2)))
.catch(console.error);
- document.querySelector(".md code").innerText = imageURL;
+ document.querySelector(".json code").innerText = imageURL;
+ document.querySelector(".copy-md").parentElement.style.display = "none";
+ document.querySelector(".copy-html").parentElement.style.display = "none";
+ document.querySelector(".output img").style.display = "none";
+ document.querySelector(".output .json").style.display = "block";
+ document.querySelector(".copy-json").parentElement.style.display = "block";
}
// disable copy button if username is invalid
- const copyButton = document.querySelector(".copy-button");
- copyButton.disabled = Boolean(document.querySelector("#user:invalid") || !document.querySelector("#user").value);
+ const copyButtons = document.querySelectorAll(".copy-button");
+ copyButtons.forEach((button) => {
+ button.disabled = Boolean(document.querySelector("#user:invalid") || !document.querySelector("#user").value);
+ });
// disable clear button if no added advanced options
const clearButton = document.querySelector("#clear-button");
clearButton.disabled = !document.querySelectorAll(".minus").length;
@@ -213,6 +225,7 @@ const preview = {
const option = Array.prototype.find.call(selectElement.options, (o) => o.value === property);
selectElement.disabled = false;
option.disabled = false;
+ selectElement.value = option.value;
// update and exit
this.update();
},
@@ -379,7 +392,13 @@ const clipboard = {
copy(el) {
// create input box to copy from
const input = document.createElement("input");
- input.value = document.querySelector(".md code").innerText;
+ if (el.classList.contains("copy-md")) {
+ input.value = document.querySelector(".md code").innerText;
+ } else if (el.classList.contains("copy-html")) {
+ input.value = document.querySelector(".html code").innerText;
+ } else if (el.classList.contains("copy-json")) {
+ input.value = document.querySelector(".json code").innerText;
+ }
document.body.appendChild(input);
// select all
input.select();
diff --git a/src/index.php b/src/index.php
index 41cc4e0b..610543ad 100644
--- a/src/index.php
+++ b/src/index.php
@@ -19,10 +19,11 @@
renderOutput($message, 500);
}
-// set cache to refresh once per hour
-header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600) . " GMT");
+// set cache to refresh once per three horus
+$cacheMinutes = 3 * 60 * 60;
+header("Expires: " . gmdate("D, d M Y H:i:s", time() + $cacheMinutes) . " GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
-header("Cache-Control: public, max-age=3600");
+header("Cache-Control: public, max-age=$cacheMinutes");
// redirect to demo site if user is not given
if (!isset($_REQUEST["user"])) {
diff --git a/src/themes.php b/src/themes.php
index 12d6b5d9..e6fc193d 100644
--- a/src/themes.php
+++ b/src/themes.php
@@ -1848,4 +1848,225 @@
"dates" => "#327698",
"excludeDaysLabel" => "#84A0C6",
],
+ "whatsapp-light2" => [
+ "background" => "#FFFFFF",
+ "border" => "#D8FDD2",
+ "stroke" => "#D8FDD2",
+ "ring" => "#767B7D",
+ "fire" => "#767B7D",
+ "currStreakNum" => "#1DAB61",
+ "sideNums" => "#1DAB61",
+ "currStreakLabel" => "#131A20",
+ "sideLabels" => "#131A20",
+ "dates" => "#767B7D",
+ "excludeDaysLabel" => "#E5A732",
+ ],
+ "whatsapp-dark2" => [
+ "background" => "#0B141B",
+ "border" => "#103629",
+ "stroke" => "#103629",
+ "ring" => "#858A8D",
+ "fire" => "#858A8D",
+ "currStreakNum" => "#21C063",
+ "sideNums" => "#21C063",
+ "currStreakLabel" => "#F7F8FA",
+ "sideLabels" => "#F7F8FA",
+ "dates" => "#858A8D",
+ "excludeDaysLabel" => "#FFD179",
+ ],
+ "travelers-theme" => [
+ "background" => "#150E1F",
+ "border" => "#E4E2E2",
+ "stroke" => "#F28157",
+ "ring" => "#F28157",
+ "fire" => "#F28157",
+ "currStreakNum" => "#F2F2F2",
+ "sideNums" => "#F28157",
+ "currStreakLabel" => "#F2F2F2",
+ "sideLabels" => "#F2F2F2",
+ "dates" => "#F2F2F2",
+ "excludeDaysLabel" => "#464646",
+ ],
+ "youtube-dark" => [
+ "background" => "#0F0F0F",
+ "border" => "#272727",
+ "stroke" => "#272727",
+ "ring" => "#FFFFFF",
+ "fire" => "#FFFFFF",
+ "currStreakNum" => "#FF0000",
+ "sideNums" => "#FF0000",
+ "currStreakLabel" => "#FFFFFF",
+ "sideLabels" => "#FFFFFF",
+ "dates" => "#BCBCBC",
+ "excludeDaysLabel" => "#FFFFFF",
+ ],
+ "meta-light" => [
+ "background" => "#FFFFFF",
+ "border" => "#1C2B33",
+ "stroke" => "#1C2B33",
+ "ring" => "#0081FB",
+ "fire" => "#006EE9",
+ "currStreakNum" => "#1C2B33",
+ "sideNums" => "#1C2B33",
+ "currStreakLabel" => "#1C2B33",
+ "sideLabels" => "#1C2B33",
+ "dates" => "#1C2B33",
+ "excludeDaysLabel" => "#1C2B33",
+ ],
+ "meta-dark" => [
+ "background" => "#1C2B33",
+ "border" => "#FFFFFF",
+ "stroke" => "#FFFFFF",
+ "ring" => "#0081FB",
+ "fire" => "#006EE9",
+ "currStreakNum" => "#FFFFFF",
+ "sideNums" => "#FFFFFF",
+ "currStreakLabel" => "#FFFFFF",
+ "sideLabels" => "#FFFFFF",
+ "dates" => "#FFFFFF",
+ "excludeDaysLabel" => "#FFFFFF",
+ ],
+ "dark-minimalist" => [
+ "background" => "#211F27",
+ "border" => "#B9B9C0",
+ "stroke" => "#B9B9C0",
+ "ring" => "#D484F4",
+ "fire" => "#D484F4",
+ "currStreakNum" => "#89B4FA",
+ "sideNums" => "#E5E5E5",
+ "currStreakLabel" => "#89B4FA",
+ "sideLabels" => "#E5E5E5",
+ "dates" => "#D0D1D3",
+ "excludeDaysLabel" => "#D0D1D3",
+ ],
+ "telegram" => [
+ "background" => "#FFFFFF",
+ "border" => "#333333",
+ "stroke" => "#333333",
+ "ring" => "#0088CC",
+ "fire" => "#179CDE",
+ "currStreakNum" => "#179CDE",
+ "sideNums" => "#0088CC",
+ "currStreakLabel" => "#179CDE",
+ "sideLabels" => "#0088CC",
+ "dates" => "#0088CC",
+ "excludeDaysLabel" => "#0088CC",
+ ],
+ "taiga" => [
+ "background" => "#031B1B",
+ "border" => "#062E2F",
+ "stroke" => "#062E2F",
+ "ring" => "#1F8F92",
+ "fire" => "#1FBABE",
+ "currStreakNum" => "#1FBABE",
+ "sideNums" => "#1F8F92",
+ "currStreakLabel" => "#1F8F92",
+ "sideLabels" => "#1FBABE",
+ "dates" => "#1F8F92",
+ "excludeDaysLabel" => "#1F8F92",
+ ],
+ "telegram-gradient" => [
+ "background" => "45,0088CC,179CDE",
+ "border" => "#FFFFFF",
+ "stroke" => "#FFFFFF",
+ "ring" => "#FFFFFF",
+ "fire" => "#FFFFFF",
+ "currStreakNum" => "#FFFFFF",
+ "sideNums" => "#FFFFFF",
+ "currStreakLabel" => "#FFFFFF",
+ "sideLabels" => "#FFFFFF",
+ "dates" => "#FFFFFF",
+ "excludeDaysLabel" => "#FFFFFF",
+ ],
+ "microsoft" => [
+ "background" => "#FFFFFF",
+ "border" => "#737373",
+ "stroke" => "#737373",
+ "ring" => "#7FBA00",
+ "fire" => "#F25022",
+ "currStreakNum" => "#00A4EF",
+ "sideNums" => "#FFB900",
+ "currStreakLabel" => "#00A4EF",
+ "sideLabels" => "#FFB900",
+ "dates" => "#7FBA00",
+ "excludeDaysLabel" => "#7FBA00",
+ ],
+ "microsoft-dark" => [
+ "background" => "#000000",
+ "border" => "#737373",
+ "stroke" => "#737373",
+ "ring" => "#7FBA00",
+ "fire" => "#F25022",
+ "currStreakNum" => "#00A4EF",
+ "sideNums" => "#FFB900",
+ "currStreakLabel" => "#00A4EF",
+ "sideLabels" => "#FFB900",
+ "dates" => "#7FBA00",
+ "excludeDaysLabel" => "#7FBA00",
+ ],
+ "hacker-inverted" => [
+ "background" => "#20C20E",
+ "border" => "#000000",
+ "stroke" => "#000000",
+ "ring" => "#000000",
+ "fire" => "#000000",
+ "currStreakNum" => "#000000",
+ "sideNums" => "#000000",
+ "currStreakLabel" => "#000000",
+ "sideLabels" => "#000000",
+ "dates" => "#000000",
+ "excludeDaysLabel" => "#000000",
+ ],
+ "rust-ferris-dark" => [
+ "background" => "#000000",
+ "border" => "#FFFFFF",
+ "stroke" => "#F66200",
+ "ring" => "#F49600",
+ "fire" => "#F66200",
+ "currStreakNum" => "#F49600",
+ "sideNums" => "#CC3A00",
+ "currStreakLabel" => "#F49600",
+ "sideLabels" => "#CC3A00",
+ "dates" => "#F66200",
+ "excludeDaysLabel" => "#F66200",
+ ],
+ "rust-ferris-light" => [
+ "background" => "#FFFFFF",
+ "border" => "#000000",
+ "stroke" => "#F66200",
+ "ring" => "#F49600",
+ "fire" => "#F66200",
+ "currStreakNum" => "#F49600",
+ "sideNums" => "#CC3A00",
+ "currStreakLabel" => "#F49600",
+ "sideLabels" => "#CC3A00",
+ "dates" => "#F66200",
+ "excludeDaysLabel" => "#F66200",
+ ],
+ "cyber-streakglow" => [
+ "background" => "42,E20FEB,0D00EB",
+ "border" => "#00EBE1",
+ "stroke" => "#0FEB00",
+ "ring" => "#5AEB59",
+ "fire" => "#DDEB00",
+ "currStreakNum" => "#EBEBEB",
+ "sideNums" => "#D6EBC0",
+ "currStreakLabel" => "#46EB00",
+ "sideLabels" => "#64E8EB",
+ "dates" => "#EBEBEB",
+ "excludeDaysLabel" => "#A7EB3F",
+ ],
+ "vitesse" => [
+ "background" => "#000000",
+ "border" => "#4D9375",
+ "stroke" => "#5D99A9",
+ "ring" => "#4D9375",
+ "fire" => "#CB7676",
+ "currStreakNum" => "#B8A965",
+ "sideNums" => "#4D9375",
+ "currStreakLabel" => "#80A665",
+ "sideLabels" => "#80A665",
+ "dates" => "#BD976A",
+ "excludeDaysLabel" => "#758575DD",
+ ],
];
diff --git a/src/translations.php b/src/translations.php
index f84069ed..260f89d4 100644
--- a/src/translations.php
+++ b/src/translations.php
@@ -72,13 +72,23 @@
"Longest Week Streak" => "Най-дълга седмична серия",
"Present" => "Сега",
],
+ "bho" => [
+ "Total Contributions" => "कुल योगदान",
+ "Current Streak" => "चालू रोजाना योगदान",
+ "Longest Streak" => "सबसे लंबा रोजाना योगदान",
+ "Week Streak" => "सप्ताहिक योगदान",
+ "Longest Week Streak" => "सबसे लंबा सप्ताहिक योगदान",
+ "Present" => "आज ले",
+ "Excluding {days}" => "{days} के छोड़के",
+ ],
"bn" => [
"Total Contributions" => "মোট অবদান",
- "Current Streak" => "কারেন্ট স্ট্রীক",
+ "Current Streak" => "বর্তমান স্ট্রিক",
"Longest Streak" => "দীর্ঘতম স্ট্রিক",
- "Week Streak" => "সপ্তাহ স্ট্রীক",
+ "Week Streak" => "সপ্তাহ স্ট্রিক",
"Longest Week Streak" => "দীর্ঘতম সপ্তাহ স্ট্রিক",
"Present" => "বর্তমান",
+ "Excluding {days}" => "{days} বাদে",
],
"ca" => [
"Total Contributions" => "Aportacions totals",
@@ -142,6 +152,7 @@
"Week Streak" => "پیرفت هفته",
"Longest Week Streak" => "طولانی ترین پیرفت هفته",
"Present" => "اکنون",
+ "Excluding {days}" => "{days} مستثنی کردن",
"comma_separator" => "، ",
],
"fil" => [
@@ -162,6 +173,15 @@
"Present" => "Aujourd'hui",
"Excluding {days}" => "À l'exclusion de {days}",
],
+ "gu" => [
+ "Total Contributions" => "કુલ યોગદાન",
+ "Current Streak" => "સતત દૈનિક યોગદાન",
+ "Longest Streak" => "સૌથી લાંબુ દૈનિક યોગદાન",
+ "Week Streak" => "અઠવાડીક યોગદાન",
+ "Longest Week Streak" => "સૌથી લાંબુ અઠવાડીક યોગદાન",
+ "Present" => "અત્યાર સુધી",
+ "Excluding {days}" => "સિવાય {days}",
+ ],
"he" => [
"rtl" => true,
"Total Contributions" => "סכום התרומות",
@@ -213,7 +233,7 @@
"Week Streak" => "Aksi Mingguan",
"Longest Week Streak" => "Aksi Mingguan Terpanjang",
"Present" => "Sekarang",
- "Excluding {days}" => "Tidak termasuk {days}",
+ "Excluding {days}" => "Kecuali {days}",
],
"it" => [
"Total Contributions" => "Contributi Totali",
@@ -235,6 +255,15 @@
"Excluding {days}" => "{days}を除く",
"comma_separator" => "・",
],
+ "jv" => [
+ "Total Contributions" => "Total Kontribusi",
+ "Current Streak" => "Tumindak Saiki",
+ "Longest Streak" => "Tumindak Paling Dawa",
+ "Week Streak" => "Tumindak Saben Minggu",
+ "Longest Week Streak" => "Tumindak Saben Minggu Paling Dawa",
+ "Present" => "Saiki",
+ "Excluding {days}" => "Ora kelebu {days}",
+ ],
"kn" => [
"Total Contributions" => "ಒಟ್ಟು ಕೊಡುಗೆ",
"Current Streak" => "ಪ್ರಸ್ತುತ ಸ್ಟ್ರೀಕ್",
@@ -247,11 +276,11 @@
"ko" => [
"Total Contributions" => "총 기여 수",
"Current Streak" => "현재 연속 기여 수",
- "Longest Streak" => "최대 연속 기여 수",
- "Week Streak" => "주간 기여 수",
- "Longest Week Streak" => "최대 주간 기여 수",
+ "Longest Streak" => "최장 연속 기여 수",
+ "Week Streak" => "주간 연속 기여 수",
+ "Longest Week Streak" => "최장 주간 연속 기여 수",
"Present" => "현재",
- "Excluding {days}" => "제외된 날 {days}",
+ "Excluding {days}" => "{days} 제외하고",
],
"mr" => [
"Total Contributions" => "एकूण योगदान",
@@ -260,6 +289,7 @@
"Week Streak" => "साप्ताहिक सातत्यता",
"Longest Week Streak" => "दीर्घकालीन साप्ताहिक सातत्यता",
"Present" => "आज पर्यंत",
+ "Excluding {days}" => "वगळून {days}",
],
"ms" => [
"Total Contributions" => "Jumlah Sumbangan",
@@ -268,7 +298,25 @@
"Week Streak" => "Tindakan Setiap Minggu",
"Longest Week Streak" => "Tindakan Setiap Minggu Terpanjang",
"Present" => "Sekarang",
- "Excluding {days}" => "Mengecualikan {days}",
+ "Excluding {days}" => "Kecuali {days}",
+ ],
+ "ms_ID" => [
+ "Total Contributions" => "Total Kontribusi",
+ "Current Streak" => "Rangkaian Saat Ini",
+ "Longest Streak" => "Rangkaian Terpanjang",
+ "Week Streak" => "Rangkaian Mingguan",
+ "Longest Week Streak" => "Rangkaian Mingguan Terpanjang",
+ "Present" => "Sekarang",
+ "Excluding {days}" => "Tidak termasuk {days}",
+ ],
+ "my" => [
+ "Total Contributions" => "စုစုပေါင်း ပံ့ပိုးမှုများ",
+ "Current Streak" => "ယနေ့ထိ မပျက်မကွက် ပံ့ပိုးမှုရက်ပေါင်း",
+ "Longest Streak" => "အကြာဆုံးမပျက်မကွက် ပံ့ပိုးမှုရက်ပေါင်း",
+ "Week Streak" => "အပတ်စဉ် ပံ့ပိုးမှု",
+ "Longest Week Streak" => "အကြာဆုံးမပျက်မကွက် ပံ့ပိုးမှုအပတ်ပေါင်း",
+ "Present" => "လက်ရှိ",
+ "Excluding {days}" => "{days} မှလွဲ၍",
],
"ne" => [
"Total Contributions" => "कुल योगदान",
@@ -288,6 +336,15 @@
"Present" => "Vandaag",
"Excluding {days}" => "Exclusief {days}",
],
+ "no" => [
+ "Total Contributions" => "Totalt Antall Bidrag",
+ "Current Streak" => "Nåværende\nBidragsrekke",
+ "Longest Streak" => "Lengste Bidragsrekke",
+ "Week Streak" => "Ukentlig\nBidragsrekke",
+ "Longest Week Streak" => "Lengste Ukentlige\nBidragsrekke",
+ "Present" => "I dag",
+ "Excluding {days}" => "Ekskluderer {days}",
+ ],
"pl" => [
"Total Contributions" => "Suma Kontrybucji",
"Current Streak" => "Aktualna Seria",
@@ -295,6 +352,7 @@
"Week Streak" => "Seria Tygodni",
"Longest Week Streak" => "Najdłuższa Seria Tygodni",
"Present" => "Dziś",
+ "Excluding {days}" => "Wykluczono {days}",
],
"ps" => [
"rtl" => true,
@@ -305,6 +363,16 @@
"Longest Week Streak" => "د اونۍ تر ټولو اوږد پرمختګ",
"Present" => "اوس",
"comma_separator" => "، ",
+ "Excluding {days}" => "پرته {days}",
+ ],
+ "pt" => [
+ "Total Contributions" => "Contribuições Totais",
+ "Current Streak" => "Sequência Atual",
+ "Longest Streak" => "Maior Sequência",
+ "Week Streak" => "Sequência da Semana",
+ "Longest Week Streak" => "Maior Sequência da Semana",
+ "Present" => "Presente",
+ "Excluding {days}" => "Excluindo {days}",
],
"pt_BR" => [
"Total Contributions" => "Total de Contribuições",
@@ -341,6 +409,17 @@
"Present" => "वर्तमान",
"Excluding {days}" => "बहिष्करणम् {days}",
],
+ "sd_PK" => [
+ "rtl" => true,
+ "Total Contributions" => "کل حصہ داری",
+ "Current Streak" => "موجوده سلسلو",
+ "Longest Streak" => "تمام پري جو سلسلو",
+ "Week Streak" => "ھفتي جو سلسلو",
+ "Longest Week Streak" => "تمام پري جو ھفتيوار سلسلو",
+ "Present" => "موجوده",
+ "Excluding {days}" => "نڪتل {days}",
+ "comma_separator" => "، ",
+ ],
"sr" => [
"Total Contributions" => "Укупно додавања",
"Current Streak" => "Тренутна серија",
@@ -374,6 +453,7 @@
"Week Streak" => "Mfululizo wa wiki",
"Longest Week Streak" => "Mfululizo mrefu zaidi wa wiki",
"Present" => "Sasa",
+ "Excluding {days}" => "Ukiondoa {days}",
],
"ta" => [
"Total Contributions" => "மொத்த\nபங்களிப்புகள்",
@@ -455,7 +535,7 @@
"Current Streak" => "目前連續貢獻",
"Longest Streak" => "最長連續貢獻",
"Week Streak" => "周連續貢獻",
- "Longest Week Streak" => "最常周連續貢獻",
+ "Longest Week Streak" => "最長周連續貢獻",
"Present" => "至今",
"Excluding {days}" => "除外 {days}",
"comma_separator" => "、",
diff --git a/tests/RenderTest.php b/tests/RenderTest.php
index 358b4af0..a551736a 100644
--- a/tests/RenderTest.php
+++ b/tests/RenderTest.php
@@ -49,6 +49,11 @@ public function testCardRender(): void
$render = generateCard($this->testStats, $this->testParams);
$expected = file_get_contents("tests/expected/test_card.svg");
$this->assertEquals($expected, $render);
+
+ // Test short_numbers parameter
+ $this->testParams["short_numbers"] = "true";
+ $render = generateCard($this->testStats, $this->testParams);
+ $this->assertStringContainsString("2K", $render);
}
/**
@@ -233,6 +238,22 @@ public function testCardWidth(): void
$this->assertStringContainsString("
assertStringContainsString("", $render);
+ $this->assertStringContainsString("assertStringContainsString("assertStringContainsString("", $render);
+ $this->assertStringContainsString("", $render);
+ $this->assertStringContainsString("", $render);
+ }
+
/**
* Test first and third columns swapped when direction is rtl
*/
@@ -242,11 +263,11 @@ public function testFirstAndThirdColumnsSwappedWhenDirectionIsRtl(): void
$render = generateOutput($this->testStats, $this->testParams)["body"];
$renderCollapsedSpaces = preg_replace("/(\s)\s*/", '$1', $render);
$this->assertStringContainsString(
- "\n",
+ "\n",
$renderCollapsedSpaces
);
$this->assertStringContainsString(
- "\n",
+ "\n",
$renderCollapsedSpaces
);
}
diff --git a/tests/expected/test_card.svg b/tests/expected/test_card.svg
index ca488f05..08dfd779 100644
--- a/tests/expected/test_card.svg
+++ b/tests/expected/test_card.svg
@@ -31,43 +31,36 @@
-
+
2,048
-
+
Total Contributions
-
+
Aug 10, 2016 - Present
-
-
-
- 16
-
-
-
-
+
Current Streak
-
+
Mar 28, 2019 - Apr 12, 2019
@@ -83,24 +76,31 @@
+
+
+
+ 16
+
+
+
-
+
86
-
+
Longest Streak
-
+
Dec 19, 2016 - Mar 14, 2016
diff --git a/tests/expected/test_error_card.svg b/tests/expected/test_error_card.svg
index 23c28d2b..243faa50 100644
--- a/tests/expected/test_error_card.svg
+++ b/tests/expected/test_error_card.svg
@@ -16,7 +16,7 @@
-
+
An unknown error occurred