aboutsummaryrefslogtreecommitdiff
path: root/static/posts.html
blob: 0e381eabeebb66a2e16866fc57c311bd45ff8cbb (plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
{{ define "posts" }}
{{ $board := .Board }}
{{ $len := len .Posts }}
{{ range .Posts }}
{{ $opId := .Id }}
{{ if eq $board.InReplyTo "" }}
<hr>
{{ end }}
<div style="overflow: auto;">
  <div id="{{ .Id }}" style="overflow: visible; margin-bottom: 12px;">
    {{ if eq $board.ModCred $board.Domain $board.Actor }}
    <a href="/delete?id={{ .Id }}">[Delete Post]</a>
    {{ end }}        
    {{ if .Attachment }}
    {{ if eq $board.ModCred $board.Domain $board.Actor }}    
    <a href="/deleteattach?id={{ .Id }}">[Delete Attachment]</a>
    {{ end }}                
    <span style="display: block;">File: <a id="{{ .Id }}-img" href="{{ (index .Attachment 0).Href}}">{{ (index .Attachment 0).Name  }}</a><span id="{{ .Id }}-size">({{ (index .Attachment 0).Size  }})</span></span>
    <div id="media-{{ .Id }}"></div>
    <script>
      media = document.getElementById("media-{{ .Id }}")
      if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "image"){
          var img = document.createElement("img");
          img.style = "float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px; cursor: pointer;"
          img.setAttribute("id", "img")
          img.setAttribute("main", "1")
          img.setAttribute("enlarge", "0")
          img.setAttribute("attachment", "{{ (index .Attachment 0).Href }}")
          {{ if .Preview.Href }} 
          img.setAttribute("src", "{{  .Preview.Href }}")
          img.setAttribute("preview", "{{ .Preview.Href }}")          
          {{ else }}
          img.setAttribute("src", "{{  (index .Attachment 0).Href }}")
          img.setAttribute("preview", "{{ (index .Attachment 0).Href }}")                    
          {{ end }}
          media.appendChild(img)
      }          

      if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "audio"){
          var audio = document.createElement("audio")
          audio.controls = 'controls'
          audio.preload  = 'metadata'              
          audio.src      = '{{ (index .Attachment 0).Href }}'
          audio.type     = '{{ (index .Attachment 0).MediaType }}'              
          audio.style = "float: left; margin-right: 10px; margin-bottom: 10px; width: 250px;"
          audio.innerText = 'Audio is not supported.'
          media.appendChild(audio)                            
      }

      if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "video"){
          var video = document.createElement("video")
          video.controls = 'controls'
          video.preload  = 'metadata'                        
          video.muted    = 'muted'              
          video.src      = '{{ (index .Attachment 0).Href }}'
          video.type     = '{{ (index .Attachment 0).MediaType }}'              
          video.style = "float: left; margin-right: 10px; margin-bottom: 10px; width: 250px;"
          video.innerText = 'Video is not supported.'
          media.appendChild(video)                                          
      }                    
    </script>
    {{ end }}
    <span style="color: #0f0c5d;"><b>{{ .Name }}</b></span><span style="color: #117743;"><b>{{ if .AttributedTo }} {{.AttributedTo }} {{ else }} Anonymous {{ end }}</b></span><span>{{ .Published }} <a id="{{ .Id }}-anchor" href="/{{ $board.Name }}/">No.</a> <a id="{{ .Id }}-link" title="{{ .Id }}" href="javascript:quote('{{ $board.Actor }}', '{{ $opId }}', '{{ .Id }}')">{{ .Id }}</a> {{ if ne .Type "Tombstone" }}<a href="javascript:report('{{ $board.Actor }}', '{{ .Id }}')">[Report]</a>{{ end }}</span>
    <p id="{{ .Id }}-content" style="white-space: pre-wrap; margin: 10px 30px 10px 30px;">{{.Content}}</p>
    {{ if .Replies }}
    {{ $replies := .Replies }}
    {{ if gt $replies.TotalItems 5 }}
    {{ if gt $len 1 }}
    <span>{{ $replies.TotalItems }} replies{{ if gt $replies.TotalImgs 0}} and {{ $replies.TotalImgs }} images{{ end }}, Click <a id="view" post="{{.Id}}" href="/{{ $board.Name }}/{{ .Id }}">here</a> to view all.</span>
    {{ end }}
    {{ end }}
    {{ range $replies.OrderedItems }}
    <div id="{{ .Id }}">
      <div  style="display: inline-block; overflow: auto;">
        <div style="float: left; display: block; margin-right: 5px;">>></div>
        <div class="post" style="overflow: auto; padding: 5px; margin-bottom: 2px;">
          {{ if eq $board.ModCred $board.Domain $board.Actor }}          
          <a href="/delete?id={{ .Id }}">[Delete Post]</a>
          {{ end }}              
          {{ if .Attachment }}
          {{ if eq $board.ModCred $board.Domain $board.Actor }}                    
          <a href="/deleteattach?id={{ .Id }}">[Delete Attachment]</a>
          {{ end }}
          <span style="display: block;">File <a id="{{ .Id }}-img" href="{{ (index .Attachment 0).Href}}">{{ (index .Attachment 0).Name  }}</a> <span id="{{ .Id }}-size">({{ (index .Attachment 0).Size  }})</span></span>
          <div id="media-{{ .Id }}"></div>
          <script>
            media = document.getElementById("media-{{ .Id }}")
            if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "image"){
                var img = document.createElement("img");
                img.style = "float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px; cursor: pointer;"
                img.setAttribute("id", "img")
                img.setAttribute("main", "1")
                img.setAttribute("enlarge", "0")
                img.setAttribute("attachment", "{{ (index .Attachment 0).Href }}")
                {{ if .Preview.Href }} 
                img.setAttribute("src", "{{  .Preview.Href }}")
                img.setAttribute("preview", "{{ .Preview.Href }}")          
                {{ else }}
                img.setAttribute("src", "{{  (index .Attachment 0).Href }}")
                img.setAttribute("preview", "{{ (index .Attachment 0).Href }}")                    
                {{ end }}                
                media.appendChild(img)
            }

            if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "audio"){
                var audio = document.createElement("audio")
                audio.controls = 'controls'
                audio.preload  = 'metadata'              
                audio.src      = '{{ (index .Attachment 0).Href }}'
                audio.type     = '{{ (index .Attachment 0).MediaType }}'              
                audio.style = "float: left; margin-right: 10px; margin-bottom: 10px; width: 250px;"
                audio.innerText = 'Audio is not supported.'
                media.appendChild(audio)              
            }

            if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "video"){
                var video = document.createElement("video")
                video.controls = 'controls'
                video.preload  = 'metadata'                                        
                video.muted    = 'muted'              
                video.src      = '{{ (index .Attachment 0).Href }}'
                video.type     = '{{ (index .Attachment 0).MediaType }}'              
                video.style = "float: left; margin-right: 10px; margin-bottom: 10px; width: 250px;"
                video.innerText = 'Video is not supported.'
                media.appendChild(video)                                                        
            }                    
          </script>              
          {{ end }}
          <span style="color: #0f0c5d;"><b>{{ .Name }}</b></span><span style="color: #117743;"><b>{{ if .AttributedTo }} {{.AttributedTo }} {{ else }} Anonymous {{ end }}</b></span><span>{{ .Published }} <a id="{{ .Id }}-anchor" href="/{{ $board.Name }}/post/{{ $opId }}#{{ .Id }}">No. </a><a id="{{ .Id }}-link" title="{{ .Id }}" href="javascript:quote('{{ $board.Actor }}', '{{ $opId }}', '{{ .Id }}')">{{ .Id }}</a> {{ if ne .Type "Tombstone" }}<a href="javascript:report('{{ $board.Actor }}', '{{ .Id }}')">[Report]</a>{{ end }}</span>
          {{ $parentId := .Id }}
          {{ if .Replies.OrderedItems }}
          {{ range .Replies.OrderedItems }}
          <span id="{{$parentId}}-replyto-{{.Id}}"></span>
          <script>document.getElementById("{{ $parentId }}-replyto-{{.Id}}").innerHTML = "<a title='{{ .Id }}' href='/{{ $board.Name }}/" + shortURL("{{ $board.Actor }}", "{{ $opId }}") + "#" + shortURL("{{ $board.Actor }}", "{{ .Id }}") + "'>>>" + shortURL("{{ $board.Actor }}", "{{ .Id }}") + "</a>";</script>
                                                                                                                                                                                                                                                                                                             {{ end }}
                                                                                                                                                                                                                                                                                                             {{ end }}
                                                                                                                                                                                                                                                                                                             <p id="{{ .Id }}-content" style="white-space: pre-wrap; margin: 10px 30px 10px 30px;">{{.Content}}</p>
        </div>
      </div>
    </div>
    <script>
      {{ if .Attachment }}
      document.getElementById("{{ .Id }}-size").innerText = " (" + convertSize({{ (index .Attachment 0).Size }}) + ")";
      document.getElementById("{{ .Id }}-img").innerText = shortImg("{{ (index .Attachment 0).Name }}");
      {{ end }}

      document.getElementById("{{ .Id }}-link").innerText = shortURL("{{ $board.Actor }}", "{{ .Id }}");

      document.getElementById("{{ .Id }}-anchor").href = "/{{ $board.Name }}/" + shortURL("{{$board.Actor}}", "{{ $opId }}") +
    "#" + shortURL("{{$board.Actor}}", "{{ .Id }}");                
      document.getElementById("{{ .Id }}").setAttribute("id", shortURL("{{$board.Actor}}", "{{ .Id }}"));

      var content = document.getElementById("{{ .Id }}-content");

      content.innerHTML = convertContent('{{$board.Actor}}', content.innerText, '{{ $opId }}')        

    </script>      
    {{ end }}
    {{ end }}
  </div>
</div>
<script>
  {{ if .Attachment }}      
  document.getElementById("{{ .Id }}-size").innerText = " (" + convertSize({{ (index .Attachment 0).Size }}) + ")";
  document.getElementById("{{ .Id }}-img").innerText = shortImg("{{ (index .Attachment 0).Name }}");
  {{ end }}

  document.getElementById("{{ .Id }}-link").innerText = shortURL("{{ $board.Actor }}", "{{ .Id }}");

  document.getElementById("{{ .Id }}").setAttribute("id", shortURL("{{ $board.Actor }}", "{{ .Id }}"));

  document.getElementById("{{ .Id }}-anchor").href = "/{{ $board.Name }}/" + shortURL("{{$board.Actor}}", "{{ $opId }}") +
    "#" + shortURL("{{$board.Actor}}", "{{ .Id }}");

  var content = document.getElementById("{{ .Id }}-content");

  content.innerHTML = convertContent('{{$board.Actor}}', content.innerText, '{{ $opId }}')              
</script>
{{ end }}
{{ end }}