Fossil SCM
Added style_emit_noscript_for_js_page() to emit a NOSCRIPT tag and an error message if JS is not available, and call it from the pages which *required* JS in order to work. Added a note about potential browser-induced SVG blurring when using the pikchrshow dark mode option.
Commit
070716d835efaeb54be98f95a00451f0dc7845535693833712bef41796a31c44
Parent
c92ff2daef6fdbe…
6 files changed
+6
+1
+6
-2
+3
-3
+12
+1
+6
| --- src/default.css | ||
| +++ src/default.css | ||
| @@ -1378,5 +1378,11 @@ | ||
| 1378 | 1378 | .fossil-tooltip.help-buttonlet-content { |
| 1379 | 1379 | cursor: default; |
| 1380 | 1380 | text-align: left; |
| 1381 | 1381 | border-style: outset; |
| 1382 | 1382 | } |
| 1383 | + | |
| 1384 | +noscript > .error { | |
| 1385 | + /* Part of the style_emit_noscript_for_js_page() interface. */ | |
| 1386 | + padding: 1em; | |
| 1387 | + font-size: 150%; | |
| 1388 | +} | |
| 1383 | 1389 |
| --- src/default.css | |
| +++ src/default.css | |
| @@ -1378,5 +1378,11 @@ | |
| 1378 | .fossil-tooltip.help-buttonlet-content { |
| 1379 | cursor: default; |
| 1380 | text-align: left; |
| 1381 | border-style: outset; |
| 1382 | } |
| 1383 |
| --- src/default.css | |
| +++ src/default.css | |
| @@ -1378,5 +1378,11 @@ | |
| 1378 | .fossil-tooltip.help-buttonlet-content { |
| 1379 | cursor: default; |
| 1380 | text-align: left; |
| 1381 | border-style: outset; |
| 1382 | } |
| 1383 | |
| 1384 | noscript > .error { |
| 1385 | /* Part of the style_emit_noscript_for_js_page() interface. */ |
| 1386 | padding: 1em; |
| 1387 | font-size: 150%; |
| 1388 | } |
| 1389 |
+1
| --- src/fileedit.c | ||
| +++ src/fileedit.c | ||
| @@ -1633,10 +1633,11 @@ | ||
| 1633 | 1633 | } |
| 1634 | 1634 | |
| 1635 | 1635 | db_begin_transaction(); |
| 1636 | 1636 | CheckinMiniInfo_init(&cimi); |
| 1637 | 1637 | style_header("File Editor"); |
| 1638 | + style_emit_noscript_for_js_page(); | |
| 1638 | 1639 | /* As of this point, don't use return or fossil_fatal(). Write any |
| 1639 | 1640 | ** error in (&err) and goto end_footer instead so that we can be |
| 1640 | 1641 | ** sure to emit the error message, do any cleanup, and end the |
| 1641 | 1642 | ** transaction cleanly. |
| 1642 | 1643 | */ |
| 1643 | 1644 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -1633,10 +1633,11 @@ | |
| 1633 | } |
| 1634 | |
| 1635 | db_begin_transaction(); |
| 1636 | CheckinMiniInfo_init(&cimi); |
| 1637 | style_header("File Editor"); |
| 1638 | /* As of this point, don't use return or fossil_fatal(). Write any |
| 1639 | ** error in (&err) and goto end_footer instead so that we can be |
| 1640 | ** sure to emit the error message, do any cleanup, and end the |
| 1641 | ** transaction cleanly. |
| 1642 | */ |
| 1643 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -1633,10 +1633,11 @@ | |
| 1633 | } |
| 1634 | |
| 1635 | db_begin_transaction(); |
| 1636 | CheckinMiniInfo_init(&cimi); |
| 1637 | style_header("File Editor"); |
| 1638 | style_emit_noscript_for_js_page(); |
| 1639 | /* As of this point, don't use return or fossil_fatal(). Write any |
| 1640 | ** error in (&err) and goto end_footer instead so that we can be |
| 1641 | ** sure to emit the error message, do any cleanup, and end the |
| 1642 | ** transaction cleanly. |
| 1643 | */ |
| 1644 |
+6
-2
| --- src/fossil.page.pikchrshow.js | ||
| +++ src/fossil.page.pikchrshow.js | ||
| @@ -138,15 +138,19 @@ | ||
| 138 | 138 | D.append( |
| 139 | 139 | P.e.uiControls, |
| 140 | 140 | D.append( |
| 141 | 141 | P.e.cbDarkMode.parentNode/*the .input-with-label element*/, |
| 142 | 142 | F.helpButtonlets.create( |
| 143 | - D.span(), | |
| 143 | + D.div(), | |
| 144 | 144 | 'Dark mode changes the colors of rendered SVG to ', |
| 145 | 145 | 'make them more visible in dark-themed skins. ', |
| 146 | 146 | 'This only changes (using CSS) how they are rendered, ', |
| 147 | - 'not any actual colors written in the script.' | |
| 147 | + 'not any actual colors written in the script.', | |
| 148 | + D.br(), D.br(), | |
| 149 | + 'In some color combinations, certain browsers might ', | |
| 150 | + 'cause the SVG image to blur considerably with this ', | |
| 151 | + 'setting enabled!' | |
| 148 | 152 | ) |
| 149 | 153 | ) |
| 150 | 154 | ); |
| 151 | 155 | |
| 152 | 156 | //////////////////////////////////////////////////////////// |
| 153 | 157 |
| --- src/fossil.page.pikchrshow.js | |
| +++ src/fossil.page.pikchrshow.js | |
| @@ -138,15 +138,19 @@ | |
| 138 | D.append( |
| 139 | P.e.uiControls, |
| 140 | D.append( |
| 141 | P.e.cbDarkMode.parentNode/*the .input-with-label element*/, |
| 142 | F.helpButtonlets.create( |
| 143 | D.span(), |
| 144 | 'Dark mode changes the colors of rendered SVG to ', |
| 145 | 'make them more visible in dark-themed skins. ', |
| 146 | 'This only changes (using CSS) how they are rendered, ', |
| 147 | 'not any actual colors written in the script.' |
| 148 | ) |
| 149 | ) |
| 150 | ); |
| 151 | |
| 152 | //////////////////////////////////////////////////////////// |
| 153 |
| --- src/fossil.page.pikchrshow.js | |
| +++ src/fossil.page.pikchrshow.js | |
| @@ -138,15 +138,19 @@ | |
| 138 | D.append( |
| 139 | P.e.uiControls, |
| 140 | D.append( |
| 141 | P.e.cbDarkMode.parentNode/*the .input-with-label element*/, |
| 142 | F.helpButtonlets.create( |
| 143 | D.div(), |
| 144 | 'Dark mode changes the colors of rendered SVG to ', |
| 145 | 'make them more visible in dark-themed skins. ', |
| 146 | 'This only changes (using CSS) how they are rendered, ', |
| 147 | 'not any actual colors written in the script.', |
| 148 | D.br(), D.br(), |
| 149 | 'In some color combinations, certain browsers might ', |
| 150 | 'cause the SVG image to blur considerably with this ', |
| 151 | 'setting enabled!' |
| 152 | ) |
| 153 | ) |
| 154 | ); |
| 155 | |
| 156 | //////////////////////////////////////////////////////////// |
| 157 |
+3
-3
| --- src/pikchrshow.c | ||
| +++ src/pikchrshow.c | ||
| @@ -30,11 +30,11 @@ | ||
| 30 | 30 | ** with pikchr code or prototype it for use in copy/pasting into forum |
| 31 | 31 | ** posts, wiki pages, or embedded docs. |
| 32 | 32 | */ |
| 33 | 33 | void pikchrshow_page(void){ |
| 34 | 34 | const char *zContent = 0; |
| 35 | - int isDark, flipColors; | |
| 35 | + int isDark; /* true if the current skin is "dark" */ | |
| 36 | 36 | |
| 37 | 37 | login_check_credentials(); |
| 38 | 38 | if( !g.perm.RdWiki && !g.perm.Read && !g.perm.RdForum ){ |
| 39 | 39 | cgi_redirectf("%s/login?g=%s/pikchrshow", g.zTop, g.zTop); |
| 40 | 40 | } |
| @@ -57,12 +57,12 @@ | ||
| 57 | 57 | }else{ |
| 58 | 58 | CX("<pre>No content! Nothing to render</pre>"); |
| 59 | 59 | } |
| 60 | 60 | return; |
| 61 | 61 | } |
| 62 | + style_emit_noscript_for_js_page(); | |
| 62 | 63 | isDark = skin_detail_boolean("white-foreground"); |
| 63 | - flipColors = zContent ? P("flipcolors")!=0 : isDark; | |
| 64 | 64 | if(!zContent){ |
| 65 | 65 | zContent = "arrow right 200% \"Markdown\" \"Source\"\n" |
| 66 | 66 | "box rad 10px \"Markdown\" \"Formatter\" \"(markdown.c)\" fit\n" |
| 67 | 67 | "arrow right 200% \"HTML+SVG\" \"Output\"\n" |
| 68 | 68 | "arrow <-> down from last box.s\n" |
| @@ -128,11 +128,11 @@ | ||
| 128 | 128 | zContent/*safe-for-%s*/); |
| 129 | 129 | CX("<div id='pikchrshow-controls'>"); |
| 130 | 130 | CX("<button id='pikchr-submit-preview'>Preview</button>"); |
| 131 | 131 | style_labeled_checkbox("flipcolors-wrapper", "flipcolors", |
| 132 | 132 | "Dark mode?", |
| 133 | - "1", flipColors, 0); | |
| 133 | + "1", isDark, 0); | |
| 134 | 134 | CX("</div>"/*#pikchrshow-controls*/); |
| 135 | 135 | CX("</div>"/*#pikchrshow-form*/); |
| 136 | 136 | CX("<fieldset id='pikchrshow-output-wrapper'>"); |
| 137 | 137 | CX("<legend></legend>" |
| 138 | 138 | /* Reminder: Firefox does not properly flexbox a LEGEND element, |
| 139 | 139 |
| --- src/pikchrshow.c | |
| +++ src/pikchrshow.c | |
| @@ -30,11 +30,11 @@ | |
| 30 | ** with pikchr code or prototype it for use in copy/pasting into forum |
| 31 | ** posts, wiki pages, or embedded docs. |
| 32 | */ |
| 33 | void pikchrshow_page(void){ |
| 34 | const char *zContent = 0; |
| 35 | int isDark, flipColors; |
| 36 | |
| 37 | login_check_credentials(); |
| 38 | if( !g.perm.RdWiki && !g.perm.Read && !g.perm.RdForum ){ |
| 39 | cgi_redirectf("%s/login?g=%s/pikchrshow", g.zTop, g.zTop); |
| 40 | } |
| @@ -57,12 +57,12 @@ | |
| 57 | }else{ |
| 58 | CX("<pre>No content! Nothing to render</pre>"); |
| 59 | } |
| 60 | return; |
| 61 | } |
| 62 | isDark = skin_detail_boolean("white-foreground"); |
| 63 | flipColors = zContent ? P("flipcolors")!=0 : isDark; |
| 64 | if(!zContent){ |
| 65 | zContent = "arrow right 200% \"Markdown\" \"Source\"\n" |
| 66 | "box rad 10px \"Markdown\" \"Formatter\" \"(markdown.c)\" fit\n" |
| 67 | "arrow right 200% \"HTML+SVG\" \"Output\"\n" |
| 68 | "arrow <-> down from last box.s\n" |
| @@ -128,11 +128,11 @@ | |
| 128 | zContent/*safe-for-%s*/); |
| 129 | CX("<div id='pikchrshow-controls'>"); |
| 130 | CX("<button id='pikchr-submit-preview'>Preview</button>"); |
| 131 | style_labeled_checkbox("flipcolors-wrapper", "flipcolors", |
| 132 | "Dark mode?", |
| 133 | "1", flipColors, 0); |
| 134 | CX("</div>"/*#pikchrshow-controls*/); |
| 135 | CX("</div>"/*#pikchrshow-form*/); |
| 136 | CX("<fieldset id='pikchrshow-output-wrapper'>"); |
| 137 | CX("<legend></legend>" |
| 138 | /* Reminder: Firefox does not properly flexbox a LEGEND element, |
| 139 |
| --- src/pikchrshow.c | |
| +++ src/pikchrshow.c | |
| @@ -30,11 +30,11 @@ | |
| 30 | ** with pikchr code or prototype it for use in copy/pasting into forum |
| 31 | ** posts, wiki pages, or embedded docs. |
| 32 | */ |
| 33 | void pikchrshow_page(void){ |
| 34 | const char *zContent = 0; |
| 35 | int isDark; /* true if the current skin is "dark" */ |
| 36 | |
| 37 | login_check_credentials(); |
| 38 | if( !g.perm.RdWiki && !g.perm.Read && !g.perm.RdForum ){ |
| 39 | cgi_redirectf("%s/login?g=%s/pikchrshow", g.zTop, g.zTop); |
| 40 | } |
| @@ -57,12 +57,12 @@ | |
| 57 | }else{ |
| 58 | CX("<pre>No content! Nothing to render</pre>"); |
| 59 | } |
| 60 | return; |
| 61 | } |
| 62 | style_emit_noscript_for_js_page(); |
| 63 | isDark = skin_detail_boolean("white-foreground"); |
| 64 | if(!zContent){ |
| 65 | zContent = "arrow right 200% \"Markdown\" \"Source\"\n" |
| 66 | "box rad 10px \"Markdown\" \"Formatter\" \"(markdown.c)\" fit\n" |
| 67 | "arrow right 200% \"HTML+SVG\" \"Output\"\n" |
| 68 | "arrow <-> down from last box.s\n" |
| @@ -128,11 +128,11 @@ | |
| 128 | zContent/*safe-for-%s*/); |
| 129 | CX("<div id='pikchrshow-controls'>"); |
| 130 | CX("<button id='pikchr-submit-preview'>Preview</button>"); |
| 131 | style_labeled_checkbox("flipcolors-wrapper", "flipcolors", |
| 132 | "Dark mode?", |
| 133 | "1", isDark, 0); |
| 134 | CX("</div>"/*#pikchrshow-controls*/); |
| 135 | CX("</div>"/*#pikchrshow-form*/); |
| 136 | CX("<fieldset id='pikchrshow-output-wrapper'>"); |
| 137 | CX("<legend></legend>" |
| 138 | /* Reminder: Firefox does not properly flexbox a LEGEND element, |
| 139 |
+12
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -1456,5 +1456,17 @@ | ||
| 1456 | 1456 | } |
| 1457 | 1457 | }else{ |
| 1458 | 1458 | CX("</script>\n"); |
| 1459 | 1459 | } |
| 1460 | 1460 | } |
| 1461 | + | |
| 1462 | +/* | |
| 1463 | +** Emits a NOSCRIPT tag with an error message stating that JS is | |
| 1464 | +** required for the current page. This "should" be called near the top | |
| 1465 | +** of pages which *require* JS. The inner DIV has the CSS class | |
| 1466 | +** 'error' and can be styled via a (noscript > .error) CSS selector. | |
| 1467 | +*/ | |
| 1468 | +void style_emit_noscript_for_js_page(void){ | |
| 1469 | + CX("<noscript><div class='error'>" | |
| 1470 | + "This page requires JavaScript (ES2015, a.k.a. ES6, or newer)." | |
| 1471 | + "</div></noscript>"); | |
| 1472 | +} | |
| 1461 | 1473 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -1456,5 +1456,17 @@ | |
| 1456 | } |
| 1457 | }else{ |
| 1458 | CX("</script>\n"); |
| 1459 | } |
| 1460 | } |
| 1461 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -1456,5 +1456,17 @@ | |
| 1456 | } |
| 1457 | }else{ |
| 1458 | CX("</script>\n"); |
| 1459 | } |
| 1460 | } |
| 1461 | |
| 1462 | /* |
| 1463 | ** Emits a NOSCRIPT tag with an error message stating that JS is |
| 1464 | ** required for the current page. This "should" be called near the top |
| 1465 | ** of pages which *require* JS. The inner DIV has the CSS class |
| 1466 | ** 'error' and can be styled via a (noscript > .error) CSS selector. |
| 1467 | */ |
| 1468 | void style_emit_noscript_for_js_page(void){ |
| 1469 | CX("<noscript><div class='error'>" |
| 1470 | "This page requires JavaScript (ES2015, a.k.a. ES6, or newer)." |
| 1471 | "</div></noscript>"); |
| 1472 | } |
| 1473 |
+1
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -1126,10 +1126,11 @@ | ||
| 1126 | 1126 | login_needed(rid ? g.anon.WrWiki : g.anon.NewWiki); |
| 1127 | 1127 | return; |
| 1128 | 1128 | } |
| 1129 | 1129 | } |
| 1130 | 1130 | style_header("Wiki Editor"); |
| 1131 | + style_emit_noscript_for_js_page(); | |
| 1131 | 1132 | |
| 1132 | 1133 | /* Status bar */ |
| 1133 | 1134 | CX("<div id='fossil-status-bar' " |
| 1134 | 1135 | "title='Status message area. Double-click to clear them.'>" |
| 1135 | 1136 | "Status messages will go here.</div>\n" |
| 1136 | 1137 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -1126,10 +1126,11 @@ | |
| 1126 | login_needed(rid ? g.anon.WrWiki : g.anon.NewWiki); |
| 1127 | return; |
| 1128 | } |
| 1129 | } |
| 1130 | style_header("Wiki Editor"); |
| 1131 | |
| 1132 | /* Status bar */ |
| 1133 | CX("<div id='fossil-status-bar' " |
| 1134 | "title='Status message area. Double-click to clear them.'>" |
| 1135 | "Status messages will go here.</div>\n" |
| 1136 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -1126,10 +1126,11 @@ | |
| 1126 | login_needed(rid ? g.anon.WrWiki : g.anon.NewWiki); |
| 1127 | return; |
| 1128 | } |
| 1129 | } |
| 1130 | style_header("Wiki Editor"); |
| 1131 | style_emit_noscript_for_js_page(); |
| 1132 | |
| 1133 | /* Status bar */ |
| 1134 | CX("<div id='fossil-status-bar' " |
| 1135 | "title='Status message area. Double-click to clear them.'>" |
| 1136 | "Status messages will go here.</div>\n" |
| 1137 |