1
0
mirror of https://github.com/teoxoy/factorio-blueprint-editor.git synced 2024-11-24 08:22:16 +02:00

add factorio.school as a source

closes #227
This commit is contained in:
teoxoy 2021-02-10 16:27:12 +01:00
parent b6910441d3
commit abe58f4b3b
3 changed files with 13 additions and 7 deletions

View File

@ -20,7 +20,7 @@ Example blueprint book: https://fbe.teoxoy.com/?source=https://pastebin.com/Xp9u
- rendering and editing blueprints - rendering and editing blueprints
- history (undo/redo) - history (undo/redo)
- copy and delete selections - copy and delete selections
- import blueprints and books from multiple sources (direct bp string, pastebin, hastebin, gist, gitlab, factorioprints, google docs) - import blueprints and books from multiple sources (direct bp string, pastebin, hastebin, gist, gitlab, factorioprints, factorio.school, google docs)
- generating blueprint images - generating blueprint images
- oil outpost generator - oil outpost generator
- customizable keybinds - customizable keybinds

View File

@ -158,15 +158,15 @@ function getBlueprintOrBookFromSource(source: string): Promise<Blueprint | Book>
}) })
// TODO: add dropbox support https://www.dropbox.com/s/ID?raw=1 // TODO: add dropbox support https://www.dropbox.com/s/ID?raw=1
switch (url.hostname.split('.')[0]) { switch (url.hostname.replace(/^www\./, '').split('.')[0]) {
case 'pastebin': case 'pastebin':
return fetchData(`https://pastebin.com/raw/${pathParts[0]}`).then(r => r.text()) return fetchData(`https://pastebin.com/raw/${pathParts[0]}`).then(r => r.text())
case 'hastebin': case 'hastebin':
return fetchData(`https://hastebin.com/raw/${pathParts[0]}`).then(r => r.text()) return fetchData(`https://hastebin.com/raw/${pathParts[0]}`).then(r => r.text())
case 'gist': case 'gist':
return fetchData(`https://api.github.com/gists/${pathParts[1]}`).then(r => return fetchData(`https://api.github.com/gists/${pathParts[1]}`)
r.json().then(data => data.files[Object.keys(data.files)[0]].content) .then(r => r.json())
) .then(data => data.files[Object.keys(data.files)[0]].content)
case 'gitlab': case 'gitlab':
return fetchData(`https://gitlab.com/${pathParts.join('/')}/raw`).then(r => return fetchData(`https://gitlab.com/${pathParts.join('/')}/raw`).then(r =>
r.text() r.text()
@ -174,7 +174,13 @@ function getBlueprintOrBookFromSource(source: string): Promise<Blueprint | Book>
case 'factorioprints': case 'factorioprints':
return fetchData( return fetchData(
`https://facorio-blueprints.firebaseio.com/blueprints/${pathParts[1]}.json` `https://facorio-blueprints.firebaseio.com/blueprints/${pathParts[1]}.json`
).then(r => r.json().then(data => data.blueprintString)) )
.then(r => r.json())
.then(data => data.blueprintString)
case 'factorio': // factorio.school
return fetchData(`https://www.factorio.school/api/blueprint/${pathParts[1]}`)
.then(r => r.json())
.then(data => data.blueprintString.blueprintString)
case 'docs': case 'docs':
return fetchData( return fetchData(
`https://docs.google.com/document/d/${pathParts[2]}/export?format=txt` `https://docs.google.com/document/d/${pathParts[2]}/export?format=txt`

View File

@ -67,7 +67,7 @@
<li>copy and delete selections</li> <li>copy and delete selections</li>
<li> <li>
import blueprints and books from multiple sources (direct bp string, pastebin, import blueprints and books from multiple sources (direct bp string, pastebin,
hastebin, gist, gitlab, factorioprints, google docs) hastebin, gist, gitlab, factorioprints, factorio.school, google docs)
</li> </li>
<li>generating blueprint images</li> <li>generating blueprint images</li>
<li>oil outpost generator</li> <li>oil outpost generator</li>