add aceEditorTheme to config and userDefaults
parent
35d1c09243
commit
e4b322d80a
|
@ -169,6 +169,7 @@ func printSettings(ser *settings.Server, set *settings.Settings, auther auth.Aut
|
||||||
fmt.Fprintf(w, "\tView mode:\t%s\n", set.Defaults.ViewMode)
|
fmt.Fprintf(w, "\tView mode:\t%s\n", set.Defaults.ViewMode)
|
||||||
fmt.Fprintf(w, "\tSingle Click:\t%t\n", set.Defaults.SingleClick)
|
fmt.Fprintf(w, "\tSingle Click:\t%t\n", set.Defaults.SingleClick)
|
||||||
fmt.Fprintf(w, "\tCommands:\t%s\n", strings.Join(set.Defaults.Commands, " "))
|
fmt.Fprintf(w, "\tCommands:\t%s\n", strings.Join(set.Defaults.Commands, " "))
|
||||||
|
fmt.Fprintf(w, "\tAce editor syntax highlighting theme:\t%s\n", set.Defaults.AceEditorTheme)
|
||||||
fmt.Fprintf(w, "\tSorting:\n")
|
fmt.Fprintf(w, "\tSorting:\n")
|
||||||
fmt.Fprintf(w, "\t\tBy:\t%s\n", set.Defaults.Sorting.By)
|
fmt.Fprintf(w, "\t\tBy:\t%s\n", set.Defaults.Sorting.By)
|
||||||
fmt.Fprintf(w, "\t\tAsc:\t%t\n", set.Defaults.Sorting.Asc)
|
fmt.Fprintf(w, "\t\tAsc:\t%t\n", set.Defaults.Sorting.Asc)
|
||||||
|
|
|
@ -326,6 +326,7 @@ func quickSetup(flags *pflag.FlagSet, d pythonData) {
|
||||||
Scope: ".",
|
Scope: ".",
|
||||||
Locale: "en",
|
Locale: "en",
|
||||||
SingleClick: false,
|
SingleClick: false,
|
||||||
|
AceEditorTheme: getParam(flags, "defaults.aceEditorTheme"),
|
||||||
Perm: users.Permissions{
|
Perm: users.Permissions{
|
||||||
Admin: false,
|
Admin: false,
|
||||||
Execute: true,
|
Execute: true,
|
||||||
|
|
|
@ -77,6 +77,7 @@ func addUserFlags(flags *pflag.FlagSet) {
|
||||||
flags.String("locale", "en", "locale for users")
|
flags.String("locale", "en", "locale for users")
|
||||||
flags.String("viewMode", string(users.ListViewMode), "view mode for users")
|
flags.String("viewMode", string(users.ListViewMode), "view mode for users")
|
||||||
flags.Bool("singleClick", false, "use single clicks only")
|
flags.Bool("singleClick", false, "use single clicks only")
|
||||||
|
flags.String("aceEditorTheme", "", "ace editor's syntax highlighting theme for users")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getViewMode(flags *pflag.FlagSet) users.ViewMode {
|
func getViewMode(flags *pflag.FlagSet) users.ViewMode {
|
||||||
|
@ -99,6 +100,8 @@ func getUserDefaults(flags *pflag.FlagSet, defaults *settings.UserDefaults, all
|
||||||
defaults.ViewMode = getViewMode(flags)
|
defaults.ViewMode = getViewMode(flags)
|
||||||
case "singleClick":
|
case "singleClick":
|
||||||
defaults.SingleClick = mustGetBool(flags, flag.Name)
|
defaults.SingleClick = mustGetBool(flags, flag.Name)
|
||||||
|
case "aceEditorTheme":
|
||||||
|
defaults.AceEditorTheme = mustGetString(flags, flag.Name)
|
||||||
case "perm.admin":
|
case "perm.admin":
|
||||||
defaults.Perm.Admin = mustGetBool(flags, flag.Name)
|
defaults.Perm.Admin = mustGetBool(flags, flag.Name)
|
||||||
case "perm.execute":
|
case "perm.execute":
|
||||||
|
|
|
@ -20,6 +20,7 @@ interface SettingsDefaults {
|
||||||
commands: any[];
|
commands: any[];
|
||||||
hideDotfiles: boolean;
|
hideDotfiles: boolean;
|
||||||
dateFormat: boolean;
|
dateFormat: boolean;
|
||||||
|
aceEditorTheme: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SettingsBranding {
|
interface SettingsBranding {
|
||||||
|
|
|
@ -13,6 +13,7 @@ interface IUser {
|
||||||
dateFormat: boolean;
|
dateFormat: boolean;
|
||||||
viewMode: ViewModeType;
|
viewMode: ViewModeType;
|
||||||
sorting?: Sorting;
|
sorting?: Sorting;
|
||||||
|
aceEditorTheme: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type ViewModeType = "list" | "mosaic" | "mosaic gallery";
|
type ViewModeType = "list" | "mosaic" | "mosaic gallery";
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import { theme } from "./constants";
|
import { theme } from "./constants";
|
||||||
|
import "ace-builds";
|
||||||
|
import { themesByName } from "ace-builds/src-noconflict/ext-themelist";
|
||||||
|
|
||||||
export const getTheme = (): UserTheme => {
|
export const getTheme = (): UserTheme => {
|
||||||
return (document.documentElement.className as UserTheme) || theme;
|
return (document.documentElement.className as UserTheme) || theme;
|
||||||
|
@ -32,3 +34,17 @@ export const getMediaPreference = (): UserTheme => {
|
||||||
return "light";
|
return "light";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getEditorTheme = (themeName: string) => {
|
||||||
|
if (!themeName.startsWith("ace/theme/")) {
|
||||||
|
themeName = `ace/theme/${themeName}`;
|
||||||
|
}
|
||||||
|
const themeKey = themeName.replace("ace/theme/", "");
|
||||||
|
if (themesByName[themeKey] !== undefined) {
|
||||||
|
return themeName;
|
||||||
|
} else if (getTheme() === "dark") {
|
||||||
|
return "ace/theme/twilight";
|
||||||
|
} else {
|
||||||
|
return "ace/theme/chrome";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -51,7 +51,7 @@ import { useLayoutStore } from "@/stores/layout";
|
||||||
import { inject, onBeforeUnmount, onMounted, ref, watchEffect } from "vue";
|
import { inject, onBeforeUnmount, onMounted, ref, watchEffect } from "vue";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { getTheme } from "@/utils/theme";
|
import { getEditorTheme } from "@/utils/theme";
|
||||||
import { marked } from "marked";
|
import { marked } from "marked";
|
||||||
|
|
||||||
const $showError = inject<IToastError>("$showError")!;
|
const $showError = inject<IToastError>("$showError")!;
|
||||||
|
@ -107,7 +107,7 @@ onMounted(() => {
|
||||||
value: fileContent,
|
value: fileContent,
|
||||||
showPrintMargin: false,
|
showPrintMargin: false,
|
||||||
readOnly: fileStore.req?.type === "textImmutable",
|
readOnly: fileStore.req?.type === "textImmutable",
|
||||||
theme: "ace/theme/chrome",
|
theme: getEditorTheme(authStore.user?.aceEditorTheme ?? ""),
|
||||||
mode: modelist.getModeForPath(fileStore.req!.name).mode,
|
mode: modelist.getModeForPath(fileStore.req!.name).mode,
|
||||||
wrap: true,
|
wrap: true,
|
||||||
enableBasicAutocompletion: true,
|
enableBasicAutocompletion: true,
|
||||||
|
@ -115,10 +115,6 @@ onMounted(() => {
|
||||||
enableSnippets: true,
|
enableSnippets: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (getTheme() === "dark") {
|
|
||||||
editor.value!.setTheme("ace/theme/twilight");
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.value.focus();
|
editor.value.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ type userInfo struct {
|
||||||
LockPassword bool `json:"lockPassword"`
|
LockPassword bool `json:"lockPassword"`
|
||||||
HideDotfiles bool `json:"hideDotfiles"`
|
HideDotfiles bool `json:"hideDotfiles"`
|
||||||
DateFormat bool `json:"dateFormat"`
|
DateFormat bool `json:"dateFormat"`
|
||||||
|
AceEditorTheme string `json:"aceEditorTheme"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type authToken struct {
|
type authToken struct {
|
||||||
|
@ -195,6 +196,7 @@ func printToken(w http.ResponseWriter, _ *http.Request, d *data, user *users.Use
|
||||||
Commands: user.Commands,
|
Commands: user.Commands,
|
||||||
HideDotfiles: user.HideDotfiles,
|
HideDotfiles: user.HideDotfiles,
|
||||||
DateFormat: user.DateFormat,
|
DateFormat: user.DateFormat,
|
||||||
|
AceEditorTheme: user.AceEditorTheme,
|
||||||
},
|
},
|
||||||
RegisteredClaims: jwt.RegisteredClaims{
|
RegisteredClaims: jwt.RegisteredClaims{
|
||||||
IssuedAt: jwt.NewNumericDate(time.Now()),
|
IssuedAt: jwt.NewNumericDate(time.Now()),
|
||||||
|
|
|
@ -17,6 +17,7 @@ type UserDefaults struct {
|
||||||
Commands []string `json:"commands"`
|
Commands []string `json:"commands"`
|
||||||
HideDotfiles bool `json:"hideDotfiles"`
|
HideDotfiles bool `json:"hideDotfiles"`
|
||||||
DateFormat bool `json:"dateFormat"`
|
DateFormat bool `json:"dateFormat"`
|
||||||
|
AceEditorTheme string `json:"aceEditorTheme"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply applies the default options to a user.
|
// Apply applies the default options to a user.
|
||||||
|
@ -30,4 +31,5 @@ func (d *UserDefaults) Apply(u *users.User) {
|
||||||
u.Commands = d.Commands
|
u.Commands = d.Commands
|
||||||
u.HideDotfiles = d.HideDotfiles
|
u.HideDotfiles = d.HideDotfiles
|
||||||
u.DateFormat = d.DateFormat
|
u.DateFormat = d.DateFormat
|
||||||
|
u.AceEditorTheme = d.AceEditorTheme
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ type User struct {
|
||||||
Rules []rules.Rule `json:"rules"`
|
Rules []rules.Rule `json:"rules"`
|
||||||
HideDotfiles bool `json:"hideDotfiles"`
|
HideDotfiles bool `json:"hideDotfiles"`
|
||||||
DateFormat bool `json:"dateFormat"`
|
DateFormat bool `json:"dateFormat"`
|
||||||
|
AceEditorTheme string `json:"aceEditorTheme"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRules implements rules.Provider.
|
// GetRules implements rules.Provider.
|
||||||
|
|
Loading…
Reference in New Issue