Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to support high contrast #17

Merged
merged 2 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ A simple MediaWiki extension for rendering Scratch Blocks used on Scratch 3.0. S

Transforms `<scratchblocks>` tags inside wiki articles into `<pre class="blocks">` in the HTML, which are then rendered to scratch blocks using CSS and JS included in the page. Inline blocks are rendered with `<sb>` tags, and become `<code class="blocks">` tags.

Use `version` attribute to set the version. Valid values are `2`, `3`, and `hc-3` (for High Contrast colors).

- Maintained by apple502j.
- Contributed to by Kenny2github
- Original by tjvr and ErnieParke
Expand All @@ -24,3 +26,5 @@ $wgScratchBlocks4Langs = ['ja', 'zh_TW'];
Note that the TW is preceded by an underscore rather than a hyphen.

This variable is accessible through JavaScript via `mw.config.get("wgScratchBlocks4Lang")`.

Use `$wgScratchBlocks4BlockVersion` to specify the default version. Valid values are `2`, `3`, and `hc-3` (for High Contrast colors).
6 changes: 3 additions & 3 deletions lib/scratchblocks.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/translations-all.js

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions run_scratchblocks4.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ mw.hook('wikipage.content').add(function run_scratchblocks() {
if (version == 2 || version[0] == '2') { // to handle '2.0'
version = 'scratch2';
} else {
version = 'scratch3';
version = (version === 'hc-3' || version === 'hc-3.0') ? 'scratch3-high-contrast' : 'scratch3';
scale = 0.675;
}
var langs = ['en'].concat(mw.config.get('wgScratchBlocks4Langs'));
scratchblocks.renderMatching('pre.blocks', { languages: langs, style: version, scale: scale });
scratchblocks.renderMatching('code.blocks', { languages: langs, style: version, inline: true, scale: scale });
scratchblocks.renderMatching('pre[class^=blocks-hc-3]', { languages: langs, style: 'scratch3-high-contrast', scale: 0.675 });
scratchblocks.renderMatching('code[class^=blocks-hc-3]', { languages: langs, style: 'scratch3-high-contrast', inline: true, scale: 0.675 });
scratchblocks.renderMatching('pre[class^=blocks-3]', { languages: langs, style: 'scratch3', scale: 0.675 });
scratchblocks.renderMatching('code[class^=blocks-3]', { languages: langs, style: 'scratch3', inline: true, scale: 0.675 });
scratchblocks.renderMatching('pre[class^=blocks-2]', { languages: langs, style: 'scratch2' });
scratchblocks.renderMatching('code[class^=blocks-2]', { languages: langs, style: 'scratch2', inline: true });
var query = '[class^=blocks-3] .scratchblocks svg';
if (version === 'scratch3') {
query = '.blocks .scratchblocks svg, ' + query;
}
Kenny2github marked this conversation as resolved.
Show resolved Hide resolved
});