Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Merge src & doc leaves back. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
d14adf1032924428f6eda72570fa81b6 |
| User & Date: | kejoki 2008-11-19 16:55:14.000 |
Context
|
2008-11-19
| ||
| 22:44 | Fix a bug in the cluster creater. The bug prevents clusters from being created correctly when there are phantom artifacts. ... (check-in: 72959c415e user: drh tags: trunk) | |
| 16:55 | Merge src & doc leaves back. ... (check-in: d14adf1032 user: kejoki tags: trunk) | |
|
2008-11-18
| ||
| 15:33 | In wiki, hyperlinks or the form [./filename] (hyperlinks that begin with character ".") work correctly. Need to add more docs on how the [...] wiki markup really works. ... (check-in: 63886daad8 user: drh tags: trunk) | |
|
2008-11-17
| ||
| 17:11 | Initial doc for update. ... (check-in: 6d6959b47d user: kejoki tags: trunk) | |
Changes
Changes to src/cgi.c.
| ︙ | ︙ | |||
334 335 336 337 338 339 340 |
if( strcmp(zContentType,"application/x-fossil")==0 ){
cgi_combine_header_and_body();
blob_compress(&cgiContent[0], &cgiContent[0]);
}
if( iReplyStatus != 304 ) {
total_size = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
| > > > > > > > > | > > > > > > > > | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
if( strcmp(zContentType,"application/x-fossil")==0 ){
cgi_combine_header_and_body();
blob_compress(&cgiContent[0], &cgiContent[0]);
}
if( iReplyStatus != 304 ) {
total_size = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
#ifdef __MINGW32__
/* In windows versions of Apache, extra \r characters get added to the
** response, which mess up the Content-Length. So let apache figure
** out the content length for itself if we are using CGI. If this
** is a complete stand-alone webserver, on the other hand, we still
** need the Content-Length.
*/
if( g.fullHttpReply ){
fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
}
#else
/* On unix, \n to \r\n translation is never a problem. We know the
** content length, so we might as well go ahead and tell the webserver
** what it is in all cases.
*/
fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
#endif
}
fprintf(g.httpOut, "\r\n");
if( total_size>0 && iReplyStatus != 304 ){
int i, size;
for(i=0; i<2; i++){
size = blob_size(&cgiContent[i]);
if( size>0 ){
|
| ︙ | ︙ |
Changes to src/clearsign.c.
| ︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
int clearsign(Blob *pIn, Blob *pOut){
char *zRand;
char *zIn;
char *zOut;
char *zBase = db_get("pgp-command", "gpg --clearsign -o ");
char *zCmd;
int rc;
zRand = db_text(0, "SELECT hex(randomblob(10))");
zOut = mprintf("out-%s", zRand);
zIn = mprintf("in-%z", zRand);
blob_write_to_file(pIn, zOut);
zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
rc = system(zCmd);
free(zCmd);
| > > > | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
int clearsign(Blob *pIn, Blob *pOut){
char *zRand;
char *zIn;
char *zOut;
char *zBase = db_get("pgp-command", "gpg --clearsign -o ");
char *zCmd;
int rc;
if( is_false(zBase) ){
return 0;
}
zRand = db_text(0, "SELECT hex(randomblob(10))");
zOut = mprintf("out-%s", zRand);
zIn = mprintf("in-%z", zRand);
blob_write_to_file(pIn, zOut);
zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
rc = system(zCmd);
free(zCmd);
|
| ︙ | ︙ |
Changes to src/doc.c.
| ︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
**
** This file contains code to implement the "/doc" web page and related
** pages.
*/
#include "config.h"
#include "doc.h"
#include <assert.h>
/*
** Guess the mime-type of a document based on its name.
*/
const char *mimetype_from_name(const char *zName){
const char *z;
int i;
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
**
** This file contains code to implement the "/doc" web page and related
** pages.
*/
#include "config.h"
#include "doc.h"
#include <assert.h>
/*
** Try to guess the mimetype from content.
**
** If the content is pure text, return NULL.
**
** For image types, attempt to return an appropriate mimetype
** name like "image/gif" or "image/jpeg".
**
** For any other binary type, return "unknown/unknown".
*/
const char *mimetype_from_content(Blob *pBlob){
int i;
int n;
const unsigned char *x;
static const char isBinary[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1,
};
/* A table of mimetypes based on file content prefixes
*/
static const struct {
const char *zPrefix; /* The file prefix */
int size; /* Length of the prefix */
const char *zMimetype; /* The corresponding mimetype */
} aMime[] = {
{ "GIF87a", 6, "image/gif" },
{ "GIF89a", 6, "image/gif" },
{ "\211PNG\r\n\032\r", 8, "image/png" },
{ "\377\332\377", 3, "image/jpeg" },
};
x = (const unsigned char*)blob_buffer(pBlob);
n = blob_size(pBlob);
for(i=0; i<n; i++){
unsigned char c = x[i];
if( c<=0x1f && isBinary[c] ){
break;
}
}
if( i>=n ){
return 0; /* Plain text */
}
for(i=0; i<sizeof(aMime)/sizeof(aMime[0]); i++){
if( n>=aMime[i].size && memcmp(x, aMime[i].zPrefix, aMime[i].size)==0 ){
return aMime[i].zMimetype;
}
}
return "unknown/unknown";
}
/*
** Guess the mime-type of a document based on its name.
*/
const char *mimetype_from_name(const char *zName){
const char *z;
int i;
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
684 685 686 687 688 689 690 | ** ** If the object is a manifest, then mention: ** ** * It's uuid ** * date of check-in ** * Comment & user */ | | > > > | 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 |
**
** If the object is a manifest, then mention:
**
** * It's uuid
** * date of check-in
** * Comment & user
*/
static void object_description(
int rid, /* The artifact ID */
int linkToView /* Add viewer link if true */
){
Stmt q;
int cnt = 0;
int nWiki = 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),"
|
| ︙ | ︙ | |||
708 709 710 711 712 713 714 |
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
const char *zDate = db_column_text(&q, 1);
const char *zFuuid = db_column_text(&q, 2);
const char *zCom = db_column_text(&q, 3);
const char *zUser = db_column_text(&q, 4);
const char *zVers = db_column_text(&q, 5);
| > > > > > | | > > > | > | > > > | | 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 |
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
const char *zDate = db_column_text(&q, 1);
const char *zFuuid = db_column_text(&q, 2);
const char *zCom = db_column_text(&q, 3);
const char *zUser = db_column_text(&q, 4);
const char *zVers = db_column_text(&q, 5);
if( cnt>0 ){
@ Also file
}else{
@ 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).
cnt++;
}
db_finalize(&q);
db_prepare(&q,
"SELECT substr(tagname, 6, 10000), datetime(event.mtime),"
" coalesce(event.euser, event.user), uuid"
" FROM tagxref, tag, event, blob"
" WHERE tagxref.rid=%d"
" AND tag.tagid=tagxref.tagid"
" AND tag.tagname LIKE 'wiki-%%'"
" AND event.objid=tagxref.rid"
" AND blob.rid=tagxref.rid",
rid
);
while( db_step(&q)==SQLITE_ROW ){
const char *zPagename = db_column_text(&q, 0);
const char *zDate = db_column_text(&q, 1);
const char *zUser = db_column_text(&q, 2);
const char *zUuid = db_column_text(&q, 3);
if( cnt>0 ){
@ Also wiki page
}else{
@ 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++;
}
db_finalize(&q);
if( nWiki==0 ){
db_prepare(&q,
"SELECT datetime(mtime), user, comment, uuid, type"
" FROM event, blob"
" WHERE event.objid=%d"
" AND blob.rid=%d",
rid, rid
);
while( db_step(&q)==SQLITE_ROW ){
const char *zDate = db_column_text(&q, 0);
const char *zUuid = db_column_text(&q, 3);
const char *zUser = db_column_text(&q, 1);
const char *zCom = db_column_text(&q, 2);
const char *zType = db_column_text(&q, 4);
if( cnt>0 ){
@ Also
}
if( zType[0]=='w' ){
@ Wiki edit
}else if( zType[0]=='t' ){
@ Ticket change
}else if( zType[0]=='c' ){
@ Manifest of baseline
}else{
@ Control file referencing
}
hyperlink_to_uuid(zUuid);
@ %w(zCom) by %h(zUser) on %s(zDate).
cnt++;
}
db_finalize(&q);
}
if( cnt==0 ){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
@ Control file %s(zUuid).
|
| ︙ | ︙ | |||
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 |
blob_reset(&c1);
blob_reset(&c2);
@ %h(blob_str(&diff))
@ </pre></blockquote>
blob_reset(&diff);
style_footer();
}
/*
** 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;
rid = name_to_rid(PD("name","0"));
login_check_credentials();
if( !g.okRead ){ login_needed(); return; }
if( rid==0 ){ cgi_redirect("/home"); }
if( g.okAdmin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 |
blob_reset(&c1);
blob_reset(&c2);
@ %h(blob_str(&diff))
@ </pre></blockquote>
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);
}
/*
** Render a hex dump of a file.
*/
static void hexdump(Blob *pBlob){
const unsigned char *x;
int n, i, j, k;
char zLine[100];
static const char zHex[] = "0123456789abcdef";
x = (const unsigned char*)blob_buffer(pBlob);
n = blob_size(pBlob);
for(i=0; i<n; i+=16){
j = 0;
zLine[0] = zHex[(i>>24)&0xf];
zLine[1] = zHex[(i>>16)&0xf];
zLine[2] = zHex[(i>>8)&0xf];
zLine[3] = zHex[i&0xf];
zLine[4] = ':';
sprintf(zLine, "%04x: ", i);
for(j=0; j<16; j++){
k = 5+j*3;
zLine[k] = ' ';
if( i+j<n ){
unsigned char c = x[i+j];
zLine[k+1] = zHex[c>>4];
zLine[k+2] = zHex[c&0xf];
}else{
zLine[k+1] = ' ';
zLine[k+2] = ' ';
}
}
zLine[53] = ' ';
zLine[54] = ' ';
for(j=0; j<16; j++){
k = j+55;
if( i+j<n ){
unsigned char c = x[i+j];
if( c>=0x20 && c<=0x7e ){
zLine[k] = c;
}else{
zLine[k] = '.';
}
}else{
zLine[k] = 0;
}
}
zLine[71] = 0;
@ %h(zLine)
}
}
/*
** WEBPAGE: hexdump
** URL: /hexdump?name=ARTIFACTID
**
** Show the complete content of a file identified by ARTIFACTID
** as preformatted text.
*/
void hexdump_page(void){
int rid;
Blob content;
rid = name_to_rid(PD("name","0"));
login_check_credentials();
if( !g.okRead ){ login_needed(); return; }
if( rid==0 ){ cgi_redirect("/home"); }
if( g.okAdmin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( db_exists("SELECT 1 FROM shun WHERE uuid='%s'", zUuid) ){
style_submenu_element("Unshun","Unshun", "%s/shun?uuid=%s&sub=1",
g.zTop, zUuid);
}else{
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
g.zTop, zUuid);
}
}
style_header("Hex Artifact Content");
@ <h2>Hexadecimal Content Of:</h2>
@ <blockquote>
object_description(rid, 0);
@ </blockquote>
@ <hr>
content_get(rid, &content);
@ <blockquote><pre>
hexdump(&content);
@ </pre></blockquote>
style_footer();
}
/*
** 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"); }
if( g.okAdmin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
|
| ︙ | ︙ | |||
842 843 844 845 846 847 848 |
}
style_header("Artifact Content");
@ <h2>Content Of:</h2>
@ <blockquote>
object_description(rid, 0);
@ </blockquote>
@ <hr>
| | > > > | | > > > > > > | > > > | 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 |
}
style_header("Artifact Content");
@ <h2>Content Of:</h2>
@ <blockquote>
object_description(rid, 0);
@ </blockquote>
@ <hr>
@ <blockquote>
content_get(rid, &content);
zMime = mimetype_from_content(&content);
if( zMime==0 ){
@ <pre>
@ %h(blob_str(&content))
@ </pre>
style_submenu_element("Hex","Hex", "%s/hexdump?name=%d", g.zTop, rid);
}else if( strncmp(zMime, "image/", 6)==0 ){
@ <img src="%s(g.zBaseURL)/raw?name=%d(rid)&m=%s(zMime)"></img>
style_submenu_element("Hex","Hex", "%s/hexdump?name=%d", g.zTop, rid);
}else{
@ <pre>
hexdump(&content);
@ </pre>
}
@ </blockquote>
style_footer();
}
/*
** WEBPAGE: tinfo
** URL: /tinfo?name=ARTIFACTID
**
|
| ︙ | ︙ |
Changes to src/wiki.c.
| ︙ | ︙ | |||
81 82 83 84 85 86 87 |
void home_page(void){
char *zPageName = db_get("project-name",0);
if( zPageName ){
login_check_credentials();
g.zExtra = zPageName;
cgi_set_parameter_nocopy("name", g.zExtra);
g.okRdWiki = 1;
| < | < | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
void home_page(void){
char *zPageName = db_get("project-name",0);
if( zPageName ){
login_check_credentials();
g.zExtra = zPageName;
cgi_set_parameter_nocopy("name", g.zExtra);
g.okRdWiki = 1;
g.argv[1] = "home";
wiki_page();
return;
}
login_check_credentials();
style_header("Home");
@ <p>This is a stub home-page for the project.
@ To fill in this page, first go to
|
| ︙ | ︙ | |||
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
int rid = 0;
int isSandbox;
Blob wiki;
Manifest m;
const char *zPageName;
char *zHtmlPageName;
char *zBody = mprintf("%s","<i>Empty Page</i>");
login_check_credentials();
if( !g.okRdWiki ){ login_needed(); return; }
zPageName = P("name");
if( zPageName==0 ){
style_header("Wiki");
@ <ul>
| > | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
int rid = 0;
int isSandbox;
Blob wiki;
Manifest m;
const char *zPageName;
char *zHtmlPageName;
char *zBody = mprintf("%s","<i>Empty Page</i>");
int isHome = g.argv[1][0]=='h';
login_check_credentials();
if( !g.okRdWiki ){ login_needed(); return; }
zPageName = P("name");
if( zPageName==0 ){
style_header("Wiki");
@ <ul>
|
| ︙ | ︙ | |||
167 168 169 170 171 172 173 |
content_get(rid, &content);
manifest_parse(&m, &content);
if( m.type==CFTYPE_WIKI ){
zBody = m.zWiki;
}
}
}
| > | | | | | | | | | | | > | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
content_get(rid, &content);
manifest_parse(&m, &content);
if( m.type==CFTYPE_WIKI ){
zBody = m.zWiki;
}
}
}
if( !isHome ){
if( isSandbox || (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
style_submenu_element("Edit", "Edit Wiki Page", "%s/wikiedit?name=%T",
g.zTop, zPageName);
}
if( isSandbox || (rid && g.okApndWiki) ){
style_submenu_element("Append", "Add A Comment", "%s/wikiappend?name=%T",
g.zTop, zPageName);
}
if( !isSandbox && g.okHistory ){
style_submenu_element("History", "History", "%s/whistory?name=%T",
g.zTop, zPageName);
}
}
zHtmlPageName = mprintf("%h", zPageName);
style_header(zHtmlPageName);
blob_init(&wiki, zBody, -1);
wiki_convert(&wiki, 0, 0);
blob_reset(&wiki);
if( !isSandbox ){
|
| ︙ | ︙ |
Changes to src/wikiformat.c.
| ︙ | ︙ | |||
936 937 938 939 940 941 942 943 944 945 946 947 948 949 |
){
blob_appendf(p->pOut, "<a href=\"%s\">", zTarget);
}else if( zTarget[0]=='/' ){
if( g.okHistory ){
blob_appendf(p->pOut, "<a href=\"%s%h\">", g.zBaseURL, zTarget);
}else{
zTerm = "";
}
}else if( is_valid_uuid(zTarget) ){
int isClosed;
if( is_ticket(zTarget, &isClosed) ){
/* Special display processing for tickets. Display the hyperlink
** as crossed out if the ticket is closed.
*/
| > > > > > > | 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 |
){
blob_appendf(p->pOut, "<a href=\"%s\">", zTarget);
}else if( zTarget[0]=='/' ){
if( g.okHistory ){
blob_appendf(p->pOut, "<a href=\"%s%h\">", g.zBaseURL, zTarget);
}else{
zTerm = "";
}
}else if( zTarget[0]=='.' ){
if( g.okHistory ){
blob_appendf(p->pOut, "<a href=\"%h\">", zTarget);
}else{
zTerm = "";
}
}else if( is_valid_uuid(zTarget) ){
int isClosed;
if( is_ticket(zTarget, &isClosed) ){
/* Special display processing for tickets. Display the hyperlink
** as crossed out if the ticket is closed.
*/
|
| ︙ | ︙ |