~bigbes/sr-ht-spec

ref: 658bae75f9714af212b463dbba6bb2de565112f9 sr-ht-spec/web/templates/threads.html -rw-r--r-- 3.0 KiB
658bae75 — Eugene Blikh feat(prosediff): recover the source line each word edit sits on (spec-by6.3.5) 24 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{{/*
  The review-thread markup, defined once and parsed into every page set.

  The diff renderer (web/diff.go) executes "blockthreads" into the HTML it
  builds for one block, and the proposal page renders "thread" directly for the
  comments whose anchor no longer names a block. Both go through html/template
  rather than string building because a comment body is prose someone else
  wrote: contextual auto-escaping is what keeps it text.
*/}}

{{define "thread"}}
<article class="ph-thread{{if .Resolved}} ph-thread-resolved{{end}}" id="thread-{{.ID}}">
  <header class="ph-thread-head">
    <span class="ph-author">{{.Author}}</span>
    {{if .Agent}}<span class="badge badge-secondary">agent</span>{{end}}
    <span class="ph-when">{{.When}}</span>
    {{if .Resolved}}<span class="badge badge-success">resolved</span>{{end}}
    {{if .Note}}<span class="badge badge-warning" title="{{.NoteWhy}}">{{.Note}}</span>{{end}}
    {{if .DocPath}}<code class="ph-when">{{.DocPath}}</code>{{end}}
  </header>
  <div class="ph-comment-body">{{.Body}}</div>

  {{range .Replies}}
  <div class="ph-reply">
    <header class="ph-thread-head">
      <span class="ph-author">{{.Author}}</span>
      {{if .Agent}}<span class="badge badge-secondary">agent</span>{{end}}
      <span class="ph-when">{{.When}}</span>
    </header>
    <div class="ph-comment-body">{{.Body}}</div>
  </div>
  {{end}}

  <div class="ph-thread-actions">
    {{if .CanReply}}
    <details class="ph-form">
      <summary>Reply</summary>
      <form method="POST" action="{{.ActionBase}}/reply">
        <input type="hidden" name="thread" value="{{.ID}}">
        <textarea class="form-control" name="body" rows="3" required
                  placeholder="Answer the critique"></textarea>
        <button type="submit" class="btn btn-sm btn-primary">Reply</button>
      </form>
    </details>
    {{end}}
    {{if .CanResolve}}
    <form method="POST" action="{{.ActionBase}}/resolve" class="ph-form">
      <input type="hidden" name="thread" value="{{.ID}}">
      <input type="hidden" name="resolved" value="{{if .Resolved}}0{{else}}1{{end}}">
      <button type="submit" class="btn btn-sm btn-outline-secondary">
        {{if .Resolved}}Reopen{{else}}Resolve{{end}}
      </button>
    </form>
    {{end}}
  </div>
</article>
{{end}}

{{define "blockthreads"}}
{{if .Threads}}
<div class="ph-threads">
  {{range .Threads}}{{template "thread" .}}{{end}}
</div>
{{end}}
{{if .Compose}}
<details class="ph-form ph-compose">
  <summary>Comment on this block</summary>
  <form method="POST" action="{{.Compose.ActionBase}}/comment">
    <input type="hidden" name="doc" value="{{.Compose.DocPath}}">
    <input type="hidden" name="block" value="{{.Compose.Ordinal}}">
    <input type="hidden" name="side" value="{{.Compose.Side}}">
    <input type="hidden" name="hash" value="{{.Compose.Hash}}">
    <textarea class="form-control" name="body" rows="3" required
              placeholder="What is wrong with this block?"></textarea>
    <button type="submit" class="btn btn-sm btn-primary">Comment</button>
  </form>
</details>
{{end}}
{{end}}