sophuwu.site > manhttpd
almost overwrote a file by accident. should commit more.
sophuwu sophie@skisiel.com
Mon, 10 Feb 2025 04:02:06 +0100
commit

d340c1852a89c27c4dc93a49754250669c52c56c

parent

6a16e47e7313e968dba9573328c935d4e6a73311

4 files changed, 104 insertions(+), 21 deletions(-)

jump to
M README.mdREADME.md

@@ -13,13 +13,6 @@ - Able to correctly interpret and display incorrectly formatted man pages, to a degree.

- Auto updates man pages when new packages are installed or removed using standard installation methods. -### Contents -- [Installation Using Apt](#installation-using-apt) -- [Compiling From Source](#compiling-from-source) -- [Using As Systemd Service](#using-as-systemd-service) -- [Accessing the Web Interface](#accessing-the-web-interface) -- [Example Usage](#example-usage) - # Installation Using Apt Simply run the following commands to add my repository and install the package. This will install the latest release and automatically update the server when new versions are released.
M dark_theme.cssdark_theme.css

@@ -1,3 +1,6 @@

+ + + @import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap');

@@ -28,7 +31,7 @@ --rf-color: color-mix(in srgb, #ff7597, #4c86ce calc(0% + (100% * (max(0,calc(var(--col) - 4))))));

--rf-hover: color-mix(in srgb, var(--rf-color), var(--st-color) 40%); --dimmer: rgba(0,0,0,69); - + --lessdimmer: rgba(0,0,0,20%); font-variant-ligatures: none!important; --font-family: var(--font, 'JetBrains Mono');

@@ -71,6 +74,65 @@ height: 100%;

width: 100%; background-color: var(--bg-color); } +.settings { + input { + &[type=range] { + margin: 0; + &[id="theme"] { + width: 100%; + --grad0: 0; + --grad1: 1; + --grad2: 2; + --grad3: 3; + --grad4: 4; + --grad5: 5; + --graddy: 18%; + background-image: linear-gradient(90deg, color-mix(in srgb, color-mix(in srgb, white, yellow calc( 10% * (var(--grad0) + 2) * (min(1,var(--grad0))))), var(--dark-bg) calc(0% + (100% * (max(0,calc(var(--grad0) - 3)))))) calc(var(--grad0) * var(--graddy)), + color-mix(in srgb, color-mix(in srgb, white, yellow calc( 10% * (var(--grad1) + 2) * (min(1,var(--grad1))))), var(--dark-bg) calc(0% + (100% * (max(0,calc(var(--grad1) - 3)))))) calc(var(--grad1) * var(--graddy)), + color-mix(in srgb, color-mix(in srgb, white, yellow calc( 10% * (var(--grad2) + 2) * (min(1,var(--grad2))))), var(--dark-bg) calc(0% + (100% * (max(0,calc(var(--grad2) - 3)))))) calc(var(--grad2) * var(--graddy)), + color-mix(in srgb, color-mix(in srgb, white, yellow calc( 10% * (var(--grad3) + 2) * (min(1,var(--grad3))))), var(--dark-bg) calc(0% + (100% * (max(0,calc(var(--grad3) - 3)))))) calc(var(--grad3) * var(--graddy)), + color-mix(in srgb, color-mix(in srgb, white, yellow calc( 10% * (var(--grad4) + 2) * (min(1,var(--grad4))))), var(--dark-bg) calc(0% + (100% * (max(0,calc(var(--grad4) - 3)))))) calc(var(--grad4) * var(--graddy)), + color-mix(in srgb, color-mix(in srgb, white, yellow calc( 10% * (var(--grad5) + 2) * (min(1,var(--grad5))))), var(--dark-bg) calc(0% + (100% * (max(0,calc(var(--grad5) - 3)))))) calc(var(--grad5) * var(--graddy)))!important; + } + &[id="contrast"] { + width: 2rem; + } + + } + height:1rem; + &[type="text"]{ + font-size: 0.7rem; + padding: 0.2em 1ch; + margin: -0.2em -1ch; + } + border: 1px solid var(--fg-color); + border-radius: 0.5rem; + border-color: var(--fg-color); + background: var(--lessdimmer); + } + + .slider::-webkit-slider-thumb, .slider::-moz-range-thumb { + width: calc(100% / 12); + min-width: 1rem; + background: var(--hl-color); + height: calc(1rem - 0.1em); + } + height: 100%; + tr > th { + width: 100%; + margin: 0; + } + td { + padding: 0.5ch; + margin: auto; + } + label { + display: contents; + } + input#font { + width: 100%; + } +} table.head, table.foot { width: inherit; }

@@ -146,7 +208,7 @@ display: flex;

flex-direction: row; align-content: center; justify-content: center; - + form, div{ display: contents; * {

@@ -193,10 +255,13 @@ height: inherit;

} } -.content{ + +main{ width: calc( 100% - 1em ); - margin: 0; - overflow-y: scroll; + height: 100%; + margin: 0 auto 0 auto; + overflow: auto; padding: 0; } - + +
M index.htmlindex.html

@@ -20,7 +20,7 @@ <h3>@{{ hostname }}</h3>

</div> <form method="post"> <h3>Find:</h3> - <input type="text" name="q" autocomplete="off"> + <input type="text" name="q" autocomplete="off" value="{{ query }}"> <input type="submit" value="Search"> </form> <div>

@@ -29,8 +29,32 @@ <button id="SetButt">Settings</button>

</div> </header> - <div class="content"> + <main> + <article class="settings"> + <table> + <tr> + <td>Theme</td> + <td> <input type="range" min="0" max="5" value="4" id="theme" class="slider"></td> + </tr> + <tr class="yeet"> + <td> + <label>High Contrast</label> + <input type="range" min="0" max="1" value="0" id="contrast" class="slider"></td> + <td> + <label>Font Size</label> + <input type="text" id="fontsize" placeholder="18px"></td> + </tr> + <tr> + <td>Custom Font</td> + <td><input type="text" id="font"></td> + </tr> + <tr> + + </tr> + </table> + + </article> {{ content }} - </div> + </main> </body> </html>
M main.gomain.go

@@ -82,9 +82,10 @@ http.HandleFunc("/", indexHandler)

http.ListenAndServe(CFG.Addr+":"+CFG.Port, nil) } -func WriteHtml(w http.ResponseWriter, r *http.Request, title, html string) { +func WriteHtml(w http.ResponseWriter, r *http.Request, title, html string, q string) { out := strings.ReplaceAll(index, "{{ host }}", r.Host) out = strings.ReplaceAll(out, "{{ title }}", title) + out = strings.ReplaceAll(out, "{{ query }}", q) out = strings.ReplaceAll(out, "{{ content }}", html) w.Header().Set("Content-Type", "text/html; charset=utf-8") w.WriteHeader(http.StatusOK)

@@ -164,7 +165,7 @@ }

cmd := exec.Command("whatis", args...) b, e := cmd.Output() if len(b) < 1 || e != nil { - WriteHtml(w, r, "Search", fmt.Sprintf("<p>404: no resualts matching %s</p>", q)) + WriteHtml(w, r, "Search", fmt.Sprintf("<p>404: no resualts matching %s</p>", q), q) return } var output string

@@ -173,7 +174,7 @@ if len(line) == 4 {

output += fmt.Sprintf(`<p><a href="?%s.%s">%s (%s)</a> - %s</p>%c`, line[1], line[2], line[1], line[2], line[3], 10) } } - WriteHtml(w, r, "Search", output) + WriteHtml(w, r, "Search", output, q) } func indexHandler(w http.ResponseWriter, r *http.Request) { path := filepath.Base(r.URL.Path)

@@ -192,9 +193,9 @@ r.ParseForm()

name := r.URL.RawQuery if name != "" { man := NewManPage(name) - WriteHtml(w, r, man.Name, man.Html()) + WriteHtml(w, r, man.Name, man.Html(), name) return } - WriteHtml(w, r, "Index", "") + WriteHtml(w, r, "Index", "", name) return }