1
0
mirror of https://github.com/teoxoy/factorio-blueprint-editor.git synced 2024-11-21 17:06:30 +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
- history (undo/redo)
- 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
- oil outpost generator
- 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
switch (url.hostname.split('.')[0]) {
switch (url.hostname.replace(/^www\./, '').split('.')[0]) {
case 'pastebin':
return fetchData(`https://pastebin.com/raw/${pathParts[0]}`).then(r => r.text())
case 'hastebin':
return fetchData(`https://hastebin.com/raw/${pathParts[0]}`).then(r => r.text())
case 'gist':
return fetchData(`https://api.github.com/gists/${pathParts[1]}`).then(r =>
r.json().then(data => data.files[Object.keys(data.files)[0]].content)
)
return fetchData(`https://api.github.com/gists/${pathParts[1]}`)
.then(r => r.json())
.then(data => data.files[Object.keys(data.files)[0]].content)
case 'gitlab':
return fetchData(`https://gitlab.com/${pathParts.join('/')}/raw`).then(r =>
r.text()
@ -174,7 +174,13 @@ function getBlueprintOrBookFromSource(source: string): Promise<Blueprint | Book>
case 'factorioprints':
return fetchData(
`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':
return fetchData(
`https://docs.google.com/document/d/${pathParts[2]}/export?format=txt`

View File

@ -67,7 +67,7 @@
<li>copy and delete selections</li>
<li>
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>generating blueprint images</li>
<li>oil outpost generator</li>