Explorar o código

Work on #34: at least display versions of posts

George S. Baugh %!s(int64=5) %!d(string=hai) anos
pai
achega
12e11976ec

+ 12 - 1
lib/Trog/Data/DUMMY.pm

@@ -101,7 +101,18 @@ sub get ($self, %request) {
     my @filtered = @$example_posts;
 
     # If an ID is passed, just get that
-    @filtered = grep { $_->{id} eq $request{id} } @filtered if $request{id};
+    if ($request{id}) {
+        @filtered = grep { $_->{id} eq $request{id} } @filtered if $request{id};
+        # Sort by version
+        @filtered = sort { $b->{version} cmp $a->{version} } @filtered;
+
+        @filtered = _add_post_type(@filtered);
+        # Next, add the type of post this is
+        @filtered = _add_media_type(@filtered);
+        # Finally, add visibility
+        @filtered = _add_visibility(@filtered);
+        return (1, \@filtered);
+    }
 
     # Next, handle the query, tags and ACLs
     @filtered = grep { my $tags = $_->{tags}; grep { my $t = $_; grep {$t eq $_ } @{$request{tags}} } @$tags } @filtered if @{$request{tags}};

+ 1 - 4
www/templates/blog.tx

@@ -3,8 +3,5 @@
     : include "preview.tx";
     : include "acls.tx";
     : include "tags.tx";
-    Content<br /><textarea required class="cooltext" name="data" placeholder="Potzrebie"><: $post.data :></textarea>
-    <input type="hidden" name="app" value="blog" />
-    <input type="hidden" name="to" value="<: $route :>" />
-    <input class="coolbutton" type="submit" value="Publish" text="Publish" />
+    : include "form_common.tx";
 </form>

+ 1 - 4
www/templates/file.tx

@@ -7,8 +7,5 @@
     : include "preview.tx";
     : include "acls.tx";
     : include "tags.tx";
-    Comments<br /><textarea class="cooltext" name="data" placeholder="Potzrebie"><: $post.data :></textarea>
-    <input type="hidden" name="app" value="<: $app :>" />
-    <input type="hidden" name="to" value="<: $route :>" />
-    <input class="coolbutton" type="submit" value="Publish" text="Publish" />
+    : include "form_common.tx";
 </form>

+ 7 - 0
www/templates/form_common.tx

@@ -0,0 +1,7 @@
+Content<br /><textarea class="cooltext" name="data" placeholder="Potzrebie"><: $post.data :></textarea>
+<input type="hidden" name="app" value="<: $app :>" />
+<input type="hidden" name="to"  value="<: $route :>" />
+: if ( $post.id ) {
+<input type="hidden" name="id" value="<: $post.id :>" />
+: }
+<input class="coolbutton" type="submit" value="Publish" text="Publish" />

+ 2 - 5
www/templates/microblog.tx

@@ -1,13 +1,10 @@
 <form class="Submissions" action="/post/save" method="POST" enctype="multipart/form-data">
     Title *<br /><input required class="cooltext" type="text" name="title" placeholder="Iowa Man Destroys Moon" value="<: $post.title :>" />
-    URL *<br /><input required class="cooltext" type="href" name="URL" placeholder="https://oneweirdtrick.scam" value="<: $post.href :>" />
+    URL *<br /><input required class="cooltext" type="href" name="href" placeholder="https://oneweirdtrick.scam" value="<: $post.href :>" />
     : include "preview.tx";
     Audio<br /><input class="cooltext" type="url" name="audio_href" placeholder="https://soundclod.com/static.mp3" value="<: $post.audio_href :>" />
     Video<br /><input class="cooltext" type="url" name="video_href" placeholder="https://youvimeo.tv/infomercial.mp4" value="<: $post.video_href :>" />
     : include "acls.tx";
     : include "tags.tx";
-    Comments<br /><textarea class="cooltext" name="data" placeholder="Potzrebie"><: $post.data :></textarea>
-    <input type="hidden" name="app" value="microblog" />
-    <input type="hidden" name="to" value="<: $route :>" />
-    <input class="coolbutton" type="submit" value="Publish" text="Publish" />
+    : include "form_common.tx";
 </form>

+ 5 - 5
www/templates/posts.tx

@@ -19,7 +19,7 @@
             <h3 class='blogtitles'>
                 <a href='/posts/<: $post.id :>'><: $post.title :></a>
                 <a class="undecorated" href='<: $post.href :>'>🔗</a>
-                <span id="<: $post.id :>-time" style="float:right;"><: $post.created :></span>
+                <span id="<: $post.id :>-<: $post.version :>-time" style="float:right;"><: $post.created :></span>
                 <a class='usericon <: $post.user :>' title='Posted by <: $post.user :>'></a>
             </h3>
             : if ( !$post.video_href && !$post.is_image && $post.preview ) {
@@ -55,9 +55,9 @@
             : $post.data | mark_raw;
             : if ( $can_edit ) {
             <br />
-            <a style="display: inline-block;" onclick="switchMenu('<: $post.id :>');">[Edit]</a>
-            <div id="<: $post.id :>" style="display:none;">
-                : include $post.type ~ ".tx" { post => $post};
+            <a style="display: inline-block;" onclick="switchMenu('<: $post.id :>-<: $post.version :>');">[Edit]</a>
+            <div id="<: $post.id :>-<: $post.version :>" style="display:none;">
+                : include $post.type ~ ".tx" { post => $post };
                 <form class="Submissions" action="/post/delete" method="POST" class="inline">
                     <input type="hidden" name="id" value="<: $post.id :>"></input>
                     <input type="hidden" name="to" value="<: $route :>"></input>
@@ -68,7 +68,7 @@
             <script type="text/javascript">
                 // Fix post dates to be localized
                 document.addEventListener("DOMContentLoaded", function(event) {
-                    var e = document.getElementById("<: $post.id :>-time");
+                    var e = document.getElementById("<: $post.id :>-<: $post.version :>-time");
                     var d = new Date(Date(e.innerText));
                     e.innerHTML = "&nbsp;" + d.toDateString();
                 });

+ 1 - 4
www/templates/profile.tx

@@ -9,8 +9,5 @@
     Title  <br /><input class="cooltext" type="text" name="title" value="<: $post.title :>" />
     : include "acls.tx";
     : include "tags.tx";
-    Content<br /><textarea class="cooltext" name="data" placeholder="Potzrebie"><: $post.data :></textarea>
-    <input type="hidden" name="app" value="file" />
-    <input type="hidden" name="to" value="<: $route :>" />
-    <input class="coolbutton" type="submit" value="Publish" text="Publish" />
+    : include "form_common.tx";
 </form>

+ 1 - 4
www/templates/series.tx

@@ -8,8 +8,5 @@
             <option <: $post.visibility == $visibility ? 'selected' : '' :> value="<: $visibility :>"><: $visibility :></option>
         : }
     </select>
-    Comments<br /><textarea class="cooltext" name="data" placeholder="Potzrebie"><: $post.data :></textarea>
-    <input type="hidden" name="app" value="series" />
-    <input type="hidden" name="to" value="<: $route :>" />
-    <input class="coolbutton" type="submit" value="Publish" text="Publish" />
+    : include "form_common.tx";
 </form>