Merge pull request 'fix: lib mode in subpath' (#39) from test/lib into master
continuous-integration/drone/tag Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
Reviewed-on: #39feat/muzan v0.1.3
commit
c9031c6f3f
|
@ -7,7 +7,7 @@ steps:
|
||||||
commands:
|
commands:
|
||||||
- git tag $DRONE_TAG
|
- git tag $DRONE_TAG
|
||||||
- bash release.sh cmd/configui/main.go
|
- bash release.sh cmd/configui/main.go
|
||||||
- echo -n "latest,$DRONE_TAG" > .tags
|
- echo -n "latest,${DRONE_TAG#v}" > .tags
|
||||||
|
|
||||||
- name: gitea_release
|
- name: gitea_release
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
|
|
2
app.go
2
app.go
|
@ -24,6 +24,7 @@ type Editor struct {
|
||||||
|
|
||||||
type Page struct {
|
type Page struct {
|
||||||
AppName string
|
AppName string
|
||||||
|
BaseUrl string
|
||||||
Version string
|
Version string
|
||||||
Build string
|
Build string
|
||||||
Files []ActiveFile
|
Files []ActiveFile
|
||||||
|
@ -62,6 +63,7 @@ func (cui *ConfigUI) App(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
data := Page{
|
data := Page{
|
||||||
AppName: cui.AppName,
|
AppName: cui.AppName,
|
||||||
|
BaseUrl: cui.BaseUrl,
|
||||||
File: ActiveFile{},
|
File: ActiveFile{},
|
||||||
Files: Files,
|
Files: Files,
|
||||||
Editor: Editor{
|
Editor: Editor{
|
||||||
|
|
|
@ -29,6 +29,7 @@ var Ext2Mode map[string]string = map[string]string{
|
||||||
|
|
||||||
type ConfigUI struct {
|
type ConfigUI struct {
|
||||||
AppName string `json:"app_name"`
|
AppName string `json:"app_name"`
|
||||||
|
BaseUrl string `json:"base_url"`
|
||||||
ConfigPath string `json:"config_path"`
|
ConfigPath string `json:"config_path"`
|
||||||
|
|
||||||
NoReconfig bool `json:"no_reconfig"`
|
NoReconfig bool `json:"no_reconfig"`
|
||||||
|
@ -37,7 +38,6 @@ type ConfigUI struct {
|
||||||
Files []*File `json:"files"`
|
Files []*File `json:"files"`
|
||||||
fileIndex map[string]int
|
fileIndex map[string]int
|
||||||
|
|
||||||
// TODO
|
|
||||||
ResultBellow bool `json:"result_bellow"`
|
ResultBellow bool `json:"result_bellow"`
|
||||||
HideConfig bool `json:"hide_config"`
|
HideConfig bool `json:"hide_config"`
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ func New() *ConfigUI {
|
||||||
return &ConfigUI{
|
return &ConfigUI{
|
||||||
fileIndex: map[string]int{},
|
fileIndex: map[string]int{},
|
||||||
AppName: "ConfigUI",
|
AppName: "ConfigUI",
|
||||||
|
BaseUrl: "/",
|
||||||
PublicFS: public.FS,
|
PublicFS: public.FS,
|
||||||
TmplFS: tmplFS,
|
TmplFS: tmplFS,
|
||||||
tmpl: tmpl,
|
tmpl: tmpl,
|
||||||
|
@ -109,6 +110,7 @@ func (cui *ConfigUI) LoadConfig(confstr string) error {
|
||||||
cui.LogPath = tmpConf.LogPath
|
cui.LogPath = tmpConf.LogPath
|
||||||
cui.NoReconfig = tmpConf.NoReconfig
|
cui.NoReconfig = tmpConf.NoReconfig
|
||||||
cui.AppName = tmpConf.AppName
|
cui.AppName = tmpConf.AppName
|
||||||
|
cui.BaseUrl = tmpConf.BaseUrl
|
||||||
|
|
||||||
// NOT implemented
|
// NOT implemented
|
||||||
cui.ResultBellow = tmpConf.ResultBellow
|
cui.ResultBellow = tmpConf.ResultBellow
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -13,6 +13,7 @@ func (cui *ConfigUI) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
func (cui *ConfigUI) middleware(next http.Handler) http.Handler {
|
func (cui *ConfigUI) middleware(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(
|
return http.HandlerFunc(
|
||||||
func(w http.ResponseWriter, r *http.Request) {
|
func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// log.Println(r.URL)
|
||||||
rw := &CuiResponseWriter{w, 0}
|
rw := &CuiResponseWriter{w, 0}
|
||||||
defer catch(rw, r)
|
defer catch(rw, r)
|
||||||
ip := GetIP(r)
|
ip := GetIP(r)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
font-family: 'Material Icons';
|
font-family: 'Material Icons';
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
src: url(/public/assets/mat.ttf) format('truetype');
|
src: url(../assets/mat.ttf) format('truetype');
|
||||||
}
|
}
|
||||||
|
|
||||||
.material-icons {
|
.material-icons {
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<script src="/public/ace/js/ace.js" type="text/javascript" charset="utf-8"></script>
|
<script src="{{.BaseUrl}}public/ace/js/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<script src="/public/ace/js/ext-beautify.js" type="text/javascript" charset="utf-8"></script>
|
<script src="{{.BaseUrl}}public/ace/js/ext-beautify.js" type="text/javascript" charset="utf-8"></script>
|
||||||
{{template "base/script" .}}
|
{{template "base/script" .}}
|
||||||
<!-- <script src="/public/js/main.js"></script> -->
|
<!-- <script src="/public/js/main.js"></script> -->
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>{{.AppName}}</title>
|
<title>{{.AppName}}</title>
|
||||||
<link rel="stylesheet" href="/public/css/main.css">
|
<link rel="stylesheet" href="{{.BaseUrl}}public/css/main.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{end}}
|
{{end}}
|
|
@ -7,7 +7,7 @@ async function FileGet(follower=false){
|
||||||
let f = ''
|
let f = ''
|
||||||
if (Active == 'ConfigUI') {
|
if (Active == 'ConfigUI') {
|
||||||
if (follower) f = '?f=true'
|
if (follower) f = '?f=true'
|
||||||
const res = await fetch('/api/conf'+f)
|
const res = await fetch('{{.BaseUrl}}api/conf'+f)
|
||||||
.catch(err=>{console.log(err);return;});
|
.catch(err=>{console.log(err);return;});
|
||||||
const body = await res.text();
|
const body = await res.text();
|
||||||
if(!res.ok){
|
if(!res.ok){
|
||||||
|
@ -18,7 +18,7 @@ async function FileGet(follower=false){
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (follower) f = '&f=true'
|
if (follower) f = '&f=true'
|
||||||
const res = await fetch('/api/file?name=' + Active + f)
|
const res = await fetch('{{.BaseUrl}}api/file?name=' + Active + f)
|
||||||
.catch(err=>{console.log(err);return;});
|
.catch(err=>{console.log(err);return;});
|
||||||
const body = await res.json();
|
const body = await res.json();
|
||||||
if(!res.ok){
|
if(!res.ok){
|
||||||
|
@ -31,7 +31,7 @@ async function FileGet(follower=false){
|
||||||
|
|
||||||
async function FileSave(){
|
async function FileSave(){
|
||||||
if (Active == '{{.AppName}}') {
|
if (Active == '{{.AppName}}') {
|
||||||
const res = await fetch('/api/conf', {
|
const res = await fetch('{{.BaseUrl}}api/conf', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: editor.getValue(),
|
body: editor.getValue(),
|
||||||
headers: new Headers({
|
headers: new Headers({
|
||||||
|
@ -45,7 +45,7 @@ async function FileSave(){
|
||||||
else Catch(res)
|
else Catch(res)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const res = await fetch('/api/file', {
|
const res = await fetch('{{.BaseUrl}}api/file', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({"name":Active,"data":editor.getValue()}),
|
body: JSON.stringify({"name":Active,"data":editor.getValue()}),
|
||||||
headers: new Headers({
|
headers: new Headers({
|
||||||
|
@ -62,7 +62,7 @@ async function FileApply(){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const res = await fetch('/api/apply?name='+ Active, {
|
const res = await fetch('{{.BaseUrl}}api/apply?name='+ Active, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
});
|
});
|
||||||
if(!res.ok){
|
if(!res.ok){
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<li>
|
<li>
|
||||||
<a class="has-tooltip-arrow {{if eq $.File.Name .Name }}is-active{{end}}"
|
<a class="has-tooltip-arrow {{if eq $.File.Name .Name }}is-active{{end}}"
|
||||||
data-tooltip="{{.Path}}"
|
data-tooltip="{{.Path}}"
|
||||||
href="/?name={{.Name}}"
|
href="{{$.BaseUrl}}?name={{.Name}}"
|
||||||
>{{ .Name }}</a>
|
>{{ .Name }}</a>
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
<li>
|
<li>
|
||||||
<a class="has-tooltip-arrow {{if eq .File.Name .AppName }}is-active{{end}}"
|
<a class="has-tooltip-arrow {{if eq .File.Name .AppName }}is-active{{end}}"
|
||||||
data-tooltip="{{$.File.Path}}"
|
data-tooltip="{{$.File.Path}}"
|
||||||
href="/"
|
href="{{.BaseUrl}}"
|
||||||
>Config</a></li>
|
>Config</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -105,7 +105,7 @@
|
||||||
|
|
||||||
<p class="control">
|
<p class="control">
|
||||||
<a class="button is-small has-tooltip-arrow" data-tooltip="Download"
|
<a class="button is-small has-tooltip-arrow" data-tooltip="Download"
|
||||||
href="/api/export?name={{.File.Name}}">
|
href="{{.BaseUrl}}api/export?name={{.File.Name}}">
|
||||||
<span class="icon is-small"><span class="material-icons">
|
<span class="icon is-small"><span class="material-icons">
|
||||||
download
|
download
|
||||||
</span></span>
|
</span></span>
|
||||||
|
|
|
@ -19,7 +19,7 @@ var Active = "{{.File.Name}}";
|
||||||
{{template "components/menu" .}}
|
{{template "components/menu" .}}
|
||||||
</div>
|
</div>
|
||||||
<div class="box has-text-centered">
|
<div class="box has-text-centered">
|
||||||
<a href="/api/export" class="button is-small">Export Files</a>
|
<a href="{{.BaseUrl}}api/export" class="button is-small">Export Files</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
|
Loading…
Reference in New Issue