From e8e50381292a6532cdc3c2802f37262b279fe30b Mon Sep 17 00:00:00 2001 From: Kevin Hamer Date: Sun, 11 Oct 2020 15:31:58 -0400 Subject: fix automatic reload logic --- layouts/partials/js.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'layouts/partials') diff --git a/layouts/partials/js.html b/layouts/partials/js.html index b398fbe..fbe102c 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -88,8 +88,8 @@ lastUpdated.innerHTML = '{{ T "lastChecked" }} ' + timeSince(lastUpdate) + ' {{ T "someTimeAgo" }}'; // Refresh almost every 5m - if (lastUpdate > 290000) { - location.reload; + if (Math.floor(new Date() - lastUpdate) > 290000) { + location.reload(); } } }, 5000) -- cgit v1.2.3-70-g09d2 From 78b3b15525d756c5b522b07e98049dcb9c024a6a Mon Sep 17 00:00:00 2001 From: Kevin Hamer Date: Sun, 11 Oct 2020 17:12:45 -0400 Subject: Add .relative-time class and JS logic --- layouts/issues/small.html | 18 +++---- layouts/partials/index/summary.html | 4 +- layouts/partials/js.html | 93 +++++++++++++++++++------------------ 3 files changed, 59 insertions(+), 56 deletions(-) (limited to 'layouts/partials') diff --git a/layouts/issues/small.html b/layouts/issues/small.html index 6ed2cce..6112e46 100644 --- a/layouts/issues/small.html +++ b/layouts/issues/small.html @@ -7,8 +7,8 @@ {{ if .Params.informational }} - - + + {{ if .Site.Params.dateFormat }} {{ .Date.Format .Site.Params.dateFormat }} {{ else }} @@ -21,9 +21,9 @@ {{ .Summary | truncate 200 }} - + {{ else if .Params.Resolved }} - + {{ if .Site.Params.dateFormat }} {{ .Date.Format .Site.Params.dateFormat }} {{ else }} @@ -67,7 +67,7 @@ {{ end }} {{ else }} - + {{ if .Site.Params.dateFormat }} {{ .Date.Format .Site.Params.dateFormat }} {{ else }} @@ -82,17 +82,17 @@ {{ if eq .Params.severity "notice" }} - ◆ + ◆ {{ T "downtimeOngoing" }} {{ else }} {{ if eq .Params.severity "down" }} - ■ + ■ {{ else if eq .Params.severity "disrupted" }} - ▲ + ▲ {{ else }} - ◆ + ◆ {{ end }} {{ T "downtimeOngoing" }} diff --git a/layouts/partials/index/summary.html b/layouts/partials/index/summary.html index de6bceb..dcf753c 100644 --- a/layouts/partials/index/summary.html +++ b/layouts/partials/index/summary.html @@ -20,5 +20,5 @@ {{ end }}{{ end }}{{ end }} -
- \ No newline at end of file +
+ diff --git a/layouts/partials/js.html b/layouts/partials/js.html index fbe102c..7971bc5 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -41,58 +41,61 @@ } /** - * Timer + * Returns a relative date string for the given date. */ + function timeSince(date) { + var seconds = Math.floor((new Date() - date) / 1000); - function hasClass(element, className) { - return (' ' + element.className + ' ').indexOf(' ' + className+ ' ') > -1; - } - - if (hasClass(document.querySelector('body'), 'status-homepage')) { - var lastUpdated = document.querySelector('.summary__date'); - lastUpdated.innerHTML = '{{ T "lastChecked" }} {{ T "justNow" }}'; - - var lastUpdate = new Date(); - - function timeSince(date) { - var seconds = Math.floor((new Date() - date) / 1000); + var interval = Math.floor(seconds / 31536000); - var interval = Math.floor(seconds / 31536000); - - if (interval > 1) { - return interval + ' {{ T "yearsAgo" }}'; - } - interval = Math.floor(seconds / 2592000); - if (interval > 1) { - return interval + ' {{ T "monthsAgo" }}'; - } - interval = Math.floor(seconds / 86400); - if (interval > 1) { - return interval + '{{ T "daysAgo" }}'; - } - interval = Math.floor(seconds / 3600); - if (interval > 1) { - return interval + '{{ T "hoursAgo" }}'; - } - interval = Math.floor(seconds / 60); - if (interval > 1) { - return interval + ' {{ T "minsAgo" }}'; - } - return Math.floor(seconds) + '{{ T "secondsAgo" }}'; + if (interval > 1) { + return interval + ' {{ T "yearsAgo" }}'; + } + interval = Math.floor(seconds / 2592000); + if (interval > 1) { + return interval + ' {{ T "monthsAgo" }}'; + } + interval = Math.floor(seconds / 86400); + if (interval > 1) { + return interval + '{{ T "daysAgo" }}'; } - var aDay = 24*60*60*1000; + interval = Math.floor(seconds / 3600); + if (interval > 1) { + return interval + '{{ T "hoursAgo" }}'; + } + interval = Math.floor(seconds / 60); + if (interval > 1) { + return interval + ' {{ T "minsAgo" }}'; + } + return Math.floor(seconds) + '{{ T "secondsAgo" }}'; } - window.setInterval(function() { - if (hasClass(document.querySelector('body'), 'status-homepage')) { - lastUpdated.innerHTML = '{{ T "lastChecked" }} ' + timeSince(lastUpdate) + ' {{ T "someTimeAgo" }}'; + /** + * Changes elements with the class 'relative-time' into relative times and + * moves the timestamp to a title attribute tooltip. + */ + function updateRelativeTimes() { + document.querySelectorAll('.relative-time') + .forEach(function(element) { + var time = Date.parse(element.getAttribute('title')); + var html = element.getAttribute('data-prefix') || ''; + if (!time) { + time = element.innerText; + element.setAttribute('title', time || new Date); + html += '{{ T "justNow" }}'; + } else { + html += timeSince(time) + ' {{ T "someTimeAgo" }}'; + } + element.innerHTML = html.trim(); + }) + } + updateRelativeTimes(); + setInterval(updateRelativeTimes, 5000); - // Refresh almost every 5m - if (Math.floor(new Date() - lastUpdate) > 290000) { - location.reload(); - } - } - }, 5000) + // Reload homepage eevery 290 seconds + if (document.querySelector('body.status-homepage')) { + setInterval(location.reload, 290000) + } -- cgit v1.2.3-70-g09d2 From 656f716ecb87ac563e1566592472a65db7019409 Mon Sep 17 00:00:00 2001 From: Kevin Hamer Date: Sun, 11 Oct 2020 17:18:40 -0400 Subject: fix IE bug; rename 'data-prefix' to 'data-time-prefix' and add unused 'data-time-suffix' --- layouts/partials/index/summary.html | 2 +- layouts/partials/js.html | 34 +++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 16 deletions(-) (limited to 'layouts/partials') diff --git a/layouts/partials/index/summary.html b/layouts/partials/index/summary.html index dcf753c..41f285b 100644 --- a/layouts/partials/index/summary.html +++ b/layouts/partials/index/summary.html @@ -20,5 +20,5 @@ {{ end }}{{ end }}{{ end }} -
+
diff --git a/layouts/partials/js.html b/layouts/partials/js.html index 7971bc5..c4c5a85 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -75,26 +75,30 @@ * moves the timestamp to a title attribute tooltip. */ function updateRelativeTimes() { - document.querySelectorAll('.relative-time') - .forEach(function(element) { - var time = Date.parse(element.getAttribute('title')); - var html = element.getAttribute('data-prefix') || ''; - if (!time) { - time = element.innerText; - element.setAttribute('title', time || new Date); - html += '{{ T "justNow" }}'; - } else { - html += timeSince(time) + ' {{ T "someTimeAgo" }}'; - } - element.innerHTML = html.trim(); - }) + var elements = document.querySelectorAll('.relative-time'); + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var time = Date.parse(element.getAttribute('title')); + var html = element.getAttribute('data-time-prefix') || ''; + if (!time) { + time = element.innerText; + element.setAttribute('title', time || new Date); + html += '{{ T "justNow" }}'; + } else { + html += timeSince(time) + ' {{ T "someTimeAgo" }}'; + } + html += element.getAttribute('data-time-suffix') || ''; + element.innerHTML = html.trim(); + } } updateRelativeTimes(); setInterval(updateRelativeTimes, 5000); - // Reload homepage eevery 290 seconds + /** + * Reload homepage after 290 seconds. + */ if (document.querySelector('body.status-homepage')) { - setInterval(location.reload, 290000) + setTimeout(location.reload, 290000) } -- cgit v1.2.3-70-g09d2 From 49c081a97d8442a8267247a98d196fe05d7b3092 Mon Sep 17 00:00:00 2001 From: Kevin Hamer Date: Sun, 11 Oct 2020 17:35:30 -0400 Subject: add .Site.Params.skipSeconds --- exampleSite/config.yml | 5 +++++ layouts/partials/js.html | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'layouts/partials') diff --git a/exampleSite/config.yml b/exampleSite/config.yml index 967505f..9060163 100644 --- a/exampleSite/config.yml +++ b/exampleSite/config.yml @@ -162,6 +162,11 @@ params: # Default: true useRelativeTime: true + # If enabled, doesn't show seconds on relative times. + # + # Default: false + skipSeconds: false + # What header design should we use? # # Default: true diff --git a/layouts/partials/js.html b/layouts/partials/js.html index c4c5a85..8465483 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -67,7 +67,11 @@ if (interval > 1) { return interval + ' {{ T "minsAgo" }}'; } - return Math.floor(seconds) + '{{ T "secondsAgo" }}'; + {{ if .Site.Params.skipSeconds }} + return '<1 {{ T "minsAgo" }}' + {{ else }} + return Math.floor(seconds) + '{{ T "secondsAgo" }}'; + {{ end }} } /** -- cgit v1.2.3-70-g09d2 From 925027e85b74a77e06448be5baa6053f1222fb78 Mon Sep 17 00:00:00 2001 From: Mantas Vilčinskas Date: Wed, 24 Feb 2021 13:48:14 +0200 Subject: Doc updates, bugfixes, add rel time to NCMS --- exampleSite/config.yml | 35 ++++- .../issues/2019-10-08-testing-new-pipeline.md | 2 +- .../issues/2020-06-13-maintenance-window.md | 13 -- .../issues/2021-02-13-maintenance-window.md | 14 ++ i18n/tl.yaml | 159 +++++++++++++++++++++ i18n/tl.yml | 159 --------------------- layouts/index.json | 4 +- layouts/issues/small.html | 9 +- layouts/partials/js.html | 18 ++- layouts/partials/meta.html | 2 +- static/admin/config.yml | 22 ++- static/admin/index.html | 2 +- 12 files changed, 239 insertions(+), 200 deletions(-) delete mode 100644 exampleSite/content/issues/2020-06-13-maintenance-window.md create mode 100644 exampleSite/content/issues/2021-02-13-maintenance-window.md create mode 100644 i18n/tl.yaml delete mode 100644 i18n/tl.yml (limited to 'layouts/partials') diff --git a/exampleSite/config.yml b/exampleSite/config.yml index 49faaee..7dc5972 100644 --- a/exampleSite/config.yml +++ b/exampleSite/config.yml @@ -161,17 +161,44 @@ params: # # dateFormat Default: "January 2, 2006 at 3:04 PM" # shortDateFormat Default: "15:04 — Jan 2" - dateFormat: January 2, 2006 at 3:04 PM - shortDateFormat: 15:04 — Jan 2 + dateFormat: January 2, 2006 at 3:04 PM UTC + shortDateFormat: 15:04 UTC — Jan 2 - # If enabled, will display relative times for incident history and summaries instead of using dateFormat. + # Should relative time (x min ago) be used? + # + # IMPORTANT: In the frontmatter, the dates MUST be in + # the UTC time zone for this to work preperly. If you + # use Netlify CMS, all good — the CMS picks UTC time + # by default. Otherwise, there may be very inaccurate + # times if multiple time zones are in your issue files. + # + # FOR YOUR CONSIDERATION: This feature was introduced in + # v5. It may be a breaking change in the case when you + # wish to use relative time but old issues do not have + # UTC time (and therefore are out of sync by ±24 hours) + # + # Read the wiki for more: + # https://github.com/cstate/cstate/wiki/Customization#time + # + # If enabled, will display relative times in places like + # the incident history and summaries instead of using + # dateFormat and shortDateFormat (except for if you use + # the old shortcode). # # Default: `true` + # BOOLEAN; `true`, `false` useRelativeTime: true - + # If enabled, doesn't show seconds on relative times. # + # With option ON (true): + # "Last checked <1 min ago" + # + # With option OFF (false; default): + # "Last checked 20s ago" + # # Default: `false` + # BOOLEAN; `true`, `false` skipSeconds: false # What header design should we use? diff --git a/exampleSite/content/issues/2019-10-08-testing-new-pipeline.md b/exampleSite/content/issues/2019-10-08-testing-new-pipeline.md index 4f139de..4e9da4f 100644 --- a/exampleSite/content/issues/2019-10-08-testing-new-pipeline.md +++ b/exampleSite/content/issues/2019-10-08-testing-new-pipeline.md @@ -1,7 +1,7 @@ --- title: New Pipeline Rollout date: 2019-10-05 16:24:00 -resolved: false +resolved: true resolvedWhen: 2019-10-05 16:58:00 # Possible severity levels: down, disrupted, notice severity: disrupted diff --git a/exampleSite/content/issues/2020-06-13-maintenance-window.md b/exampleSite/content/issues/2020-06-13-maintenance-window.md deleted file mode 100644 index 404ccc4..0000000 --- a/exampleSite/content/issues/2020-06-13-maintenance-window.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Maintenance Window -date: 2020-06-13 15:54:00 -resolved: true -resolvedWhen: 2020-06-13 16:54:00 -# Possible severity levels: down, disrupted, notice -severity: disrupted -affected: - - API -section: issue ---- - -*Just began* - We're currently shutting down the network. {{< track "2018-06-13 15:54:00" >}} diff --git a/exampleSite/content/issues/2021-02-13-maintenance-window.md b/exampleSite/content/issues/2021-02-13-maintenance-window.md new file mode 100644 index 0000000..00b4765 --- /dev/null +++ b/exampleSite/content/issues/2021-02-13-maintenance-window.md @@ -0,0 +1,14 @@ +--- +title: Maintenance Window +#date: 24 Feb 21 12:35 +0200 +date: 2021-02-24 10:35:00 +resolved: false +resolvedWhen: 2021-02-24 12:10:00 +# Possible severity levels: down, disrupted, notice +severity: disrupted +affected: + - API +section: issue +--- + +*Just began* - We're currently shutting down the network. {{< track "2018-06-13 12:54:00" >}} diff --git a/i18n/tl.yaml b/i18n/tl.yaml new file mode 100644 index 0000000..1600abc --- /dev/null +++ b/i18n/tl.yaml @@ -0,0 +1,159 @@ +# Tagalog language file for cState +# Version 4.4 + +- id: languageCode + translation: tl +- id: languageName + translation: Tagalog +- id: languageNameShort + translation: TGL + +## +## INDEX.HTML +## + +# Summary status message +- id: isDown + translation: Nakakaranas ng malaking isyu +- id: isDisrupted + translation: Nakakaranas ng pagkagambala +- id: isNotice + translation: Pakiusap paki-basa ang anunsyo +- id: isOk + translation: Lahat ng sistema ay gumagana + +# No JS warning +- id: noScriptingIntro + translation: Ay! Mukhang naka-diseybol ang Javascript mo. Pakiusap +- id: noScriptingLink + translation: i-eneybol ang skripting +- id: noScriptingOutro + translation: para mas maganda ang iyong eksperyensha sa websayt na ito. +- id: thisIsDown + translation: Hindi gumagana +- id: thisIsDisrupted + translation: May pagkagambala +- id: thisIsNotice + translation: Pagpapanatili +- id: thisIsOk + translation: Gumagana + +# "Last checked" + "just now" +- id: lastChecked + translation: Huling na-chek +- id: justNow + translation: ngayon lamang +- id: someTimeAgo + translation: nakaraan + +# Example usage: `5` + `years` +# Final result: 'Last checked 5 years ago' +# Number goes before string +# Use short variants until months +- id: yearsAgo + translation: mga taon +- id: monthsAgo + translation: mga buwan +- id: daysAgo + translation: a +- id: hoursAgo + translation: o +- id: minsAgo + translation: min +- id: secondsAgo + translation: s + +- id: autoRefreshNotice + translation: Susubukan naming mag-refresh bawat 5 min + +# Incidents +- id: incidents + translation: Mga insidente +- id: incidentHistory + translation: Kasaysayan ng mga insidente + +- id: resolved + translation: Na-resolba # if it's less than a min +- id: inUnderAMinute + translation: sa ilalim ng isang minuto # continuing the last string +- id: resolvedAfter + translation: Na-resolba pagkatapos ng # + 19 min +- id: ofDowntime + translation: ng dawntaym + +- id: downtimeOngoing + translation: Ang isyung ito ay hindi pa na-reresolba + + +- id: calmBeforeTheStorm + translation: Ito ba ang katahimikan bago ang bagyo? +- id: noIncidentsDesc + translation: Ang status peyg na ito ay walang na-itala na insidente. This status page has no logged incidents. This may be because the status page owner (or owners) have recently set up their status page, have had no downtime, or have not logged any downtime. + + +- id: continueReading + translation: Ipagpatuloy ang pagbabasa +- id: prev + translation: Dati +- id: next + translation: Susunod + +## +## OTHER +## + +- id: goBack + translation: Bumalik sa +- id: backToTop + translation: Bumalik sa ibabaw +- id: poweredBy + translation: Pinapatakbo ng + +- id: notFound + translation: Walang dito. +- id: notFoundText + translation: Ito'y maaaring problema sa amin. Maaring may nilipat kami na resors at ngayon ay nawala na ito. Posible din na ang resors na nais mong makita ay walang laman. Pero, ayos lang ba sa iyo ang dobol-check sa link? + +- id: rss + translation: Mag-subskrayb sa pamamagitan ng RSS +- id: toAllUpdates + translation: sa lahat ng mga updeyt +- id: or + translation: o +- id: onlyThisFeed + translation: sa feed lamang na ito + +## +## v3 +## +- id: entries + translation: mga entri +- id: newestToOldest + translation: mula sa pinaka-bago hanggang sa pinaka-luma + +## +## v4 +## +- id: notFoundAffected + translation: Mukang ang sistemang ito ay hindi na nag-eesist o di kailan mang nagkaroon ng na-rekord na dawntaym. + +## +## v4.1 +## + +- id: averageSystemsDowntime + translation: Kamakailan, base sa iyong average na data, mukang ang sistemang ito ay nag-dawn ng mga +- id: averageSystemsDowntimeSecondPart + translation: minuto nang paisa-isa. + + +## +## v4.4 +## + +- id: in + translation: sa +- id: weeksAgo + translation: " l" +- id: yearAgo + translation: " taon" diff --git a/i18n/tl.yml b/i18n/tl.yml deleted file mode 100644 index 1600abc..0000000 --- a/i18n/tl.yml +++ /dev/null @@ -1,159 +0,0 @@ -# Tagalog language file for cState -# Version 4.4 - -- id: languageCode - translation: tl -- id: languageName - translation: Tagalog -- id: languageNameShort - translation: TGL - -## -## INDEX.HTML -## - -# Summary status message -- id: isDown - translation: Nakakaranas ng malaking isyu -- id: isDisrupted - translation: Nakakaranas ng pagkagambala -- id: isNotice - translation: Pakiusap paki-basa ang anunsyo -- id: isOk - translation: Lahat ng sistema ay gumagana - -# No JS warning -- id: noScriptingIntro - translation: Ay! Mukhang naka-diseybol ang Javascript mo. Pakiusap -- id: noScriptingLink - translation: i-eneybol ang skripting -- id: noScriptingOutro - translation: para mas maganda ang iyong eksperyensha sa websayt na ito. -- id: thisIsDown - translation: Hindi gumagana -- id: thisIsDisrupted - translation: May pagkagambala -- id: thisIsNotice - translation: Pagpapanatili -- id: thisIsOk - translation: Gumagana - -# "Last checked" + "just now" -- id: lastChecked - translation: Huling na-chek -- id: justNow - translation: ngayon lamang -- id: someTimeAgo - translation: nakaraan - -# Example usage: `5` + `years` -# Final result: 'Last checked 5 years ago' -# Number goes before string -# Use short variants until months -- id: yearsAgo - translation: mga taon -- id: monthsAgo - translation: mga buwan -- id: daysAgo - translation: a -- id: hoursAgo - translation: o -- id: minsAgo - translation: min -- id: secondsAgo - translation: s - -- id: autoRefreshNotice - translation: Susubukan naming mag-refresh bawat 5 min - -# Incidents -- id: incidents - translation: Mga insidente -- id: incidentHistory - translation: Kasaysayan ng mga insidente - -- id: resolved - translation: Na-resolba # if it's less than a min -- id: inUnderAMinute - translation: sa ilalim ng isang minuto # continuing the last string -- id: resolvedAfter - translation: Na-resolba pagkatapos ng # + 19 min -- id: ofDowntime - translation: ng dawntaym - -- id: downtimeOngoing - translation: Ang isyung ito ay hindi pa na-reresolba - - -- id: calmBeforeTheStorm - translation: Ito ba ang katahimikan bago ang bagyo? -- id: noIncidentsDesc - translation: Ang status peyg na ito ay walang na-itala na insidente. This status page has no logged incidents. This may be because the status page owner (or owners) have recently set up their status page, have had no downtime, or have not logged any downtime. - - -- id: continueReading - translation: Ipagpatuloy ang pagbabasa -- id: prev - translation: Dati -- id: next - translation: Susunod - -## -## OTHER -## - -- id: goBack - translation: Bumalik sa -- id: backToTop - translation: Bumalik sa ibabaw -- id: poweredBy - translation: Pinapatakbo ng - -- id: notFound - translation: Walang dito. -- id: notFoundText - translation: Ito'y maaaring problema sa amin. Maaring may nilipat kami na resors at ngayon ay nawala na ito. Posible din na ang resors na nais mong makita ay walang laman. Pero, ayos lang ba sa iyo ang dobol-check sa link? - -- id: rss - translation: Mag-subskrayb sa pamamagitan ng RSS -- id: toAllUpdates - translation: sa lahat ng mga updeyt -- id: or - translation: o -- id: onlyThisFeed - translation: sa feed lamang na ito - -## -## v3 -## -- id: entries - translation: mga entri -- id: newestToOldest - translation: mula sa pinaka-bago hanggang sa pinaka-luma - -## -## v4 -## -- id: notFoundAffected - translation: Mukang ang sistemang ito ay hindi na nag-eesist o di kailan mang nagkaroon ng na-rekord na dawntaym. - -## -## v4.1 -## - -- id: averageSystemsDowntime - translation: Kamakailan, base sa iyong average na data, mukang ang sistemang ito ay nag-dawn ng mga -- id: averageSystemsDowntimeSecondPart - translation: minuto nang paisa-isa. - - -## -## v4.4 -## - -- id: in - translation: sa -- id: weeksAgo - translation: " l" -- id: yearAgo - translation: " taon" diff --git a/layouts/index.json b/layouts/index.json index 5c47558..b37af7a 100644 --- a/layouts/index.json +++ b/layouts/index.json @@ -5,8 +5,8 @@ {{ $isDown := where $active "Params.severity" "=" "down" }} { "is": "index", - "cStateVersion": "4.4", - "apiVersion": "1.0.0", + "cStateVersion": "5.0", + "apiVersion": "2.0", "title": "{{ .Site.Title }}", "languageCodeHTML": "{{ .Site.LanguageCode }}", "languageCode": "{{ T "languageCode" }}", diff --git a/layouts/issues/small.html b/layouts/issues/small.html index 79db524..531b47b 100644 --- a/layouts/issues/small.html +++ b/layouts/issues/small.html @@ -8,7 +8,7 @@
{{ if .Params.informational }} - + {{ if .Site.Params.dateFormat }} {{ .Date.Format .Site.Params.dateFormat }} {{ else }} @@ -23,7 +23,7 @@ {{ else if .Params.Resolved }} - + {{ if .Site.Params.dateFormat }} {{ .Date.Format .Site.Params.dateFormat }} {{ else }} @@ -65,9 +65,10 @@ {{ end }} {{ end }} - {{ else }} - + {{ else }} + + {{ if .Site.Params.dateFormat }} {{ .Date.Format .Site.Params.dateFormat }} {{ else }} diff --git a/layouts/partials/js.html b/layouts/partials/js.html index 8465483..d966643 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -3,11 +3,11 @@ * Dev toolset */ - console.log('cState v4.4 - https://github.com/cstate/cstate'); + console.log('cState v5 Dev - https://github.com/cstate/cstate'); document.getElementsByTagName('html')[0].className = 'js'; /** - * Make theme color pretty + * Change header color based on status */ if (document.body.className === 'change-header-color') { @@ -43,6 +43,7 @@ /** * Returns a relative date string for the given date. */ + function timeSince(date) { var seconds = Math.floor((new Date() - date) / 1000); @@ -78,6 +79,7 @@ * Changes elements with the class 'relative-time' into relative times and * moves the timestamp to a title attribute tooltip. */ + function updateRelativeTimes() { var elements = document.querySelectorAll('.relative-time'); for (var i = 0; i < elements.length; i++) { @@ -95,21 +97,17 @@ element.innerHTML = html.trim(); } } + updateRelativeTimes(); - setInterval(updateRelativeTimes, 5000); - /** - * Reload homepage after 290 seconds. - */ - if (document.querySelector('body.status-homepage')) { - setTimeout(location.reload, 290000) - } + // Update "time since" feature every 5s + setInterval(updateRelativeTimes, 5000); {{ if ne .Site.Params.googleAnalytics "UA-00000000-1" }} - + + - {{ range $categories }} -
+
{{ if not .untitled }}
@@ -42,6 +32,8 @@ {{ end }} + +
{{ else }} @@ -94,8 +86,54 @@ {{ end }}
{{ end }} -
+ + + + {{ end }} - + \ No newline at end of file diff --git a/layouts/partials/js.html b/layouts/partials/js.html index d966643..765e787 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -40,6 +40,18 @@ document.location.pathname = '/admin'; } + /** + * Category logic + */ + + function toggleCategoryHead(el) { + if (el.parentNode.className == 'category category--open category--titled') { + el.parentNode.className = 'category category--closed category--titled'; + } else { + el.parentNode.className = 'category category--open category--titled'; + } + } + /** * Returns a relative date string for the given date. */ diff --git a/layouts/partials/meta.html b/layouts/partials/meta.html index 283e840..dfb5a98 100644 --- a/layouts/partials/meta.html +++ b/layouts/partials/meta.html @@ -319,14 +319,23 @@ .status-notice .announcement-box { border-top: 0; } /** - * Dynamically show individual component statuses + * Dynamically show component statuses */ - .component-status { float: right; } - .component[data-status="ok"] .component-status { color: {{ .Site.Params.ok }}; } - .component[data-status="disrupted"] .component-status { color: {{ .Site.Params.disrupted }}; } - .component[data-status="down"] .component-status { color: {{ .Site.Params.down }}; } - .component[data-status="notice"] .component-status { color: {{ .Site.Params.notice }}; } + .category--open .category-status { display: none; } + .component-status, .category-status { float: right; } + .component[data-status="ok"] .component-status, + .category__head[data-status="ok"] .category-status + { color: {{ .Site.Params.ok }}; } + .component[data-status="disrupted"] .component-status, + .category__head[data-status="disrupted"] .category-status + { color: {{ .Site.Params.disrupted }}; } + .component[data-status="notice"] .component-status, + .category__head[data-status="notice"] .category-status + { color: {{ .Site.Params.notice }}; } + .component[data-status="down"] .component-status, + .category__head[data-status="down"] .category-status + { color: {{ .Site.Params.down }}; } /** * Responsiveness @@ -386,15 +395,19 @@ .error { color: #ff4242; } .warning {color: #ffde7f; } .ok { color: #7fff7f; } - - .component[data-status="ok"] - .component-status { color: #7fff7f; } - .component[data-status="disrupted"] - .component-status { color: #ffde7f; } - .component[data-status="notice"] - .component-status { color: #83a4e8; } - .component[data-status="down"] - .component-status { color: #ff8181; } + + .component[data-status="ok"] .component-status, + .category__head[data-status="ok"] .category-status + { color: #7fff7f; } + .component[data-status="disrupted"] .component-status, + .category__head[data-status="disrupted"] .category-status + { color: #ffde7f; } + .component[data-status="notice"] .component-status, + .category__head[data-status="notice"] .category-status + { color: #83a4e8; } + .component[data-status="down"] .component-status, + .category__head[data-status="down"] .category-status + { color: #ff8181; } } {{ end }} -- cgit v1.2.3-70-g09d2 From 740f8fe924ecda15de73002f648454cf5612142f Mon Sep 17 00:00:00 2001 From: Mantas Vilčinskas Date: Sat, 17 Apr 2021 14:05:27 +0300 Subject: v5 ready to deploy --- layouts/partials/js.html | 2 +- layouts/partials/meta.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'layouts/partials') diff --git a/layouts/partials/js.html b/layouts/partials/js.html index 765e787..28ce0a1 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -3,7 +3,7 @@ * Dev toolset */ - console.log('cState v5 Dev - https://github.com/cstate/cstate'); + console.log('cState v5.0 - https://github.com/cstate/cstate'); document.getElementsByTagName('html')[0].className = 'js'; /** diff --git a/layouts/partials/meta.html b/layouts/partials/meta.html index dfb5a98..c46ee94 100644 --- a/layouts/partials/meta.html +++ b/layouts/partials/meta.html @@ -12,7 +12,7 @@ {{ range .AlternativeOutputFormats -}} {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} {{ end -}} - +