Skip to content
Open
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
10 changes: 10 additions & 0 deletions packages/blockly/appengine/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ handlers:
- url: /static/demos/custom-fields/.*
static_files: redirect.html
upload: redirect.html
# Playgrounds moved to GitHub Pages.
- url: /static/tests/playgrounds/advanced_playground\.html
static_files: redirect.html
upload: redirect.html
- url: /static/tests/multi_playground\.html
static_files: redirect.html
upload: redirect.html
- url: /static/tests/playground\.html
static_files: redirect.html
upload: redirect.html

# Blockly files.
- url: /static
Expand Down
11 changes: 11 additions & 0 deletions packages/blockly/appengine/redirect.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@
loc = 'https://google.github.io/blockly-samples/examples/pitch-field-demo/';
}

// Playgrounds moved to GitHub Pages in 2026.
var ghPagesBase =
'https://raspberrypifoundation.github.io/blockly/packages/blockly/tests/';
if (loc.includes('/tests/playgrounds/advanced_playground.html')) {
loc = ghPagesBase + 'playgrounds/advanced_playground.html';
} else if (loc.includes('/tests/multi_playground.html')) {
loc = ghPagesBase + 'multi_playground.html';
} else if (loc.includes('/tests/playground.html')) {
loc = ghPagesBase + 'playground.html';
}

location = loc;

</script>
Expand Down
5 changes: 4 additions & 1 deletion packages/blockly/demos/blockfactory/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
</button>
</h1>
<div id="legacyBanner">
This version of Developer Tools is only compatible with Blockly version 10 and earlier. Try the <a target="_blank" href="https://google.github.io/blockly-samples/examples/developer-tools/index.html">new Block Factory</a> and <a target="_blank" href="https://developers.google.com/blockly/guides/create-custom-blocks/blockly-developer-tools#import_from_legacy_block_factory">learn how to migrate your blocks</a>.
<strong>This service will be shut down on December 1, 2026.</strong>
Please export your block definitions before then, using the "Export Block Library" button, so you can import them into the new Block Factory.
<br>
This version of Developer Tools is only compatible with Blockly version 10 and earlier. Try the <a target="_blank" href="https://raspberrypifoundation.github.io/blockly-samples/examples/developer-tools/index.html">new Block Factory</a> and <a target="_blank" href="https://docs.blockly.com/guides/create-custom-blocks/blockly-developer-tools/#import-from-legacy-block-factory">learn how to migrate your blocks</a>.
</div>
<div id="tabContainer">
<div id="blockFactory_tab" class="tab tabon">Block Factory</div>
Expand Down
19 changes: 19 additions & 0 deletions packages/blockly/demos/code/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ Code.init = function() {

Code.bindClick('trashButton',
function() {Code.discard(); Code.renderContent();});
Code.bindClick('exportButton', Code.exportWorkspace);
Code.bindClick('runButton', Code.runJS);
// Disable the link button if page isn't backed by App Engine storage.
var linkButton = document.getElementById('linkButton');
Expand Down Expand Up @@ -604,6 +605,24 @@ Code.runJS = function(event) {
}
};

/**
* Download the current workspace as a JSON file that can be loaded into the
* Blockly Playground.
*/
Code.exportWorkspace = function() {
var state = Blockly.serialization.workspaces.save(Code.workspace);
var text = JSON.stringify(state, null, 2);
var blob = new Blob([text], {type: 'application/json'});
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = 'blockly-workspace.json';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
};

/**
* Discard all blocks from the workspace.
*/
Expand Down
12 changes: 12 additions & 0 deletions packages/blockly/demos/code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ <h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt;
<a class="privacyLink" href="https://policies.google.com/privacy">Privacy</a>
</td>
</tr>
<tr>
<td colspan=2>
<div id="deprecationBanner">
<strong>This service will be shut down on December 1, 2026.</strong>
Saving and sharing via App Engine will no longer be available after
that date. Please use the "Export" button to download your work
before then. You can load the exported file into the
<a target="_blank" href="https://raspberrypifoundation.github.io/blockly/packages/blockly/tests/playground.html">Blockly Playground</a>.
</div>
</td>
</tr>
<tr>
<td colspan=2>
<table width="100%">
Expand All @@ -54,6 +65,7 @@ <h1><a href="https://developers.google.com/blockly/">Blockly</a>&rlm; &gt;
<select id="code_menu"></select>
</td>
<td class="tabmax">
<button id="exportButton" title="Download your workspace as a JSON file.">Export</button>
<button id="trashButton" class="notext" title="...">
<img src='../../media/1x1.gif' class="trash icon21">
</button>
Expand Down
12 changes: 12 additions & 0 deletions packages/blockly/demos/code/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ button.disabled {
button.notext {
font-size: 10%;
}
#exportButton {
font-size: medium;
padding: 5px 10px;
vertical-align: middle;
}
#deprecationBanner {
border: #ccc 1px solid;
background-color: #FFCDD2;
margin: 5px;
padding: 8px;
font-size: medium;
}

h1 {
font-weight: normal;
Expand Down
31 changes: 31 additions & 0 deletions packages/blockly/demos/storage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,26 @@
font-size: small;
text-decoration: none;
}
#deprecationBanner {
border: #ccc 1px solid;
background-color: #FFCDD2;
margin: 4px 0;
padding: 8px;
}
</style>
</head>
<body>
<h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
<a href="../index.html">Demos</a> &gt; Cloud Storage</h1>

<div id="deprecationBanner">
<strong>This service will be shut down on December 1, 2026.</strong>
Cloud storage will no longer be available after that date. Please use the
"Export" button to download your work before then. You can load the
exported file into the
<a target="_blank" href="https://raspberrypifoundation.github.io/blockly/packages/blockly/tests/playground.html">Blockly Playground</a>.
</div>

<p>This is a simple demo of cloud storage using App Engine.</p>

<script>
Expand All @@ -50,6 +64,7 @@ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;

<p>
<button onclick="BlocklyStorage.link()">Save Blocks</button>
<button onclick="exportWorkspace()" title="Download your workspace as a JSON file.">Export</button>
</p>

<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
Expand Down Expand Up @@ -95,6 +110,22 @@ <h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
if ('BlocklyStorage' in window && window.location.hash.length > 1) {
BlocklyStorage.retrieveXml(window.location.hash.substring(1));
}

// Download the current workspace as a JSON file that can be loaded into
// the Blockly Playground.
function exportWorkspace() {
var state = Blockly.serialization.workspaces.save(demoWorkspace);
var text = JSON.stringify(state, null, 2);
var blob = new Blob([text], {type: 'application/json'});
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = 'blockly-workspace.json';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
</script>

</body>
Expand Down
Loading