fix styling + opt-out flag

This commit is contained in:
Pietro Bonaldo Gregori 2023-07-19 10:40:43 +02:00
parent f09260e0f5
commit 01829e722d
4 changed files with 13 additions and 6 deletions

View file

@ -34,6 +34,7 @@ type pageTemplate struct {
Title template.HTML
ExtraPath template.HTML
Ro bool
HelpMessage bool
RowsFiles []rowTemplate
RowsFolders []rowTemplate
}
@ -45,6 +46,7 @@ var symlinks = flag.Bool("symlinks", false, "follow symlinks \033[4mWARNING\033[
var verb = flag.Bool("verb", false, "verbosity")
var skipHidden = flag.Bool("k", true, "\nskip hidden files")
var ro = flag.Bool("ro", false, "read only mode (no upload, rename, move, etc...)")
var helpMessage = flag.Bool("m", true, "display small text showing how to open help menu")
type rpcCall struct {
Call string `json:"call"`
@ -98,6 +100,7 @@ func replyList(w http.ResponseWriter, r *http.Request, fullPath string, path str
}
p.ExtraPath = template.HTML(html.EscapeString(*extraPath))
p.Ro = *ro
p.HelpMessage = *helpMessage
p.Title = template.HTML(html.EscapeString(title))
for _, el := range _files {
@ -281,7 +284,7 @@ func main() {
handler = http.StripPrefix(*extraPath, http.FileServer(http.Dir(rootPath)))
fmt.Printf("Gossa starting on directory %s\n", rootPath)
fmt.Printf("Verbose: %t, Symlinks: %t, Read-Only: %t, Hidden-Files Skipped: %t\n", *verb, *symlinks, *ro, *skipHidden)
fmt.Printf("Verbose: %t, Symlinks: %t, Read-Only: %t, Hidden-Files Skipped: %t, Display Help Message: %t\n", *verb, *symlinks, *ro, *skipHidden, *helpMessage)
fmt.Printf("Listening on http://%s:%s%s\n", *host, *port, *extraPath)
if err = server.ListenAndServe(); err != http.ErrServerClosed {
check(err)

3
ui/script.js vendored
View file

@ -44,6 +44,9 @@ const flicker = w => w.classList.remove('runFade') || void w.offsetWidth || w.cl
const encodeURIHash = e => encodeURI(e).replaceAll('#', '%23')
// Display help message
if (!window.helpMessage) document.getElementById("help_message").remove()
// Manual upload
manualUpload.addEventListener('change', () => Array.from(manualUpload.files).forEach(f => isDupe(f.name) || postFile(f, '/' + f.name)), false)

8
ui/style.css vendored
View file

@ -388,12 +388,12 @@ h1 > span:hover {
z-index: 101;
}
.help_message {
#help_message {
font-family: monospace;
font-size: 10px;
float: left;
position: absolute;
font-size: 12px;
position: fixed;
bottom: 3px;
right: 12px;
opacity: 50%;
}

3
ui/ui.tmpl vendored
View file

@ -15,6 +15,7 @@
<script>
window.ro = {{.Ro}}
window.extraPath = {{.ExtraPath}}.slice(0, -1)
window.helpMessage = {{.HelpMessage}}
window.onload = function () { js_will_be_here }
</script>
</head>
@ -78,12 +79,12 @@
</tr>
{{end}}
</table>
<p id="help_message">Help: Ctrl/Cmd + h<p>
</body>
<div id="upBar" class="bar">
<span style="display: none;" class="barName" id="upBarName"></span>
<div style="display: none; background-color: green;" class="barPc" id="upBarPc">1%</div>
</div>
<p class="help_message">Help: Ctrl/Cmd + h<p>
<div id="ok" class="notif icon-large-ok"></div>
<div id="sad" class="notif icon-large-sad-server"></div>
</html>