Fossil SCM

Many changes and bug fixes in the wiki processing. Moving toward a workable wiki system. The "Home" menu option now takes you to the wiki page whose name is the same as the Project Name. There is a "wcontent" page, but no link to it yet. Many other changes.

drh 2007-10-10 21:15 trunk
Commit 50a58adb76175391f3179deff1fb954a204b0f93
+1 -1
--- src/info.c
+++ src/info.c
@@ -421,11 +421,11 @@
421421
}
422422
@ <tr><th>Original&nbsp;User:</th><td>%s(db_column_text(&q, 3))</td></tr>
423423
@ <tr><th>Commands:</th>
424424
@ <td>
425425
/* @ <a href="%s(g.zBaseURL)/wdiff/%d(rid)">diff</a> | */
426
- @ <a href="%s(g.zBaseURL)/wlist/%t(zName)">history</a>
426
+ @ <a href="%s(g.zBaseURL)/whistory/%t(zName)">history</a>
427427
@ | <a href="%s(g.zBaseURL)/fview/%d(rid)">raw-text</a>
428428
@ </td>
429429
@ </tr>
430430
@ </table></p>
431431
}else{
432432
--- src/info.c
+++ src/info.c
@@ -421,11 +421,11 @@
421 }
422 @ <tr><th>Original&nbsp;User:</th><td>%s(db_column_text(&q, 3))</td></tr>
423 @ <tr><th>Commands:</th>
424 @ <td>
425 /* @ <a href="%s(g.zBaseURL)/wdiff/%d(rid)">diff</a> | */
426 @ <a href="%s(g.zBaseURL)/wlist/%t(zName)">history</a>
427 @ | <a href="%s(g.zBaseURL)/fview/%d(rid)">raw-text</a>
428 @ </td>
429 @ </tr>
430 @ </table></p>
431 }else{
432
--- src/info.c
+++ src/info.c
@@ -421,11 +421,11 @@
421 }
422 @ <tr><th>Original&nbsp;User:</th><td>%s(db_column_text(&q, 3))</td></tr>
423 @ <tr><th>Commands:</th>
424 @ <td>
425 /* @ <a href="%s(g.zBaseURL)/wdiff/%d(rid)">diff</a> | */
426 @ <a href="%s(g.zBaseURL)/whistory/%t(zName)">history</a>
427 @ | <a href="%s(g.zBaseURL)/fview/%d(rid)">raw-text</a>
428 @ </td>
429 @ </tr>
430 @ </table></p>
431 }else{
432
+1 -1
--- src/login.c
+++ src/login.c
@@ -287,11 +287,11 @@
287287
*/
288288
void login_set_capabilities(const char *zCap){
289289
int i;
290290
for(i=0; zCap[i]; i++){
291291
switch( zCap[i] ){
292
- case 's': g.okSetup = g.okDelete = 1;
292
+ case 's': g.okSetup = 1;
293293
case 'a': g.okAdmin = g.okRdTkt = g.okWrTkt = g.okQuery =
294294
g.okRdWiki = g.okWrWiki = g.okNewWiki =
295295
g.okHistory = g.okClone =
296296
g.okNewTkt = g.okPassword = 1;
297297
case 'i': g.okRead = g.okWrite = 1; break;
298298
--- src/login.c
+++ src/login.c
@@ -287,11 +287,11 @@
287 */
288 void login_set_capabilities(const char *zCap){
289 int i;
290 for(i=0; zCap[i]; i++){
291 switch( zCap[i] ){
292 case 's': g.okSetup = g.okDelete = 1;
293 case 'a': g.okAdmin = g.okRdTkt = g.okWrTkt = g.okQuery =
294 g.okRdWiki = g.okWrWiki = g.okNewWiki =
295 g.okHistory = g.okClone =
296 g.okNewTkt = g.okPassword = 1;
297 case 'i': g.okRead = g.okWrite = 1; break;
298
--- src/login.c
+++ src/login.c
@@ -287,11 +287,11 @@
287 */
288 void login_set_capabilities(const char *zCap){
289 int i;
290 for(i=0; zCap[i]; i++){
291 switch( zCap[i] ){
292 case 's': g.okSetup = 1;
293 case 'a': g.okAdmin = g.okRdTkt = g.okWrTkt = g.okQuery =
294 g.okRdWiki = g.okWrWiki = g.okNewWiki =
295 g.okHistory = g.okClone =
296 g.okNewTkt = g.okPassword = 1;
297 case 'i': g.okRead = g.okWrite = 1; break;
298
+12 -7
--- src/main.c
+++ src/main.c
@@ -59,10 +59,11 @@
5959
int fSqlPrint; /* True if -sqlprint flag is present */
6060
int fHttpTrace; /* Trace outbound HTTP requests */
6161
char *zPath; /* Name of webpage being served */
6262
char *zExtra; /* Extra path information past the webpage name */
6363
char *zBaseURL; /* Full text of the URL being served */
64
+ char *zTop; /* Parent directory of zPath */
6465
const char *zContentType; /* The content type of the input HTTP request */
6566
int iErrPriority; /* Priority of current error message */
6667
char *zErrMsg; /* Text of an error message */
6768
Blob cgiIn; /* Input to an xfer www method */
6869
int cgiPanic; /* Write error messages to CGI */
@@ -98,10 +99,11 @@
9899
int okClone; /* g: clone */
99100
int okRdWiki; /* j: view wiki via web */
100101
int okNewWiki; /* f: create new wiki via web */
101102
int okApndWiki; /* m: append to wiki via web */
102103
int okWrWiki; /* k: edit wiki via web */
104
+ int okLockWiki; /* l: lock and unlock wiki via web */
103105
int okRdTkt; /* r: view tickets via web */
104106
int okNewTkt; /* n: create new tickets */
105107
int okApndTkt; /* c: append to tickets via the web */
106108
int okWrTkt; /* w: make changes to tickets via web */
107109
@@ -412,15 +414,15 @@
412414
}
413415
putchar('\n');
414416
}
415417
416418
/*
417
-** RSS feeds need to reference absolute URLs so we need to calculate
418
-** the base URL onto which we add components. This is basically
419
-** cgi_redirect() stripped down and always returning an absolute URL.
419
+** Set the g.zBaseURL value to the full URL for the toplevel of
420
+** the fossil tree. Set g.zHomeURL to g.zBaseURL without the
421
+** leading "http://" and the host and port.
420422
*/
421
-static char *get_base_url(void){
423
+void set_base_url(void){
422424
int i;
423425
const char *zHost = PD("HTTP_HOST","");
424426
const char *zMode = PD("HTTPS","off");
425427
const char *zCur = PD("REQUEST_URI","/");
426428
@@ -436,13 +438,16 @@
436438
}
437439
while( i>0 && zCur[i-1]!='/' ){ i--; }
438440
while( i>0 && zCur[i-1]=='/' ){ i--; }
439441
440442
if( strcmp(zMode,"on")==0 ){
441
- return mprintf("https://%s%.*s", zHost, i, zCur);
443
+ g.zBaseURL = mprintf("https://%s%.*s", zHost, i, zCur);
444
+ g.zTop = &g.zBaseURL[8+strlen(zHost)+i];
445
+ }else{
446
+ g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur);
447
+ g.zTop = &g.zBaseURL[7+strlen(zHost)+i];
442448
}
443
- return mprintf("http://%s%.*s", zHost, i, zCur);
444449
}
445450
446451
/*
447452
** Preconditions:
448453
**
@@ -484,11 +489,11 @@
484489
zPath[i] = 0;
485490
g.zExtra = &zPath[i+1];
486491
}else{
487492
g.zExtra = 0;
488493
}
489
- g.zBaseURL = get_base_url();
494
+ set_base_url();
490495
if( g.zExtra ){
491496
/* CGI parameters get this treatment elsewhere, but places like getfile
492497
** will use g.zExtra directly.
493498
*/
494499
dehttpize(g.zExtra);
495500
--- src/main.c
+++ src/main.c
@@ -59,10 +59,11 @@
59 int fSqlPrint; /* True if -sqlprint flag is present */
60 int fHttpTrace; /* Trace outbound HTTP requests */
61 char *zPath; /* Name of webpage being served */
62 char *zExtra; /* Extra path information past the webpage name */
63 char *zBaseURL; /* Full text of the URL being served */
 
64 const char *zContentType; /* The content type of the input HTTP request */
65 int iErrPriority; /* Priority of current error message */
66 char *zErrMsg; /* Text of an error message */
67 Blob cgiIn; /* Input to an xfer www method */
68 int cgiPanic; /* Write error messages to CGI */
@@ -98,10 +99,11 @@
98 int okClone; /* g: clone */
99 int okRdWiki; /* j: view wiki via web */
100 int okNewWiki; /* f: create new wiki via web */
101 int okApndWiki; /* m: append to wiki via web */
102 int okWrWiki; /* k: edit wiki via web */
 
103 int okRdTkt; /* r: view tickets via web */
104 int okNewTkt; /* n: create new tickets */
105 int okApndTkt; /* c: append to tickets via the web */
106 int okWrTkt; /* w: make changes to tickets via web */
107
@@ -412,15 +414,15 @@
412 }
413 putchar('\n');
414 }
415
416 /*
417 ** RSS feeds need to reference absolute URLs so we need to calculate
418 ** the base URL onto which we add components. This is basically
419 ** cgi_redirect() stripped down and always returning an absolute URL.
420 */
421 static char *get_base_url(void){
422 int i;
423 const char *zHost = PD("HTTP_HOST","");
424 const char *zMode = PD("HTTPS","off");
425 const char *zCur = PD("REQUEST_URI","/");
426
@@ -436,13 +438,16 @@
436 }
437 while( i>0 && zCur[i-1]!='/' ){ i--; }
438 while( i>0 && zCur[i-1]=='/' ){ i--; }
439
440 if( strcmp(zMode,"on")==0 ){
441 return mprintf("https://%s%.*s", zHost, i, zCur);
 
 
 
 
442 }
443 return mprintf("http://%s%.*s", zHost, i, zCur);
444 }
445
446 /*
447 ** Preconditions:
448 **
@@ -484,11 +489,11 @@
484 zPath[i] = 0;
485 g.zExtra = &zPath[i+1];
486 }else{
487 g.zExtra = 0;
488 }
489 g.zBaseURL = get_base_url();
490 if( g.zExtra ){
491 /* CGI parameters get this treatment elsewhere, but places like getfile
492 ** will use g.zExtra directly.
493 */
494 dehttpize(g.zExtra);
495
--- src/main.c
+++ src/main.c
@@ -59,10 +59,11 @@
59 int fSqlPrint; /* True if -sqlprint flag is present */
60 int fHttpTrace; /* Trace outbound HTTP requests */
61 char *zPath; /* Name of webpage being served */
62 char *zExtra; /* Extra path information past the webpage name */
63 char *zBaseURL; /* Full text of the URL being served */
64 char *zTop; /* Parent directory of zPath */
65 const char *zContentType; /* The content type of the input HTTP request */
66 int iErrPriority; /* Priority of current error message */
67 char *zErrMsg; /* Text of an error message */
68 Blob cgiIn; /* Input to an xfer www method */
69 int cgiPanic; /* Write error messages to CGI */
@@ -98,10 +99,11 @@
99 int okClone; /* g: clone */
100 int okRdWiki; /* j: view wiki via web */
101 int okNewWiki; /* f: create new wiki via web */
102 int okApndWiki; /* m: append to wiki via web */
103 int okWrWiki; /* k: edit wiki via web */
104 int okLockWiki; /* l: lock and unlock wiki via web */
105 int okRdTkt; /* r: view tickets via web */
106 int okNewTkt; /* n: create new tickets */
107 int okApndTkt; /* c: append to tickets via the web */
108 int okWrTkt; /* w: make changes to tickets via web */
109
@@ -412,15 +414,15 @@
414 }
415 putchar('\n');
416 }
417
418 /*
419 ** Set the g.zBaseURL value to the full URL for the toplevel of
420 ** the fossil tree. Set g.zHomeURL to g.zBaseURL without the
421 ** leading "http://" and the host and port.
422 */
423 void set_base_url(void){
424 int i;
425 const char *zHost = PD("HTTP_HOST","");
426 const char *zMode = PD("HTTPS","off");
427 const char *zCur = PD("REQUEST_URI","/");
428
@@ -436,13 +438,16 @@
438 }
439 while( i>0 && zCur[i-1]!='/' ){ i--; }
440 while( i>0 && zCur[i-1]=='/' ){ i--; }
441
442 if( strcmp(zMode,"on")==0 ){
443 g.zBaseURL = mprintf("https://%s%.*s", zHost, i, zCur);
444 g.zTop = &g.zBaseURL[8+strlen(zHost)+i];
445 }else{
446 g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur);
447 g.zTop = &g.zBaseURL[7+strlen(zHost)+i];
448 }
 
449 }
450
451 /*
452 ** Preconditions:
453 **
@@ -484,11 +489,11 @@
489 zPath[i] = 0;
490 g.zExtra = &zPath[i+1];
491 }else{
492 g.zExtra = 0;
493 }
494 set_base_url();
495 if( g.zExtra ){
496 /* CGI parameters get this treatment elsewhere, but places like getfile
497 ** will use g.zExtra directly.
498 */
499 dehttpize(g.zExtra);
500
+10 -3
--- src/setup.c
+++ src/setup.c
@@ -130,10 +130,11 @@
130130
@ <li value="7"><b>Clone</b>: Clone the repository</li>
131131
@ <li value="8"><b>History</b>: View detail repository history</li>
132132
@ <li value="9"><b>Check-In</b>: Commit new versions in the repository</li>
133133
@ <li value="10"><b>Read-Wiki</b>: View wiki pages</li>
134134
@ <li value="11"><b>Write-Wiki</b>: Edit wiki pages</li>
135
+ @ <li value="12"><b>Lock-Wiki</b>: Lock or unlock wiki pages</li>
135136
@ <li value="13"><b>Append-Wiki</b>: Append to wiki pages</li>
136137
@ <li value="14"><b>New-Tkt</b>: Create new tickets</li>
137138
@ <li value="15"><b>Check-Out</b>: Check out versions</li>
138139
@ <li value="16"><b>Password</b>: Change your own password</li>
139140
@ <li value="17"><b>Query</b>: Create new queries against tickets</li>
@@ -159,11 +160,11 @@
159160
** WEBPAGE: /setup_uedit
160161
*/
161162
void user_edit(void){
162163
const char *zId, *zLogin, *zInfo, *zCap;
163164
char *oaa, *oas, *oar, *oaw, *oan, *oai, *oaj, *oao, *oap ;
164
- char *oak, *oad, *oaq, *oac, *oaf, *oam, *oah, *oag;
165
+ char *oak, *oad, *oaq, *oac, *oaf, *oam, *oah, *oag, *oal;
165166
int doWrite;
166167
int uid;
167168
int higherUser = 0; /* True if user being edited is SETUP and the */
168169
/* user doing the editing is ADMIN. Disallow editing */
169170
@@ -213,19 +214,21 @@
213214
int ac = P("ac")!=0;
214215
int af = P("af")!=0;
215216
int am = P("am")!=0;
216217
int ah = P("ah")!=0;
217218
int ag = P("ag")!=0;
219
+ int al = P("al")!=0;
218220
if( aa ){ zCap[i++] = 'a'; }
219221
if( ac ){ zCap[i++] = 'c'; }
220222
if( ad ){ zCap[i++] = 'd'; }
221223
if( af ){ zCap[i++] = 'f'; }
222224
if( ah ){ zCap[i++] = 'h'; }
223225
if( ag ){ zCap[i++] = 'g'; }
224226
if( ai ){ zCap[i++] = 'i'; }
225227
if( aj ){ zCap[i++] = 'j'; }
226228
if( ak ){ zCap[i++] = 'k'; }
229
+ if( al ){ zCap[i++] = 'l'; }
227230
if( am ){ zCap[i++] = 'm'; }
228231
if( an ){ zCap[i++] = 'n'; }
229232
if( ao ){ zCap[i++] = 'o'; }
230233
if( ap ){ zCap[i++] = 'p'; }
231234
if( aq ){ zCap[i++] = 'q'; }
@@ -262,11 +265,11 @@
262265
/* Load the existing information about the user, if any
263266
*/
264267
zLogin = "";
265268
zInfo = "";
266269
zCap = "";
267
- oaa = oac = oad = oaf = oag = oah = oai = oaj = oak = oam =
270
+ oaa = oac = oad = oaf = oag = oah = oai = oaj = oak = oal = oam =
268271
oan = oao = oap = oaq = oar = oas = oaw = "";
269272
if( uid ){
270273
zLogin = db_text("", "SELECT login FROM user WHERE uid=%d", uid);
271274
zInfo = db_text("", "SELECT info FROM user WHERE uid=%d", uid);
272275
zCap = db_text("", "SELECT cap FROM user WHERE uid=%d", uid);
@@ -277,10 +280,11 @@
277280
if( strchr(zCap, 'g') ) oag = " checked";
278281
if( strchr(zCap, 'h') ) oah = " checked";
279282
if( strchr(zCap, 'i') ) oai = " checked";
280283
if( strchr(zCap, 'j') ) oaj = " checked";
281284
if( strchr(zCap, 'k') ) oak = " checked";
285
+ if( strchr(zCap, 'l') ) oal = " checked";
282286
if( strchr(zCap, 'm') ) oam = " checked";
283287
if( strchr(zCap, 'n') ) oan = " checked";
284288
if( strchr(zCap, 'o') ) oao = " checked";
285289
if( strchr(zCap, 'p') ) oap = " checked";
286290
if( strchr(zCap, 'q') ) oaq = " checked";
@@ -332,10 +336,11 @@
332336
@ <input type="checkbox" name="ag"%s(oag)>Clone</input><br>
333337
@ <input type="checkbox" name="aj"%s(oaj)>Read Wiki</input><br>
334338
@ <input type="checkbox" name="af"%s(oaf)>New Wiki</input><br>
335339
@ <input type="checkbox" name="am"%s(oam)>Append Wiki</input><br>
336340
@ <input type="checkbox" name="ak"%s(oak)>Write Wiki</input><br>
341
+ @ <input type="checkbox" name="al"%s(oak)>Lock Wiki</input><br>
337342
@ <input type="checkbox" name="ar"%s(oar)>Read Tkt</input><br>
338343
@ <input type="checkbox" name="an"%s(oan)>New Tkt</input><br>
339344
@ <input type="checkbox" name="ac"%s(oac)>Append Tkt</input><br>
340345
@ <input type="checkbox" name="aw"%s(oaw)>Write Tkt</input>
341346
@ </td>
@@ -362,11 +367,13 @@
362367
}
363368
@
364369
@ <li><p>
365370
@ The <b>Delete</b> privilege give the user the ability to erase
366371
@ wiki, tickets, and atttachments that have been added by anonymous
367
- @ users. This capability is intended for deletion of spam.
372
+ @ users. This capability is intended for deletion of spam. The
373
+ @ delete capability is only in effect for 24 hours after the item
374
+ @ is first posted. The Setup user can delete anything at any time.
368375
@ </p></li>
369376
@
370377
@ <li><p>
371378
@ The <b>Query</b> privilege allows the user to create or edit
372379
@ report formats by specifying appropriate SQL. Users can run
373380
--- src/setup.c
+++ src/setup.c
@@ -130,10 +130,11 @@
130 @ <li value="7"><b>Clone</b>: Clone the repository</li>
131 @ <li value="8"><b>History</b>: View detail repository history</li>
132 @ <li value="9"><b>Check-In</b>: Commit new versions in the repository</li>
133 @ <li value="10"><b>Read-Wiki</b>: View wiki pages</li>
134 @ <li value="11"><b>Write-Wiki</b>: Edit wiki pages</li>
 
135 @ <li value="13"><b>Append-Wiki</b>: Append to wiki pages</li>
136 @ <li value="14"><b>New-Tkt</b>: Create new tickets</li>
137 @ <li value="15"><b>Check-Out</b>: Check out versions</li>
138 @ <li value="16"><b>Password</b>: Change your own password</li>
139 @ <li value="17"><b>Query</b>: Create new queries against tickets</li>
@@ -159,11 +160,11 @@
159 ** WEBPAGE: /setup_uedit
160 */
161 void user_edit(void){
162 const char *zId, *zLogin, *zInfo, *zCap;
163 char *oaa, *oas, *oar, *oaw, *oan, *oai, *oaj, *oao, *oap ;
164 char *oak, *oad, *oaq, *oac, *oaf, *oam, *oah, *oag;
165 int doWrite;
166 int uid;
167 int higherUser = 0; /* True if user being edited is SETUP and the */
168 /* user doing the editing is ADMIN. Disallow editing */
169
@@ -213,19 +214,21 @@
213 int ac = P("ac")!=0;
214 int af = P("af")!=0;
215 int am = P("am")!=0;
216 int ah = P("ah")!=0;
217 int ag = P("ag")!=0;
 
218 if( aa ){ zCap[i++] = 'a'; }
219 if( ac ){ zCap[i++] = 'c'; }
220 if( ad ){ zCap[i++] = 'd'; }
221 if( af ){ zCap[i++] = 'f'; }
222 if( ah ){ zCap[i++] = 'h'; }
223 if( ag ){ zCap[i++] = 'g'; }
224 if( ai ){ zCap[i++] = 'i'; }
225 if( aj ){ zCap[i++] = 'j'; }
226 if( ak ){ zCap[i++] = 'k'; }
 
227 if( am ){ zCap[i++] = 'm'; }
228 if( an ){ zCap[i++] = 'n'; }
229 if( ao ){ zCap[i++] = 'o'; }
230 if( ap ){ zCap[i++] = 'p'; }
231 if( aq ){ zCap[i++] = 'q'; }
@@ -262,11 +265,11 @@
262 /* Load the existing information about the user, if any
263 */
264 zLogin = "";
265 zInfo = "";
266 zCap = "";
267 oaa = oac = oad = oaf = oag = oah = oai = oaj = oak = oam =
268 oan = oao = oap = oaq = oar = oas = oaw = "";
269 if( uid ){
270 zLogin = db_text("", "SELECT login FROM user WHERE uid=%d", uid);
271 zInfo = db_text("", "SELECT info FROM user WHERE uid=%d", uid);
272 zCap = db_text("", "SELECT cap FROM user WHERE uid=%d", uid);
@@ -277,10 +280,11 @@
277 if( strchr(zCap, 'g') ) oag = " checked";
278 if( strchr(zCap, 'h') ) oah = " checked";
279 if( strchr(zCap, 'i') ) oai = " checked";
280 if( strchr(zCap, 'j') ) oaj = " checked";
281 if( strchr(zCap, 'k') ) oak = " checked";
 
282 if( strchr(zCap, 'm') ) oam = " checked";
283 if( strchr(zCap, 'n') ) oan = " checked";
284 if( strchr(zCap, 'o') ) oao = " checked";
285 if( strchr(zCap, 'p') ) oap = " checked";
286 if( strchr(zCap, 'q') ) oaq = " checked";
@@ -332,10 +336,11 @@
332 @ <input type="checkbox" name="ag"%s(oag)>Clone</input><br>
333 @ <input type="checkbox" name="aj"%s(oaj)>Read Wiki</input><br>
334 @ <input type="checkbox" name="af"%s(oaf)>New Wiki</input><br>
335 @ <input type="checkbox" name="am"%s(oam)>Append Wiki</input><br>
336 @ <input type="checkbox" name="ak"%s(oak)>Write Wiki</input><br>
 
337 @ <input type="checkbox" name="ar"%s(oar)>Read Tkt</input><br>
338 @ <input type="checkbox" name="an"%s(oan)>New Tkt</input><br>
339 @ <input type="checkbox" name="ac"%s(oac)>Append Tkt</input><br>
340 @ <input type="checkbox" name="aw"%s(oaw)>Write Tkt</input>
341 @ </td>
@@ -362,11 +367,13 @@
362 }
363 @
364 @ <li><p>
365 @ The <b>Delete</b> privilege give the user the ability to erase
366 @ wiki, tickets, and atttachments that have been added by anonymous
367 @ users. This capability is intended for deletion of spam.
 
 
368 @ </p></li>
369 @
370 @ <li><p>
371 @ The <b>Query</b> privilege allows the user to create or edit
372 @ report formats by specifying appropriate SQL. Users can run
373
--- src/setup.c
+++ src/setup.c
@@ -130,10 +130,11 @@
130 @ <li value="7"><b>Clone</b>: Clone the repository</li>
131 @ <li value="8"><b>History</b>: View detail repository history</li>
132 @ <li value="9"><b>Check-In</b>: Commit new versions in the repository</li>
133 @ <li value="10"><b>Read-Wiki</b>: View wiki pages</li>
134 @ <li value="11"><b>Write-Wiki</b>: Edit wiki pages</li>
135 @ <li value="12"><b>Lock-Wiki</b>: Lock or unlock wiki pages</li>
136 @ <li value="13"><b>Append-Wiki</b>: Append to wiki pages</li>
137 @ <li value="14"><b>New-Tkt</b>: Create new tickets</li>
138 @ <li value="15"><b>Check-Out</b>: Check out versions</li>
139 @ <li value="16"><b>Password</b>: Change your own password</li>
140 @ <li value="17"><b>Query</b>: Create new queries against tickets</li>
@@ -159,11 +160,11 @@
160 ** WEBPAGE: /setup_uedit
161 */
162 void user_edit(void){
163 const char *zId, *zLogin, *zInfo, *zCap;
164 char *oaa, *oas, *oar, *oaw, *oan, *oai, *oaj, *oao, *oap ;
165 char *oak, *oad, *oaq, *oac, *oaf, *oam, *oah, *oag, *oal;
166 int doWrite;
167 int uid;
168 int higherUser = 0; /* True if user being edited is SETUP and the */
169 /* user doing the editing is ADMIN. Disallow editing */
170
@@ -213,19 +214,21 @@
214 int ac = P("ac")!=0;
215 int af = P("af")!=0;
216 int am = P("am")!=0;
217 int ah = P("ah")!=0;
218 int ag = P("ag")!=0;
219 int al = P("al")!=0;
220 if( aa ){ zCap[i++] = 'a'; }
221 if( ac ){ zCap[i++] = 'c'; }
222 if( ad ){ zCap[i++] = 'd'; }
223 if( af ){ zCap[i++] = 'f'; }
224 if( ah ){ zCap[i++] = 'h'; }
225 if( ag ){ zCap[i++] = 'g'; }
226 if( ai ){ zCap[i++] = 'i'; }
227 if( aj ){ zCap[i++] = 'j'; }
228 if( ak ){ zCap[i++] = 'k'; }
229 if( al ){ zCap[i++] = 'l'; }
230 if( am ){ zCap[i++] = 'm'; }
231 if( an ){ zCap[i++] = 'n'; }
232 if( ao ){ zCap[i++] = 'o'; }
233 if( ap ){ zCap[i++] = 'p'; }
234 if( aq ){ zCap[i++] = 'q'; }
@@ -262,11 +265,11 @@
265 /* Load the existing information about the user, if any
266 */
267 zLogin = "";
268 zInfo = "";
269 zCap = "";
270 oaa = oac = oad = oaf = oag = oah = oai = oaj = oak = oal = oam =
271 oan = oao = oap = oaq = oar = oas = oaw = "";
272 if( uid ){
273 zLogin = db_text("", "SELECT login FROM user WHERE uid=%d", uid);
274 zInfo = db_text("", "SELECT info FROM user WHERE uid=%d", uid);
275 zCap = db_text("", "SELECT cap FROM user WHERE uid=%d", uid);
@@ -277,10 +280,11 @@
280 if( strchr(zCap, 'g') ) oag = " checked";
281 if( strchr(zCap, 'h') ) oah = " checked";
282 if( strchr(zCap, 'i') ) oai = " checked";
283 if( strchr(zCap, 'j') ) oaj = " checked";
284 if( strchr(zCap, 'k') ) oak = " checked";
285 if( strchr(zCap, 'l') ) oal = " checked";
286 if( strchr(zCap, 'm') ) oam = " checked";
287 if( strchr(zCap, 'n') ) oan = " checked";
288 if( strchr(zCap, 'o') ) oao = " checked";
289 if( strchr(zCap, 'p') ) oap = " checked";
290 if( strchr(zCap, 'q') ) oaq = " checked";
@@ -332,10 +336,11 @@
336 @ <input type="checkbox" name="ag"%s(oag)>Clone</input><br>
337 @ <input type="checkbox" name="aj"%s(oaj)>Read Wiki</input><br>
338 @ <input type="checkbox" name="af"%s(oaf)>New Wiki</input><br>
339 @ <input type="checkbox" name="am"%s(oam)>Append Wiki</input><br>
340 @ <input type="checkbox" name="ak"%s(oak)>Write Wiki</input><br>
341 @ <input type="checkbox" name="al"%s(oak)>Lock Wiki</input><br>
342 @ <input type="checkbox" name="ar"%s(oar)>Read Tkt</input><br>
343 @ <input type="checkbox" name="an"%s(oan)>New Tkt</input><br>
344 @ <input type="checkbox" name="ac"%s(oac)>Append Tkt</input><br>
345 @ <input type="checkbox" name="aw"%s(oaw)>Write Tkt</input>
346 @ </td>
@@ -362,11 +367,13 @@
367 }
368 @
369 @ <li><p>
370 @ The <b>Delete</b> privilege give the user the ability to erase
371 @ wiki, tickets, and atttachments that have been added by anonymous
372 @ users. This capability is intended for deletion of spam. The
373 @ delete capability is only in effect for 24 hours after the item
374 @ is first posted. The Setup user can delete anything at any time.
375 @ </p></li>
376 @
377 @ <li><p>
378 @ The <b>Query</b> privilege allows the user to create or edit
379 @ report formats by specifying appropriate SQL. Users can run
380
+6 -86
--- src/style.c
+++ src/style.c
@@ -60,11 +60,11 @@
6060
/*
6161
** Compare two submenu items for sorting purposes
6262
*/
6363
static int submenuCompare(const void *a, const void *b){
6464
const struct Submenu *A = (const struct Submenu*)a;
65
- const struct Submenu *B = (const struct Submenu*)B;
65
+ const struct Submenu *B = (const struct Submenu*)b;
6666
return strcmp(A->zLabel, B->zLabel);
6767
}
6868
6969
/*
7070
** Draw the header.
@@ -91,11 +91,11 @@
9191
}else{
9292
@ logged in as %h(g.zLogin)
9393
}
9494
@ </div>
9595
@ <div id="main-menu">
96
- @ <a href="%s(g.zBaseURL)/index">Home</a>
96
+ @ <a href="%s(g.zBaseURL)/home">Home</a>
9797
if( g.okRead ){
9898
@ | <a href="%s(g.zBaseURL)/leaves">Leaves</a>
9999
@ | <a href="%s(g.zBaseURL)/timeline">Timeline</a>
100100
}
101101
#if 0
@@ -140,101 +140,21 @@
140140
@ <div id="style-footer">
141141
@ Fossil version %s(MANIFEST_VERSION) %s(MANIFEST_DATE)
142142
@ </div>
143143
}
144144
145
-/*
146
-** WEBPAGE: index
147
-** WEBPAGE: home
148
-** WEBPAGE: not_found
149
-*/
150
-void page_index(void){
151
- char *zHome = "Home";
152
- if( zHome ){
153
- g.zExtra = zHome;
154
- g.okRdWiki = 1;
155
- wiki_page();
156
- }else{
157
- style_header("Main Title Page");
158
- @ No homepage configured for this server
159
- style_footer();
160
- }
161
-}
162
-
163
-/*
164
-** TODO: COPIED FROM WIKI.C... BAD
165
-*/
166
-/*
167
-** Create a fake replicate of the "vfile" table as a TEMP table
168
-** using the manifest identified by manid.
169
-*/
170
-static void style_create_fake_vfile(int manid){
171
- static const char zVfileDef[] =
172
- @ CREATE TEMP TABLE vfile(
173
- @ id INTEGER PRIMARY KEY, -- ID of the checked out file
174
- @ vid INTEGER REFERENCES blob, -- The version this file is part of.
175
- @ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add
176
- @ deleted BOOLEAN DEFAULT 0, -- True if deleted
177
- @ rid INTEGER, -- Originally from this repository record
178
- @ mrid INTEGER, -- Based on this record due to a merge
179
- @ pathname TEXT, -- Full pathname
180
- @ UNIQUE(pathname,vid)
181
- @ );
182
- ;
183
- db_multi_exec(zVfileDef);
184
- load_vfile_from_rid(manid);
185
-}
186
-
187145
188146
/*
189147
** WEBPAGE: style.css
190148
*/
191149
void page_style_css(void){
192
- Stmt q;
193
- int id = 0;
194
- int rid = 0;
195
- int chnged = 0;
196
- char *zPathname = 0;
197
- char *z;
150
+ char *zCSS = 0;
198151
199152
cgi_set_content_type("text/css");
200
-
201
- login_check_credentials();
202
- if( !g.localOpen ){
203
- int headid = db_int(0,
204
- "SELECT cid FROM plink ORDER BY mtime DESC LIMIT 1"
205
- );
206
- style_create_fake_vfile(headid);
207
- }
208
-
209
- db_prepare(&q,
210
- "SELECT id, rid, chnged, pathname FROM vfile"
211
- " WHERE (pathname='style.css' OR pathname LIKE '%%/style.css')"
212
- " AND NOT deleted"
213
- );
214
- if( db_step(&q)==SQLITE_ROW ){
215
- id = db_column_int(&q, 0);
216
- rid = db_column_int(&q, 1);
217
- chnged = db_column_int(&q, 2);
218
- if( chnged || rid==0 ){
219
- zPathname = db_column_malloc(&q, 3);
220
- }
221
- }
222
- db_finalize(&q);
223
- if( id ){
224
- Blob src;
225
- blob_zero(&src);
226
- if( zPathname ){
227
- zPathname = mprintf("%s/%z", g.zLocalRoot, zPathname);
228
- blob_read_from_file(&src, zPathname);
229
- free(zPathname);
230
- }else{
231
- content_get(rid, &src);
232
- }
233
-
234
- z = blob_str(&src);
235
- @ %s(z)
153
+ zCSS = db_get("css",0);
154
+ if( zCSS ){
155
+ cgi_append_content(zCSS, -1);
236156
}else{
237157
/* No CSS file found, use our own */
238158
/*
239159
** Selector order: tags, ids, classes, other
240160
** Content order: margin, borders, padding, fonts, colors, other
241161
--- src/style.c
+++ src/style.c
@@ -60,11 +60,11 @@
60 /*
61 ** Compare two submenu items for sorting purposes
62 */
63 static int submenuCompare(const void *a, const void *b){
64 const struct Submenu *A = (const struct Submenu*)a;
65 const struct Submenu *B = (const struct Submenu*)B;
66 return strcmp(A->zLabel, B->zLabel);
67 }
68
69 /*
70 ** Draw the header.
@@ -91,11 +91,11 @@
91 }else{
92 @ logged in as %h(g.zLogin)
93 }
94 @ </div>
95 @ <div id="main-menu">
96 @ <a href="%s(g.zBaseURL)/index">Home</a>
97 if( g.okRead ){
98 @ | <a href="%s(g.zBaseURL)/leaves">Leaves</a>
99 @ | <a href="%s(g.zBaseURL)/timeline">Timeline</a>
100 }
101 #if 0
@@ -140,101 +140,21 @@
140 @ <div id="style-footer">
141 @ Fossil version %s(MANIFEST_VERSION) %s(MANIFEST_DATE)
142 @ </div>
143 }
144
145 /*
146 ** WEBPAGE: index
147 ** WEBPAGE: home
148 ** WEBPAGE: not_found
149 */
150 void page_index(void){
151 char *zHome = "Home";
152 if( zHome ){
153 g.zExtra = zHome;
154 g.okRdWiki = 1;
155 wiki_page();
156 }else{
157 style_header("Main Title Page");
158 @ No homepage configured for this server
159 style_footer();
160 }
161 }
162
163 /*
164 ** TODO: COPIED FROM WIKI.C... BAD
165 */
166 /*
167 ** Create a fake replicate of the "vfile" table as a TEMP table
168 ** using the manifest identified by manid.
169 */
170 static void style_create_fake_vfile(int manid){
171 static const char zVfileDef[] =
172 @ CREATE TEMP TABLE vfile(
173 @ id INTEGER PRIMARY KEY, -- ID of the checked out file
174 @ vid INTEGER REFERENCES blob, -- The version this file is part of.
175 @ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add
176 @ deleted BOOLEAN DEFAULT 0, -- True if deleted
177 @ rid INTEGER, -- Originally from this repository record
178 @ mrid INTEGER, -- Based on this record due to a merge
179 @ pathname TEXT, -- Full pathname
180 @ UNIQUE(pathname,vid)
181 @ );
182 ;
183 db_multi_exec(zVfileDef);
184 load_vfile_from_rid(manid);
185 }
186
187
188 /*
189 ** WEBPAGE: style.css
190 */
191 void page_style_css(void){
192 Stmt q;
193 int id = 0;
194 int rid = 0;
195 int chnged = 0;
196 char *zPathname = 0;
197 char *z;
198
199 cgi_set_content_type("text/css");
200
201 login_check_credentials();
202 if( !g.localOpen ){
203 int headid = db_int(0,
204 "SELECT cid FROM plink ORDER BY mtime DESC LIMIT 1"
205 );
206 style_create_fake_vfile(headid);
207 }
208
209 db_prepare(&q,
210 "SELECT id, rid, chnged, pathname FROM vfile"
211 " WHERE (pathname='style.css' OR pathname LIKE '%%/style.css')"
212 " AND NOT deleted"
213 );
214 if( db_step(&q)==SQLITE_ROW ){
215 id = db_column_int(&q, 0);
216 rid = db_column_int(&q, 1);
217 chnged = db_column_int(&q, 2);
218 if( chnged || rid==0 ){
219 zPathname = db_column_malloc(&q, 3);
220 }
221 }
222 db_finalize(&q);
223 if( id ){
224 Blob src;
225 blob_zero(&src);
226 if( zPathname ){
227 zPathname = mprintf("%s/%z", g.zLocalRoot, zPathname);
228 blob_read_from_file(&src, zPathname);
229 free(zPathname);
230 }else{
231 content_get(rid, &src);
232 }
233
234 z = blob_str(&src);
235 @ %s(z)
236 }else{
237 /* No CSS file found, use our own */
238 /*
239 ** Selector order: tags, ids, classes, other
240 ** Content order: margin, borders, padding, fonts, colors, other
241
--- src/style.c
+++ src/style.c
@@ -60,11 +60,11 @@
60 /*
61 ** Compare two submenu items for sorting purposes
62 */
63 static int submenuCompare(const void *a, const void *b){
64 const struct Submenu *A = (const struct Submenu*)a;
65 const struct Submenu *B = (const struct Submenu*)b;
66 return strcmp(A->zLabel, B->zLabel);
67 }
68
69 /*
70 ** Draw the header.
@@ -91,11 +91,11 @@
91 }else{
92 @ logged in as %h(g.zLogin)
93 }
94 @ </div>
95 @ <div id="main-menu">
96 @ <a href="%s(g.zBaseURL)/home">Home</a>
97 if( g.okRead ){
98 @ | <a href="%s(g.zBaseURL)/leaves">Leaves</a>
99 @ | <a href="%s(g.zBaseURL)/timeline">Timeline</a>
100 }
101 #if 0
@@ -140,101 +140,21 @@
140 @ <div id="style-footer">
141 @ Fossil version %s(MANIFEST_VERSION) %s(MANIFEST_DATE)
142 @ </div>
143 }
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
146 /*
147 ** WEBPAGE: style.css
148 */
149 void page_style_css(void){
150 char *zCSS = 0;
 
 
 
 
 
151
152 cgi_set_content_type("text/css");
153 zCSS = db_get("css",0);
154 if( zCSS ){
155 cgi_append_content(zCSS, -1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156 }else{
157 /* No CSS file found, use our own */
158 /*
159 ** Selector order: tags, ids, classes, other
160 ** Content order: margin, borders, padding, fonts, colors, other
161
+6 -29
--- src/timeline.c
+++ src/timeline.c
@@ -233,10 +233,11 @@
233233
** n=INTEGER number of events to show. dflt: 25
234234
** e=INTEGER starting event id. dflt: nil
235235
** u=NAME show only events from user. dflt: nil
236236
** a show events after and including. dflt: false
237237
** r show only related events. dflt: false
238
+** y=TYPE show only TYPE ('ci' or 'w') dflt: nil
238239
*/
239240
void page_timeline(void){
240241
Stmt q;
241242
char *zSQL;
242243
Blob scriptInit;
@@ -245,10 +246,11 @@
245246
int nEntry = atoi(PD("n","20"));
246247
const char *zUser = P("u");
247248
int objid = atoi(PD("e","0"));
248249
int relatedEvents = P("r")!=0;
249250
int afterFlag = P("a")!=0;
251
+ const char *zType = P("y");
250252
int firstEvent;
251253
int lastEvent;
252254
253255
/* To view the timeline, must have permission to read project data.
254256
*/
@@ -259,13 +261,16 @@
259261
if( !g.okHistory &&
260262
db_exists("SELECT 1 FROM user"
261263
" WHERE login='anonymous'"
262264
" AND cap LIKE '%%h%%'") ){
263265
@ <p><b>Note:</b> You will be able to access <u>much</u> more
264
- @ historical information if <a href="%s(g.zBaseURL)/login">login</a>.</p>
266
+ @ historical information if <a href="%s(g.zTop)/login">login</a>.</p>
265267
}
266268
zSQL = mprintf("%s", timeline_query_for_www());
269
+ if( zType ){
270
+ zSQL = mprintf("%z AND event.type=%Q", zSQL, zType);
271
+ }
267272
if( zUser ){
268273
zSQL = mprintf("%z AND event.user=%Q", zSQL, zUser);
269274
}
270275
if( objid ){
271276
char *z = db_text(0, "SELECT datetime(event.mtime) FROM event"
@@ -389,38 +394,10 @@
389394
@ <input type="submit" value="Previous %d(nEntry) Rows">
390395
@ </form>
391396
style_footer();
392397
}
393398
394
-
395
-/*
396
-** WEBPAGE: wlist
397
-**
398
-** Show the complete change history for a single wiki page. The name
399
-** of the wiki is in g.zExtra
400
-*/
401
-void wlist_page(void){
402
- Stmt q;
403
- char *zTitle;
404
- char *zSQL;
405
- login_check_credentials();
406
- if( !g.okHistory ){ login_needed(); return; }
407
- zTitle = mprintf("History Of %h", g.zExtra);
408
- style_header(zTitle);
409
- free(zTitle);
410
-
411
- zSQL = mprintf("%s AND event.objid IN "
412
- " (SELECT rid FROM tagxref WHERE tagid="
413
- "(SELECT tagid FROM tag WHERE tagname='wiki-%q'))",
414
- timeline_query_for_www(), g.zExtra);
415
- db_prepare(&q, zSQL);
416
- free(zSQL);
417
- www_print_timeline(&q, 0, 0, 0, 0);
418
- db_finalize(&q);
419
- style_footer();
420
-}
421
-
422399
/*
423400
** The input query q selects various records. Print a human-readable
424401
** summary of those records.
425402
**
426403
** Limit the number of entries printed to nLine.
427404
--- src/timeline.c
+++ src/timeline.c
@@ -233,10 +233,11 @@
233 ** n=INTEGER number of events to show. dflt: 25
234 ** e=INTEGER starting event id. dflt: nil
235 ** u=NAME show only events from user. dflt: nil
236 ** a show events after and including. dflt: false
237 ** r show only related events. dflt: false
 
238 */
239 void page_timeline(void){
240 Stmt q;
241 char *zSQL;
242 Blob scriptInit;
@@ -245,10 +246,11 @@
245 int nEntry = atoi(PD("n","20"));
246 const char *zUser = P("u");
247 int objid = atoi(PD("e","0"));
248 int relatedEvents = P("r")!=0;
249 int afterFlag = P("a")!=0;
 
250 int firstEvent;
251 int lastEvent;
252
253 /* To view the timeline, must have permission to read project data.
254 */
@@ -259,13 +261,16 @@
259 if( !g.okHistory &&
260 db_exists("SELECT 1 FROM user"
261 " WHERE login='anonymous'"
262 " AND cap LIKE '%%h%%'") ){
263 @ <p><b>Note:</b> You will be able to access <u>much</u> more
264 @ historical information if <a href="%s(g.zBaseURL)/login">login</a>.</p>
265 }
266 zSQL = mprintf("%s", timeline_query_for_www());
 
 
 
267 if( zUser ){
268 zSQL = mprintf("%z AND event.user=%Q", zSQL, zUser);
269 }
270 if( objid ){
271 char *z = db_text(0, "SELECT datetime(event.mtime) FROM event"
@@ -389,38 +394,10 @@
389 @ <input type="submit" value="Previous %d(nEntry) Rows">
390 @ </form>
391 style_footer();
392 }
393
394
395 /*
396 ** WEBPAGE: wlist
397 **
398 ** Show the complete change history for a single wiki page. The name
399 ** of the wiki is in g.zExtra
400 */
401 void wlist_page(void){
402 Stmt q;
403 char *zTitle;
404 char *zSQL;
405 login_check_credentials();
406 if( !g.okHistory ){ login_needed(); return; }
407 zTitle = mprintf("History Of %h", g.zExtra);
408 style_header(zTitle);
409 free(zTitle);
410
411 zSQL = mprintf("%s AND event.objid IN "
412 " (SELECT rid FROM tagxref WHERE tagid="
413 "(SELECT tagid FROM tag WHERE tagname='wiki-%q'))",
414 timeline_query_for_www(), g.zExtra);
415 db_prepare(&q, zSQL);
416 free(zSQL);
417 www_print_timeline(&q, 0, 0, 0, 0);
418 db_finalize(&q);
419 style_footer();
420 }
421
422 /*
423 ** The input query q selects various records. Print a human-readable
424 ** summary of those records.
425 **
426 ** Limit the number of entries printed to nLine.
427
--- src/timeline.c
+++ src/timeline.c
@@ -233,10 +233,11 @@
233 ** n=INTEGER number of events to show. dflt: 25
234 ** e=INTEGER starting event id. dflt: nil
235 ** u=NAME show only events from user. dflt: nil
236 ** a show events after and including. dflt: false
237 ** r show only related events. dflt: false
238 ** y=TYPE show only TYPE ('ci' or 'w') dflt: nil
239 */
240 void page_timeline(void){
241 Stmt q;
242 char *zSQL;
243 Blob scriptInit;
@@ -245,10 +246,11 @@
246 int nEntry = atoi(PD("n","20"));
247 const char *zUser = P("u");
248 int objid = atoi(PD("e","0"));
249 int relatedEvents = P("r")!=0;
250 int afterFlag = P("a")!=0;
251 const char *zType = P("y");
252 int firstEvent;
253 int lastEvent;
254
255 /* To view the timeline, must have permission to read project data.
256 */
@@ -259,13 +261,16 @@
261 if( !g.okHistory &&
262 db_exists("SELECT 1 FROM user"
263 " WHERE login='anonymous'"
264 " AND cap LIKE '%%h%%'") ){
265 @ <p><b>Note:</b> You will be able to access <u>much</u> more
266 @ historical information if <a href="%s(g.zTop)/login">login</a>.</p>
267 }
268 zSQL = mprintf("%s", timeline_query_for_www());
269 if( zType ){
270 zSQL = mprintf("%z AND event.type=%Q", zSQL, zType);
271 }
272 if( zUser ){
273 zSQL = mprintf("%z AND event.user=%Q", zSQL, zUser);
274 }
275 if( objid ){
276 char *z = db_text(0, "SELECT datetime(event.mtime) FROM event"
@@ -389,38 +394,10 @@
394 @ <input type="submit" value="Previous %d(nEntry) Rows">
395 @ </form>
396 style_footer();
397 }
398
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399 /*
400 ** The input query q selects various records. Print a human-readable
401 ** summary of those records.
402 **
403 ** Limit the number of entries printed to nLine.
404
+97
--- src/wiki.c
+++ src/wiki.c
@@ -68,10 +68,37 @@
6868
style_footer();
6969
return 1;
7070
}
7171
return 0;
7272
}
73
+
74
+/*
75
+** WEBPAGE: home
76
+** WEBPAGE: index
77
+** WEBPAGE: not_found
78
+*/
79
+void home_page(void){
80
+ char *zPageName = db_get("project-name",0);
81
+ if( zPageName ){
82
+ login_check_credentials();
83
+ g.zExtra = zPageName;
84
+ g.okRdWiki = 1;
85
+ g.okApndWiki = 0;
86
+ g.okWrWiki = 0;
87
+ g.okHistory = 0;
88
+ wiki_page();
89
+ return;
90
+ }
91
+ style_header("Home");
92
+ @ <p>This is a stub home-page for the project.
93
+ @ To fill in this page, first go to
94
+ @ <a href="%s(g.zBaseURL)/setup_config">setup/config</a>
95
+ @ and establish a "Project Name". Then create a
96
+ @ wiki page with that name. The content of that wiki page
97
+ @ will be displayed in place of this message.
98
+ style_footer();
99
+}
73100
74101
/*
75102
** WEBPAGE: wiki
76103
** URL: /wiki/PAGENAME
77104
*/
@@ -78,10 +105,11 @@
78105
void wiki_page(void){
79106
char *zTag;
80107
int rid;
81108
Blob wiki;
82109
Manifest m;
110
+ int seenHr = 0;
83111
char *zPageName;
84112
char *zHtmlPageName;
85113
char *zBody = mprintf("%s","<i>Empty Page</i>");
86114
87115
login_check_credentials();
@@ -104,20 +132,38 @@
104132
manifest_parse(&m, &content);
105133
if( m.type==CFTYPE_WIKI ){
106134
zBody = m.zWiki;
107135
}
108136
}
137
+ if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
138
+ style_submenu_element("Edit", "Edit Wiki Page",
139
+ mprintf("%s/wikiedit/%s", g.zTop, g.zExtra));
140
+ }
141
+ if( g.okHistory ){
142
+ style_submenu_element("History", "History",
143
+ mprintf("%s/whistory/%s", g.zTop, g.zExtra));
144
+ }
109145
zHtmlPageName = mprintf("%h", zPageName);
110146
style_header(zHtmlPageName);
111147
blob_init(&wiki, zBody, -1);
112148
wiki_convert(&wiki, 0);
113149
blob_reset(&wiki);
114150
manifest_clear(&m);
151
+#if 0
115152
if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
116153
@ <hr>
117154
@ [<a href="%s(g.zBaseURL)/wikiedit/%s(g.zExtra)">Edit</a>]
155
+ seenHr = 1;
156
+ }
157
+ if( g.okHistory ){
158
+ if( !seenHr ){
159
+ @ <hr>
160
+ seenHr = 1;
161
+ }
162
+ @ [<a href="%s(g.zBaseUrl)/whistory/%s(g.zExtra)">History</a>]
118163
}
164
+#endif
119165
style_footer();
120166
}
121167
122168
/*
123169
** WEBPAGE: wikiedit
@@ -225,10 +271,61 @@
225271
@ </form>
226272
manifest_clear(&m);
227273
style_footer();
228274
229275
}
276
+
277
+/*
278
+** WEBPAGE: whistory
279
+**
280
+** Show the complete change history for a single wiki page. The name
281
+** of the wiki is in g.zExtra
282
+*/
283
+void whistory_page(void){
284
+ Stmt q;
285
+ char *zTitle;
286
+ char *zSQL;
287
+ login_check_credentials();
288
+ if( !g.okHistory ){ login_needed(); return; }
289
+ zTitle = mprintf("History Of %h", g.zExtra);
290
+ style_header(zTitle);
291
+ free(zTitle);
292
+
293
+ zSQL = mprintf("%s AND event.objid IN "
294
+ " (SELECT rid FROM tagxref WHERE tagid="
295
+ "(SELECT tagid FROM tag WHERE tagname='wiki-%q'))"
296
+ "ORDER BY mtime DESC",
297
+ timeline_query_for_www(), g.zExtra);
298
+ db_prepare(&q, zSQL);
299
+ free(zSQL);
300
+ www_print_timeline(&q, 0, 0, 0, 0);
301
+ db_finalize(&q);
302
+ style_footer();
303
+}
304
+
305
+/*
306
+** WEBPAGE: wcontent
307
+**
308
+** List all available wiki pages with date created and last modified.
309
+*/
310
+void wcontent_page(void){
311
+ Stmt q;
312
+ login_check_credentials();
313
+ if( !g.okRdWiki ){ login_needed(); return; }
314
+ style_header("Available Wiki Pages");
315
+ @ <ul>
316
+ db_prepare(&q,
317
+ "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname GLOB 'wiki-*'"
318
+ " ORDER BY lower(tagname)"
319
+ );
320
+ while( db_step(&q)==SQLITE_ROW ){
321
+ const char *zName = db_column_text(&q, 0);
322
+ @ <li><a href="%s(g.zBaseURL)/wiki/%t(zName)">%h(zName)</a></li>
323
+ }
324
+ db_finalize(&q);
325
+ style_footer();
326
+}
230327
231328
/*
232329
** WEBPAGE: ambiguous
233330
**
234331
** This is the destination for UUID hyperlinks that are ambiguous.
235332
--- src/wiki.c
+++ src/wiki.c
@@ -68,10 +68,37 @@
68 style_footer();
69 return 1;
70 }
71 return 0;
72 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
74 /*
75 ** WEBPAGE: wiki
76 ** URL: /wiki/PAGENAME
77 */
@@ -78,10 +105,11 @@
78 void wiki_page(void){
79 char *zTag;
80 int rid;
81 Blob wiki;
82 Manifest m;
 
83 char *zPageName;
84 char *zHtmlPageName;
85 char *zBody = mprintf("%s","<i>Empty Page</i>");
86
87 login_check_credentials();
@@ -104,20 +132,38 @@
104 manifest_parse(&m, &content);
105 if( m.type==CFTYPE_WIKI ){
106 zBody = m.zWiki;
107 }
108 }
 
 
 
 
 
 
 
 
109 zHtmlPageName = mprintf("%h", zPageName);
110 style_header(zHtmlPageName);
111 blob_init(&wiki, zBody, -1);
112 wiki_convert(&wiki, 0);
113 blob_reset(&wiki);
114 manifest_clear(&m);
 
115 if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
116 @ <hr>
117 @ [<a href="%s(g.zBaseURL)/wikiedit/%s(g.zExtra)">Edit</a>]
 
 
 
 
 
 
 
 
118 }
 
119 style_footer();
120 }
121
122 /*
123 ** WEBPAGE: wikiedit
@@ -225,10 +271,61 @@
225 @ </form>
226 manifest_clear(&m);
227 style_footer();
228
229 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
231 /*
232 ** WEBPAGE: ambiguous
233 **
234 ** This is the destination for UUID hyperlinks that are ambiguous.
235
--- src/wiki.c
+++ src/wiki.c
@@ -68,10 +68,37 @@
68 style_footer();
69 return 1;
70 }
71 return 0;
72 }
73
74 /*
75 ** WEBPAGE: home
76 ** WEBPAGE: index
77 ** WEBPAGE: not_found
78 */
79 void home_page(void){
80 char *zPageName = db_get("project-name",0);
81 if( zPageName ){
82 login_check_credentials();
83 g.zExtra = zPageName;
84 g.okRdWiki = 1;
85 g.okApndWiki = 0;
86 g.okWrWiki = 0;
87 g.okHistory = 0;
88 wiki_page();
89 return;
90 }
91 style_header("Home");
92 @ <p>This is a stub home-page for the project.
93 @ To fill in this page, first go to
94 @ <a href="%s(g.zBaseURL)/setup_config">setup/config</a>
95 @ and establish a "Project Name". Then create a
96 @ wiki page with that name. The content of that wiki page
97 @ will be displayed in place of this message.
98 style_footer();
99 }
100
101 /*
102 ** WEBPAGE: wiki
103 ** URL: /wiki/PAGENAME
104 */
@@ -78,10 +105,11 @@
105 void wiki_page(void){
106 char *zTag;
107 int rid;
108 Blob wiki;
109 Manifest m;
110 int seenHr = 0;
111 char *zPageName;
112 char *zHtmlPageName;
113 char *zBody = mprintf("%s","<i>Empty Page</i>");
114
115 login_check_credentials();
@@ -104,20 +132,38 @@
132 manifest_parse(&m, &content);
133 if( m.type==CFTYPE_WIKI ){
134 zBody = m.zWiki;
135 }
136 }
137 if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
138 style_submenu_element("Edit", "Edit Wiki Page",
139 mprintf("%s/wikiedit/%s", g.zTop, g.zExtra));
140 }
141 if( g.okHistory ){
142 style_submenu_element("History", "History",
143 mprintf("%s/whistory/%s", g.zTop, g.zExtra));
144 }
145 zHtmlPageName = mprintf("%h", zPageName);
146 style_header(zHtmlPageName);
147 blob_init(&wiki, zBody, -1);
148 wiki_convert(&wiki, 0);
149 blob_reset(&wiki);
150 manifest_clear(&m);
151 #if 0
152 if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
153 @ <hr>
154 @ [<a href="%s(g.zBaseURL)/wikiedit/%s(g.zExtra)">Edit</a>]
155 seenHr = 1;
156 }
157 if( g.okHistory ){
158 if( !seenHr ){
159 @ <hr>
160 seenHr = 1;
161 }
162 @ [<a href="%s(g.zBaseUrl)/whistory/%s(g.zExtra)">History</a>]
163 }
164 #endif
165 style_footer();
166 }
167
168 /*
169 ** WEBPAGE: wikiedit
@@ -225,10 +271,61 @@
271 @ </form>
272 manifest_clear(&m);
273 style_footer();
274
275 }
276
277 /*
278 ** WEBPAGE: whistory
279 **
280 ** Show the complete change history for a single wiki page. The name
281 ** of the wiki is in g.zExtra
282 */
283 void whistory_page(void){
284 Stmt q;
285 char *zTitle;
286 char *zSQL;
287 login_check_credentials();
288 if( !g.okHistory ){ login_needed(); return; }
289 zTitle = mprintf("History Of %h", g.zExtra);
290 style_header(zTitle);
291 free(zTitle);
292
293 zSQL = mprintf("%s AND event.objid IN "
294 " (SELECT rid FROM tagxref WHERE tagid="
295 "(SELECT tagid FROM tag WHERE tagname='wiki-%q'))"
296 "ORDER BY mtime DESC",
297 timeline_query_for_www(), g.zExtra);
298 db_prepare(&q, zSQL);
299 free(zSQL);
300 www_print_timeline(&q, 0, 0, 0, 0);
301 db_finalize(&q);
302 style_footer();
303 }
304
305 /*
306 ** WEBPAGE: wcontent
307 **
308 ** List all available wiki pages with date created and last modified.
309 */
310 void wcontent_page(void){
311 Stmt q;
312 login_check_credentials();
313 if( !g.okRdWiki ){ login_needed(); return; }
314 style_header("Available Wiki Pages");
315 @ <ul>
316 db_prepare(&q,
317 "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname GLOB 'wiki-*'"
318 " ORDER BY lower(tagname)"
319 );
320 while( db_step(&q)==SQLITE_ROW ){
321 const char *zName = db_column_text(&q, 0);
322 @ <li><a href="%s(g.zBaseURL)/wiki/%t(zName)">%h(zName)</a></li>
323 }
324 db_finalize(&q);
325 style_footer();
326 }
327
328 /*
329 ** WEBPAGE: ambiguous
330 **
331 ** This is the destination for UUID hyperlinks that are ambiguous.
332
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -760,10 +760,12 @@
760760
|| strncmp(zTarget, "https:", 6)==0
761761
|| strncmp(zTarget, "ftp:", 4)==0
762762
|| strncmp(zTarget, "mailto:", 7)==0
763763
){
764764
blob_appendf(p->pOut, zTarget);
765
+ }else if( zTarget[0]=='/' ){
766
+ blob_appendf(p->pOut, "%s%h", g.zBaseURL, zTarget);
765767
}else if( wiki_name_is_wellformed(zTarget) ){
766768
blob_appendf(p->pOut, "%s/wiki/%T", g.zBaseURL, zTarget);
767769
}else{
768770
blob_appendf(p->pOut, "error");
769771
}
770772
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -760,10 +760,12 @@
760 || strncmp(zTarget, "https:", 6)==0
761 || strncmp(zTarget, "ftp:", 4)==0
762 || strncmp(zTarget, "mailto:", 7)==0
763 ){
764 blob_appendf(p->pOut, zTarget);
 
 
765 }else if( wiki_name_is_wellformed(zTarget) ){
766 blob_appendf(p->pOut, "%s/wiki/%T", g.zBaseURL, zTarget);
767 }else{
768 blob_appendf(p->pOut, "error");
769 }
770
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -760,10 +760,12 @@
760 || strncmp(zTarget, "https:", 6)==0
761 || strncmp(zTarget, "ftp:", 4)==0
762 || strncmp(zTarget, "mailto:", 7)==0
763 ){
764 blob_appendf(p->pOut, zTarget);
765 }else if( zTarget[0]=='/' ){
766 blob_appendf(p->pOut, "%s%h", g.zBaseURL, zTarget);
767 }else if( wiki_name_is_wellformed(zTarget) ){
768 blob_appendf(p->pOut, "%s/wiki/%T", g.zBaseURL, zTarget);
769 }else{
770 blob_appendf(p->pOut, "error");
771 }
772

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button