Skip to content

Commit

Permalink
Add overrides for issue templates
Browse files Browse the repository at this point in the history
Introduces overrides for issue templates in order to always have the
same coloring for "resolved" information. Content is taken from
https://github.com/cstate/cstate/tree/d0d39000c2d3eef82f63c8a6a00dd8b30ba6688a/layouts/issues
  • Loading branch information
m90 committed May 15, 2024
1 parent b4a0d54 commit 98e5c16
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 0 deletions.
78 changes: 78 additions & 0 deletions layouts/issues/issue.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{{ $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" }}

<div class="article">
<h1 class="clean">
{{ .Title }}
</h1>

<small class="date">
{{ if .Site.Params.dateFormat }}
{{ dateFormat .Site.Params.dateFormat .Params.date }}
{{ else }}
{{ .Date.Format "January 2, 2006 at 3:04 PM" }}
{{ end }}
</small>

<p><small>
{{ range .Params.Affected }}
<a href="{{ printf "affected/%s/" (. | urlize) | relURL }}" class="tag no-underline">{{ . }}</a>
{{ end }}
</small></p>

{{ if .Params.informational }}
{{ else if .Params.Resolved }}
{{ $t := (time .Params.ResolvedWhen) }}
{{ $timeDiff := (sub $t.Unix .Date.Unix) }}
{{ $diffInMin := (div $timeDiff 60) }}


<!-- Marker -->
{{ if lt $timeDiff 60 }}
<div class="faded">
<strong>
{{ T "resolved" }} {{ T "inUnderAMinute" }}.
</strong>
</div>
{{ else }}
<div class="ok tooltip">
<strong>
{{ T "resolvedAfter" }}

{{ $secsForCalc := (mod $timeDiff 60) }}

{{ div (sub $timeDiff $secsForCalc) 60 }}m
{{ if eq .Params.severity "down" }}
{{ T "ofDowntime" }}
{{ end }}
</strong>

<span class="tooltip__text">
{{ if .Site.Params.dateFormat }}
{{ dateFormat .Site.Params.dateFormat .Params.resolvedWhen }}
{{ else }}
{{ dateFormat "January 2, 2006 at 3:04 PM" .Params.resolvedWhen }}
{{ end }}
</span>
</div>
{{ end }}
{{ else }}
<strong class="error">
{{ if eq .Params.severity "down" }}
{{ else if eq .Params.severity "disrupted" }}
{{ else }}
{{ end }}
{{ T "downtimeOngoing" }}</strong>
{{ end }}

<hr>
<div class="markdown">{{ .Content }}</div>
</div>
<div class="padding"></div>
109 changes: 109 additions & 0 deletions layouts/issues/small.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{{ $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" }}

<a href="{{ .Permalink }}" class="issue no-underline">
{{ if .Params.informational }}

<small class="date float-right {{ cond .Site.Params.useRelativeTime "relative-time" "" }}" title="{{ dateFormat .Site.Params.dateFormat .Params.date }}" data-date="{{ .Date.Format "Jan 2 15:04:05 2006 UTC" }}">
{{ if .Site.Params.dateFormat }}
{{ dateFormat .Site.Params.dateFormat .Params.date }}
{{ else }}
{{ .Date.Format "January 2, 2006 at 3:04 PM" }}
{{ end }}
</small>

<h3>
{{ .Title }} &nbsp;ℹ
</h3>
<span class="faded">{{ .Summary | truncate 200 }}
</span>

{{ else if .Params.Resolved }}
<small class="date float-right {{ cond .Site.Params.useRelativeTime "relative-time" "" }}" title="{{ dateFormat .Site.Params.dateFormat .Params.date }}" data-date="{{ .Date.Format "Jan 2 15:04:05 2006 UTC" }}">
{{ if .Site.Params.dateFormat }}
{{ dateFormat .Site.Params.dateFormat .Params.date }}
{{ else }}
{{ .Date.Format "January 2, 2006 at 3:04 PM" }}
{{ end }}
</small>

<h3>
{{ .Title }}
</h3>

{{ $t := (time .Params.ResolvedWhen) }}
{{ $timeDiff := (sub $t.Unix .Date.Unix) }}
{{ $diffInMin := (div $timeDiff 60) }}

<!-- Marker -->
{{ if lt $timeDiff 60 }}
<div class="faded">
{{ T "resolved" }} {{ T "inUnderAMinute" }}
</div>
{{ else }}
<div class="ok">
{{ T "resolvedAfter" }}

{{ $secsForCalc := (mod $timeDiff 60) }}

{{ div (sub $timeDiff $secsForCalc) 60 }}m
{{ if eq .Params.severity "down" }}
<!-- {{ $secsForCalc }}s --> {{ T "ofDowntime" }}
{{ end }}
</div>
{{ end }}

{{ else }}
<!-- If not resolved -->
<small class="date float-right {{ cond .Site.Params.useRelativeTime "relative-time" "" }}" title="{{ dateFormat .Site.Params.dateFormat .Params.date }}" data-date="{{ .Date.Format "Jan 2 15:04:05 2006 UTC" }}">

{{ if .Date.Before now }}
{{ if .Site.Params.dateFormat }}
{{ dateFormat .Site.Params.dateFormat .Params.date }}
{{ else }}
{{ .Date.Format "January 2, 2006 at 3:04 PM" }}
{{ end }}
{{ else }}
{{ end }}
</small>

<h3>
{{ .Title }}
</h3>



<!-- Marker -->
{{ if eq .Params.severity "notice" }}
<strong class="error">
{{ if .Date.Before now }}
{{ T "downtimeOngoing" }}
{{ else }}
{{ if .Site.Params.dateFormat }}
{{ dateFormat .Site.Params.dateFormat .Params.date }}
{{ else }}
{{ .Date.Format "January 2, 2006 at 3:04 PM" }}
{{ end }}
{{ end }}
</strong>
{{ else }}

<strong class="error">
{{ if eq .Params.severity "down" }}
{{ else if eq .Params.severity "disrupted" }}
{{ else }}
{{ end }}
{{ T "downtimeOngoing" }}
</strong>
{{ end }}

{{ end }}
</a>

0 comments on commit 98e5c16

Please sign in to comment.