mirror of https://github.com/dirtbags/moth.git
Compare commits
No commits in common. "7c5b5b5ccf38e5b7f2c7b6e5a88cf61d23d92891" and "0696e7c61ca051d9ec07e26154f201e53304cb3a" have entirely different histories.
7c5b5b5ccf
...
0696e7c61c
|
@ -5,6 +5,6 @@
|
||||||
__debug_bin
|
__debug_bin
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
transpile
|
transpile
|
||||||
|
mothd
|
||||||
winmoth.*.zip
|
winmoth.*.zip
|
||||||
/mothd
|
*.exe
|
||||||
/*.exe
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"mime"
|
"mime"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
|
@ -55,38 +54,21 @@ func main() {
|
||||||
)
|
)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
var theme *Theme
|
|
||||||
osfs := afero.NewOsFs()
|
osfs := afero.NewOsFs()
|
||||||
if p, err := filepath.Abs(*themePath); err != nil {
|
theme := NewTheme(afero.NewBasePathFs(osfs, *themePath))
|
||||||
log.Fatal(err)
|
|
||||||
} else {
|
|
||||||
theme = NewTheme(afero.NewBasePathFs(osfs, p))
|
|
||||||
}
|
|
||||||
|
|
||||||
config := Configuration{}
|
config := Configuration{}
|
||||||
|
|
||||||
var provider PuzzleProvider
|
var provider PuzzleProvider
|
||||||
if p, err := filepath.Abs(*mothballPath); err != nil {
|
provider = NewMothballs(afero.NewBasePathFs(osfs, *mothballPath))
|
||||||
log.Fatal(err)
|
|
||||||
} else {
|
|
||||||
provider = NewMothballs(afero.NewBasePathFs(osfs, p))
|
|
||||||
}
|
|
||||||
if *puzzlePath != "" {
|
if *puzzlePath != "" {
|
||||||
if p, err := filepath.Abs(*puzzlePath); err != nil {
|
provider = NewTranspilerProvider(afero.NewBasePathFs(osfs, *puzzlePath))
|
||||||
log.Fatal(err)
|
|
||||||
} else {
|
|
||||||
provider = NewTranspilerProvider(afero.NewBasePathFs(osfs, p))
|
|
||||||
}
|
|
||||||
config.Devel = true
|
config.Devel = true
|
||||||
log.Println("-=- You are in development mode, champ! -=-")
|
log.Println("-=- You are in development mode, champ! -=-")
|
||||||
}
|
}
|
||||||
|
|
||||||
var state StateProvider
|
var state StateProvider
|
||||||
if p, err := filepath.Abs(*statePath); err != nil {
|
state = NewState(afero.NewBasePathFs(osfs, *statePath))
|
||||||
log.Fatal(err)
|
|
||||||
} else {
|
|
||||||
state = NewState(afero.NewBasePathFs(osfs, p))
|
|
||||||
}
|
|
||||||
if config.Devel {
|
if config.Devel {
|
||||||
state = NewDevelState(state)
|
state = NewDevelState(state)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
"": 0
|
"": 0
|
||||||
},
|
},
|
||||||
"Puzzle": {
|
"Puzzle": {
|
||||||
|
"SyntaxHighlighting": true,
|
||||||
"": 0
|
"": 0
|
||||||
},
|
},
|
||||||
"Scoreboard": {
|
"Scoreboard": {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as pyodide from "https://cdn.jsdelivr.net/npm/pyodide@0.25.1/pyodide.mjs" // v0.16.1 known good
|
const pyodidePromise = import("https://cdn.jsdelivr.net/npm/pyodide@0.25.1/pyodide.mjs")
|
||||||
|
|
||||||
const HOME = "/home/web_user"
|
const HOME = "/home/web_user"
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
import {Toast} from "../common.mjs"
|
import {Toast} from "../common.mjs"
|
||||||
//import "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"
|
import "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"
|
||||||
import "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js"
|
|
||||||
import "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"
|
|
||||||
import * as CodeJar from "https://cdn.jsdelivr.net/npm/codejar@4.2.0"
|
import * as CodeJar from "https://cdn.jsdelivr.net/npm/codejar@4.2.0"
|
||||||
|
|
||||||
Prism.plugins.autoloader.languages_path = "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/"
|
var workers = {}
|
||||||
const prismCssUrl = "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css"
|
|
||||||
|
// loadWorker returns an existing worker if one exists, otherwise, it starts a new worker
|
||||||
|
function loadWorker(language) {
|
||||||
|
let worker = workers[language]
|
||||||
|
if (!worker) {
|
||||||
|
let url = new URL(language + ".mjs", import.meta.url)
|
||||||
|
worker = new Worker(url, {
|
||||||
|
type: "module",
|
||||||
|
})
|
||||||
|
workers[language] = worker
|
||||||
|
}
|
||||||
|
return worker
|
||||||
|
}
|
||||||
|
|
||||||
export class Workspace {
|
export class Workspace {
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +85,7 @@ export class Workspace {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
codeBlock.parentElement.replaceWith(this.element)
|
codeBlock.parentElement.replaceWith(this.element)
|
||||||
})
|
})
|
||||||
.catch(err => console.warn(`Unable to load interpreter: `, this.language))
|
.catch(err => console.warn(`Unable to load ${this.language} interpreter`))
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
loadingElement.remove()
|
loadingElement.remove()
|
||||||
})
|
})
|
||||||
|
@ -222,16 +232,3 @@ export class Workspace {
|
||||||
this.element.classList.toggle("fixed")
|
this.element.classList.toggle("fixed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function init() {
|
|
||||||
let link = document.head.appendChild(document.createElement("link"))
|
|
||||||
link.rel = "stylesheet"
|
|
||||||
link.href = prismCssUrl
|
|
||||||
}
|
|
||||||
|
|
||||||
if (document.readyState === "loading") {
|
|
||||||
document.addEventListener("DOMContentLoaded", init)
|
|
||||||
} else {
|
|
||||||
init()
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue