소스 검색

Fix #42: simplify image upload

George S. Baugh 5 년 전
부모
커밋
97bd6b351c
4개의 변경된 파일10개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 0
      lib/Trog/Data/DUMMY.pm
  2. 6 0
      lib/Trog/Routes/HTML.pm
  3. 1 3
      www/templates/file.tx
  4. 2 0
      www/templates/preview.tx

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

@@ -188,6 +188,7 @@ sub _process ($post) {
 
     $post->{href}    = _handle_upload($post->{file}, $post->{id})         if $post->{file};
     $post->{preview} = _handle_upload($post->{preview_file}, $post->{id}) if $post->{preview_file};
+    $post->{preview} = $post->{href} if $post->{app} eq 'image';
     delete $post->{app};
     delete $post->{file};
     delete $post->{preview_file};

+ 6 - 0
lib/Trog/Routes/HTML.pm

@@ -442,6 +442,11 @@ sub post ($query, $render_cb) {
     push(@$css, '/styles/avatars.css');
     my (undef, $acls) = _post_helper({}, ['series'], $query->{acls});
 
+    my $app = 'file';
+    $app = 'image' if $query->{route} =~ m/image$/;
+    $app = 'video' if $query->{route} =~ m/video$/;
+    $app = 'audio' if $query->{route} =~ m/audio$/;
+
     return $render_cb->('post.tx', {
         title       => 'New Post',
         to          => $query->{to},
@@ -461,6 +466,7 @@ sub post ($query, $render_cb) {
         acls        => $acls,
         post        => { tags => $query->{tag} },
         edittype    => $query->{type} || 'microblog',
+        app         => $app,
     });
 }
 

+ 1 - 3
www/templates/file.tx

@@ -4,13 +4,11 @@
     : if ( $post.href ) {
     <input type="hidden" name="href" value="<: $post.href :>" />
     : }
-    <!-- Need to validate file or add an upload link that kicks off WS streaming of the file at some point? TAB -->
-    <br /> TODO: Add "alternative" links, which scrape the appropriate icon for the alt link from the favicon<br />
     : 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="file" />
+    <input type="hidden" name="app" value="<: $app :>" />
     <input type="hidden" name="to" value="<: $route :>" />
     <input class="coolbutton" type="submit" value="Publish" text="Publish" />
 </form>

+ 2 - 0
www/templates/preview.tx

@@ -1,4 +1,6 @@
+: if ( $app != 'image' ) {
 Preview Image<br /><input type="file" class="cooltext" name="preview_file" placeholder="PROMO.JPG" />
 : if ( $post.preview ) {
 <input type="hidden" name="preview" value="<: $post.preview :>" />
 : }
+: }