Fossil SCM

Get rid of the "locking" capability on wiki pages. Assume that anybody who can write or append to a wiki page can do so to any wiki page. Add the /wikiappend page for appending comments to the end of wiki.

drh 2007-10-10 23:10 trunk
Commit 61ce5e3685fb867ff382c7336f96d9b1033f71ad
+1 -1
--- src/login.c
+++ src/login.c
@@ -290,11 +290,11 @@
290290
for(i=0; zCap[i]; i++){
291291
switch( zCap[i] ){
292292
case 's': g.okSetup = 1;
293293
case 'a': g.okAdmin = g.okRdTkt = g.okWrTkt = g.okQuery =
294294
g.okRdWiki = g.okWrWiki = g.okNewWiki =
295
- g.okHistory = g.okClone =
295
+ g.okApndWiki = g.okHistory = g.okClone =
296296
g.okNewTkt = g.okPassword = 1;
297297
case 'i': g.okRead = g.okWrite = 1; break;
298298
case 'o': g.okRead = 1; break;
299299
300300
case 'd': g.okDelete = 1; break;
301301
--- src/login.c
+++ src/login.c
@@ -290,11 +290,11 @@
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 case 'o': g.okRead = 1; break;
299
300 case 'd': g.okDelete = 1; break;
301
--- src/login.c
+++ src/login.c
@@ -290,11 +290,11 @@
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.okApndWiki = g.okHistory = g.okClone =
296 g.okNewTkt = g.okPassword = 1;
297 case 'i': g.okRead = g.okWrite = 1; break;
298 case 'o': g.okRead = 1; break;
299
300 case 'd': g.okDelete = 1; break;
301
-1
--- src/main.c
+++ src/main.c
@@ -99,11 +99,10 @@
9999
int okClone; /* g: clone */
100100
int okRdWiki; /* j: view wiki via web */
101101
int okNewWiki; /* f: create new wiki via web */
102102
int okApndWiki; /* m: append to wiki via web */
103103
int okWrWiki; /* k: edit wiki via web */
104
- int okLockWiki; /* l: lock and unlock wiki via web */
105104
int okRdTkt; /* r: view tickets via web */
106105
int okNewTkt; /* n: create new tickets */
107106
int okApndTkt; /* c: append to tickets via the web */
108107
int okWrTkt; /* w: make changes to tickets via web */
109108
110109
--- src/main.c
+++ src/main.c
@@ -99,11 +99,10 @@
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
110
--- src/main.c
+++ src/main.c
@@ -99,11 +99,10 @@
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 okRdTkt; /* r: view tickets via web */
105 int okNewTkt; /* n: create new tickets */
106 int okApndTkt; /* c: append to tickets via the web */
107 int okWrTkt; /* w: make changes to tickets via web */
108
109
--- src/schema.c
+++ src/schema.c
@@ -217,10 +217,13 @@
217217
@ tagname TEXT UNIQUE -- Tag name.
218218
@ );
219219
@ INSERT INTO tag VALUES(1, 'bgcolor'); -- TAG_BGCOLOR
220220
@ INSERT INTO tag VALUES(2, 'comment'); -- TAG_COMMENT
221221
@ INSERT INTO tag VALUES(3, 'user'); -- TAG_USER
222
+@ INSERT INTO tag VALUES(4, 'hidden'); -- TAG_HIDDEN
223
+@ INSERT INTO tag VALUES(5, 'readonly'); -- TAG_READONLY
224
+@ INSERT INTO tag VALUES(6, 'appendonly'); -- TAG_APPENDONLY
222225
@
223226
@ -- Assignments of tags to baselines. Note that we allow tags to
224227
@ -- have values assigned to them. So we are not really dealing with
225228
@ -- tags here. These are really properties. But we are going to
226229
@ -- keep calling them tags because in many cases the value is ignored.
@@ -242,10 +245,13 @@
242245
*/
243246
#if INTERFACE
244247
# define TAG_BGCOLOR 1
245248
# define TAG_COMMENT 2
246249
# define TAG_USER 3
250
+# define TAG_HIDDEN 4
251
+# define TAG_READONLY 5
252
+# define TAG_APPENDONLY 6
247253
#endif
248254
249255
/*
250256
** The schema for the locate FOSSIL database file found at the root
251257
** of very check-out. This database contains the complete state of
252258
--- src/schema.c
+++ src/schema.c
@@ -217,10 +217,13 @@
217 @ tagname TEXT UNIQUE -- Tag name.
218 @ );
219 @ INSERT INTO tag VALUES(1, 'bgcolor'); -- TAG_BGCOLOR
220 @ INSERT INTO tag VALUES(2, 'comment'); -- TAG_COMMENT
221 @ INSERT INTO tag VALUES(3, 'user'); -- TAG_USER
 
 
 
222 @
223 @ -- Assignments of tags to baselines. Note that we allow tags to
224 @ -- have values assigned to them. So we are not really dealing with
225 @ -- tags here. These are really properties. But we are going to
226 @ -- keep calling them tags because in many cases the value is ignored.
@@ -242,10 +245,13 @@
242 */
243 #if INTERFACE
244 # define TAG_BGCOLOR 1
245 # define TAG_COMMENT 2
246 # define TAG_USER 3
 
 
 
247 #endif
248
249 /*
250 ** The schema for the locate FOSSIL database file found at the root
251 ** of very check-out. This database contains the complete state of
252
--- src/schema.c
+++ src/schema.c
@@ -217,10 +217,13 @@
217 @ tagname TEXT UNIQUE -- Tag name.
218 @ );
219 @ INSERT INTO tag VALUES(1, 'bgcolor'); -- TAG_BGCOLOR
220 @ INSERT INTO tag VALUES(2, 'comment'); -- TAG_COMMENT
221 @ INSERT INTO tag VALUES(3, 'user'); -- TAG_USER
222 @ INSERT INTO tag VALUES(4, 'hidden'); -- TAG_HIDDEN
223 @ INSERT INTO tag VALUES(5, 'readonly'); -- TAG_READONLY
224 @ INSERT INTO tag VALUES(6, 'appendonly'); -- TAG_APPENDONLY
225 @
226 @ -- Assignments of tags to baselines. Note that we allow tags to
227 @ -- have values assigned to them. So we are not really dealing with
228 @ -- tags here. These are really properties. But we are going to
229 @ -- keep calling them tags because in many cases the value is ignored.
@@ -242,10 +245,13 @@
245 */
246 #if INTERFACE
247 # define TAG_BGCOLOR 1
248 # define TAG_COMMENT 2
249 # define TAG_USER 3
250 # define TAG_HIDDEN 4
251 # define TAG_READONLY 5
252 # define TAG_APPENDONLY 6
253 #endif
254
255 /*
256 ** The schema for the locate FOSSIL database file found at the root
257 ** of very check-out. This database contains the complete state of
258
+2 -7
--- src/setup.c
+++ src/setup.c
@@ -130,11 +130,10 @@
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>
136135
@ <li value="13"><b>Append-Wiki</b>: Append to wiki pages</li>
137136
@ <li value="14"><b>New-Tkt</b>: Create new tickets</li>
138137
@ <li value="15"><b>Check-Out</b>: Check out versions</li>
139138
@ <li value="16"><b>Password</b>: Change your own password</li>
140139
@ <li value="17"><b>Query</b>: Create new queries against tickets</li>
@@ -160,11 +159,11 @@
160159
** WEBPAGE: /setup_uedit
161160
*/
162161
void user_edit(void){
163162
const char *zId, *zLogin, *zInfo, *zCap;
164163
char *oaa, *oas, *oar, *oaw, *oan, *oai, *oaj, *oao, *oap ;
165
- char *oak, *oad, *oaq, *oac, *oaf, *oam, *oah, *oag, *oal;
164
+ char *oak, *oad, *oaq, *oac, *oaf, *oam, *oah, *oag;
166165
int doWrite;
167166
int uid;
168167
int higherUser = 0; /* True if user being edited is SETUP and the */
169168
/* user doing the editing is ADMIN. Disallow editing */
170169
@@ -214,21 +213,19 @@
214213
int ac = P("ac")!=0;
215214
int af = P("af")!=0;
216215
int am = P("am")!=0;
217216
int ah = P("ah")!=0;
218217
int ag = P("ag")!=0;
219
- int al = P("al")!=0;
220218
if( aa ){ zCap[i++] = 'a'; }
221219
if( ac ){ zCap[i++] = 'c'; }
222220
if( ad ){ zCap[i++] = 'd'; }
223221
if( af ){ zCap[i++] = 'f'; }
224222
if( ah ){ zCap[i++] = 'h'; }
225223
if( ag ){ zCap[i++] = 'g'; }
226224
if( ai ){ zCap[i++] = 'i'; }
227225
if( aj ){ zCap[i++] = 'j'; }
228226
if( ak ){ zCap[i++] = 'k'; }
229
- if( al ){ zCap[i++] = 'l'; }
230227
if( am ){ zCap[i++] = 'm'; }
231228
if( an ){ zCap[i++] = 'n'; }
232229
if( ao ){ zCap[i++] = 'o'; }
233230
if( ap ){ zCap[i++] = 'p'; }
234231
if( aq ){ zCap[i++] = 'q'; }
@@ -265,11 +262,11 @@
265262
/* Load the existing information about the user, if any
266263
*/
267264
zLogin = "";
268265
zInfo = "";
269266
zCap = "";
270
- oaa = oac = oad = oaf = oag = oah = oai = oaj = oak = oal = oam =
267
+ oaa = oac = oad = oaf = oag = oah = oai = oaj = oak = oam =
271268
oan = oao = oap = oaq = oar = oas = oaw = "";
272269
if( uid ){
273270
zLogin = db_text("", "SELECT login FROM user WHERE uid=%d", uid);
274271
zInfo = db_text("", "SELECT info FROM user WHERE uid=%d", uid);
275272
zCap = db_text("", "SELECT cap FROM user WHERE uid=%d", uid);
@@ -280,11 +277,10 @@
280277
if( strchr(zCap, 'g') ) oag = " checked";
281278
if( strchr(zCap, 'h') ) oah = " checked";
282279
if( strchr(zCap, 'i') ) oai = " checked";
283280
if( strchr(zCap, 'j') ) oaj = " checked";
284281
if( strchr(zCap, 'k') ) oak = " checked";
285
- if( strchr(zCap, 'l') ) oal = " checked";
286282
if( strchr(zCap, 'm') ) oam = " checked";
287283
if( strchr(zCap, 'n') ) oan = " checked";
288284
if( strchr(zCap, 'o') ) oao = " checked";
289285
if( strchr(zCap, 'p') ) oap = " checked";
290286
if( strchr(zCap, 'q') ) oaq = " checked";
@@ -336,11 +332,10 @@
336332
@ <input type="checkbox" name="ag"%s(oag)>Clone</input><br>
337333
@ <input type="checkbox" name="aj"%s(oaj)>Read Wiki</input><br>
338334
@ <input type="checkbox" name="af"%s(oaf)>New Wiki</input><br>
339335
@ <input type="checkbox" name="am"%s(oam)>Append Wiki</input><br>
340336
@ <input type="checkbox" name="ak"%s(oak)>Write Wiki</input><br>
341
- @ <input type="checkbox" name="al"%s(oak)>Lock Wiki</input><br>
342337
@ <input type="checkbox" name="ar"%s(oar)>Read Tkt</input><br>
343338
@ <input type="checkbox" name="an"%s(oan)>New Tkt</input><br>
344339
@ <input type="checkbox" name="ac"%s(oac)>Append Tkt</input><br>
345340
@ <input type="checkbox" name="aw"%s(oaw)>Write Tkt</input>
346341
@ </td>
347342
--- src/setup.c
+++ src/setup.c
@@ -130,11 +130,10 @@
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>
@@ -160,11 +159,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
@@ -214,21 +213,19 @@
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'; }
@@ -265,11 +262,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);
@@ -280,11 +277,10 @@
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";
@@ -336,11 +332,10 @@
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>
347
--- src/setup.c
+++ src/setup.c
@@ -130,11 +130,10 @@
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>
@@ -160,11 +159,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
@@ -214,21 +213,19 @@
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'; }
@@ -265,11 +262,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);
@@ -280,11 +277,10 @@
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";
@@ -336,11 +332,10 @@
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>
342
+127 -16
--- src/wiki.c
+++ src/wiki.c
@@ -105,11 +105,10 @@
105105
void wiki_page(void){
106106
char *zTag;
107107
int rid;
108108
Blob wiki;
109109
Manifest m;
110
- int seenHr = 0;
111110
char *zPageName;
112111
char *zHtmlPageName;
113112
char *zBody = mprintf("%s","<i>Empty Page</i>");
114113
115114
login_check_credentials();
@@ -134,11 +133,15 @@
134133
zBody = m.zWiki;
135134
}
136135
}
137136
if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
138137
style_submenu_element("Edit", "Edit Wiki Page",
139
- mprintf("%s/wikiedit/%s", g.zTop, g.zExtra));
138
+ mprintf("%s/wikiedit/%s", g.zTop, g.zExtra));
139
+ }
140
+ if( rid && g.okApndWiki ){
141
+ style_submenu_element("Append", "Add A Comment",
142
+ mprintf("%s/wikiappend/%s", g.zTop, g.zExtra));
140143
}
141144
if( g.okHistory ){
142145
style_submenu_element("History", "History",
143146
mprintf("%s/whistory/%s", g.zTop, g.zExtra));
144147
}
@@ -146,24 +149,10 @@
146149
style_header(zHtmlPageName);
147150
blob_init(&wiki, zBody, -1);
148151
wiki_convert(&wiki, 0);
149152
blob_reset(&wiki);
150153
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
165154
style_footer();
166155
}
167156
168157
/*
169158
** WEBPAGE: wikiedit
@@ -269,11 +258,133 @@
269258
@ <input type="submit" name="submit" value="Apply These Changes">
270259
@ <input type="submit" name="cancel" value="Cancel">
271260
@ </form>
272261
manifest_clear(&m);
273262
style_footer();
263
+}
264
+
265
+/*
266
+** Append the wiki text for an remark to the end of the given BLOB.
267
+*/
268
+static void appendRemark(Blob *p){
269
+ char *zDate;
270
+ const char *zUser;
271
+ const char *zRemark;
272
+
273
+ zDate = db_text(0, "SELECT datetime('now')");
274
+ blob_appendf(p, "On %s UTC %h", zDate, g.zLogin);
275
+ free(zDate);
276
+ zUser = PD("u",g.zLogin);
277
+ if( zUser[0] && strcmp(zUser,g.zLogin) ){
278
+ blob_appendf(p, " (claiming to be %h)", zUser);
279
+ }
280
+ zRemark = PD("r","");
281
+ blob_appendf(p, " added:\n\n%s", zRemark);
282
+}
283
+
284
+/*
285
+** WEBPAGE: wikiappend
286
+** URL: /wikiappend/PAGENAME
287
+*/
288
+void wikiappend_page(void){
289
+ char *zTag;
290
+ int rid;
291
+ char *zPageName;
292
+ char *zHtmlPageName;
293
+ const char *zUser;
294
+
295
+ login_check_credentials();
296
+ zPageName = mprintf("%s", g.zExtra);
297
+ dehttpize(zPageName);
298
+ if( check_name(zPageName) ) return;
299
+ zTag = mprintf("wiki-%s", zPageName);
300
+ rid = db_int(0,
301
+ "SELECT rid FROM tagxref"
302
+ " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
303
+ " ORDER BY mtime DESC", zTag
304
+ );
305
+ free(zTag);
306
+ if( !rid ){
307
+ cgi_redirect("index");
308
+ return;
309
+ }
310
+ if( !g.okApndWiki ){
311
+ login_needed();
312
+ return;
313
+ }
314
+ if( P("submit")!=0 && P("r")!=0 && P("u")!=0 ){
315
+ char *zDate;
316
+ Blob cksum;
317
+ int nrid;
318
+ Blob body;
319
+ Blob content;
320
+ Blob wiki;
321
+ Manifest m;
274322
323
+ content_get(rid, &content);
324
+ manifest_parse(&m, &content);
325
+ blob_zero(&body);
326
+ if( m.type==CFTYPE_WIKI ){
327
+ blob_appendf(&body, m.zWiki, -1);
328
+ }
329
+ manifest_clear(&m);
330
+ blob_zero(&wiki);
331
+ db_begin_transaction();
332
+ zDate = db_text(0, "SELECT datetime('now')");
333
+ zDate[10] = 'T';
334
+ blob_appendf(&wiki, "D %s\n", zDate);
335
+ blob_appendf(&wiki, "L %F\n", zPageName);
336
+ if( rid ){
337
+ char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
338
+ blob_appendf(&wiki, "P %s\n", zUuid);
339
+ free(zUuid);
340
+ }
341
+ if( g.zLogin ){
342
+ blob_appendf(&wiki, "U %F\n", g.zLogin);
343
+ }
344
+ blob_appendf(&body, "\n<hr>\n");
345
+ appendRemark(&body);
346
+ blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
347
+ md5sum_blob(&wiki, &cksum);
348
+ blob_appendf(&wiki, "Z %b\n", &cksum);
349
+ blob_reset(&cksum);
350
+ nrid = content_put(&wiki, 0, 0);
351
+ db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
352
+ manifest_crosslink(nrid, &wiki);
353
+ blob_reset(&wiki);
354
+ content_deltify(rid, nrid, 0);
355
+ db_end_transaction(0);
356
+ cgi_redirect(mprintf("wiki/%s", g.zExtra));
357
+ }
358
+ if( P("cancel")!=0 ){
359
+ cgi_redirect(mprintf("wiki/%s", g.zExtra));
360
+ return;
361
+ }
362
+ zHtmlPageName = mprintf("Append Comment To: %h", zPageName);
363
+ style_header(zHtmlPageName);
364
+ if( P("preview")!=0 ){
365
+ Blob preview;
366
+ blob_zero(&preview);
367
+ appendRemark(&preview);
368
+ @ Preview:<hr>
369
+ wiki_convert(&preview, 0);
370
+ @ <hr>
371
+ blob_reset(&preview);
372
+ }
373
+ zUser = PD("u", g.zLogin);
374
+ @ <form method="POST" action="%s(g.zBaseURL)/wikiappend/%t(g.zExtra)">
375
+ @ Your Name:
376
+ @ <input type="text" name="u" size="20" value="%h(zUser)"><br>
377
+ @ Comment to append:<br>
378
+ @ <textarea name="r" class="wikiedit" cols="80"
379
+ @ rows="10" wrap="virtual">%h(PD("r",""))</textarea>
380
+ @ <br>
381
+ @ <input type="submit" name="preview" value="Preview Your Comment">
382
+ @ <input type="submit" name="submit" value="Append Your Changes">
383
+ @ <input type="submit" name="cancel" value="Cancel">
384
+ @ </form>
385
+ style_footer();
275386
}
276387
277388
/*
278389
** WEBPAGE: whistory
279390
**
280391
--- src/wiki.c
+++ src/wiki.c
@@ -105,11 +105,10 @@
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();
@@ -134,11 +133,15 @@
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 }
@@ -146,24 +149,10 @@
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
@@ -269,11 +258,133 @@
269 @ <input type="submit" name="submit" value="Apply These Changes">
270 @ <input type="submit" name="cancel" value="Cancel">
271 @ </form>
272 manifest_clear(&m);
273 style_footer();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275 }
276
277 /*
278 ** WEBPAGE: whistory
279 **
280
--- src/wiki.c
+++ src/wiki.c
@@ -105,11 +105,10 @@
105 void wiki_page(void){
106 char *zTag;
107 int rid;
108 Blob wiki;
109 Manifest m;
 
110 char *zPageName;
111 char *zHtmlPageName;
112 char *zBody = mprintf("%s","<i>Empty Page</i>");
113
114 login_check_credentials();
@@ -134,11 +133,15 @@
133 zBody = m.zWiki;
134 }
135 }
136 if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
137 style_submenu_element("Edit", "Edit Wiki Page",
138 mprintf("%s/wikiedit/%s", g.zTop, g.zExtra));
139 }
140 if( rid && g.okApndWiki ){
141 style_submenu_element("Append", "Add A Comment",
142 mprintf("%s/wikiappend/%s", g.zTop, g.zExtra));
143 }
144 if( g.okHistory ){
145 style_submenu_element("History", "History",
146 mprintf("%s/whistory/%s", g.zTop, g.zExtra));
147 }
@@ -146,24 +149,10 @@
149 style_header(zHtmlPageName);
150 blob_init(&wiki, zBody, -1);
151 wiki_convert(&wiki, 0);
152 blob_reset(&wiki);
153 manifest_clear(&m);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154 style_footer();
155 }
156
157 /*
158 ** WEBPAGE: wikiedit
@@ -269,11 +258,133 @@
258 @ <input type="submit" name="submit" value="Apply These Changes">
259 @ <input type="submit" name="cancel" value="Cancel">
260 @ </form>
261 manifest_clear(&m);
262 style_footer();
263 }
264
265 /*
266 ** Append the wiki text for an remark to the end of the given BLOB.
267 */
268 static void appendRemark(Blob *p){
269 char *zDate;
270 const char *zUser;
271 const char *zRemark;
272
273 zDate = db_text(0, "SELECT datetime('now')");
274 blob_appendf(p, "On %s UTC %h", zDate, g.zLogin);
275 free(zDate);
276 zUser = PD("u",g.zLogin);
277 if( zUser[0] && strcmp(zUser,g.zLogin) ){
278 blob_appendf(p, " (claiming to be %h)", zUser);
279 }
280 zRemark = PD("r","");
281 blob_appendf(p, " added:\n\n%s", zRemark);
282 }
283
284 /*
285 ** WEBPAGE: wikiappend
286 ** URL: /wikiappend/PAGENAME
287 */
288 void wikiappend_page(void){
289 char *zTag;
290 int rid;
291 char *zPageName;
292 char *zHtmlPageName;
293 const char *zUser;
294
295 login_check_credentials();
296 zPageName = mprintf("%s", g.zExtra);
297 dehttpize(zPageName);
298 if( check_name(zPageName) ) return;
299 zTag = mprintf("wiki-%s", zPageName);
300 rid = db_int(0,
301 "SELECT rid FROM tagxref"
302 " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
303 " ORDER BY mtime DESC", zTag
304 );
305 free(zTag);
306 if( !rid ){
307 cgi_redirect("index");
308 return;
309 }
310 if( !g.okApndWiki ){
311 login_needed();
312 return;
313 }
314 if( P("submit")!=0 && P("r")!=0 && P("u")!=0 ){
315 char *zDate;
316 Blob cksum;
317 int nrid;
318 Blob body;
319 Blob content;
320 Blob wiki;
321 Manifest m;
322
323 content_get(rid, &content);
324 manifest_parse(&m, &content);
325 blob_zero(&body);
326 if( m.type==CFTYPE_WIKI ){
327 blob_appendf(&body, m.zWiki, -1);
328 }
329 manifest_clear(&m);
330 blob_zero(&wiki);
331 db_begin_transaction();
332 zDate = db_text(0, "SELECT datetime('now')");
333 zDate[10] = 'T';
334 blob_appendf(&wiki, "D %s\n", zDate);
335 blob_appendf(&wiki, "L %F\n", zPageName);
336 if( rid ){
337 char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
338 blob_appendf(&wiki, "P %s\n", zUuid);
339 free(zUuid);
340 }
341 if( g.zLogin ){
342 blob_appendf(&wiki, "U %F\n", g.zLogin);
343 }
344 blob_appendf(&body, "\n<hr>\n");
345 appendRemark(&body);
346 blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
347 md5sum_blob(&wiki, &cksum);
348 blob_appendf(&wiki, "Z %b\n", &cksum);
349 blob_reset(&cksum);
350 nrid = content_put(&wiki, 0, 0);
351 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
352 manifest_crosslink(nrid, &wiki);
353 blob_reset(&wiki);
354 content_deltify(rid, nrid, 0);
355 db_end_transaction(0);
356 cgi_redirect(mprintf("wiki/%s", g.zExtra));
357 }
358 if( P("cancel")!=0 ){
359 cgi_redirect(mprintf("wiki/%s", g.zExtra));
360 return;
361 }
362 zHtmlPageName = mprintf("Append Comment To: %h", zPageName);
363 style_header(zHtmlPageName);
364 if( P("preview")!=0 ){
365 Blob preview;
366 blob_zero(&preview);
367 appendRemark(&preview);
368 @ Preview:<hr>
369 wiki_convert(&preview, 0);
370 @ <hr>
371 blob_reset(&preview);
372 }
373 zUser = PD("u", g.zLogin);
374 @ <form method="POST" action="%s(g.zBaseURL)/wikiappend/%t(g.zExtra)">
375 @ Your Name:
376 @ <input type="text" name="u" size="20" value="%h(zUser)"><br>
377 @ Comment to append:<br>
378 @ <textarea name="r" class="wikiedit" cols="80"
379 @ rows="10" wrap="virtual">%h(PD("r",""))</textarea>
380 @ <br>
381 @ <input type="submit" name="preview" value="Preview Your Comment">
382 @ <input type="submit" name="submit" value="Append Your Changes">
383 @ <input type="submit" name="cancel" value="Cancel">
384 @ </form>
385 style_footer();
386 }
387
388 /*
389 ** WEBPAGE: whistory
390 **
391

Keyboard Shortcuts

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