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 --- layouts/index.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'layouts/index.json') 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" }}", -- cgit v1.2.3-70-g09d2 From 96477340dd7d7127ce5a6190e78974ad7a895bea Mon Sep 17 00:00:00 2001 From: Mantas Vilčinskas Date: Wed, 24 Feb 2021 14:39:32 +0200 Subject: API v2 Index features --- .../issues/2018-05-25-us-east-conn-issues.md | 2 +- .../issues/2019-10-04-testing-cstate-functions.md | 10 ---- .../content/issues/i-testing-cstate-functions.md | 10 ++++ layouts/index.json | 58 +++++++++++++--------- 4 files changed, 45 insertions(+), 35 deletions(-) delete mode 100644 exampleSite/content/issues/2019-10-04-testing-cstate-functions.md create mode 100644 exampleSite/content/issues/i-testing-cstate-functions.md (limited to 'layouts/index.json') diff --git a/exampleSite/content/issues/2018-05-25-us-east-conn-issues.md b/exampleSite/content/issues/2018-05-25-us-east-conn-issues.md index 8d56cf2..1b87285 100644 --- a/exampleSite/content/issues/2018-05-25-us-east-conn-issues.md +++ b/exampleSite/content/issues/2018-05-25-us-east-conn-issues.md @@ -1,7 +1,7 @@ --- title: US East Connection Issues date: 2018-04-25 04:13:00 -resolved: true +resolved: false resolvedWhen: 2018-04-25 04:13:59 # Possible severity levels: down, disrupted, notice severity: down diff --git a/exampleSite/content/issues/2019-10-04-testing-cstate-functions.md b/exampleSite/content/issues/2019-10-04-testing-cstate-functions.md deleted file mode 100644 index efdf7d7..0000000 --- a/exampleSite/content/issues/2019-10-04-testing-cstate-functions.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: Testing New cState Features -date: 2019-10-04 18:05:00 -informational: true -section: issue ---- - -There is a new feature in cState version 4 that lets you make what are called _informational_ posts. The main difference is that there will be no _Unresolved_ or _Resolved in under a minute_ text on the pages. - -This is essentially a page with a date and title. \ No newline at end of file diff --git a/exampleSite/content/issues/i-testing-cstate-functions.md b/exampleSite/content/issues/i-testing-cstate-functions.md new file mode 100644 index 0000000..cf833ac --- /dev/null +++ b/exampleSite/content/issues/i-testing-cstate-functions.md @@ -0,0 +1,10 @@ +--- +title: Testing New cState Features +date: 2019-10-04 18:05:00 +informational: true +section: issue +--- + +There is a new feature in cState version 4 that lets you make what are called _informational_ posts. The main difference is that there will be no _Unresolved_ or _Resolved in under a minute_ text on the pages. + +This is essentially a page with a date and title that shows up in the incident history. \ No newline at end of file diff --git a/layouts/index.json b/layouts/index.json index b37af7a..eea1926 100644 --- a/layouts/index.json +++ b/layouts/index.json @@ -1,9 +1,4 @@ -{{ $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" }} -{ +{{ $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", "apiVersion": "2.0", @@ -12,9 +7,8 @@ "languageCode": "{{ T "languageCode" }}", "baseURL": "{{ .Site.BaseURL }}", "description": "{{ .Site.Params.Description }}", - "logo": "{{ .Site.Params.logo | absURL }}", - "categories": [ - {{ range $i, $e := .Site.Params.categories }}{{ if $i }},{{ end }} + "summaryStatus":{{ if $isDown }}"down",{{ else }}{{ if $isDisrupted }}"disrupted",{{ else }}{{ if $isNotice }}"notice",{{ else }}"ok",{{ end }}{{ end }}{{ end }} + "categories": [{{ range $i, $e := .Site.Params.categories }}{{ if $i }},{{ end }} { "name": "{{ .name }}",{{ if .description }} "description": "{{ .description }}",{{ end }} @@ -28,32 +22,48 @@ { "name": "{{ .name }}",{{ if .description }} "description": "{{ .description }}",{{ end }} - "category": "{{ .category }}" + "category": "{{ .category }}", + {{ $activeComponentIssues := where $active "Params.affected" "intersect" (slice .name) }}{{ $thisIsNotice := where $activeComponentIssues "Params.severity" "=" "notice" }}{{ $thisIsDisrupted := where $activeComponentIssues "Params.severity" "=" "disrupted" }}{{ $thisIsDown := where $activeComponentIssues "Params.severity" "=" "down" }} + "status": {{ if $thisIsDown }}"down"{{ else }}{{ if $thisIsDisrupted }}"disrupted"{{ else }}{{ if $thisIsNotice }}"notice"{{ else }}"ok"{{ end }}{{ end }}{{ end }}, + {{ if not $activeComponentIssues }} + "unresolvedIssues": [] + {{ else }} + "unresolvedIssues": [{{ range $i, $e := $activeComponentIssues }}{{ if $i }},{{ end }} + { + "is": "issue", + "title": "{{ .Title }}", + "createdAt": "{{ .Date }}", + "lastMod": "{{ .Lastmod }}", + "permalink": "{{ .Permalink }}", + "severity": "{{ .Params.severity }}", + "resolved": {{ if .Params.resolved }}true{{ else }}false{{ end }}, + "informational": {{ if .Params.informational }}true{{ else }}false{{ end }}, + "resolvedAt": "{{ .Params.resolvedWhen }}", + "affected": [{{ range $i, $e := .Params.Affected }}{{ if $i }}, {{ end }}"{{ . }}"{{ end }}], + "filename": "{{ .File.LogicalName }}" + } + {{ end }} + ]{{ end }} + }{{ end }} + ], + {{ if .Site.Params.customTabs }} + "tabs": [{{ range $i, $e := .Site.Params.customTabs }}{{ if $i }},{{ end }} + { + "name": "{{ .name }}", + "link": "{{ .description }}" } {{ end }} - ], - + ],{{ end }} "buildDate": "{{ now.Format "2006-01-02" }}", "buildTime": "{{ now.Format "15:04" }}", "buildTimezone": "{{ now.Format "MST" }}", - "summaryStatus":{{ if $isDown }} - "down", - {{ else }} - {{ if $isDisrupted }} - "disrupted", - {{ else }} - {{ if $isNotice }} - "notice", - {{ else }} - "ok", - {{ end }}{{ end }}{{ end }} "colorBrand": "{{ .Site.Params.Brand }}", "colorOk": "{{ .Site.Params.Ok }}", "colorDisrupted": "{{ .Site.Params.Disrupted }}", "colorDown": "{{ .Site.Params.Down }}", "colorNotice": "{{ .Site.Params.Notice }}", "alwaysKeepBrandColor": "{{ .Site.Params.alwaysKeepBrandColor }}", - + "logo": "{{ .Site.Params.logo | absURL }}", "googleAnalytics": "{{ .Site.Params.googleAnalytics }}" } -- cgit v1.2.3-70-g09d2 From 548fcb9e38409902e12d117c745297e7637a7e67 Mon Sep 17 00:00:00 2001 From: Mantas Vilčinskas Date: Wed, 24 Feb 2021 16:29:44 +0200 Subject: API updates, lastmod, NCMS/default config changes, version to 0.80 --- exampleSite/config.yml | 24 +++++++++ exampleSite/netlify.toml | 2 +- i18n/en.yaml | 2 +- layouts/404.json | 4 ++ layouts/_default/list.json | 32 ++++++++++++ layouts/affected/list.json | 37 +++++++++++++ layouts/index.json | 2 +- layouts/issues/single.html | 17 +++++- layouts/issues/single.json | 8 +-- static/admin/config.yml | 127 ++++++++++++++++++++++++++++----------------- 10 files changed, 199 insertions(+), 56 deletions(-) create mode 100644 layouts/404.json create mode 100644 layouts/_default/list.json create mode 100644 layouts/affected/list.json (limited to 'layouts/index.json') diff --git a/exampleSite/config.yml b/exampleSite/config.yml index 7dc5972..ee52734 100644 --- a/exampleSite/config.yml +++ b/exampleSite/config.yml @@ -99,6 +99,19 @@ defaultContentLanguage: en # baseUrl: / baseURL: https://cstate.mnts.lt +# For features like Last modified, you +# need to use a Git repository. If you +# are using Netlify, you are already +# using Git (with GitHub, GitLab, etc) +# +# So, should Git information be used +# for this website? +# +# We recommend to keep this at `true`. +# BOOLEAN; `true`, `false` +enableGitInfo: true + + ############################################################ # +------------------------------------------------------+ # # | Preferences | # @@ -201,6 +214,13 @@ params: # BOOLEAN; `true`, `false` skipSeconds: false + # Should there be an automatic "Last updated" + # text shown below issues? + # + # Default: `true` + # BOOLEAN; `true`, `false` + enableLastMod: true + # What header design should we use? # # Default: `true` @@ -374,6 +394,10 @@ outputs: - json - rss - svg + term: + - html + - json + - rss outputFormats: svg: diff --git a/exampleSite/netlify.toml b/exampleSite/netlify.toml index d649777..0645d58 100644 --- a/exampleSite/netlify.toml +++ b/exampleSite/netlify.toml @@ -4,7 +4,7 @@ functions = "functions" [build.environment] - HUGO_VERSION = "0.48" + HUGO_VERSION = "0.80" [context.production.environment] HUGO_ENV = "production" diff --git a/i18n/en.yaml b/i18n/en.yaml index f5c7103..d47d970 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -42,7 +42,7 @@ # "Last checked" + "just now" - id: lastChecked - translation: Last checked + translation: Last updated - id: justNow translation: just now - id: someTimeAgo diff --git a/layouts/404.json b/layouts/404.json new file mode 100644 index 0000000..82681f1 --- /dev/null +++ b/layouts/404.json @@ -0,0 +1,4 @@ +{ + "is" : "404", + "title" : "Error - Not Found" +} \ No newline at end of file diff --git a/layouts/_default/list.json b/layouts/_default/list.json new file mode 100644 index 0000000..f469523 --- /dev/null +++ b/layouts/_default/list.json @@ -0,0 +1,32 @@ +{{ $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": "{{ .Section }}", + "title": "{{ .Title }}", + "baseURL": "{{ .Site.BaseURL }}", + "description": "{{ if .Params.Description }}{{ .Params.description }}{{ else }}{{ end }}", + "pages": [{{ range $i, $e := .Pages }}{{ if $i }},{{ end }}{{ if eq .Section "issues" }} + { + "is": "issue", + "title": "{{ .Title }}", + "createdAt": "{{ .Date }}", + "lastMod": "{{ .Lastmod }}", + "permalink": "{{ .Permalink }}", + "severity": "{{ .Params.severity }}", + "resolved": {{ if .Params.resolved }}true{{ else }}false{{ end }}, + "informational": {{ if .Params.informational }}true{{ else }}false{{ end }}, + "resolvedAt": "{{ .Params.resolvedWhen }}", + "affected": [{{ range $i, $e := .Params.Affected }}{{ if $i }}, {{ end }}"{{ . }}"{{ end }}], + "filename": "{{ .File.LogicalName }}" + } + {{ else }} + { + "is": "page", + "title": "{{ .Title }}", + "createdAt": "{{ .Date }}", + "lastMod": "{{ .Lastmod }}", + "permalink": "{{ .Permalink }}", + "filename": "{{ .File.LogicalName }}", + "summary": {{ jsonify .Summary }} + } + {{ end }}{{ end }} + ], +} diff --git a/layouts/affected/list.json b/layouts/affected/list.json new file mode 100644 index 0000000..1fde8d1 --- /dev/null +++ b/layouts/affected/list.json @@ -0,0 +1,37 @@ +{{ $incidents := .Pages }}{{ $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": "system", + "title": "{{ .Title }}", + "permalink": "{{ .Permalink }}", + "status": {{ if $isDown }}"down",{{ else }}{{ if $isDisrupted }}"disrupted",{{ else }}{{ if $isNotice }}"notice",{{ else }}"ok",{{ end }}{{ end }}{{ end }} + "pages": [{{ range $i, $e := .Pages }}{{ if $i }},{{ end }}{{ if eq .Section "issues" }} + { + "is": "issue", + "title": "{{ .Title }}", + "createdAt": "{{ .Date }}", + "lastMod": "{{ .Lastmod }}", + "permalink": "{{ .Permalink }}", + "severity": "{{ .Params.severity }}", + "resolved": {{ if .Params.resolved }}true{{ else }}false{{ end }}, + "informational": {{ if .Params.informational }}true{{ else }}false{{ end }}, + "resolvedAt": "{{ .Params.resolvedWhen }}", + "affected": [{{ range $i, $e := .Params.Affected }}{{ if $i }}, {{ end }}"{{ . }}"{{ end }}], + "filename": "{{ .File.LogicalName }}" + } + {{ else }} + { + "is": "page", + "title": "{{ .Title }}", + "createdAt": "{{ .Date }}", + "lastMod": "{{ .Lastmod }}", + "permalink": "{{ .Permalink }}", + "filename": "{{ .File.LogicalName }}", + "summary": {{ jsonify .Summary }} + } + {{ end }}{{ end }} + ], +} + + + + + diff --git a/layouts/index.json b/layouts/index.json index eea1926..9834cec 100644 --- a/layouts/index.json +++ b/layouts/index.json @@ -7,7 +7,7 @@ "languageCode": "{{ T "languageCode" }}", "baseURL": "{{ .Site.BaseURL }}", "description": "{{ .Site.Params.Description }}", - "summaryStatus":{{ if $isDown }}"down",{{ else }}{{ if $isDisrupted }}"disrupted",{{ else }}{{ if $isNotice }}"notice",{{ else }}"ok",{{ end }}{{ end }}{{ end }} + "summaryStatus": {{ if $isDown }}"down",{{ else }}{{ if $isDisrupted }}"disrupted",{{ else }}{{ if $isNotice }}"notice",{{ else }}"ok",{{ end }}{{ end }}{{ end }} "categories": [{{ range $i, $e := .Site.Params.categories }}{{ if $i }},{{ end }} { "name": "{{ .name }}",{{ if .description }} diff --git a/layouts/issues/single.html b/layouts/issues/single.html index 5761477..402c794 100644 --- a/layouts/issues/single.html +++ b/layouts/issues/single.html @@ -13,9 +13,24 @@
- {{ .Render "issue" }} + {{ .Render "issue" }}
+ + {{ if .Site.Params.enableLastMod }} +
+

