aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMantas Vilčinskas <hi@mnts.lt>2021-02-24 14:39:32 +0200
committerMantas Vilčinskas <hi@mnts.lt>2021-02-24 14:39:32 +0200
commit96477340dd7d7127ce5a6190e78974ad7a895bea (patch)
tree8383e10879d82d17e2c9b6be1825011df4cdba08
parent925027e85b74a77e06448be5baa6053f1222fb78 (diff)
API v2 Index features
-rw-r--r--exampleSite/content/issues/2018-05-25-us-east-conn-issues.md2
-rw-r--r--exampleSite/content/issues/i-testing-cstate-functions.md (renamed from exampleSite/content/issues/2019-10-04-testing-cstate-functions.md)2
-rw-r--r--layouts/index.json58
3 files changed, 36 insertions, 26 deletions
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/i-testing-cstate-functions.md
index efdf7d7..cf833ac 100644
--- a/exampleSite/content/issues/2019-10-04-testing-cstate-functions.md
+++ b/exampleSite/content/issues/i-testing-cstate-functions.md
@@ -7,4 +7,4 @@ 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
+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 }}"
}