This repository has been archived by the owner on Oct 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
/
article.html
148 lines (147 loc) · 4.47 KB
/
article.html
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
{% import "fmt" %}
{% import "strconv" %}
{% import "github.com/bakape/meguca/common" %}
{% import "github.com/bakape/meguca/imager/assets" %}
{% func renderArticle(p common.Post, op uint64, omit, imageOmit int, subject, root string) %}{% stripspace %}
{% code id := strconv.FormatUint(p.ID, 10) %}
<article id="p{%s= id %}" class="glass{% if p.Editing %}{% space %}editing{% endif %}">
<header class="spaced">
{% if subject != "" %}
<h3>
「{%s subject %}」
</h3>
{% endif %}
<b class="name"{% if p.Auth != "" %}{% space %}class="admin"{% endif %}>
{% if p.Name != "" || p.Trip == "" %}
{% if p.Name != "" %}
{%s p.Name %}
{% else %}
Anonymous
{% endif %}
{% if p.Trip != "" %}
{% space %}
{% endif %}
{% endif %}
{% if p.Trip != "" %}
<code>
!{%s p.Trip %}
</code>
{% endif %}
{% if p.Auth != "" %}
##{% space %}{%s p.Auth %}
{% endif %}
</b>
<time>
{%s= formatTime(p.Time) %}
</time>
<nav>
<a href="#p{%s= id %}">
No.
</a>
<a class="quote">
{%s= id %}
</a>
</nav>
<a class="control">
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
<path d="M1.5 0l-1.5 1.5 4 4 4-4-1.5-1.5-2.5 2.5-2.5-2.5z" transform="translate(0 1)" />
</svg>
</a>
</header>
{% code var src string %}
{% if p.Image != nil %}
{% code img := *p.Image %}
{% code src = assets.SourcePath(img.FileType, img.SHA1) %}
{% code ISSrc := root + src %}
<figcaption class="spaced">
<a class="image-toggle act" hidden></a>
<span class="spaced image-search-container">
<a class="image-search google" target="_blank" rel="nofollow" href="https://www.google.com/searchbyimage?image_url={%s= ISSrc %}">
G
</a>
<a class="image-search iqdb" target="_blank" rel="nofollow" href="http://iqdb.org/?url={%s= ISSrc %}">
Iq
</a>
<a class="image-search saucenao" target="_blank" rel="nofollow" href="http://saucenao.com/search.php?db=999&url={%s= ISSrc %}">
Sn
</a>
<a class="image-search desustorage" target="_blank" rel="nofollow" href="https://desuarchive.org/_/search/image/{%s= img.MD5 %}">
Ds
</a>
<a class="image-search exhentai" target="_blank" rel="nofollow" href="http://exhentai.org/?fs_similar=1&fs_exp=1&f_shash={%s= img.SHA1 %}">
Ex
</a>
</span>
<span>
(
{% if img.Audio %}
♫,{% space %}
{% endif %}
{% if img.Length != 0 %}
{% code l := img.Length %}
{% if l < 60 %}
{%s= fmt.Sprintf("0:%02d", l) %}
{% else %}
{% code min := l / 6 %}
{%s= fmt.Sprintf("%02d:%02d", min, l-min) %}
{% endif %}
,{% space %}
{% endif %}
{% if img.APNG %}
APNG,{% space %}
{% endif %}
{%s= readableFileSize(img.Size) %},{% space %}
{%s= strconv.FormatUint(uint64(img.Dims[0]), 10) %}
x
{%s= strconv.FormatUint(uint64(img.Dims[1]), 10) %}
)
</span>
{% code name := imageName(img.FileType, img.Name) %}
<a href="{%s= src %}" download="{%s= name %}">
{%s= name %}
</a>
</figcaption>
{% endif %}
<div class="post-container">
{% if p.Image != nil %}
{% code img := *p.Image %}
<figure>
<a target="_blank" href="{%s= src %}">
{% if img.Spoiler %}
<!-- TODO: board-specific server-side spoiler rendering -->
<img src="/assets/spoil/default.jpg" width="125" height="125">
{% else %}
{% code w, h := correctDims(subject != "", img.Dims[2], img.Dims[3]) %}
<img src="{%s= assets.ThumbPath(img.FileType, img.ThumbType, img.SHA1) %}" width="{%s= w %}" height="{%s= h %}">
{% endif %}
</a>
</figure>
{% endif %}
<blockquote>
{%= body(p, op) %}
</blockquote>
</div>
{% if omit != 0 %}
<span class="omit" data-omit="{%d omit %}" data-image-omit="{%d imageOmit %}">
{%d omit %}{% space %}post{% if omit > 1 %}s{% endif %}
{% space %}and{% space %}{%d imageOmit %}
{% space %}image{% if imageOmit > 1 %}s{% endif %}
omitted{% space %}
<span class="act">
<a href="{%s= strconv.FormatUint(op, 10) %}" class="history">
See All
</a>
</span>
</span>
{% endif %}
{% if p.Backlinks != nil %}
<span class="backlinks spaced">
{% for id, link := range p.Backlinks %}
<em>
{%= postLink(id, link.OP, link.Board, link.OP != op) %}
</em>
{% endfor %}
</span>
{% endif %}
</article>
{% endstripspace %}{% endfunc %}