Skip to content

Commit

Permalink
added image uploads
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kfarwell committed Apr 6, 2016
1 parent f0f8823 commit 58aa83c
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 7 deletions.
22 changes: 22 additions & 0 deletions apps/dirdir/app.rc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ fn dirdir_init {
}
}

if(! ~ '' $"post_arg_file) {
if(~ $post_arg_file *.gif ||
~ $post_arg_file *.jpeg ||
~ $post_arg_file *.jpg ||
~ $post_arg_file *.png ||
~ $post_arg_file *.ff ||
~ $post_arg_file *.tif ||
~ $post_arg_file *.tiff ||
~ $post_arg_file *.bmp) {
file=`{basename $post_arg_file | sed 's/[^a-zA-Z0-9_.]//g'}
name=`{echo $file | sed 's/\.(gif|jpeg|jpg|png|ff|tif|tiff|bmp)$//'}
ext=`{echo $file | sed 's/.*\.(gif|jpeg|jpg|png|ff|tif|tiff|bmp)$/\1/'}

curl $post_arg_file > $postd/image.$ext

# make sure it's a real image
if(! convert $postd/image.$ext /tmp/tokumeiup.jpg ||
! convert $postd/image.$ext /tmp/tokumeiup.png)
rm $postd/image.$ext
}
}

if(! ~ '' $"post_arg_password) {
salt=`{cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 64 | head -n 1}
echo -n $post_arg_password$salt | sha256sum | sed 's/ -$//' > etc/passwords/$postn
Expand Down
19 changes: 15 additions & 4 deletions apps/dirdir/edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="input-field">
<input type="text" name="tags" id="tags">
<label for="tags">Tags (space separated)</label>
<label for="tags">Tags (comma separated)</label>
</div>
<!-- <div class="input-field file-field">
Expand All @@ -18,10 +18,15 @@
<input type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="(optional)">
<input class="file-path validate" type="text">
</div>
</div> -->
<div class="input-field">
<input type="text" placeholder="https://example.com/image.png" name="file" id="file">
<label for="file">Attachment</label>
</div>
<div class="input-field">
<input type="password" name="password" id="password">
<label for="password">Deletion password</label>
Expand All @@ -43,7 +48,7 @@
<div class="input-field">
<input type="text" name="tags" id="tags">
<label for="tags">Tags (space separated)</label>
<label for="tags">Tags (comma separated)</label>
</div>
<script>
Expand All @@ -65,10 +70,16 @@
<input type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="(optional)">
<input class="file-path validate" type="text">
</div>
</div> -->

<br /><br />
<div class="input-field">
<input type="text" placeholder="https://example.com/image.png" name="file" id="file">
<label for="file">Attachment</label>
</div>

<div class="input-field">
<input type="password" name="password" id="password">
<label for="password">Deletion password</label>
Expand Down
9 changes: 7 additions & 2 deletions sites/tokumei.co/_werc/pub/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ blockquote {
.card > a:hover {
color: initial !important;
}
.card-content {
.card-content.clicky {
cursor: pointer;
}
.card-content:hover {
.card-content.clicky:hover {
background-color: rgba(0, 0, 0, 0.05);
}

Expand Down Expand Up @@ -349,3 +349,8 @@ blockquote {
.sitemap-list {
padding-left: 2em;
}

.attachment {
width: 100%;
max-height: 80vh;
}
44 changes: 43 additions & 1 deletion tpl/post.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@
% if(~ $req_path /p/[0-9]*) echo '<br />'
% if(! test -f $postd/spam || ~ $req_path /p/[0-9]*) {
<div class="card">
<div class="card-content" onclick="window.location='/p/%($postn%)'">
% if(~ $req_path /p/[0-9]*) {
<div class="card-content">
% }
% if not {
<div class="card-content clicky" onclick="window.location='/p/%($postn%)'">
% }
% sed $postfilter < $postf
% if(test -f $postd/image.*) {
% file=`{basename `{ls $postd/image.*}}
% if(~ $req_path /p/[0-9]*) {
<br /><a href="%($postn%)_werc/%($file%)"><img src="%($postn%)_werc/%($file%)" class="attachment" /></a>
% }
% if not {
<br /><a href="%($postn%)_werc/%($file%)">%($file%)</a>
% }
% }
</div>
<div class="card-action">

Expand Down Expand Up @@ -145,6 +159,10 @@
<h5><a href="%($shareurl%)">%($shareurl%)</a></h5>
<p class="break-word">
% sed $postfilter < $postf
% if(test -f $postd/image.*) {
% file=`{ls $postd/image.*}
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
% }
</p>
<div class="collection">
<a class="collection-item" href="http://twitter.com/home/?status=%($shareurl%)">
Expand Down Expand Up @@ -189,6 +207,10 @@
<h5><a href="%($shareurl%)">%($shareurl%)</a></h5>
<p class="break-word">
% sed $postfilter < $postf
% if(test -f $postd/image.*) {
% file=`{ls $postd/image.*}
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
% }
</p>
<div class="collection">
<a class="collection-item" href="http://twitter.com/home/?status=%($shareurl%)">
Expand Down Expand Up @@ -253,6 +275,10 @@
<h5><a href="%($shareurl%)">%($shareurl%)</a></h5>
<p class="break-word">
% sed $postfilter < $postf
% if(test -f $postd/image.*) {
% file=`{ls $postd/image.*}
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
% }
</p>
<div class="collection">
<form action="" method="post">
Expand Down Expand Up @@ -280,6 +306,10 @@
<h5><a href="%($shareurl%)">%($shareurl%)</a></h5>
<p class="break-word">
% sed $postfilter < $postf
% if(test -f $postd/image.*) {
% file=`{ls $postd/image.*}
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
% }
</p>
<div class="collection">
<form action="" method="post">
Expand Down Expand Up @@ -309,6 +339,10 @@
<h5>If you wrote this post and set a password when you did, enter it below. If not, you're out of luck.</h5>
<p class="break-word">
% sed $postfilter < $postf
% if(test -f $postd/image.*) {
% file=`{ls $postd/image.*}
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
% }
</p>
<form action="" method="post">
<input type="hidden" name="postn" value="%($postn%)">
Expand All @@ -328,6 +362,10 @@
<h5>If you wrote this post and set a password when you did, enter it below. If not, you're out of luck.</h5>
<p class="break-word">
% sed $postfilter < $postf
% if(test -f $postd/image.*) {
% file=`{ls $postd/image.*}
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
% }
</p>
<br /><div class="input-field">
<input type="password" name="delete" id="delete%($postn%)">
Expand All @@ -349,6 +387,10 @@
<h5>If you wrote this post and set a password when you did, enter it below. If not, you're out of luck.</h5>
<p class="break-word">
% sed $postfilter < $postf
% if(test -f $postd/image.*) {
% file=`{ls $postd/image.*}
<br /><a href="%($postd%)/%($file%)">%($file%)</a>
% }
</p>
<br /><div class="input-field">
<input type="password" name="delete" id="delete%($postn%)">
Expand Down

0 comments on commit 58aa83c

Please sign in to comment.