Fossil SCM

Add a configuration option that enables WYSIWYG wiki editing. The traditional markup editor is still used unless this option is enabled.

drh 2012-08-11 15:37 UTC wysiwyg
Commit ebc48bf180d84a82f7f8955d818b62d8dc5fdac3
2 files changed +7 -1 +21 -6
+7 -1
--- src/setup.c
+++ src/setup.c
@@ -1248,15 +1248,21 @@
12481248
@ <hr />
12491249
entry_attribute("Project Name", 60, "project-name", "pn", "");
12501250
@ <p>Give your project a name so visitors know what this site is about.
12511251
@ The project name will also be used as the RSS feed title.</p>
12521252
@ <hr />
1253
- textarea_attribute("Project Description", 5, 60,
1253
+ textarea_attribute("Project Description", 3, 80,
12541254
"project-description", "pd", "");
12551255
@ <p>Describe your project. This will be used in page headers for search
12561256
@ engines as well as a short RSS description.</p>
12571257
@ <hr />
1258
+ onoff_attribute("Enable WYSIWYG Wiki Editing",
1259
+ "wysiwyg-wiki", "wysiwyg-wiki", 0);
1260
+ @ <p>Enable what-you-see-is-what-you-get (WYSIWYG) editing of wiki pages.
1261
+ @ The WYSIWYG editor generates HTML instead of markup, which makes
1262
+ @ subsequent manual editing more difficult.</p>
1263
+ @ <hr />
12581264
entry_attribute("Index Page", 60, "index-page", "idxpg", "/home");
12591265
@ <p>Enter the pathname of the page to display when the "Home" menu
12601266
@ option is selected and when no pathname is
12611267
@ specified in the URL. For example, if you visit the url:</p>
12621268
@
12631269
--- src/setup.c
+++ src/setup.c
@@ -1248,15 +1248,21 @@
1248 @ <hr />
1249 entry_attribute("Project Name", 60, "project-name", "pn", "");
1250 @ <p>Give your project a name so visitors know what this site is about.
1251 @ The project name will also be used as the RSS feed title.</p>
1252 @ <hr />
1253 textarea_attribute("Project Description", 5, 60,
1254 "project-description", "pd", "");
1255 @ <p>Describe your project. This will be used in page headers for search
1256 @ engines as well as a short RSS description.</p>
1257 @ <hr />
 
 
 
 
 
 
1258 entry_attribute("Index Page", 60, "index-page", "idxpg", "/home");
1259 @ <p>Enter the pathname of the page to display when the "Home" menu
1260 @ option is selected and when no pathname is
1261 @ specified in the URL. For example, if you visit the url:</p>
1262 @
1263
--- src/setup.c
+++ src/setup.c
@@ -1248,15 +1248,21 @@
1248 @ <hr />
1249 entry_attribute("Project Name", 60, "project-name", "pn", "");
1250 @ <p>Give your project a name so visitors know what this site is about.
1251 @ The project name will also be used as the RSS feed title.</p>
1252 @ <hr />
1253 textarea_attribute("Project Description", 3, 80,
1254 "project-description", "pd", "");
1255 @ <p>Describe your project. This will be used in page headers for search
1256 @ engines as well as a short RSS description.</p>
1257 @ <hr />
1258 onoff_attribute("Enable WYSIWYG Wiki Editing",
1259 "wysiwyg-wiki", "wysiwyg-wiki", 0);
1260 @ <p>Enable what-you-see-is-what-you-get (WYSIWYG) editing of wiki pages.
1261 @ The WYSIWYG editor generates HTML instead of markup, which makes
1262 @ subsequent manual editing more difficult.</p>
1263 @ <hr />
1264 entry_attribute("Index Page", 60, "index-page", "idxpg", "/home");
1265 @ <p>Enter the pathname of the page to display when the "Home" menu
1266 @ option is selected and when no pathname is
1267 @ specified in the URL. For example, if you visit the url:</p>
1268 @
1269
+21 -6
--- src/wiki.c
+++ src/wiki.c
@@ -185,14 +185,19 @@
185185
zBody = pWiki->zWiki;
186186
}
187187
}
188188
if( !g.isHome ){
189189
if( (rid && g.perm.WrWiki) || (!rid && g.perm.NewWiki) ){
190
- style_submenu_element("Edit", "Edit Wiki Page", "%s/wikiedit?name=%T",
191
- g.zTop, zPageName);
192
- style_submenu_element("Wysiwyg", "Wysiwyg Editor",
193
- "%s/wikiedit?name=%T&wysiwyg", g.zTop, zPageName);
190
+ if( db_get_boolean("wysiwyg-wiki", 0) ){
191
+ style_submenu_element("Edit", "Edit Wiki Page",
192
+ "%s/wikiedit?name=%T&wysiwyg=1",
193
+ g.zTop, zPageName);
194
+ }else{
195
+ style_submenu_element("Edit", "Edit Wiki Page",
196
+ "%s/wikiedit?name=%T",
197
+ g.zTop, zPageName);
198
+ }
194199
}
195200
if( rid && g.perm.ApndWiki && g.perm.Attach ){
196201
style_submenu_element("Attach", "Add An Attachment",
197202
"%s/attachadd?page=%T&from=%s/wiki%%3fname=%T",
198203
g.zTop, zPageName, g.zTop, zPageName);
@@ -264,10 +269,12 @@
264269
int n;
265270
const char *z;
266271
char *zBody = (char*)P("w");
267272
int isWysiwyg = P("wysiwyg")!=0;
268273
274
+ if( P("edit-wysiwyg")!=0 ){ isWysiwyg = 1; zBody = 0; }
275
+ if( P("edit-markup")!=0 ){ isWysiwyg = 0; zBody = 0; }
269276
if( zBody ){
270277
if( isWysiwyg ){
271278
Blob body;
272279
blob_zero(&body);
273280
htmlTidy(zBody, &body);
@@ -359,17 +366,20 @@
359366
for(n=2, z=zBody; z[0]; z++){
360367
if( z[0]=='\n' ) n++;
361368
}
362369
if( n<20 ) n = 20;
363370
if( n>30 ) n = 30;
364
- if( P("wysiwyg")==0 ){
371
+ if( !isWysiwyg ){
365372
/* Traditional markup-only editing */
366373
@ <form method="post" action="%s(g.zTop)/wikiedit"><div>
367374
@ <textarea name="w" class="wikiedit" cols="80"
368375
@ rows="%d(n)" wrap="virtual">%h(zBody)</textarea>
369376
@ <br />
370377
@ <input type="submit" name="preview" value="Preview Your Changes" />
378
+ if( db_get_boolean("wysiwyg-wiki", 0) ){
379
+ @ <input type="submit" name="edit-wysiwyg" value="Wysiwyg Editor" />
380
+ }
371381
}else{
372382
/* Wysiwyg editing */
373383
Blob html, temp;
374384
@ <form method="post" action="%s(g.zTop)/wikiedit"
375385
@ onsubmit="wysiwygSubmit()"><div>
@@ -380,10 +390,11 @@
380390
htmlTidy(blob_str(&temp), &html);
381391
blob_reset(&temp);
382392
wysiwygEditor("w", blob_str(&html), 60, n);
383393
blob_reset(&html);
384394
@ <br />
395
+ @ <input type="submit" name="edit-markup" value="Markup Editor" />
385396
}
386397
@ <input type="submit" name="submit" value="Apply These Changes" />
387398
login_insert_csrf_secret();
388399
@ <input type="hidden" name="name" value="%h(zPageName)" />
389400
@ <input type="submit" name="cancel" value="Cancel" />
@@ -407,11 +418,15 @@
407418
login_needed();
408419
return;
409420
}
410421
zName = PD("name","");
411422
if( zName[0] && wiki_name_is_wellformed((const unsigned char *)zName) ){
412
- cgi_redirectf("wikiedit?name=%T&wysiwyg", zName);
423
+ if( db_get_boolean("wysiwyg-wiki", 0) ){
424
+ cgi_redirectf("wikiedit?name=%T&wysiwyg=1", zName);
425
+ }else{
426
+ cgi_redirectf("wikiedit?name=%T", zName);
427
+ }
413428
}
414429
style_header("Create A New Wiki Page");
415430
@ <p>Rules for wiki page names:</p>
416431
well_formed_wiki_name_rules();
417432
@ <form method="post" action="%s(g.zTop)/wikinew">
418433
--- src/wiki.c
+++ src/wiki.c
@@ -185,14 +185,19 @@
185 zBody = pWiki->zWiki;
186 }
187 }
188 if( !g.isHome ){
189 if( (rid && g.perm.WrWiki) || (!rid && g.perm.NewWiki) ){
190 style_submenu_element("Edit", "Edit Wiki Page", "%s/wikiedit?name=%T",
191 g.zTop, zPageName);
192 style_submenu_element("Wysiwyg", "Wysiwyg Editor",
193 "%s/wikiedit?name=%T&wysiwyg", g.zTop, zPageName);
 
 
 
 
 
194 }
195 if( rid && g.perm.ApndWiki && g.perm.Attach ){
196 style_submenu_element("Attach", "Add An Attachment",
197 "%s/attachadd?page=%T&from=%s/wiki%%3fname=%T",
198 g.zTop, zPageName, g.zTop, zPageName);
@@ -264,10 +269,12 @@
264 int n;
265 const char *z;
266 char *zBody = (char*)P("w");
267 int isWysiwyg = P("wysiwyg")!=0;
268
 
 
269 if( zBody ){
270 if( isWysiwyg ){
271 Blob body;
272 blob_zero(&body);
273 htmlTidy(zBody, &body);
@@ -359,17 +366,20 @@
359 for(n=2, z=zBody; z[0]; z++){
360 if( z[0]=='\n' ) n++;
361 }
362 if( n<20 ) n = 20;
363 if( n>30 ) n = 30;
364 if( P("wysiwyg")==0 ){
365 /* Traditional markup-only editing */
366 @ <form method="post" action="%s(g.zTop)/wikiedit"><div>
367 @ <textarea name="w" class="wikiedit" cols="80"
368 @ rows="%d(n)" wrap="virtual">%h(zBody)</textarea>
369 @ <br />
370 @ <input type="submit" name="preview" value="Preview Your Changes" />
 
 
 
371 }else{
372 /* Wysiwyg editing */
373 Blob html, temp;
374 @ <form method="post" action="%s(g.zTop)/wikiedit"
375 @ onsubmit="wysiwygSubmit()"><div>
@@ -380,10 +390,11 @@
380 htmlTidy(blob_str(&temp), &html);
381 blob_reset(&temp);
382 wysiwygEditor("w", blob_str(&html), 60, n);
383 blob_reset(&html);
384 @ <br />
 
385 }
386 @ <input type="submit" name="submit" value="Apply These Changes" />
387 login_insert_csrf_secret();
388 @ <input type="hidden" name="name" value="%h(zPageName)" />
389 @ <input type="submit" name="cancel" value="Cancel" />
@@ -407,11 +418,15 @@
407 login_needed();
408 return;
409 }
410 zName = PD("name","");
411 if( zName[0] && wiki_name_is_wellformed((const unsigned char *)zName) ){
412 cgi_redirectf("wikiedit?name=%T&wysiwyg", zName);
 
 
 
 
413 }
414 style_header("Create A New Wiki Page");
415 @ <p>Rules for wiki page names:</p>
416 well_formed_wiki_name_rules();
417 @ <form method="post" action="%s(g.zTop)/wikinew">
418
--- src/wiki.c
+++ src/wiki.c
@@ -185,14 +185,19 @@
185 zBody = pWiki->zWiki;
186 }
187 }
188 if( !g.isHome ){
189 if( (rid && g.perm.WrWiki) || (!rid && g.perm.NewWiki) ){
190 if( db_get_boolean("wysiwyg-wiki", 0) ){
191 style_submenu_element("Edit", "Edit Wiki Page",
192 "%s/wikiedit?name=%T&wysiwyg=1",
193 g.zTop, zPageName);
194 }else{
195 style_submenu_element("Edit", "Edit Wiki Page",
196 "%s/wikiedit?name=%T",
197 g.zTop, zPageName);
198 }
199 }
200 if( rid && g.perm.ApndWiki && g.perm.Attach ){
201 style_submenu_element("Attach", "Add An Attachment",
202 "%s/attachadd?page=%T&from=%s/wiki%%3fname=%T",
203 g.zTop, zPageName, g.zTop, zPageName);
@@ -264,10 +269,12 @@
269 int n;
270 const char *z;
271 char *zBody = (char*)P("w");
272 int isWysiwyg = P("wysiwyg")!=0;
273
274 if( P("edit-wysiwyg")!=0 ){ isWysiwyg = 1; zBody = 0; }
275 if( P("edit-markup")!=0 ){ isWysiwyg = 0; zBody = 0; }
276 if( zBody ){
277 if( isWysiwyg ){
278 Blob body;
279 blob_zero(&body);
280 htmlTidy(zBody, &body);
@@ -359,17 +366,20 @@
366 for(n=2, z=zBody; z[0]; z++){
367 if( z[0]=='\n' ) n++;
368 }
369 if( n<20 ) n = 20;
370 if( n>30 ) n = 30;
371 if( !isWysiwyg ){
372 /* Traditional markup-only editing */
373 @ <form method="post" action="%s(g.zTop)/wikiedit"><div>
374 @ <textarea name="w" class="wikiedit" cols="80"
375 @ rows="%d(n)" wrap="virtual">%h(zBody)</textarea>
376 @ <br />
377 @ <input type="submit" name="preview" value="Preview Your Changes" />
378 if( db_get_boolean("wysiwyg-wiki", 0) ){
379 @ <input type="submit" name="edit-wysiwyg" value="Wysiwyg Editor" />
380 }
381 }else{
382 /* Wysiwyg editing */
383 Blob html, temp;
384 @ <form method="post" action="%s(g.zTop)/wikiedit"
385 @ onsubmit="wysiwygSubmit()"><div>
@@ -380,10 +390,11 @@
390 htmlTidy(blob_str(&temp), &html);
391 blob_reset(&temp);
392 wysiwygEditor("w", blob_str(&html), 60, n);
393 blob_reset(&html);
394 @ <br />
395 @ <input type="submit" name="edit-markup" value="Markup Editor" />
396 }
397 @ <input type="submit" name="submit" value="Apply These Changes" />
398 login_insert_csrf_secret();
399 @ <input type="hidden" name="name" value="%h(zPageName)" />
400 @ <input type="submit" name="cancel" value="Cancel" />
@@ -407,11 +418,15 @@
418 login_needed();
419 return;
420 }
421 zName = PD("name","");
422 if( zName[0] && wiki_name_is_wellformed((const unsigned char *)zName) ){
423 if( db_get_boolean("wysiwyg-wiki", 0) ){
424 cgi_redirectf("wikiedit?name=%T&wysiwyg=1", zName);
425 }else{
426 cgi_redirectf("wikiedit?name=%T", zName);
427 }
428 }
429 style_header("Create A New Wiki Page");
430 @ <p>Rules for wiki page names:</p>
431 well_formed_wiki_name_rules();
432 @ <form method="post" action="%s(g.zTop)/wikinew">
433

Keyboard Shortcuts

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