[tor-commits] [status-site/main] Add support for network experiments

anarcat at torproject.org anarcat at torproject.org
Mon May 31 15:43:20 UTC 2021


commit 9cd9ef60bdb7e564d9906e195bb321863b2a40d4
Author: Georg Koppen <gk at torproject.org>
Date:   Fri May 28 10:59:44 2021 +0000

    Add support for network experiments
    
    This commit adds support for network experiments on our status page
    without the incident language.
    
    In particular, it
    
    1) creates a new layout (experiments),
    2) overwrites the default components page to take network experiment
       differences into account,
    3) adds a Network Experiments item to the Tor Network section.
    
    Note: this commit has a dependency on a cstate commit providing the new
    strings to use.
---
 config.yml                             |   3 +
 layouts/experiments/experiment.html    |  99 +++++++++++++++++++++++++++++
 layouts/experiments/single.html        |  23 +++++++
 layouts/experiments/single.json        |   9 +++
 layouts/experiments/small.html         |  97 +++++++++++++++++++++++++++++
 layouts/partials/index/components.html | 110 +++++++++++++++++++++++++++++++++
 6 files changed, 341 insertions(+)

diff --git a/config.yml b/config.yml
index 0d9cc50..df5f61c 100644
--- a/config.yml
+++ b/config.yml
@@ -146,6 +146,9 @@ params:
     - name: Directory Authorities
       description: Special-purpose relays that maintain a list of currently-running relays and periodically publish a consensus together.
       category: Tor Network
+    - name: Network Experiments
+      description: Experiments running on the Tor network.
+      category: Tor Network
     - name: torproject.org
       description: Our official website and its associated portals (e.g. community.torproject.org).
       category: Tor Project websites
