Fossil SCM
Add a configuration option that enables WYSIWYG wiki editing. The traditional markup editor is still used unless this option is enabled.
Commit
ebc48bf180d84a82f7f8955d818b62d8dc5fdac3
Parent
bf27074c825143d…
2 files changed
+7
-1
+21
-6
+7
-1
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -1248,15 +1248,21 @@ | ||
| 1248 | 1248 | @ <hr /> |
| 1249 | 1249 | entry_attribute("Project Name", 60, "project-name", "pn", ""); |
| 1250 | 1250 | @ <p>Give your project a name so visitors know what this site is about. |
| 1251 | 1251 | @ The project name will also be used as the RSS feed title.</p> |
| 1252 | 1252 | @ <hr /> |
| 1253 | - textarea_attribute("Project Description", 5, 60, | |
| 1253 | + textarea_attribute("Project Description", 3, 80, | |
| 1254 | 1254 | "project-description", "pd", ""); |
| 1255 | 1255 | @ <p>Describe your project. This will be used in page headers for search |
| 1256 | 1256 | @ engines as well as a short RSS description.</p> |
| 1257 | 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 /> | |
| 1258 | 1264 | entry_attribute("Index Page", 60, "index-page", "idxpg", "/home"); |
| 1259 | 1265 | @ <p>Enter the pathname of the page to display when the "Home" menu |
| 1260 | 1266 | @ option is selected and when no pathname is |
| 1261 | 1267 | @ specified in the URL. For example, if you visit the url:</p> |
| 1262 | 1268 | @ |
| 1263 | 1269 |
| --- 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 @@ | ||
| 185 | 185 | zBody = pWiki->zWiki; |
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | if( !g.isHome ){ |
| 189 | 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); | |
| 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 | + } | |
| 194 | 199 | } |
| 195 | 200 | if( rid && g.perm.ApndWiki && g.perm.Attach ){ |
| 196 | 201 | style_submenu_element("Attach", "Add An Attachment", |
| 197 | 202 | "%s/attachadd?page=%T&from=%s/wiki%%3fname=%T", |
| 198 | 203 | g.zTop, zPageName, g.zTop, zPageName); |
| @@ -264,10 +269,12 @@ | ||
| 264 | 269 | int n; |
| 265 | 270 | const char *z; |
| 266 | 271 | char *zBody = (char*)P("w"); |
| 267 | 272 | int isWysiwyg = P("wysiwyg")!=0; |
| 268 | 273 | |
| 274 | + if( P("edit-wysiwyg")!=0 ){ isWysiwyg = 1; zBody = 0; } | |
| 275 | + if( P("edit-markup")!=0 ){ isWysiwyg = 0; zBody = 0; } | |
| 269 | 276 | if( zBody ){ |
| 270 | 277 | if( isWysiwyg ){ |
| 271 | 278 | Blob body; |
| 272 | 279 | blob_zero(&body); |
| 273 | 280 | htmlTidy(zBody, &body); |
| @@ -359,17 +366,20 @@ | ||
| 359 | 366 | for(n=2, z=zBody; z[0]; z++){ |
| 360 | 367 | if( z[0]=='\n' ) n++; |
| 361 | 368 | } |
| 362 | 369 | if( n<20 ) n = 20; |
| 363 | 370 | if( n>30 ) n = 30; |
| 364 | - if( P("wysiwyg")==0 ){ | |
| 371 | + if( !isWysiwyg ){ | |
| 365 | 372 | /* Traditional markup-only editing */ |
| 366 | 373 | @ <form method="post" action="%s(g.zTop)/wikiedit"><div> |
| 367 | 374 | @ <textarea name="w" class="wikiedit" cols="80" |
| 368 | 375 | @ rows="%d(n)" wrap="virtual">%h(zBody)</textarea> |
| 369 | 376 | @ <br /> |
| 370 | 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 | + } | |
| 371 | 381 | }else{ |
| 372 | 382 | /* Wysiwyg editing */ |
| 373 | 383 | Blob html, temp; |
| 374 | 384 | @ <form method="post" action="%s(g.zTop)/wikiedit" |
| 375 | 385 | @ onsubmit="wysiwygSubmit()"><div> |
| @@ -380,10 +390,11 @@ | ||
| 380 | 390 | htmlTidy(blob_str(&temp), &html); |
| 381 | 391 | blob_reset(&temp); |
| 382 | 392 | wysiwygEditor("w", blob_str(&html), 60, n); |
| 383 | 393 | blob_reset(&html); |
| 384 | 394 | @ <br /> |
| 395 | + @ <input type="submit" name="edit-markup" value="Markup Editor" /> | |
| 385 | 396 | } |
| 386 | 397 | @ <input type="submit" name="submit" value="Apply These Changes" /> |
| 387 | 398 | login_insert_csrf_secret(); |
| 388 | 399 | @ <input type="hidden" name="name" value="%h(zPageName)" /> |
| 389 | 400 | @ <input type="submit" name="cancel" value="Cancel" /> |
| @@ -407,11 +418,15 @@ | ||
| 407 | 418 | login_needed(); |
| 408 | 419 | return; |
| 409 | 420 | } |
| 410 | 421 | zName = PD("name",""); |
| 411 | 422 | 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 | + } | |
| 413 | 428 | } |
| 414 | 429 | style_header("Create A New Wiki Page"); |
| 415 | 430 | @ <p>Rules for wiki page names:</p> |
| 416 | 431 | well_formed_wiki_name_rules(); |
| 417 | 432 | @ <form method="post" action="%s(g.zTop)/wikinew"> |
| 418 | 433 |
| --- 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 |