mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
Merge bf1c7a0e36 into 88a149c085
This commit is contained in:
commit
1a26c61b42
7 changed files with 59 additions and 6 deletions
|
|
@ -11,6 +11,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -255,6 +256,9 @@ func Initialize() (*Server, error) {
|
|||
staticUI = statigz.FileServer(ui.UIBox.(fs.ReadDirFS))
|
||||
}
|
||||
|
||||
// handle favicon override
|
||||
r.HandleFunc("/favicon.ico", handleFavicon(staticUI))
|
||||
|
||||
// Serve the web app
|
||||
r.HandleFunc("/*", func(w http.ResponseWriter, r *http.Request) {
|
||||
ext := path.Ext(r.URL.Path)
|
||||
|
|
@ -295,6 +299,31 @@ func Initialize() (*Server, error) {
|
|||
return server, nil
|
||||
}
|
||||
|
||||
func handleFavicon(staticUI *statigz.Server) func(w http.ResponseWriter, r *http.Request) {
|
||||
mgr := manager.GetInstance()
|
||||
cfg := mgr.Config
|
||||
|
||||
// check if favicon.ico exists in the config directory
|
||||
// if so, use that
|
||||
// otherwise, use the embedded one
|
||||
iconPath := filepath.Join(cfg.GetConfigPath(), "favicon.ico")
|
||||
exists, _ := fsutil.FileExists(iconPath)
|
||||
|
||||
if exists {
|
||||
logger.Debugf("Using custom favicon at %s", iconPath)
|
||||
}
|
||||
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Cache-Control", "no-cache")
|
||||
|
||||
if exists {
|
||||
http.ServeFile(w, r, iconPath)
|
||||
} else {
|
||||
staticUI.ServeHTTP(w, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start starts the server. It listens on the configured address and port.
|
||||
// It calls ListenAndServeTLS if TLS is configured, otherwise it calls ListenAndServe.
|
||||
// Calls to Start are blocked until the server is shutdown.
|
||||
|
|
|
|||
|
|
@ -307,7 +307,8 @@ export const App: React.FC = () => {
|
|||
);
|
||||
}
|
||||
|
||||
const titleProps = makeTitleProps();
|
||||
const title = config.data?.configuration.ui.title || "Stash";
|
||||
const titleProps = makeTitleProps(title);
|
||||
|
||||
if (!messages) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -248,6 +248,14 @@ export const SettingsInterfacePanel: React.FC = PatchComponent(
|
|||
onChange={(v) => saveInterface({ sfwContentMode: v })}
|
||||
/>
|
||||
|
||||
<StringSetting
|
||||
id="custom-title"
|
||||
headingID="config.ui.custom_title.heading"
|
||||
subHeadingID="config.ui.custom_title.description"
|
||||
value={ui.title ?? ""}
|
||||
onChange={(v) => saveUI({ title: v })}
|
||||
/>
|
||||
|
||||
<div className="setting-group">
|
||||
<div className="setting">
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -103,6 +103,8 @@ export interface IUIConfig {
|
|||
defaultFilters?: DefaultFilters;
|
||||
|
||||
taggerConfig?: ITaggerConfig;
|
||||
|
||||
title?: string;
|
||||
}
|
||||
|
||||
export function getFrontPageContent(
|
||||
|
|
|
|||
|
|
@ -165,6 +165,12 @@ The following environment variables are also supported:
|
|||
|----------------------|---------|
|
||||
| `STASH_SQLITE_CACHE_SIZE` | Sets the SQLite cache size. See https://www.sqlite.org/pragma.html#pragma_cache_size. Default is `-2000` which is 2MB. |
|
||||
|
||||
### Custom favicon
|
||||
|
||||
You can provide a custom favicon by placing a `favicon.ico` file in the configuration directory. The configuration directory is located alongside the `config.yml` file.
|
||||
|
||||
When a custom favicon is provided, it will be served instead of the default embedded favicon.
|
||||
|
||||
### Custom served folders
|
||||
|
||||
Custom served folders are served when the server handles a request with the `/custom` URL prefix. The following is an example configuration:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
import { MessageDescriptor, useIntl } from "react-intl";
|
||||
import { useConfigurationContext } from "./Config";
|
||||
|
||||
export const TITLE = "Stash";
|
||||
export const TITLE_SEPARATOR = " | ";
|
||||
|
||||
export function useTitleProps(...messages: (string | MessageDescriptor)[]) {
|
||||
const intl = useIntl();
|
||||
const config = useConfigurationContext();
|
||||
const title = config.configuration.ui.title || TITLE;
|
||||
|
||||
const parts = messages.map((msg) => {
|
||||
if (typeof msg === "object") {
|
||||
|
|
@ -14,13 +17,13 @@ export function useTitleProps(...messages: (string | MessageDescriptor)[]) {
|
|||
}
|
||||
});
|
||||
|
||||
return makeTitleProps(...parts);
|
||||
return makeTitleProps(title, ...parts);
|
||||
}
|
||||
|
||||
export function makeTitleProps(...parts: string[]) {
|
||||
const title = [...parts, TITLE].join(TITLE_SEPARATOR);
|
||||
export function makeTitleProps(title: string, ...parts: string[]) {
|
||||
const fullTitle = [...parts, title].join(TITLE_SEPARATOR);
|
||||
return {
|
||||
titleTemplate: `%s | ${title}`,
|
||||
defaultTitle: title,
|
||||
titleTemplate: `%s | ${fullTitle}`,
|
||||
defaultTitle: fullTitle,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -621,6 +621,10 @@
|
|||
"heading": "Custom localisation",
|
||||
"option_label": "Custom localisation enabled"
|
||||
},
|
||||
"custom_title": {
|
||||
"description": "Custom text to append to the page title. If empty, defaults to 'Stash'.",
|
||||
"heading": "Custom Title"
|
||||
},
|
||||
"delete_options": {
|
||||
"description": "Default settings when deleting images, galleries, and scenes.",
|
||||
"heading": "Delete Options",
|
||||
|
|
|
|||
Loading…
Reference in a new issue