diff --git a/layouts/experiments/experiment.html b/layouts/experiments/experiment.html
new file mode 100644
index 0000000..676a435
--- /dev/null
+++ b/layouts/experiments/experiment.html
@@ -0,0 +1,99 @@
+{{ $incidents := where .Site.RegularPages "Params.section" "experiment" }}
+{{ $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 }}
+      {{ .Date.Format .Site.Params.dateFormat }}
+    {{ 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) }}
+
+   {{ if eq .Params.severity "ongoing" }}
+      <div class="error">
+        <strong>
+          {{ T "experimentOngoing" }}
+        </strong>
+   {{ end }}
+
+  <!-- Marker -->
+  {{ if lt $timeDiff 60 }}
+  <div class="faded">
+    <strong>
+    {{ T "resolved" }} {{ T "inUnderAMinute" }}.
+    </strong>
+  </div>
+  {{ else }}
+    {{ if gt $timeDiff 3600 }}
+      <div class="warning tooltip">
+        <strong>
+          {{ T "resolvedAfter" }}
+
+          {{ $minutesForCalc := (mod $diffInMin 60) }}
+
+          {{ div (sub $diffInMin $minutesForCalc) 60 }}h
+          {{ $minutesForCalc }}m {{ T "ofDowntime" }}.
+        </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>
+    {{ else }}
+      <div class="ok tooltip">
+        <strong>
+          {{ T "resolvedAfter" }}
+
+          {{ $secsForCalc := (mod $timeDiff 60) }}
+
+          {{ div (sub $timeDiff $secsForCalc) 60 }}m
+          {{ T "ofDowntime" }}.
+        </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 }}
+  {{ end }}
+  {{ else }}
+    <strong class="ok">
+      {{ if eq .Params.severity "ongoing" }}
+        {{ T "experimentOngoing" }}
+      {{ end }}
+      </strong>
+  {{ end }}
+
+  <hr>
+  {{ .Content }}
+</div>
+<div class="padding"></div>
diff --git a/layouts/experiments/single.html b/layouts/experiments/single.html
new file mode 100644
index 0000000..ff32496
--- /dev/null
+++ b/layouts/experiments/single.html
@@ -0,0 +1,23 @@
+{{ partial "meta" . }}
+
+{{ $incidents := where .Site.RegularPages "Params.section" "experiment" }}
+{{ $active := where $incidents "Params.resolved" "=" false }}
+
+{{ $isNotice := where $active "Params.severity" "=" "notice" }}
+{{ $isDisrupted := where $active "Params.severity" "=" "disrupted" }}
+{{ $isDown := where $active "Params.severity" "=" "down" }}
+
+  <body class="experiment single">
+    <div class="contain">
+      <a href="{{ .Site.BaseURL }}">← {{ T "goBack" }} <em>{{ .Site.Title }}</em></a>
+    </div>
+
+    <div class="contain">
+      {{ .Render "experiment" }}
+    </div>
+
+
+    {{ partial "js" . }}
+    {{ partial "footer" . }}
+  </body>
+</html>
diff --git a/layouts/experiments/single.json b/layouts/experiments/single.json
new file mode 100644
index 0000000..1612e5c
--- /dev/null
+++ b/layouts/experiments/single.json
@@ -0,0 +1,9 @@
+{
+  "is": "experiment",
+  "title": "{{ .Title }}",
+  "createdAt": "{{ .Date }}",
+  "permalink": "{{ .Permalink }}",
+  "affected": [{{ range $i, $e := .Params.Affected }}{{ if $i }}, {{ end }}"{{ . }}"{{ end }}],
+  "filename": "{{ .File.LogicalName }}",
+  "body": {{ jsonify .Content }}
+}
diff --git a/layouts/experiments/small.html b/layouts/experiments/small.html
new file mode 100644
index 0000000..0767a21
--- /dev/null
+++ b/layouts/experiments/small.html
@@ -0,0 +1,97 @@
+{{ $incidents := where .Site.RegularPages "Params.section" "experiment" }}
+{{ $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">
+      {{ if .Site.Params.dateFormat }}
+        {{ .Date.Format .Site.Params.dateFormat }}
+      {{ else }}
+        {{ .Date.Format "January 2, 2006 at 3:04 PM" }}
+      {{ end }}
+    </small>
+
+    <h3>
+      {{ .Title }}  â„¹
+    </h3>
+    <span class="faded">{{ .Summary | truncate 200 }}
+    </span>
+  
+  {{ else if .Params.Resolved }}
+    <small class="date float-right">
+      {{ if .Site.Params.dateFormat }}
+        {{ .Date.Format .Site.Params.dateFormat }}
+      {{ 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 }}
+      {{ if gt $timeDiff 3600 }}
+        <div class="warning">
+          {{ T "resolvedAfter" }}
+
+          {{ $minutesForCalc := (mod $diffInMin 60) }}
+
+          {{ div (sub $diffInMin $minutesForCalc) 60 }}h
+          {{ $minutesForCalc }}m {{ T "ofDowntime" }}
+        </div>
+      {{ else }}
+        <div class="ok">
+          {{ T "resolvedAfter" }}
+
+          {{ $secsForCalc := (mod $timeDiff 60) }}
+
+          {{ div (sub $timeDiff $secsForCalc) 60 }}m
+          <!-- {{ $secsForCalc }}s --> {{ T "ofDowntime" }}
+        </div>
+      {{ end }}
+    {{ end }}
+  {{ else }}
+
+    <small class="date float-right">
+      {{ if .Site.Params.dateFormat }}
+        {{ .Date.Format .Site.Params.dateFormat }}
+      {{ else }}
+        {{ .Date.Format "January 2, 2006 at 3:04 PM" }}
+      {{ end }}
+    </small>
+
+    <h3>
+      {{ .Title }}
+    </h3>
+
+    <!-- Marker -->
+    {{ if eq .Params.severity "notice" }}
+      <strong class="warning">
+        â—† 
+        {{ T "downtimeOngoing" }}
+      </strong>
+    {{ else }}
+      <strong class="ok">
+        {{ if eq .Params.severity "ongoing" }}
+          {{ T "experimentOngoing" }}
+        {{ end }}
+      </strong>
+    {{ end }}
+
+  {{ end }}
+</a>
diff --git a/layouts/partials/index/components.html b/layouts/partials/index/components.html
new file mode 100644
index 0000000..c1526ec
--- /dev/null
+++ b/layouts/partials/index/components.html
@@ -0,0 +1,110 @@
+{{ $incidents := where .Site.RegularPages "Params.section" "issue" }}
+{{ $experiments := where .Site.RegularPages "Params.section" "experiment" }}
+{{ $active := $experiments | union (where $incidents "Params.resolved" "=" false)}}
+
+{{ $isNotice := where $active "Params.severity" "=" "notice" }}
+{{ $isDisrupted := where $active "Params.severity" "=" "disrupted" }}
+{{ $isDown := where $active "Params.severity" "=" "down" }}
+
+<!-- Individual info -->
+<div class="categories">
+  {{ $systems := .Site.Params.systems }}
+  {{ $categories := .Site.Params.categories }}
+
+  <script>
+  function toggleCategoryHead(el) {
+    if (el.parentNode.className == 'category category--open') {
+      el.parentNode.className = 'category category--closed';
+    } else {
+      el.parentNode.className = 'category category--open';
+    }
+  }
+  </script>
+
+  {{ range $categories }}
+    <div class="category {{ if .closed }}category--closed{{ else }}category--open{{ end }}" id="{{ .name | urlize }}">
+      {{ if not .untitled }}
+      <div class="bold padding clicky category__head" onclick="toggleCategoryHead(this)">
+        <span class="hide-without-js">
+          <span class="category__closed-marker">â–º</span>
+          <span class="category__open-marker">✕</span>
+        </span>
+
+      <b>
+        {{ .name }}
+      </b>
+      
+      {{ with .description }}
+        <span class="tooltip tooltip--small">
+            <span class="faded">(?)</span>
+
+          <span class="tooltip__text">
+            {{ . }}
+          </span>
+        </span>
+      {{ end }}
+
+      </div>
+      {{ else }}
+      <div class="padding"></div>
+      {{ end }}
+
+      {{ $categorySystems := where $systems "category" "=" .name }}
+
+      <div class="components">
+      {{ range $categorySystems }}
+        {{ $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" }}
+        {{ $thisIsOngoing := where $activeComponentIssues "Params.severity" "=" "ongoing" }}
+        {{ $thisIsNone := where $activeComponentIssues "Params.severity" "=" nil }}
+
+        <div class="component" data-status="{{ if $thisIsDown }}down{{ else }}{{ if $thisIsDisrupted }}disrupted{{ else }}{{ if $thisIsNotice }}notice{{ else }}ok{{ end }}{{ end }}{{ end }}">
+          <a href="{{ printf "/affected/%s/" (.name | urlize) | relURL }}" class="no-underline">
+            {{ default .name .displayName }}
+          </a>
+
+          {{ with .description }}
+            <span class="tooltip tooltip--small">
+                <span class="faded">(?)</span>
+
+              <span class="tooltip__text">
+                {{ . }}
+              </span>
+            </span>
+          {{ end }}
+
+          <span class="component-status">
+            {{ if $thisIsDown }}
+              {{ T "thisIsDown" }}
+            {{ else }}
+            {{ if $thisIsDisrupted }}
+              {{ T "thisIsDisrupted" }}
+            {{ else }}
+            {{ if $thisIsNotice }}
+              {{ T "thisIsNotice" }}
+            {{ else }}
+            {{ if $thisIsOngoing }}
+              {{ T "thisIsOngoing" }}
+            {{ else }}
+            {{ if $thisIsNone }}
+              {{ T "thisIsNone" }}
+            {{ else }}
+            {{ T "thisIsOk" }}
+            {{ end }}{{ end }}{{ end }}{{ end }}{{ end }}
+          </span>
+
+          {{ with .partial }}
+          <div>
+            {{ partial . . }}
+          </div>
+          {{ end }}
+        </div>
+      {{ end }}
+      </div>
+    </div>
+  {{ end }}
+
+</div>





More information about the tor-commits mailing list