Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Added a "wiki" link to the main menu. Added built-in description of wiki formatting rules. Added a wiki "homepage" that displays when the "wiki" URI is used without a pagename. Added support for a wiki sandbox that does not save to the repository. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
f08adf3d58c4afc0bc526618440f0e46 |
| User & Date: | drh 2007-10-28 23:27:12.000 |
Context
|
2007-11-03
| ||
| 04:01 | Subscript interpreter is now running. ... (check-in: 8ef26c5e72 user: drh tags: trunk) | |
|
2007-10-28
| ||
| 23:27 | Added a "wiki" link to the main menu. Added built-in description of wiki formatting rules. Added a wiki "homepage" that displays when the "wiki" URI is used without a pagename. Added support for a wiki sandbox that does not save to the repository. ... (check-in: f08adf3d58 user: drh tags: trunk) | |
| 21:26 | The "wiki" URI without a page name argument now gives you a list of existing wiki pages. This works fine as long as there are a reasonable number (no more than a few hundred) wiki pages. We need to think of something better for large wikis. We also need to think of ways to give users better guidance for creating new wiki pages. ... (check-in: f40230a7e8 user: drh tags: trunk) | |
Changes
Changes to src/style.c.
| ︙ | ︙ | |||
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
@ </div>
@ <div id="main-menu">
@ <a href="%s(g.zBaseURL)/home">Home</a>
if( g.okRead ){
@ | <a href="%s(g.zBaseURL)/leaves">Leaves</a>
@ | <a href="%s(g.zBaseURL)/timeline">Timeline</a>
}
#if 0
@ | <font color="#888888">Search</font>
@ | <font color="#888888">Ticket</font>
@ | <font color="#888888">Reports</font>
#endif
if( g.okSetup ){
@ | <a href="%s(g.zBaseURL)/setup">Setup</a>
| > > > | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
@ </div>
@ <div id="main-menu">
@ <a href="%s(g.zBaseURL)/home">Home</a>
if( g.okRead ){
@ | <a href="%s(g.zBaseURL)/leaves">Leaves</a>
@ | <a href="%s(g.zBaseURL)/timeline">Timeline</a>
}
if( g.okRdWiki ){
@ | <a href="%s(g.zBaseURL)/wiki">Wiki</a>
}
#if 0
@ | <font color="#888888">Search</font>
@ | <font color="#888888">Ticket</font>
@ | <font color="#888888">Reports</font>
#endif
if( g.okSetup ){
@ | <a href="%s(g.zBaseURL)/setup">Setup</a>
|
| ︙ | ︙ |
Changes to src/wiki.c.
| ︙ | ︙ | |||
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 |
@ 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 = P("name");
if( zPageName==0 ){
| > > > > > > > > > > > > | > > > > > > > > > > > > | | | | | | | | | | | | | | | | | > | | | > | > > > > > > > > | | | | | | | | | | | | | | | | | | | > > > > | | | | | | | | | | | | | | | | | | | | | | > | 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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 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 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
@ 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();
}
/*
** Return true if the given pagename is the name of the sandbox
*/
static int is_sandbox(const char *zPagename){
return strcasecmp(zPagename,"sandbox")==0 ||
strcasecmp(zPagename,"sand box")==0;
}
/*
** WEBPAGE: wiki
** URL: /wiki?name=PAGENAME
*/
void wiki_page(void){
char *zTag;
int rid;
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>
@ <li> <a href="%s(g.zBaseURL)/timeline?y=w">Recent changes</a> to wiki
@ pages. </li>
@ <li> <a href="%s(g.zBaseURL)/wiki_rules">Formatting rules</a> for
@ wiki.</li>
@ <li> Use the <a href="%s(g.zBaseURL)/wiki?name=Sandbox">Sandbox</a>
@ to experiment.</li>
@ <li> <a href="%s(g.zBaseURL)/wcontent">List of All Wiki Pages</a>
@ available on this server.</li>
@ </ul>
style_footer();
return;
}
if( check_name(zPageName) ) return;
isSandbox = is_sandbox(zPageName);
if( isSandbox ){
zBody = db_get("sandbox",zBody);
}else{
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( isSandbox || (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
style_submenu_element("Edit", "Edit Wiki Page",
mprintf("%s/wikiedit?name=%T", g.zTop, zPageName));
}
if( isSandbox || (rid && g.okApndWiki) ){
style_submenu_element("Append", "Add A Comment",
mprintf("%s/wikiappend?name=%T", g.zTop, zPageName));
}
if( !isSandbox && 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, 0);
blob_reset(&wiki);
if( !isSandbox ){
manifest_clear(&m);
}
style_footer();
}
/*
** WEBPAGE: wikiedit
** URL: /wikiedit?name=PAGENAME
*/
void wikiedit_page(void){
char *zTag;
int rid;
int isSandbox;
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;
isSandbox = is_sandbox(zPageName);
if( isSandbox ){
if( zBody==0 ){
zBody = db_get("sandbox","");
}
}else{
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);
if( (rid && !g.okWrWiki) || (!rid && !g.okNewWiki) ){
login_needed();
return;
}
memset(&m, 0, sizeof(m));
blob_zero(&m.content);
if( rid && zBody==0 ){
Blob content;
content_get(rid, &content);
manifest_parse(&m, &content);
if( m.type==CFTYPE_WIKI ){
zBody = m.zWiki;
}
}
}
if( P("submit")!=0 && zBody!=0 ){
char *zDate;
Blob cksum;
int nrid;
blob_zero(&wiki);
db_begin_transaction();
if( isSandbox ){
db_set("sandbox",zBody,0);
}else{
zDate = db_text(0, "SELECT datetime('now')");
zDate[10] = 'T';
blob_appendf(&wiki, "D %s\n", zDate);
free(zDate);
blob_appendf(&wiki, "L %F\n", zPageName);
if( rid ){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
blob_appendf(&wiki, "P %s\n", zUuid);
free(zUuid);
}
if( g.zLogin ){
blob_appendf(&wiki, "U %F\n", g.zLogin);
}
blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody);
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
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;
}
|
| ︙ | ︙ | |||
258 259 260 261 262 263 264 | @ <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> | > | > | | > > > | | | | | | | | | | > < < > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 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 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 |
@ <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>
if( !isSandbox ){
manifest_clear(&m);
}
style_footer();
}
/*
** Append the wiki text for an remark to the end of the given BLOB.
*/
static void appendRemark(Blob *p){
char *zDate;
const char *zUser;
const char *zRemark;
zDate = db_text(0, "SELECT datetime('now')");
blob_appendf(p, "\n\n<hr><i>On %s UTC %h", zDate, g.zLogin);
free(zDate);
zUser = PD("u",g.zLogin);
if( zUser[0] && strcmp(zUser,g.zLogin) ){
blob_appendf(p, " (claiming to be %h)", zUser);
}
zRemark = PD("r","");
blob_appendf(p, " added:</i><br />\n%s", zRemark);
}
/*
** WEBPAGE: wikiappend
** URL: /wikiappend?name=PAGENAME
*/
void wikiappend_page(void){
char *zTag;
int rid;
int isSandbox;
const char *zPageName;
char *zHtmlPageName;
const char *zUser;
login_check_credentials();
zPageName = PD("name","");
if( check_name(zPageName) ) return;
isSandbox = is_sandbox(zPageName);
if( !isSandbox ){
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);
if( !rid ){
cgi_redirect("index");
return;
}
}
if( !g.okApndWiki ){
login_needed();
return;
}
if( P("submit")!=0 && P("r")!=0 && P("u")!=0 ){
char *zDate;
Blob cksum;
int nrid;
Blob body;
Blob content;
Blob wiki;
Manifest m;
blob_zero(&body);
if( isSandbox ){
blob_appendf(&body, db_get("sandbox",""));
appendRemark(&body);
db_set("sandbox", blob_str(&body), 0);
}else{
content_get(rid, &content);
manifest_parse(&m, &content);
if( m.type==CFTYPE_WIKI ){
blob_appendf(&body, m.zWiki, -1);
}
manifest_clear(&m);
blob_zero(&wiki);
db_begin_transaction();
zDate = db_text(0, "SELECT datetime('now')");
zDate[10] = 'T';
blob_appendf(&wiki, "D %s\n", zDate);
blob_appendf(&wiki, "L %F\n", zPageName);
if( rid ){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
blob_appendf(&wiki, "P %s\n", zUuid);
free(zUuid);
}
if( g.zLogin ){
blob_appendf(&wiki, "U %F\n", g.zLogin);
}
blob_appendf(&body, "\n<hr>\n");
appendRemark(&body);
blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
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);
|
| ︙ | ︙ | |||
438 439 440 441 442 443 444 |
const char *zName = db_column_text(&q, 0);
@ <li><a href="%s(g.zBaseURL)/wiki?name=%T(zName)">%h(zName)</a></li>
}
db_finalize(&q);
@ </ul>
style_footer();
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 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 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
const char *zName = db_column_text(&q, 0);
@ <li><a href="%s(g.zBaseURL)/wiki?name=%T(zName)">%h(zName)</a></li>
}
db_finalize(&q);
@ </ul>
style_footer();
}
/*
** WEBPAGE: wiki_rules
*/
void wikirules_page(void){
style_header("Wiki Formatting Rules");
@ <h2>Formatting Rule Summary</h2>
@ <ol>
@ <li> Blank lines are paragraph breaks
@ <li> Bullet list items are a "*" at the beginning of the line.
@ <li> Enumeration list items are a number at the beginning of a line.
@ <li> Indented pargraphs begin with a tab or two spaces.
@ <li> Hyperlinks are contained with square brackets: "[target]"
@ <li> Most ordinary HTML works.
@ <li> <verbatim> and <nowiki>.
@ </ol>
@ <p>We call the first five rules above "wiki" formatting rules. The
@ last two rules are the HTML formatting rule.</p>
@ <h2>Formatting Rule Details</h2>
@ <ol>
@ <li> <p><b>Paragraphs</b>. Any sequence of one or more blank lines forms
@ a paragraph break. Centered or right-justified paragraphs are not
@ supported by wiki markup, but you can do these things if you need them
@ using HTML.</p>
@ <li> <p><b>Bullet Lists</b>.
@ A bullet list item begins with a single "*" character surrounded on
@ both sides by two or more spaces or by a tab. Only a single level
@ of bullet list is supported by wiki. For tested lists, use HTML.</p>
@ <li> <p><b>Enumeration Lists</b>.
@ An enumeration list item begins with one or more digits optionally
@ followed by a "." surrounded on both sides by two or more spaces or
@ by a tab. The number is significant and becomes the number shown
@ in the rendered enumeration item. Only a single level of enumeration
@ list is supported by wiki. For nested enumerations or for
@ enumerations that count using letters or roman numerials, use HTML.</p>
@ <li> <p><b>Indented Paragraphs</b>.
@ Any paragraph that begins with two or more spaces or a tab and
@ which is not a bullet or enumeration list item is rendered
@ indented. Only a single level of indentation is supported by</p>
@ <li> <p><b>Hyperlinks</b>.
@ Text within square brackets ("[...]") becomes a hyperlink. The
@ target can be a wiki page name, the UUID of a check-in or ticket,
@ the name of an image, or a URL. By default, the target is displayed
@ as the text of the hyperlink. But you can specify alternative text
@ after the target name separated by a "|" character.</p>
@ <li> <p><b>HTML</b>.
@ The following standard HTML elements may be used:
@ <a>
@ <address>
@ <b>
@ <big>
@ <blockquote>
@ <br>
@ <center>
@ <cite>
@ <code>
@ <dd>
@ <dfn>
@ <dl>
@ <dt>
@ <em>
@ <font>
@ <h1>
@ <h2>
@ <h3>
@ <h4>
@ <h5>
@ <h6>
@ <hr>
@ <img>
@ <i>
@ <kbd>
@ <li>
@ <nobr>
@ <ol>
@ <p>
@ <pre>
@ <s>
@ <samp>
@ <small>
@ <strike>
@ <strong>
@ <sub>
@ <sup>
@ <table>
@ <td>
@ <th>
@ <tr>
@ <tt>
@ <u>
@ <ul>
@ <var>.
@ In addition, there are two non-standard elements available:
@ <verbatim> and <nowiki>.
@ No other elements are allowed. All attributes are checked and
@ only a few benign attributes are allowed on each element.
@ In particular, any attributes that specify javascript or CSS
@ are elided.</p>
@ <p>The <verbatim> tag disables all wiki and HTML markup
@ up through the next </verbatim>. The <nowiki> tag
@ disables all wiki formatting rules through the matching
@ </nowiki> element.
@ </ol>
style_footer();
}
|