From c62329ce102df226cc62b832232d6e9d528bd0df Mon Sep 17 00:00:00 2001 From: Mantas <11616378+mistermantas@users.noreply.github.com> Date: Thu, 9 May 2019 21:20:38 +0300 Subject: #27 - 1st working API kinda --- layouts/issues/single.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 layouts/issues/single.json (limited to 'layouts/issues/single.json') diff --git a/layouts/issues/single.json b/layouts/issues/single.json new file mode 100644 index 0000000..6287288 --- /dev/null +++ b/layouts/issues/single.json @@ -0,0 +1,14 @@ + +{ + "section": "{{ .Section }}", + "title": "{{ .Title }}", + "created_at": "{{ .Date }}", + "severity": "{{ .Params.severity }}", + "resolved": "{{ .Params.resolved }}", + "resolved_at": "{{ .Params.resolvedWhen }}", + "affected": [{{ range $i, $e := .Params.Affected }}{{ if $i }}, {{ end }}'{{ . }}'{{ end }}], + + "body": {{ jsonify .Content }}, + + "filename": "{{ .File.LogicalName }}" +} \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 19d5be70f84c21011869b6c8340a0589f353beb8 Mon Sep 17 00:00:00 2001 From: Mantas VilĨinskas Date: Sat, 5 Oct 2019 19:43:56 +0300 Subject: Added API for index, fully added #43 with tweaks to yrly archive --- exampleSite/config.yml | 8 ++--- .../issues/2018-01-17-sending-dms-impacted.md | 4 +-- .../issues/2018-05-25-us-east-conn-issues.md | 4 +-- layouts/index.html | 4 ++- layouts/index.json | 39 ++++++++++++++++++++++ layouts/issues/single.json | 9 +++-- layouts/partials/index/incidents-monthly.html | 29 ++++++++++++++++ layouts/partials/index/incidents-yearly.html | 9 +++-- 8 files changed, 89 insertions(+), 17 deletions(-) create mode 100644 layouts/index.json create mode 100644 layouts/partials/index/incidents-monthly.html (limited to 'layouts/issues/single.json') diff --git a/exampleSite/config.yml b/exampleSite/config.yml index 0a3afe1..a894d26 100644 --- a/exampleSite/config.yml +++ b/exampleSite/config.yml @@ -164,13 +164,13 @@ params: useLargeHeaderDesign: false # Should incident history be separated - # yearly, in an archive view? + # like in an archive view? # # Note: This WILL disable pagination. # - # Default: true - # BOOLEAN; `true`, `false` - enableYearlyIncidentHistory: true + # Default: `yearly` + # STRING; `monthly`, `yearly`, `none` + incidentHistoryFormat: "yearly" # Should we show the logo or the title # of the status page? diff --git a/exampleSite/content/issues/2018-01-17-sending-dms-impacted.md b/exampleSite/content/issues/2018-01-17-sending-dms-impacted.md index 0af6136..b96139f 100644 --- a/exampleSite/content/issues/2018-01-17-sending-dms-impacted.md +++ b/exampleSite/content/issues/2018-01-17-sending-dms-impacted.md @@ -1,8 +1,8 @@ --- title: Issues Sending DMs -date: 2018-01-17 16:24:00 +date: 2017-12-17 16:24:00 resolved: true -resolvedWhen: 2018-01-17 16:58:00 +resolvedWhen: 2017-12-17 16:58:00 # Possible severity levels: down, disrupted, notice severity: disrupted affected: 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 8178189..8d56cf2 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,8 +1,8 @@ --- title: US East Connection Issues -date: 2018-05-25 04:13:00 +date: 2018-04-25 04:13:00 resolved: true -resolvedWhen: 2018-05-25 04:13:59 +resolvedWhen: 2018-04-25 04:13:59 # Possible severity levels: down, disrupted, notice severity: down affected: diff --git a/layouts/index.html b/layouts/index.html index da6f6ad..c02224a 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -38,8 +38,10 @@
- {{ if .Site.Params.enableYearlyIncidentHistory }} + {{ if eq .Site.Params.incidentHistoryFormat "yearly" }} {{ partial "index/incidents-yearly" . }} + {{ else if eq .Site.Params.incidentHistoryFormat "monthly" }} + {{ partial "index/incidents-monthly" . }} {{ else }} {{ partial "index/incidents" . }} {{ end }} diff --git a/layouts/index.json b/layouts/index.json new file mode 100644 index 0000000..2495f60 --- /dev/null +++ b/layouts/index.json @@ -0,0 +1,39 @@ +{ + "version": "4.0", + "title": "{{ .Site.Title }}", + "languageCodeHTML": "{{ .Site.LanguageCode }}", + "languageCode": "{{ T "languageCode" }}", + "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 }} + { + "name": "{{ .name }}",{{ if .description }} + "description": "{{ .description }}",{{ end }} + "hideTitle": "{{ .untitled }}", + "closedByDefault": "{{ .closed }}" + } + {{ end }} + ], + "systems": [ + {{ range $i, $e := .Site.Params.systems }}{{ if $i }},{{ end }} + { + "name": "{{ .name }}",{{ if .description }} + "description": "{{ .description }}",{{ end }} + "category": "{{ .category }}", + "hideTitle": "{{ .untitled }}", + "closedByDefault": "{{ .closed }}" + } + {{ 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 }}", + "googleAnalytics": "{{ .Site.Params.googleAnalytics }}" +} \ No newline at end of file diff --git a/layouts/issues/single.json b/layouts/issues/single.json index 6287288..897998a 100644 --- a/layouts/issues/single.json +++ b/layouts/issues/single.json @@ -5,10 +5,9 @@ "created_at": "{{ .Date }}", "severity": "{{ .Params.severity }}", "resolved": "{{ .Params.resolved }}", + "informational": "{{ .Params.informational }}", "resolved_at": "{{ .Params.resolvedWhen }}", - "affected": [{{ range $i, $e := .Params.Affected }}{{ if $i }}, {{ end }}'{{ . }}'{{ end }}], - - "body": {{ jsonify .Content }}, - - "filename": "{{ .File.LogicalName }}" + "affected": [{{ range $i, $e := .Params.Affected }}{{ if $i }}, {{ end }}"{{ . }}"{{ end }}], + "filename": "{{ .File.LogicalName }}", + "body": {{ jsonify .Content }} } \ No newline at end of file diff --git a/layouts/partials/index/incidents-monthly.html b/layouts/partials/index/incidents-monthly.html new file mode 100644 index 0000000..263bc52 --- /dev/null +++ b/layouts/partials/index/incidents-monthly.html @@ -0,0 +1,29 @@ +{{ $incidents := where .Site.RegularPages "Params.section" "issue" }} + + + +{{ range ($incidents.GroupByDate "1") }} +
+
+

