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
14 changes: 10 additions & 4 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
"firebase.json",
"**/.*"
],
"rewrites": [{
"source": "**",
"destination": "/index.html"
}]
"rewrites": [
{
"source": "/view/**",
"destination": "/view.html"
},
{
"source": "**",
"destination": "/index.html"
}
]
}
}
32 changes: 32 additions & 0 deletions view.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Seed</title>
</head>
<body>
<script src="/third_party/bundle.min.js"></script>
<script src="/js/core.js"></script>
<script>
if (!document.location.search.startsWith('?id=')) {
throw new Error('No sketch ID');
}
const sketchId = document.location.search.substring(4);
console.log(sketchId);

async function loadSketch(id) {
const res = await fetch(`https://emrg-pcg.firebaseio.com/sketch/${id}.json`);
const json = await res.json();
const phraseBook = await parsePhraseBook(json.source, loadSketch);
return phraseBook;
}
(async() => {
const phraseBook = await loadSketch(sketchId);
const result = generateString(phraseBook, 'root', {}, 'ABC');
console.log(result);
document.write(result);
})();

</script>
</body>
</html>