Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | The g.zExtra parameter is now always available as P("name"). This means the /wiki/xyz and /wiki?name=xyz are equivalent URLs. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
677aa71bca93b776afc2f0d9b2e06bb9 |
| User & Date: | drh 2007-10-12 22:56:18.000 |
Context
|
2007-10-12
| ||
| 23:18 | Fix some (certainly not all) problems with wiki editing. check-in: df646a7f4c user: drh tags: trunk | |
| 22:56 | The g.zExtra parameter is now always available as P("name"). This means the /wiki/xyz and /wiki?name=xyz are equivalent URLs. check-in: 677aa71bca user: drh tags: trunk | |
|
2007-10-11
| ||
| 02:11 | Add the g.zExtra output to the test_env page. Fix a bug in the computation of g.zTop. check-in: 1ce716b2ec user: drh tags: trunk | |
Changes
Changes to src/cgi.c.
| ︙ | ︙ | |||
304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
cgi_reset_content();
cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zURL);
cgi_set_status(302, "Moved Temporarily");
free(zLocation);
cgi_reply();
exit(0);
}
/*
** Information about all query parameters and cookies are stored
** in these variables.
*/
static int nAllocQP = 0; /* Space allocated for aParamQP[] */
static int nUsedQP = 0; /* Space actually used in aParamQP[] */
| > > > > > > | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
cgi_reset_content();
cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zURL);
cgi_set_status(302, "Moved Temporarily");
free(zLocation);
cgi_reply();
exit(0);
}
void cgi_redirectf(const char *zFormat, ...){
va_list ap;
va_start(ap, zFormat);
cgi_redirect(vmprintf(zFormat, ap));
va_end(ap);
}
/*
** Information about all query parameters and cookies are stored
** in these variables.
*/
static int nAllocQP = 0; /* Space allocated for aParamQP[] */
static int nUsedQP = 0; /* Space actually used in aParamQP[] */
|
| ︙ | ︙ | |||
327 328 329 330 331 332 333 | ** Add another query parameter or cookie to the parameter set. ** zName is the name of the query parameter or cookie and zValue ** is its fully decoded value. ** ** zName and zValue are not copied and must not change or be ** deallocated after this routine returns. */ | | | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
** Add another query parameter or cookie to the parameter set.
** zName is the name of the query parameter or cookie and zValue
** is its fully decoded value.
**
** zName and zValue are not copied and must not change or be
** deallocated after this routine returns.
*/
void cgi_set_parameter_nocopy(const char *zName, const char *zValue){
if( nAllocQP<=nUsedQP ){
nAllocQP = nAllocQP*2 + 10;
aParamQP = realloc( aParamQP, nAllocQP*sizeof(aParamQP[0]) );
if( aParamQP==0 ) exit(1);
}
aParamQP[nUsedQP].zName = zName;
aParamQP[nUsedQP].zValue = zValue;
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
287 288 289 290 291 292 293 294 |
@ </ul>
}
}
/*
** WEBPAGE: vinfo
**
| > | < | | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
@ </ul>
}
}
/*
** WEBPAGE: vinfo
** URL: /vinfo?name=RID|UUID
**
** Return information about a version.
*/
void vinfo_page(void){
Stmt q;
int rid;
int isLeaf;
login_check_credentials();
if( !g.okHistory ){ login_needed(); return; }
rid = name_to_rid(PD("name","0"));
if( rid==0 ){
style_header("Version Information Error");
@ No such object: %h(g.argv[2])
style_footer();
return;
}
isLeaf = !db_exists("SELECT 1 FROM plink WHERE pid=%d", rid);
|
| ︙ | ︙ | |||
362 363 364 365 366 367 368 |
if( pid && fid ){
@ <b>Modified:</b>
}else if( fid ){
@ <b>Added:</b>
}else{
@ <b>Deleted:</b>
}
| | > | < | | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
if( pid && fid ){
@ <b>Modified:</b>
}else if( fid ){
@ <b>Added:</b>
}else{
@ <b>Deleted:</b>
}
@ <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a></li>
}
@ </ul>
compute_leaves(rid);
showDescendents(rid, 2, "Descendents");
showLeaves();
showAncestors(rid, 2, "Ancestors");
style_footer();
}
/*
** WEBPAGE: winfo
** URL: /winfo?name=RID
**
** Return information about a wiki page.
*/
void winfo_page(void){
Stmt q;
int rid;
login_check_credentials();
if( !g.okHistory ){ login_needed(); return; }
rid = name_to_rid(PD("name","0"));
if( rid==0 ){
style_header("Wiki Page Information Error");
@ No such object: %h(g.argv[2])
style_footer();
return;
}
db_prepare(&q,
|
| ︙ | ︙ | |||
419 420 421 422 423 424 425 |
if( g.okSetup ){
@ <tr><th>Record ID:</th><td>%d(rid)</td></tr>
}
@ <tr><th>Original User:</th><td>%s(db_column_text(&q, 3))</td></tr>
@ <tr><th>Commands:</th>
@ <td>
/* @ <a href="%s(g.zBaseURL)/wdiff/%d(rid)">diff</a> | */
| | > | < > > | | | 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
if( g.okSetup ){
@ <tr><th>Record ID:</th><td>%d(rid)</td></tr>
}
@ <tr><th>Original User:</th><td>%s(db_column_text(&q, 3))</td></tr>
@ <tr><th>Commands:</th>
@ <td>
/* @ <a href="%s(g.zBaseURL)/wdiff/%d(rid)">diff</a> | */
@ <a href="%s(g.zBaseURL)/whistory?page=%t(zName)">history</a>
@ | <a href="%s(g.zBaseURL)/fview/%d(rid)">raw-text</a>
@ </td>
@ </tr>
@ </table></p>
}else{
style_header("Wiki Information");
}
db_finalize(&q);
showTags(rid);
style_footer();
}
/*
** WEBPAGE: finfo
** URL: /finfo?name=FILENAME
**
** Show the complete change history for a single file.
*/
void finfo_page(void){
Stmt q;
const char *zFilename;
char zPrevDate[20];
login_check_credentials();
if( !g.okHistory ){ login_needed(); return; }
style_header("File History");
zPrevDate[0] = 0;
zFilename = PD("name","");
db_prepare(&q,
"SELECT a.uuid, substr(b.uuid,1,10), datetime(event.mtime,'localtime'),"
" coalesce(event.ecomment, event.comment),"
" coalesce(event.euser, event.user),"
" mlink.pid, mlink.fid"
" FROM mlink, blob a, blob b, event"
" WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
" AND a.rid=mlink.mid"
" AND b.rid=mlink.fid"
" AND event.objid=mlink.mid"
" ORDER BY event.mtime DESC",
zFilename
);
@ <h2>History of %h(zFilename)</h2>
@ <table cellspacing=0 border=0 cellpadding=0>
while( db_step(&q)==SQLITE_ROW ){
const char *zVers = db_column_text(&q, 0);
const char *zUuid = db_column_text(&q, 1);
const char *zDate = db_column_text(&q, 2);
const char *zCom = db_column_text(&q, 3);
const char *zUser = db_column_text(&q, 4);
|
| ︙ | ︙ | |||
487 488 489 490 491 492 493 |
@ <tr><td valign="top">%s(&zDate[11])</td>
@ <td width="20"></td>
@ <td valign="top" align="left">
hyperlink_to_uuid(zVers);
@ %h(zCom) (By: %h(zUser))
@ Id: %s(zUuid)/%d(frid)
@ <a href="%s(g.zBaseURL)/fview/%d(frid)">[view]</a>
| > | > | 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
@ <tr><td valign="top">%s(&zDate[11])</td>
@ <td width="20"></td>
@ <td valign="top" align="left">
hyperlink_to_uuid(zVers);
@ %h(zCom) (By: %h(zUser))
@ Id: %s(zUuid)/%d(frid)
@ <a href="%s(g.zBaseURL)/fview/%d(frid)">[view]</a>
if( fpid ){
@ <a href="%s(g.zBaseURL)/fdiff?v1=%d(fpid)&v2=%d(frid)">[diff]</a>
}
@ </td>
}
db_finalize(&q);
@ </table>
style_footer();
}
|
| ︙ | ︙ | |||
513 514 515 516 517 518 519 520 | blob_reset(&from); blob_reset(&to); blob_reset(&out); } /* ** WEBPAGE: vdiff ** | > | | | | 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
blob_reset(&from);
blob_reset(&to);
blob_reset(&out);
}
/*
** WEBPAGE: vdiff
** URL: /vdiff?name=RID
**
** Show all differences for a particular check-in.
*/
void vdiff_page(void){
int rid;
Stmt q;
char *zUuid;
login_check_credentials();
if( !g.okHistory ){ login_needed(); return; }
style_header("Version Diff");
rid = name_to_rid(PD("name",""));
if( rid==0 ){
cgi_redirect("index");
}
db_prepare(&q,
"SELECT pid, fid, name"
" FROM mlink, filename"
" WHERE mlink.mid=%d"
" AND filename.fnid=mlink.fnid"
" ORDER BY name",
rid
);
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
@ <h2>All Changes In Version
hyperlink_to_uuid(zUuid);
@ </h2>
while( db_step(&q)==SQLITE_ROW ){
int pid = db_column_int(&q,0);
int fid = db_column_int(&q,1);
const char *zName = db_column_text(&q,2);
@ <p><a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a></p>
@ <blockquote><pre>
append_diff(pid, fid);
@ </pre></blockquote>
}
db_finalize(&q);
style_footer();
}
|
| ︙ | ︙ | |||
594 595 596 597 598 599 600 |
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);
| | | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
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);
@ File <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
@ uuid %s(zFuuid) part of check-in
hyperlink_to_uuid(zVers);
@ %s(zCom) by %s(zUser) on %s(zDate).
cnt++;
}
db_finalize(&q);
db_prepare(&q,
|
| ︙ | ︙ | |||
617 618 619 620 621 622 623 |
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);
| > | | 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 |
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);
@ Wiki page
@ [<a href="%s(g.zBaseURL)/wiki?page=%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,
|
| ︙ | ︙ | |||
690 691 692 693 694 695 696 | blob_reset(&diff); style_footer(); } /* ** WEBPAGE: info ** WEBPAGE: fview | | | | 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 |
blob_reset(&diff);
style_footer();
}
/*
** WEBPAGE: info
** WEBPAGE: fview
** URL: /fview?name=UUID
**
** Show the complete content of a file identified by UUID
** as preformatted text.
*/
void fview_page(void){
int rid;
Blob content;
rid = name_to_rid(PD("name","0"));
login_check_credentials();
if( !g.okHistory ){ login_needed(); return; }
if( g.zPath[0]=='i' ){
if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)"
" WHERE rid=%d AND tagname LIKE 'wiki-%%'", rid) ){
winfo_page();
return;
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
446 447 448 449 450 451 452 |
g.zTop = &g.zBaseURL[7+strlen(zHost)];
}
}
/*
** Preconditions:
**
| | | 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
g.zTop = &g.zBaseURL[7+strlen(zHost)];
}
}
/*
** Preconditions:
**
** * Environment variables are set up according to the CGI standard.
** * The respository database has been located and opened.
**
** Process the webpage specified by the PATH_INFO or REQUEST_URI
** environment variable.
*/
static void process_one_web_page(void){
const char *zPathInfo;
|
| ︙ | ︙ | |||
492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
}
set_base_url();
if( g.zExtra ){
/* CGI parameters get this treatment elsewhere, but places like getfile
** will use g.zExtra directly.
*/
dehttpize(g.zExtra);
}
/* Prevent robots from indexing this site.
*/
if( strcmp(g.zPath, "robots.txt")==0 ){
cgi_set_content_type("text/plain");
@ User-agent: *
| > | 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
}
set_base_url();
if( g.zExtra ){
/* CGI parameters get this treatment elsewhere, but places like getfile
** will use g.zExtra directly.
*/
dehttpize(g.zExtra);
cgi_set_parameter_nocopy("name", g.zExtra);
}
/* Prevent robots from indexing this site.
*/
if( strcmp(g.zPath, "robots.txt")==0 ){
cgi_set_content_type("text/plain");
@ User-agent: *
|
| ︙ | ︙ |
Changes to src/style.c.
| ︙ | ︙ | |||
117 118 119 120 121 122 123 |
for(i=0; i<nSubmenu; i++){
struct Submenu *p = &aSubmenu[i];
char *zTail = i<nSubmenu-1 ? " | " : "";
if( p->zLink==0 ){
@ <span class="label">%h(p->zLabel)</span>
@ <span class="tail">%s(zTail)</span>
}else{
| | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
for(i=0; i<nSubmenu; i++){
struct Submenu *p = &aSubmenu[i];
char *zTail = i<nSubmenu-1 ? " | " : "";
if( p->zLink==0 ){
@ <span class="label">%h(p->zLabel)</span>
@ <span class="tail">%s(zTail)</span>
}else{
@ <a class="label" href="%s(p->zLink)">%h(p->zLabel)</a>
@ <span class="tail">%s(zTail)</span>
}
}
@ </div>
}
@ <div id="page">
g.cgiPanic = 1;
|
| ︙ | ︙ | |||
237 238 239 240 241 242 243 |
/*
** WEBPAGE: test_env
*/
void page_test_env(void){
style_header("Environment Test");
@ g.zBaseURL = %h(g.zBaseURL)<br>
@ g.zTop = %h(g.zTop)<br>
| < | 237 238 239 240 241 242 243 244 245 246 |
/*
** WEBPAGE: test_env
*/
void page_test_env(void){
style_header("Environment Test");
@ g.zBaseURL = %h(g.zBaseURL)<br>
@ g.zTop = %h(g.zTop)<br>
cgi_print_all();
style_footer();
}
|
Changes to src/wiki.c.
| ︙ | ︙ | |||
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
** WEBPAGE: not_found
*/
void home_page(void){
char *zPageName = db_get("project-name",0);
if( zPageName ){
login_check_credentials();
g.zExtra = zPageName;
g.okRdWiki = 1;
g.okApndWiki = 0;
g.okWrWiki = 0;
g.okHistory = 0;
wiki_page();
return;
}
style_header("Home");
@ <p>This is a stub home-page for the project.
@ To fill in this page, first go to
@ <a href="%s(g.zBaseURL)/setup_config">setup/config</a>
@ and establish a "Project Name". Then create a
@ wiki page with that name. The content of that wiki page
@ will be displayed in place of this message.
style_footer();
}
/*
** WEBPAGE: wiki
| > | | < | | | | | | < | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
** WEBPAGE: not_found
*/
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.okApndWiki = 0;
g.okWrWiki = 0;
g.okHistory = 0;
wiki_page();
return;
}
style_header("Home");
@ <p>This is a stub home-page for the project.
@ To fill in this page, first go to
@ <a href="%s(g.zBaseURL)/setup_config">setup/config</a>
@ and establish a "Project Name". Then create a
@ wiki page with that name. The content of that wiki page
@ will be displayed in place of this message.
style_footer();
}
/*
** WEBPAGE: wiki
** URL: /wiki?name=PAGENAME
*/
void wiki_page(void){
char *zTag;
int rid;
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 = PD("name","");
if( check_name(zPageName) ) return;
zTag = mprintf("wiki-%s", zPageName);
rid = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
" ORDER BY mtime DESC", zTag
);
free(zTag);
memset(&m, 0, sizeof(m));
blob_zero(&m.content);
if( rid ){
Blob content;
content_get(rid, &content);
manifest_parse(&m, &content);
if( m.type==CFTYPE_WIKI ){
zBody = m.zWiki;
}
}
if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
style_submenu_element("Edit", "Edit Wiki Page",
mprintf("%s/wikiedit?name=%t", g.zTop, zPageName));
}
if( rid && g.okApndWiki ){
style_submenu_element("Append", "Add A Comment",
mprintf("%s/wikiappend?name=%t", g.zTop, zPageName));
}
if( g.okHistory ){
style_submenu_element("History", "History",
mprintf("%s/whistory?name=%t", g.zTop, zPageName));
}
zHtmlPageName = mprintf("%h", zPageName);
style_header(zHtmlPageName);
blob_init(&wiki, zBody, -1);
wiki_convert(&wiki, 0);
blob_reset(&wiki);
manifest_clear(&m);
style_footer();
}
/*
** WEBPAGE: wikiedit
** URL: /wikiedit?page=PAGENAME
*/
void wikiedit_page(void){
char *zTag;
int rid;
Blob wiki;
Manifest m;
const char *zPageName;
char *zHtmlPageName;
int n;
const char *z;
char *zBody = (char*)P("w");
if( zBody ){
zBody = mprintf("%s", zBody);
}
login_check_credentials();
zPageName = PD("name","");
if( check_name(zPageName) ) return;
zTag = mprintf("wiki-%s", zPageName);
rid = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
" ORDER BY mtime DESC", zTag
);
|
| ︙ | ︙ | |||
222 223 224 225 226 227 228 |
blob_reset(&cksum);
nrid = content_put(&wiki, 0, 0);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
manifest_crosslink(nrid, &wiki);
blob_reset(&wiki);
content_deltify(rid, nrid, 0);
db_end_transaction(0);
| | | | > | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
blob_reset(&cksum);
nrid = content_put(&wiki, 0, 0);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
manifest_crosslink(nrid, &wiki);
blob_reset(&wiki);
content_deltify(rid, nrid, 0);
db_end_transaction(0);
cgi_redirectf("wiki?name=%t", zPageName);
}
if( P("cancel")!=0 ){
cgi_redirectf("wiki?name=%t", zPageName);
return;
}
if( zBody==0 ){
zBody = mprintf("<i>Empty Page</i>");
}
zHtmlPageName = mprintf("Edit: %h", zPageName);
style_header(zHtmlPageName);
if( P("preview")!=0 ){
blob_zero(&wiki);
blob_append(&wiki, zBody, -1);
@ Preview:<hr>
wiki_convert(&wiki, 0);
@ <hr>
blob_reset(&wiki);
}
for(n=2, z=zBody; z[0]; z++){
if( z[0]=='\n' ) n++;
}
if( n<20 ) n = 20;
if( n>200 ) n = 200;
@ <form method="POST" action="%s(g.zBaseURL)/wikiedit">
@ <input type="hidden" name="name" value="%t(zPageName)">
@ <textarea name="w" class="wikiedit" cols="80"
@ rows="%d(n)" wrap="virtual">%h(zBody)</textarea>
@ <br>
@ <input type="submit" name="preview" value="Preview Your Changes">
@ <input type="submit" name="submit" value="Apply These Changes">
@ <input type="submit" name="cancel" value="Cancel">
@ </form>
|
| ︙ | ︙ | |||
279 280 281 282 283 284 285 |
}
zRemark = PD("r","");
blob_appendf(p, " added:\n\n%s", zRemark);
}
/*
** WEBPAGE: wikiappend
| | | < | | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
}
zRemark = PD("r","");
blob_appendf(p, " added:\n\n%s", zRemark);
}
/*
** WEBPAGE: wikiappend
** URL: /wikiappend?name=PAGENAME
*/
void wikiappend_page(void){
char *zTag;
int rid;
const char *zPageName;
char *zHtmlPageName;
const char *zUser;
login_check_credentials();
zPageName = PD("name","");
if( check_name(zPageName) ) return;
zTag = mprintf("wiki-%s", zPageName);
rid = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
" ORDER BY mtime DESC", zTag
);
|
| ︙ | ︙ | |||
349 350 351 352 353 354 355 |
blob_reset(&cksum);
nrid = content_put(&wiki, 0, 0);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
manifest_crosslink(nrid, &wiki);
blob_reset(&wiki);
content_deltify(rid, nrid, 0);
db_end_transaction(0);
| | | | > > | < > > | | | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
blob_reset(&cksum);
nrid = content_put(&wiki, 0, 0);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
manifest_crosslink(nrid, &wiki);
blob_reset(&wiki);
content_deltify(rid, nrid, 0);
db_end_transaction(0);
cgi_redirectf("wiki?name=%t", zPageName);
}
if( P("cancel")!=0 ){
cgi_redirectf("wiki?name=%t", zPageName);
return;
}
zHtmlPageName = mprintf("Append Comment To: %h", zPageName);
style_header(zHtmlPageName);
if( P("preview")!=0 ){
Blob preview;
blob_zero(&preview);
appendRemark(&preview);
@ Preview:<hr>
wiki_convert(&preview, 0);
@ <hr>
blob_reset(&preview);
}
zUser = PD("u", g.zLogin);
@ <form method="POST" action="%s(g.zBaseURL)/wikiappend">
@ <input type="hidden" name="name" value="%t(zPageName)">
@ Your Name:
@ <input type="text" name="u" size="20" value="%h(zUser)"><br>
@ Comment to append:<br>
@ <textarea name="r" class="wikiedit" cols="80"
@ rows="10" wrap="virtual">%h(PD("r",""))</textarea>
@ <br>
@ <input type="submit" name="preview" value="Preview Your Comment">
@ <input type="submit" name="submit" value="Append Your Changes">
@ <input type="submit" name="cancel" value="Cancel">
@ </form>
style_footer();
}
/*
** WEBPAGE: whistory
** URL: /whistory?name=PAGENAME
**
** Show the complete change history for a single wiki page.
*/
void whistory_page(void){
Stmt q;
char *zTitle;
char *zSQL;
const char *zPageName;
login_check_credentials();
if( !g.okHistory ){ login_needed(); return; }
zPageName = PD("name","");
zTitle = mprintf("History Of %h", zPageName);
style_header(zTitle);
free(zTitle);
zSQL = mprintf("%s AND event.objid IN "
" (SELECT rid FROM tagxref WHERE tagid="
"(SELECT tagid FROM tag WHERE tagname='wiki-%q'))"
"ORDER BY mtime DESC",
timeline_query_for_www(), zPageName);
db_prepare(&q, zSQL);
free(zSQL);
www_print_timeline(&q, 0, 0, 0, 0);
db_finalize(&q);
style_footer();
}
|
| ︙ | ︙ | |||
426 427 428 429 430 431 432 |
@ <ul>
db_prepare(&q,
"SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname GLOB 'wiki-*'"
" ORDER BY lower(tagname)"
);
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
| | < < < < < < < < < < < < < < < < < < < < < < < < < < | 428 429 430 431 432 433 434 435 436 437 438 439 |
@ <ul>
db_prepare(&q,
"SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname GLOB 'wiki-*'"
" ORDER BY lower(tagname)"
);
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
@ <li><a href="%s(g.zBaseURL)/wiki?page=%t(zName)">%h(zName)</a></li>
}
db_finalize(&q);
style_footer();
}
|
Changes to src/zip.c.
| ︙ | ︙ | |||
320 321 322 323 324 325 326 327 | rid = name_to_rid(g.argv[2]); zip_of_baseline(rid, &zip); blob_write_to_file(&zip, g.argv[3]); } /* ** WEBPAGE: zip ** | > | | | | 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
rid = name_to_rid(g.argv[2]);
zip_of_baseline(rid, &zip);
blob_write_to_file(&zip, g.argv[3]);
}
/*
** WEBPAGE: zip
** URL: /zip/RID.zip
**
** Generate a ZIP archive for the baseline.
** Return that ZIP archive as the HTTP reply content.
*/
void baseline_zip_page(void){
int rid;
char *zName;
int i;
Blob zip;
login_check_credentials();
if( !g.okRead || !g.okHistory ){ login_needed(); return; }
zName = mprintf("%s", PD("name",""));
i = strlen(zName);
for(i=strlen(zName)-1; i>5; i--){
if( zName[i]=='.' ){
zName[i] = 0;
break;
}
}
|
| ︙ | ︙ |