Compare commits

...

6 Commits

Author SHA1 Message Date
Evan Chen 42af9eccc7 fix: format should not be locked
continuous-integration/drone/tag Build is passing Details
2021-11-30 15:28:59 +08:00
Evan Chen b7ee78bde5 disable cgo 2021-11-30 13:40:31 +08:00
Evan 0910565e20 load nothing
continuous-integration/drone/tag Build is passing Details
2021-11-27 22:19:30 +08:00
Evan 3ca2fe861f fix: name not passed 2021-11-27 22:06:47 +08:00
Evan 89c0a87118 fix: #1
continuous-integration/drone/tag Build is passing Details
2021-11-27 21:59:28 +08:00
Evan Chen 072c7d04d7 docs: add mod name to log 2021-11-24 23:13:00 +08:00
7 changed files with 23 additions and 8 deletions

View File

@ -64,7 +64,9 @@ func main() {
mux := http.NewServeMux()
k := kconfig.New()
k.AppName = flagAppName
if flagFile != "" {
k.Load = func() []byte { return nil }
go func() {
fi, err := os.Stat(flagFile)
if err != nil {
@ -98,6 +100,7 @@ func main() {
mux.Handle("/", k)
g := guard.New()
g.Skip = guard.SkipStatic
server := &http.Server{
Addr: flagAddr,

View File

@ -18,9 +18,11 @@
<div class='columns'>
<div class='column col-md-12'>
<button id='submit' class='tiny'>Submit</button>
<button id='load' class='secondary tiny'>Load</button>
<button id='download' class='secondary tiny'>Download</button>
<button id='load' class='secondary tiny'>Restore</button>
<button id='upload-btn' class='secondary tiny' onclick="upload.click()">Upload</button>
<input id="upload" style="display: none" type="file">
<a id="downloadAnchorElem" style="display:none"></a>
<button id='download' class='secondary tiny'>Download</button>
<span id='valid_indicator' class='label'></span>
</div>
</div>

View File

@ -20,6 +20,7 @@ var index string
var servePublic = http.FileServer(http.FS(public.FS))
var tmpl *engine.Engine
var l = log.With().Str("mod", "kconfig").Logger()
func init() {
tmpl = engine.Must(engine.New("").Parse(index))
@ -44,7 +45,7 @@ func New() *Kconfig {
AppName: "kconfig",
Schema: defaultSchema,
Apply: func(b []byte) error {
log.Debug().Msgf("%s", b)
l.Debug().Msgf("%s", b)
return nil
},
Load: func() []byte {

11
main.js
View File

@ -13,7 +13,7 @@ import 'spectre.css/dist/spectre-icons.min.css'
// The schema for the editor
schema: {
$ref: "api/schema",
format: "grid"
// format: "grid"
},
});
@ -77,4 +77,13 @@ import 'spectre.css/dist/spectre-icons.min.css'
dlAnchorElem.setAttribute('download', AppName+'.json');
dlAnchorElem.click();
});
document.getElementById('upload').addEventListener('change',function(e) {
var reader = new FileReader();
reader.onload = function(event) {
var jsonObj = JSON.parse(event.target.result);
editor.setValue(jsonObj);
};
reader.readAsText(e.target.files[0]);
});
})();

View File

@ -19,7 +19,7 @@ for PLATFORM in $PLATFORMS; do
GOARCH=${PLATFORM#*/}
BIN_FILENAME="${PROJ}"
if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi
CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build ${LDFLAGS} -o ${DIST}/${BIN_FILENAME} $@"
CMD="CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build ${LDFLAGS} -o ${DIST}/${BIN_FILENAME} $@"
echo "${CMD}"
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
sh -c "cd ${DIST} && tar -czf ${PROJ}-${VERSION}-${GOOS}-${GOARCH}.tar.gz ${BIN_FILENAME} && rm ${BIN_FILENAME}"
@ -29,4 +29,4 @@ if [[ "${FAILURES}" != "" ]]; then
echo ""
echo "${SCRIPT_NAME} failed on: ${FAILURES}"
exit 1
fi
fi

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<!DOCTYPE html><html><head><link rel="stylesheet" href="index.e0891ed3.css"><title>{{.AppName}}</title><style>.ace_selection{background:#7f7f00!important}</style></head><body> <div class="container" style="max-width:960px;"> <div class="columns"> <h1 class="col-md-12">{{.AppName}} Config</h1> </div> <div class="columns"> <div class="col-md-12 column"> <button id="submit" class="tiny">Submit</button> <button id="load" class="secondary tiny">Load</button> <button id="download" class="secondary tiny">Download</button> <a id="downloadAnchorElem" style="display:none"></a> <span id="valid_indicator" class="label"></span> </div> </div> <br> <div class="columns"> <div class="col-md-12 column" id="editor_holder"></div> </div> </div> <script type="module" src="index.6ef506fc.js"></script> {{.ACE_JS}} <script>let AppName="{{.AppName}}";</script> </body></html>
<!DOCTYPE html><html><head><link rel="stylesheet" href="index.e0891ed3.css"><title>{{.AppName}}</title><style>.ace_selection{background:#7f7f00!important}</style></head><body> <div class="container" style="max-width:960px;"> <div class="columns"> <h1 class="col-md-12">{{.AppName}} Config</h1> </div> <div class="columns"> <div class="col-md-12 column"> <button id="submit" class="tiny">Submit</button> <button id="load" class="secondary tiny">Restore</button> <button id="upload-btn" class="secondary tiny" onclick="upload.click()">Upload</button> <input id="upload" style="display:none" type="file"> <a id="downloadAnchorElem" style="display:none"></a> <button id="download" class="secondary tiny">Download</button> <span id="valid_indicator" class="label"></span> </div> </div> <br> <div class="columns"> <div class="col-md-12 column" id="editor_holder"></div> </div> </div> <script type="module" src="index.f85d8cc8.js"></script> {{.ACE_JS}} <script>let AppName="{{.AppName}}";</script> </body></html>