inline images as raw action
authorChristian Thaeter <ct@pipapo.org>
Tue, 8 Jan 2008 05:54:18 +0000 (06:54 +0100)
committerChristian Thaeter <ct@pipapo.org>
Tue, 8 Jan 2008 05:54:18 +0000 (06:54 +0100)
src/object.c

index 582b39a..27c5176 100644 (file)
@@ -383,7 +383,33 @@ webgit_object_blob_content_action (struct webgit_query* query, unsigned char* sh
     }
   else
     {
-      return html ("binary blob");
+      const char* mimetype = webgit_mimetype (query->path);
+
+      Html ret;
+
+      if (mimetype && !strncmp(mimetype, "image/", 6))
+        {
+          /* inline image */
+          ret = html (
+                      html_tag ("img",
+                                html_attr ("src",
+                                           html_fmt ("%s?repo=%s&action=raw&object=%s&path=%s",
+                                                            query->request->script_name,
+                                                            query->repo, query->object, query->path)
+                                           ),
+                                html_attr ("alt", query->path? query->path : query->object),
+                                html_attr ("width", "90%")
+                                )
+                      );
+        }
+      else
+        {
+          /* link to raw data */
+          ret = html ("binary blob");
+        }
+      free (mimetype);
+
+      return ret;
     }
 }