Skip to content

Commit 58aa83c

Browse files
committed
added image uploads
url input rather than file proper for now clear your fltr_cache (`rm -r /tmp/fltr_cache`) for old posts to update with new :hover behaviour
1 parent f0f8823 commit 58aa83c

4 files changed

Lines changed: 87 additions & 7 deletions

File tree

apps/dirdir/app.rc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@ fn dirdir_init {
2727
}
2828
}
2929

30+
if(! ~ '' $"post_arg_file) {
31+
if(~ $post_arg_file *.gif ||
32+
~ $post_arg_file *.jpeg ||
33+
~ $post_arg_file *.jpg ||
34+
~ $post_arg_file *.png ||
35+
~ $post_arg_file *.ff ||
36+
~ $post_arg_file *.tif ||
37+
~ $post_arg_file *.tiff ||
38+
~ $post_arg_file *.bmp) {
39+
file=`{basename $post_arg_file | sed 's/[^a-zA-Z0-9_.]//g'}
40+
name=`{echo $file | sed 's/\.(gif|jpeg|jpg|png|ff|tif|tiff|bmp)$//'}
41+
ext=`{echo $file | sed 's/.*\.(gif|jpeg|jpg|png|ff|tif|tiff|bmp)$/\1/'}
42+
43+
curl $post_arg_file > $postd/image.$ext
44+
45+
# make sure it's a real image
46+
if(! convert $postd/image.$ext /tmp/tokumeiup.jpg ||
47+
! convert $postd/image.$ext /tmp/tokumeiup.png)
48+
rm $postd/image.$ext
49+
}
50+
}
51+
3052
if(! ~ '' $"post_arg_password) {
3153
salt=`{cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 64 | head -n 1}
3254
echo -n $post_arg_password$salt | sha256sum | sed 's/ -$//' > etc/passwords/$postn

apps/dirdir/edit.tpl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<div class="input-field">
1111
<input type="text" name="tags" id="tags">
12-
<label for="tags">Tags (space separated)</label>
12+
<label for="tags">Tags (comma separated)</label>
1313
</div>
1414

1515
<!-- <div class="input-field file-field">
@@ -18,10 +18,15 @@
1818
<input type="file">
1919
</div>
2020
<div class="file-path-wrapper">
21-
<input class="file-path validate" type="text" placeholder="(optional)">
21+
<input class="file-path validate" type="text">
2222
</div>
2323
</div> -->
2424

25+
<div class="input-field">
26+
<input type="text" placeholder="https://example.com/image.png" name="file" id="file">
27+
<label for="file">Attachment</label>
28+
</div>
29+
2530
<div class="input-field">
2631
<input type="password" name="password" id="password">
2732
<label for="password">Deletion password</label>
@@ -43,7 +48,7 @@
4348

4449
<div class="input-field">
4550
<input type="text" name="tags" id="tags">
46-
<label for="tags">Tags (space separated)</label>
51+
<label for="tags">Tags (comma separated)</label>
4752
</div>
4853

4954
<script>
@@ -65,10 +70,16 @@
6570
<input type="file">
6671
</div>
6772
<div class="file-path-wrapper">
68-
<input class="file-path validate" type="text" placeholder="(optional)">
73+
<input class="file-path validate" type="text">
6974
</div>
7075
</div> -->
7176

77+
<br /><br />
78+
<div class="input-field">
79+
<input type="text" placeholder="https://example.com/image.png" name="file" id="file">
80+
<label for="file">Attachment</label>
81+
</div>
82+
7283
<div class="input-field">
7384
<input type="password" name="password" id="password">
7485
<label for="password">Deletion password</label>

sites/tokumei.co/_werc/pub/style.css

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ blockquote {
280280
.card > a:hover {
281281
color: initial !important;
282282
}
283-
.card-content {
283+
.card-content.clicky {
284284
cursor: pointer;
285285
}
286-
.card-content:hover {
286+
.card-content.clicky:hover {
287287
background-color: rgba(0, 0, 0, 0.05);
288288
}
289289

@@ -349,3 +349,8 @@ blockquote {
349349
.sitemap-list {
350350
padding-left: 2em;
351351
}
352+
353+
.attachment {
354+
width: 100%;
355+
max-height: 80vh;
356+
}

tpl/post.tpl

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,22 @@
44
% if(~ $req_path /p/[0-9]*) echo '<br />'
55
% if(! test -f $postd/spam || ~ $req_path /p/[0-9]*) {
66
<div class="card">
7-
<div class="card-content" onclick="window.location='/p/%($postn%)'">
7+
% if(~ $req_path /p/[0-9]*) {
8+
<div class="card-content">
9+
% }
10+
% if not {
11+
<div class="card-content clicky" onclick="window.location='/p/%($postn%)'">
12+
% }
813
% sed $postfilter < $postf
14+
% if(test -f $postd/image.*) {
15+
% file=`{basename `{ls $postd/image.*}}
16+
% if(~ $req_path /p/[0-9]*) {
17+
<br /><a href="%($postn%)_werc/%($file%)"><img src="%($postn%)_werc/%($file%)" class="attachment" /></a>
18+
% }
19+
% if not {
20+
<br /><a href="%($postn%)_werc/%($file%)">%($file%)</a>
21+
% }
22+
% }
923
</div>
1024
<div class="card-action">
1125

@@ -145,6 +159,10 @@
145159
<h5><a href="%($shareurl%)">%($shareurl%)</a></h5>
146160
<p class="break-word">
147161
% sed $postfilter < $postf
162+
% if(test -f $postd/image.*) {
163+
% file=`{ls $postd/image.*}
164+
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
165+
% }
148166
</p>
149167
<div class="collection">
150168
<a class="collection-item" href="http://twitter.com/home/?status=%($shareurl%)">
@@ -189,6 +207,10 @@
189207
<h5><a href="%($shareurl%)">%($shareurl%)</a></h5>
190208
<p class="break-word">
191209
% sed $postfilter < $postf
210+
% if(test -f $postd/image.*) {
211+
% file=`{ls $postd/image.*}
212+
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
213+
% }
192214
</p>
193215
<div class="collection">
194216
<a class="collection-item" href="http://twitter.com/home/?status=%($shareurl%)">
@@ -253,6 +275,10 @@
253275
<h5><a href="%($shareurl%)">%($shareurl%)</a></h5>
254276
<p class="break-word">
255277
% sed $postfilter < $postf
278+
% if(test -f $postd/image.*) {
279+
% file=`{ls $postd/image.*}
280+
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
281+
% }
256282
</p>
257283
<div class="collection">
258284
<form action="" method="post">
@@ -280,6 +306,10 @@
280306
<h5><a href="%($shareurl%)">%($shareurl%)</a></h5>
281307
<p class="break-word">
282308
% sed $postfilter < $postf
309+
% if(test -f $postd/image.*) {
310+
% file=`{ls $postd/image.*}
311+
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
312+
% }
283313
</p>
284314
<div class="collection">
285315
<form action="" method="post">
@@ -309,6 +339,10 @@
309339
<h5>If you wrote this post and set a password when you did, enter it below. If not, you're out of luck.</h5>
310340
<p class="break-word">
311341
% sed $postfilter < $postf
342+
% if(test -f $postd/image.*) {
343+
% file=`{ls $postd/image.*}
344+
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
345+
% }
312346
</p>
313347
<form action="" method="post">
314348
<input type="hidden" name="postn" value="%($postn%)">
@@ -328,6 +362,10 @@
328362
<h5>If you wrote this post and set a password when you did, enter it below. If not, you're out of luck.</h5>
329363
<p class="break-word">
330364
% sed $postfilter < $postf
365+
% if(test -f $postd/image.*) {
366+
% file=`{ls $postd/image.*}
367+
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
368+
% }
331369
</p>
332370
<br /><div class="input-field">
333371
<input type="password" name="delete" id="delete%($postn%)">
@@ -349,6 +387,10 @@
349387
<h5>If you wrote this post and set a password when you did, enter it below. If not, you're out of luck.</h5>
350388
<p class="break-word">
351389
% sed $postfilter < $postf
390+
% if(test -f $postd/image.*) {
391+
% file=`{ls $postd/image.*}
392+
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
393+
% }
352394
</p>
353395
<br /><div class="input-field">
354396
<input type="password" name="delete" id="delete%($postn%)">

0 commit comments

Comments
 (0)