aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMantas Vilčinskas <hi@mnts.lt>2021-05-01 23:15:09 +0300
committerGitHub <noreply@github.com>2021-05-01 23:15:09 +0300
commit164d0b1d0e53c3aa0bd4038e464a150f479bd41a (patch)
tree00a7e862d38201dffe9863052451f26a587f616e
parent27ffa549c10f415973f2b894b176754cbf910af5 (diff)
v5.0.2 fix #180 by showing date instead of relative time for future dates
report by @untuned
-rw-r--r--README.md3
-rw-r--r--exampleSite/content/issues/2021-02-13-maintenance-window.md2
-rw-r--r--i18n/en.yaml2
-rw-r--r--layouts/index.json2
-rw-r--r--layouts/partials/js.html13
-rw-r--r--layouts/partials/meta.html2
6 files changed, 19 insertions, 5 deletions
diff --git a/README.md b/README.md
index 58b2b9e..e073253 100644
--- a/README.md
+++ b/README.md
@@ -284,7 +284,10 @@ cd cstate/exampleSite
3. Launch the development setup like this:
```bash
+# old command
hugo serve --baseUrl=http://localhost/ --theme=cstate --themesDir=../.. --verbose
+# new command partially works for v5.0.2; does not load images from static/
+hugo serve --config=exampleSite/config.yml --theme=../ --contentDir=exampleSite/content
```
The main directory is the theme itself (the cState guts, basically) and the `exampleSite` folder houses all content. Use this local setup to experiment before making a PR.
diff --git a/exampleSite/content/issues/2021-02-13-maintenance-window.md b/exampleSite/content/issues/2021-02-13-maintenance-window.md
index d6c8b14..f5423ed 100644
--- a/exampleSite/content/issues/2021-02-13-maintenance-window.md
+++ b/exampleSite/content/issues/2021-02-13-maintenance-window.md
@@ -1,7 +1,7 @@
---
title: Maintenance Window
#date: 24 Feb 21 12:35 +0200
-date: 2021-02-24 10:35:00
+date: 2022-02-24 10:35:00
resolved: false
resolvedWhen: 2021-02-24 12:10:00
# Possible severity levels: down, disrupted, notice
diff --git a/i18n/en.yaml b/i18n/en.yaml
index 2fa284b..114699d 100644
--- a/i18n/en.yaml
+++ b/i18n/en.yaml
@@ -158,4 +158,4 @@
- id: weeksAgo
translation: " w"
- id: yearAgo
- translation: " year"
+ translation: " year" \ No newline at end of file
diff --git a/layouts/index.json b/layouts/index.json
index 7a14745..c707f5c 100644
--- a/layouts/index.json
+++ b/layouts/index.json
@@ -1,6 +1,6 @@
{{ $incidents := where .Site.RegularPages "Params.section" "issue" }}{{ $active := where $incidents "Params.resolved" "=" false }}{{ $isNotice := where $active "Params.severity" "=" "notice" }}{{ $isDisrupted := where $active "Params.severity" "=" "disrupted" }}{{ $isDown := where $active "Params.severity" "=" "down" }}{
"is": "index",
- "cStateVersion": "5.0.1",
+ "cStateVersion": "5.0.2",
"apiVersion": "2.0",
"title": "{{ .Site.Title }}",
"languageCodeHTML": "{{ .Site.LanguageCode }}",
diff --git a/layouts/partials/js.html b/layouts/partials/js.html
index 939cb9a..ef9464a 100644
--- a/layouts/partials/js.html
+++ b/layouts/partials/js.html
@@ -3,7 +3,7 @@
* Dev toolset
*/
- console.log('cState v5.0.1 - https://github.com/cstate/cstate');
+ console.log('cState v5.0.2 - https://github.com/cstate/cstate');
document.getElementsByTagName('html')[0].className = 'js';
/**
@@ -80,6 +80,13 @@
if (interval > 1) {
return interval + ' {{ T "minsAgo" }}';
}
+
+ // Negative value
+ if(Math.floor(seconds) < 0) {
+ return Math.floor(seconds);
+ }
+
+ // Non-negative seconds
{{ if .Site.Params.skipSeconds }}
return '<1 {{ T "minsAgo" }}'
{{ else }}
@@ -98,10 +105,14 @@
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 if (timeSince(time) < 0) {
+ html = element.innerText;
} else {
html += timeSince(time) + ' {{ T "someTimeAgo" }}';
}
diff --git a/layouts/partials/meta.html b/layouts/partials/meta.html
index 5c57c45..3fec38c 100644
--- a/layouts/partials/meta.html
+++ b/layouts/partials/meta.html
@@ -12,7 +12,7 @@
{{ range .AlternativeOutputFormats -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
- <meta name="generator" content="cState v5.0.1 - https://github.com/cstate/cstate">
+ <meta name="generator" content="cState v5.0.2 - https://github.com/cstate/cstate">
<meta name="theme-color" content="{{ .Site.Params.brand }}">
<script>
var themeBrandColor = '{{ .Site.Params.brand }}';