myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3039] trunk/app: If no preview image available,


From: noreply
Subject: [myexperiment-hackers] [3039] trunk/app: If no preview image available, SVGs are now used to generate them
Date: Tue, 19 Jun 2012 10:31:27 +0000 (UTC)

Revision
3039
Author
fbacall
Date
2012-06-19 10:31:27 +0000 (Tue, 19 Jun 2012)

Log Message

If no preview image available, SVGs are now used to generate them

Modified Paths

Diff

Modified: trunk/app/controllers/previews_controller.rb (3038 => 3039)


--- trunk/app/controllers/previews_controller.rb	2012-06-18 12:43:28 UTC (rev 3038)
+++ trunk/app/controllers/previews_controller.rb	2012-06-19 10:31:27 UTC (rev 3039)
@@ -44,26 +44,35 @@
 
     type = params[:id]
 
+    mime_type = nil
+
     case type
 
-      when 'full';   name = 'full';   source = 'image'; size = nil; mime_type = 'image/jpeg'
-      when 'medium'; name = 'medium'; source = 'image'; size = 500; mime_type = 'image/jpeg'
-      when 'thumb';  name = 'thumb';  source = 'image'; size = 100; mime_type = 'image/jpeg'
-      when 'svg';    name = 'svg';    source = 'svg';   size = nil; mime_type = 'image/svg+xml'
+      when 'full';   source = 'image'; size = nil; mime_type = 'image/jpeg'
+      when 'medium'; source = 'image'; size = 500; mime_type = 'image/jpeg'
+      when 'thumb';  source = 'image'; size = 100; mime_type = 'image/jpeg'
+      when 'svg';    source = 'svg';   size = nil; mime_type = 'image/svg+xml'
       else
         render(:inline => 'Bad preview type', :status => "400 Bad Request")
         return
     end
 
+    content_blob = nil
+
+    case source
+      when 'image'
+        content_blob = @context.preview.image_blob
+        if content_blob.nil? && @context.preview.svg_blob # If no image, but an SVG, render a JPG from the SVG.
+          content_blob = @context.preview.svg_blob
+          mime_type = 'image/svg+xml' if size.nil? # Just show the SVG when "full" image is requested
+        end
+      when 'svg';   content_blob = @context.preview.svg_blob
+    end
+
     file_name = @context.preview.file_name(type)
 
     send_cached_data(file_name, :type => mime_type, :disposition => 'inline') {
 
-      case source
-        when 'image'; content_blob = @context.preview.image_blob
-        when 'svg';   content_blob = @context.preview.svg_blob
-      end
-
       data = ""
 
       if size

Modified: trunk/app/views/workflows/_table.rhtml (3038 => 3039)


--- trunk/app/views/workflows/_table.rhtml	2012-06-18 12:43:28 UTC (rev 3038)
+++ trunk/app/views/workflows/_table.rhtml	2012-06-19 10:31:27 UTC (rev 3039)
@@ -76,7 +76,7 @@
 					  
             <% desc_style = "font-size: 85%;" %>
 
-            <% unless workflow.image.nil? -%>
+            <% unless workflow.image.nil? && workflow.svg.nil? -%>
               <p style="margin: 0; border: 0; width: 101px; float: left">
                 <%= link_to image_tag(workflow_preview_path(workflow, 'thumb'), :class => 'framed_nospace'), workflow_path(workflow) %>
               </p>

Modified: trunk/app/views/workflows/show.rhtml (3038 => 3039)


--- trunk/app/views/workflows/show.rhtml	2012-06-18 12:43:28 UTC (rev 3038)
+++ trunk/app/views/workflows/show.rhtml	2012-06-19 10:31:27 UTC (rev 3039)
@@ -158,7 +158,7 @@
 				Preview
 			</h3>
 			
-			<% unless @viewing_version.image.nil? %>
+			<% unless @viewing_version.image.nil? && @viewing_version.svg.nil? %>
 				<p style="font-size: 85%; font-weight: normal; margin-bottom: 0.5em; text-align: center;">
 					 (Click on the image to get the full size)
 				</p>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]