aboutsummaryrefslogtreecommitdiff
path: root/static/posts.html
blob: 319da03c35e6788777da1f100b0349ed51cd174b (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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
{{ 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.Id }}
    <a href="/delete?id={{ .Id }}&board={{ $board.Actor.Name }}">[Delete Post]</a>
    {{ end }}        
    {{ if .Attachment }}
    {{ if eq $board.ModCred $board.Domain $board.Actor.Id }}    
    <a href="/deleteattach?id={{ .Id }}&board={{ $board.Actor.Name }}">[Delete Attachment]</a>
    <a href="/marksensitive?id={{ .Id }}&board={{ $board.Actor.Name }}">[Mark Sensitive]</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="hide-{{ .Id }}" style="display: none;">[Hide]</div>
    <div id="sensitive-{{ .Id }}" style="display: none;"><div style="position: relative; text-align: center;"><img id="sensitive-img-{{ .Id }}" style="float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px;" src="/static/sensitive.png"><div id="sensitive-text-{{ .Id }}" style="width: 240px; position: absolute; margin-top: 110px; padding: 5px; background-color: black; color: white; cursor: default; ">NSFW Content</div></div></div>    
    <div id="media-{{ .Id }}"></div>
    <script>
      media = document.getElementById("media-{{ .Id }}")

      if(({{ .Sensitive }} && {{ $board.Actor.Restricted }}) || (isOnion("{{ .Id }}") && !isOnion("{{ $board.Domain }}"))){
          sensitive = document.getElementById("sensitive-{{ .Id }}")
          hide = document.getElementById("hide-{{ .Id }}")
          sensitive.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: block;"; document.getElementById("sensitive-{{ .Id }}").style="display: none;"; document.getElementById("hide-{{ .Id }}").style="display: block; cursor: pointer;"}
          hide.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: none;"; document.getElementById("sensitive-{{ .Id }}").style="display: block;"; document.getElementById("hide-{{ .Id }}").style="display: none;"}
          sensitive.style = "display: block"
          media.style = "display: none;"
      }

      if(isOnion("{{ .Id }}") && !isOnion("{{ $board.Domain }}")) {
          sensitive = document.getElementById("sensitive-{{ .Id }}")
          document.getElementById("sensitive-img-{{ .Id }}").src = "/static/onion.png"
          document.getElementById("sensitive-text-{{ .Id }}").innerText = "Tor Instance"
          hide = document.getElementById("hide-{{ .Id }}")
          sensitive.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: block;"; document.getElementById("sensitive-{{ .Id }}").style="display: none;"; document.getElementById("hide-{{ .Id }}").style="display: block; cursor: pointer;"}
          hide.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: none;"; document.getElementById("sensitive-{{ .Id }}").style="display: block;"; document.getElementById("hide-{{ .Id }}").style="display: none;"}
          sensitive.style = "display: block"
          media.style = "display: none;"          
      }
      
      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;"
          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; max-width: 250px; max-height: 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; max-width: 250px; max-height: 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 class="tripcode"> {{ .TripCode }} </span><span>{{ .Published }} <a id="{{ .Id }}-anchor" href="/{{ $board.Name }}/">No.</a> <a id="{{ .Id }}-link" title="{{ .Id }}" href="javascript:quote('{{ $board.Actor.Id }}', '{{ $opId }}', '{{ .Id }}')">{{ .Id }}</a> {{ if ne .Type "Tombstone" }}<a href="javascript:report('{{ $board.Actor.Id }}', '{{ .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.Id }}          
          <a href="/delete?id={{ .Id }}&board={{ $board.Actor.Name }}">[Delete Post]</a>
          {{ end }}              
          {{ if .Attachment }}
          {{ if eq $board.ModCred $board.Domain $board.Actor.Id }}                    
          <a href="/deleteattach?id={{ .Id }}&board={{ $board.Actor.Name }}">[Delete Attachment]</a>
          <a href="/marksensitive?id={{ .Id }}&board={{ $board.Actor.Name }}">[Mark Sensitive]</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="hide-{{ .Id }}" style="display: none;">[Hide]</div>
          <div id="sensitive-{{ .Id }}" style="display: none;"><div style="position: relative; text-align: center;"><img id="sensitive-img-{{ .Id }}" style="float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px;" src="/static/sensitive.png"><div id="sensitive-text-{{ .Id }}" style="width: 240px; position: absolute; margin-top: 110px; padding: 5px; background-color: black; color: white; cursor: default; ">NSFW Content</div></div></div>              
          <div> </div>
          <div id="media-{{ .Id }}" sensitive="0"></div>
          <script>
            media = document.getElementById("media-{{ .Id }}")
            
            if(({{ .Sensitive }} && {{ $board.Actor.Restricted }}) || (isOnion("{{ .Id }}") && !isOnion("{{ $board.Domain }}"))){            
                sensitive = document.getElementById("sensitive-{{ .Id }}")
                hide = document.getElementById("hide-{{ .Id }}")
                sensitive.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: block;"; document.getElementById("sensitive-{{ .Id }}").style="display: none;"; document.getElementById("hide-{{ .Id }}").style="display: block; cursor: pointer;"}
                hide.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: none;"; document.getElementById("sensitive-{{ .Id }}").style="display: block;"; document.getElementById("hide-{{ .Id }}").style="display: none;"}
                sensitive.style = "display: block"
                media.style = "display: none;"
            }

            if(isOnion("{{ .Id }}") && !isOnion("{{ $board.Domain }}")) {
                sensitive = document.getElementById("sensitive-{{ .Id }}")
                document.getElementById("sensitive-img-{{ .Id }}").src = "/static/onion.png"
                document.getElementById("sensitive-text-{{ .Id }}").innerText = "Tor Instance"
                hide = document.getElementById("hide-{{ .Id }}")
                sensitive.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: block;"; document.getElementById("sensitive-{{ .Id }}").style="display: none;"; document.getElementById("hide-{{ .Id }}").style="display: block; cursor: pointer;"}
                hide.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: none;"; document.getElementById("sensitive-{{ .Id }}").style="display: block;"; document.getElementById("hide-{{ .Id }}").style="display: none;"}
                sensitive.style = "display: block"
                media.style = "display: none;"          
            }            
            
            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;"
                img.setAttribute("id", "img")
                img.setAttribute("main", "1")
                img.setAttribute("enlarge", "0")
                img.setAttribute("attachment", "{{ (index .Attachment 0).Href }}")
                img.setAttribute("post", "{{ .Id }}")
                {{ if and .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; max-width: 250px; max-height: 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; max-width: 250px; max-height: 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 class="tripcode"> {{ .TripCode }} </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.Id }}', '{{ $opId }}', '{{ .Id }}')">{{ .Id }}</a> {{ if ne .Type "Tombstone" }}<a href="javascript:report('{{ $board.Actor.Id }}', '{{ .Id }}')">[Report]</a>{{ end }}</span>
          {{ $parentId := .Id }}
          {{ if .Replies.OrderedItems }}
          {{ range .Replies.OrderedItems }}
          <span id="{{$parentId}}-replyto-{{.Id}}"></span>
          <script>
            var content = convertContentNoLink('{{$board.Actor.Id}}', '{{ .Content }}', '{{ $opId }}')                    
            document.getElementById("{{ $parentId }}-replyto-{{.Id}}").innerHTML = "<a title='" + content  +"' href='/{{ $board.Name }}/" + shortURL("{{ $board.Actor.Id }}", "{{ $opId }}") + "#" + shortURL("{{ $board.Actor.Id }}", "{{ .Id }}") + "'>>>" + shortURL("{{ $board.Actor.Id }}", "{{ .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 }}", "{{ .Id }}");

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

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

      content.innerHTML = convertContent('{{$board.Actor.Id}}', 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 }}", "{{ .Id }}");

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

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

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

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