{{ T "lastChecked" }}: + {{ if .Site.Params.dateFormat }} + {{ .Lastmod.UTC.Format .Site.Params.dateFormat }} + {{ else }} + {{ .Lastmod.Format "January 2, 2006 at 3:04 PM" }} + {{ end }} +

+
+ {{ end }} + + + {{ partial "js" . }} {{ partial "footer" . }} diff --git a/layouts/issues/single.json b/layouts/issues/single.json index 36b0f67..fb78ee7 100644 --- a/layouts/issues/single.json +++ b/layouts/issues/single.json @@ -2,12 +2,12 @@ "is": "issue", "title": "{{ .Title }}", "createdAt": "{{ .Date }}", + "lastMod": "{{ .Lastmod }}", "permalink": "{{ .Permalink }}", "severity": "{{ .Params.severity }}", - "resolved": "{{ .Params.resolved }}", - "informational": "{{ .Params.informational }}", + "resolved": {{ if .Params.resolved }}true{{ else }}false{{ end }}, + "informational": {{ if .Params.informational }}true{{ else }}false{{ end }}, "resolvedAt": "{{ .Params.resolvedWhen }}", "affected": [{{ range $i, $e := .Params.Affected }}{{ if $i }}, {{ end }}"{{ . }}"{{ end }}], - "filename": "{{ .File.LogicalName }}", - "body": {{ jsonify .Content }} + "filename": "{{ .File.LogicalName }}" } \ No newline at end of file diff --git a/static/admin/config.yml b/static/admin/config.yml index 582fe2f..3de63dc 100644 --- a/static/admin/config.yml +++ b/static/admin/config.yml @@ -110,18 +110,6 @@ collections: hint: 'What is your status page called? Shows up in the browser bar and meta.' name: 'title' widget: 'string' - - label: 'Use relative time (issue began x min ago)' - name: 'useRelativeTime' - widget: 'boolean' - hint: 'IMPORTANT: In the frontmatter, the dates MUST be in the UTC time zone. If you use Netlify CMS, the CMS picks UTC time by default, so no need to worry. However, there may be very inaccurate times, if you manually define non-UTC time in your issues. Read the wiki for more: https://github.com/cstate/cstate/wiki/Customization#time' - required: false - default: true - - label: 'Skip seconds in relative time calculations?' - name: 'skipSeconds' - widget: 'boolean' - hint: 'For users of relative time. With option ON (true): "Last checked <1 min ago". With option OFF (false; default): "Last checked 20s ago". Read the wiki for more: https://github.com/cstate/cstate/wiki/Customization#skip-seconds-v50' - required: false - default: false - label: 'Build future posts' name: 'buildFuture' widget: 'boolean' @@ -189,19 +177,37 @@ collections: - {label: "Name", name: "name", widget: string} - {label: "Link", name: "link", widget: string} # Dates + - label: 'Show last modified date at bottom of issues' + name: 'enableLastMod' + widget: 'boolean' + hint: 'Experimental feature shows when changes occured based on Git info. Read the wiki for more: https://github.com/cstate/cstate/wiki/Customization#time' + required: false + default: false + - label: 'Use relative time (issue began x min ago)' + name: 'useRelativeTime' + widget: 'boolean' + hint: 'IMPORTANT: In the frontmatter, the dates MUST be in the UTC time zone. If you use Netlify CMS, the CMS picks UTC time by default, so no need to worry. However, there may be very inaccurate times, if you manually define non-UTC time in your issues. Read the wiki for more: https://github.com/cstate/cstate/wiki/Customization#time' + required: false + default: true + - label: 'Skip seconds in relative time calculations?' + name: 'skipSeconds' + widget: 'boolean' + hint: 'For users of relative time. With option ON (true): "Last checked <1 min ago". With option OFF (false; default): "Last checked 20s ago". Read the wiki for more: https://github.com/cstate/cstate/wiki/Customization#skip-seconds-v50' + required: false + default: false - label: 'Long date format' name: 'dateFormat' widget: 'string' - hint: 'Default: January 2, 2006 at 3:04 PM UTC. Ddocs: https://github.com/cstate/cstate/wiki/Customization#changing-date-formats-v30' + hint: 'Default: January 2, 2006 at 3:04 PM UTC. Docs: https://github.com/cstate/cstate/wiki/Customization#changing-date-formats-v30' default: 'January 2, 2006 at 3:04 PM UTC' - label: 'Short date format' name: 'shortDateFormat' widget: 'string' - hint: 'Default: 15:04 UTC — Jan 2. Hugo formatting docs: https://github.com/cstate/cstate/wiki/Customization#changing-date-formats-v30' + hint: 'Default: 15:04 UTC — Jan 2. Docs: https://github.com/cstate/cstate/wiki/Customization#changing-date-formats-v30' default: '15:04 UTC — Jan 2' # Design site title color toggle in v4.0.1 - label: 'Site title text color' - hint: 'This is irrelevant, if you use a logo in your header. Docs: https://github.com/cstate/cstate/wiki/Customization#changing-date-formats-v30' + hint: 'This is irrelevant, if you use a logo in your header.' name: 'headerTextColor' widget: 'select' default: 'white' @@ -303,36 +309,61 @@ collections: name: 'enableCustomHTML' widget: 'boolean' default: 'false' - # REQUIRED BUT HIDDEN - - label: 'theme' - name: 'theme' - widget: 'hidden' - default: 'cstate' - - label: 'preserveTaxonomyNames' - name: 'preserveTaxonomyNames' - widget: 'hidden' - default: 'true' - - label: "taxonomies" - name: taxonomies - widget: "hidden" - fields: - - {label: "affected", name: "affected", widget: "hidden", default: "affected"} - - label: "outputs (Do not touch!)" - name: outputs - widget: "hidden" - fields: - - label: "page" - name: page - widget: "list" - allow_add: false - default: ['html', 'json'] - - label: "section" - name: section - widget: "list" - allow_add: false - default: ['html', 'json', 'rss'] - - label: "home" - name: home - widget: "list" - allow_add: false - default: ['html', 'json', 'rss'] + # REQUIRED BUT HIDDEN + - label: 'theme' + name: 'theme' + widget: 'hidden' + default: 'cstate' + - label: 'preserveTaxonomyNames' + name: 'preserveTaxonomyNames' + widget: 'hidden' + default: 'true' + - label: "taxonomies" + name: taxonomies + widget: "hidden" + fields: + - {label: "affected", name: "affected", widget: "hidden", default: "affected"} + - label: "Outputs (Do not touch!)" + name: outputs + widget: "hidden" + fields: + - label: "page" + name: page + widget: "list" + allow_add: false + default: ['html', 'json'] + - label: "section" + name: section + widget: "list" + allow_add: false + default: ['html', 'json', 'rss'] + - label: "home" + name: home + widget: "list" + allow_add: false + default: ['html', 'json', 'rss', 'svg'] + - label: "term" + name: term + widget: "list" + allow_add: false + default: ['html', 'json', 'rss'] + - label: "Output formats (Do not touch!)" + name: outputFormats + widget: "hidden" + fields: + - label: "svg" + name: svg + fields: + - label: "isPlainText" + name: isPlainText + widget: "boolean" + default: true + - label: "mediaType" + name: mediaType + default: "image/svg+xml" + - label: 'Enable Git info' + name: 'enableGitInfo' + widget: 'hidden' + hint: 'Docs: https://github.com/cstate/cstate/wiki/Customization#time' + required: false + default: true \ No newline at end of file -- cgit v1.2.3-70-g09d2