Overview
SHA1 Hash: | 389bf5c4dac2d60bd1764419e7de8913532e19f7 |
---|---|
Date: | 2008-11-17 17:14:37 |
User: | drh |
Comment: | The "artifact" webpage shows images as images, rather than trying to render their binary content as text. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/info.c from [97b0bae401] to [17472b8889].
@@ -686,14 +686,18 @@ ** ** * It's uuid ** * date of check-in ** * Comment & user */ -static void object_description(int rid, int linkToView){ +static const char *object_description( + int rid, /* The artifact ID */ + int linkToView /* Add viewer link if true */ +){ Stmt q; int cnt = 0; int nWiki = 0; + const char *zMime = 0; db_prepare(&q, "SELECT filename.name, datetime(event.mtime), substr(a.uuid,1,10)," " coalesce(event.ecomment,event.comment)," " coalesce(event.euser,event.user)," " b.uuid" @@ -714,10 +718,11 @@ const char *zVers = db_column_text(&q, 5); @ File <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a> @ uuid %s(zFuuid) part of check-in hyperlink_to_uuid(zVers); @ %w(zCom) by %h(zUser) on %s(zDate) + zMime = mimetype_from_name(zName); cnt++; } db_finalize(&q); db_prepare(&q, "SELECT substr(tagname, 6, 10000), datetime(event.mtime)," @@ -738,10 +743,11 @@ @ Wiki page @ [<a href="%s(g.zBaseURL)/wiki?name=%t(zPagename)">%h(zPagename)</a>] @ uuid %s(zUuid) by %h(zUser) on %s(zDate) nWiki++; cnt++; + zMime = 0; } db_finalize(&q); if( nWiki==0 ){ db_prepare(&q, "SELECT datetime(mtime), user, comment, uuid, type" @@ -775,10 +781,11 @@ char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); @ Control file %s(zUuid). }else if( linkToView ){ @ <a href="%s(g.zBaseURL)/artifact/%d(rid)">[view]</a> } + return zMime; } /* ** WEBPAGE: fdiff ** @@ -814,19 +821,42 @@ blob_reset(&diff); style_footer(); } /* +** WEBPAGE: raw +** URL: /raw?name=ARTIFACTID&m=TYPE +** +** Return the uninterpreted content of an artifact. Used primarily +** to view artifacts that are images. +*/ +void rawartifact_page(void){ + int rid; + const char *zMime; + Blob content; + + rid = name_to_rid(PD("name","0")); + zMime = PD("m","application/x-fossil-artifact"); + login_check_credentials(); + if( !g.okRead ){ login_needed(); return; } + if( rid==0 ){ cgi_redirect("/home"); } + content_get(rid, &content); + cgi_set_content_type(zMime); + cgi_set_content(&content); +} + +/* ** WEBPAGE: artifact ** URL: /artifact?name=ARTIFACTID ** ** Show the complete content of a file identified by ARTIFACTID ** as preformatted text. */ void artifact_page(void){ int rid; Blob content; + const char *zMime; rid = name_to_rid(PD("name","0")); login_check_credentials(); if( !g.okRead ){ login_needed(); return; } if( rid==0 ){ cgi_redirect("/home"); } @@ -841,18 +871,22 @@ } } style_header("Artifact Content"); @ <h2>Content Of:</h2> @ <blockquote> - object_description(rid, 0); + zMime = object_description(rid, 0); @ </blockquote> @ <hr> - @ <blockquote><pre> - content_get(rid, &content); - @ %h(blob_str(&content)) - @ </pre></blockquote> - blob_reset(&content); + if( zMime && strncmp(zMime, "image/", 6)==0 ){ + @ <img src="%s(g.zBaseURL)/raw?name=%d(rid)&m=%s(zMime)"></img> + }else{ + @ <blockquote><pre> + content_get(rid, &content); + @ %h(blob_str(&content)) + @ </pre></blockquote> + blob_reset(&content); + } style_footer(); } /* ** WEBPAGE: tinfo