+ + + {{ if gt .Key 9 }} + {{ $month := printf "2006-%s-02" .Key }} + {{ $monthDate := $month | time }} + {{ $monthDate.Format "January" }} + {{ else }} + {{ $month := printf "2006-0%s-02" .Key }} + {{ $monthDate := $month | time }} + {{ $monthDate.Format "January" }} + {{ end }} + {{ range first 1 .Pages }}{{ .Date.Format "2006" }}{{ end }} + ({{ len .Pages }}) +

+
+ + {{ range .Pages }} + {{ .Render "small" }} + {{ end }} +{{ end }} diff --git a/layouts/partials/index/incidents-yearly.html b/layouts/partials/index/incidents-yearly.html index 5cc323a..d07be9d 100644 --- a/layouts/partials/index/incidents-yearly.html +++ b/layouts/partials/index/incidents-yearly.html @@ -1,9 +1,12 @@ {{ $incidents := where .Site.RegularPages "Params.section" "issue" }} -{{ range ((where .Site.RegularPages "Params.section" "issue").GroupByDate "2006") }} -

{{ .Key }} + +{{ range ($incidents.GroupByDate "2006") }} +

+
+

{{ .Key }} ({{ len .Pages }}) -

+


{{ range .Pages }} {{ .Render "small" }} -- cgit v1.2.3-70-g09d2 From ae39ee1c2d48899e75acdecff7442b4ef8a4c49c Mon Sep 17 00:00:00 2001 From: Mantas VilĨinskas Date: Sun, 6 Oct 2019 10:28:21 +0300 Subject: Mostly finished API #27 for index, issue, page; remove autorefresh #80 --- layouts/_default/single.json | 8 ++++++++ layouts/index.json | 34 ++++++++++++++++++++++++++------- layouts/issues/single.json | 8 ++++---- layouts/partials/index/autorefresh.html | 8 -------- layouts/partials/js.html | 2 +- layouts/partials/meta.html | 2 +- 6 files changed, 41 insertions(+), 21 deletions(-) create mode 100644 layouts/_default/single.json (limited to 'layouts/issues/single.json') diff --git a/layouts/_default/single.json b/layouts/_default/single.json new file mode 100644 index 0000000..634e2bc --- /dev/null +++ b/layouts/_default/single.json @@ -0,0 +1,8 @@ +{ + "is": "page", + "title": "{{ .Title }}", + "createdAt": "{{ .Date }}", + "filename": "{{ .File.LogicalName }}", + "permalink": "{{ .Permalink }}", + "body": {{ jsonify .Content }} +} \ No newline at end of file diff --git a/layouts/index.json b/layouts/index.json index 2495f60..c2a2c49 100644 --- a/layouts/index.json +++ b/layouts/index.json @@ -1,9 +1,15 @@ +{{ $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" }} { - "version": "4.0", + "is": "index", + "cStateVersion": "4.0", + "apiVersion": "1.0", "title": "{{ .Site.Title }}", "languageCodeHTML": "{{ .Site.LanguageCode }}", "languageCode": "{{ T "languageCode" }}", - "languageCode": "{{ T "languageCode" }}", "baseURL": "{{ .Site.BaseURL }}", "description": "{{ .Site.Params.Description }}", "logo": "{{ .Site.Params.logo | absURL }}", @@ -12,8 +18,8 @@ { "name": "{{ .name }}",{{ if .description }} "description": "{{ .description }}",{{ end }} - "hideTitle": "{{ .untitled }}", - "closedByDefault": "{{ .closed }}" + "hideTitle": {{ if .untitled }}true{{ else }}false{{ end }}, + "closedByDefault": {{ if .closed }}true{{ else }}false{{ end }} } {{ end }} ], @@ -22,18 +28,32 @@ { "name": "{{ .name }}",{{ if .description }} "description": "{{ .description }}",{{ end }} - "category": "{{ .category }}", - "hideTitle": "{{ .untitled }}", - "closedByDefault": "{{ .closed }}" + "category": "{{ .category }}" } {{ 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 }}", + "googleAnalytics": "{{ .Site.Params.googleAnalytics }}" } \ No newline at end of file diff --git a/layouts/issues/single.json b/layouts/issues/single.json index 897998a..36b0f67 100644 --- a/layouts/issues/single.json +++ b/layouts/issues/single.json @@ -1,12 +1,12 @@ - { - "section": "{{ .Section }}", + "is": "issue", "title": "{{ .Title }}", - "created_at": "{{ .Date }}", + "createdAt": "{{ .Date }}", + "permalink": "{{ .Permalink }}", "severity": "{{ .Params.severity }}", "resolved": "{{ .Params.resolved }}", "informational": "{{ .Params.informational }}", - "resolved_at": "{{ .Params.resolvedWhen }}", + "resolvedAt": "{{ .Params.resolvedWhen }}", "affected": [{{ range $i, $e := .Params.Affected }}{{ if $i }}, {{ end }}"{{ . }}"{{ end }}], "filename": "{{ .File.LogicalName }}", "body": {{ jsonify .Content }} diff --git a/layouts/partials/index/autorefresh.html b/layouts/partials/index/autorefresh.html index b419e2f..e69de29 100644 --- a/layouts/partials/index/autorefresh.html +++ b/layouts/partials/index/autorefresh.html @@ -1,8 +0,0 @@ -{{ if .Site.Params.autoRefresh }} -
- {{ T "autoRefreshNotice" }} -
-
- {{ else }} -
-{{ end }} \ No newline at end of file diff --git a/layouts/partials/js.html b/layouts/partials/js.html index 54909c2..54a0176 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -3,7 +3,7 @@ * Dev toolset */ - console.log('cState v4.0.0 - Dev 2019-10-04 - https://github.com/cstate/cstate'); + console.log('cState v4.0.0 - Dev 2019-10-06 - https://github.com/cstate/cstate'); document.getElementsByTagName('html')[0].className = 'js'; /** diff --git a/layouts/partials/meta.html b/layouts/partials/meta.html index 2dc58bf..277d250 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 -}} - +