From 1fa6e1de4f78043bb0125fb9b9ac11d80211f913 Mon Sep 17 00:00:00 2001 From: Paramtamtam <7326800+tarampampam@users.noreply.github.com> Date: Sat, 29 Jun 2024 00:49:59 +0400 Subject: [PATCH] =?UTF-8?q?wip:=20=F0=9F=94=95=20temporary=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/cli/serve/command.go | 4 +- internal/http/handlers/error_page/handler.go | 4 +- profile001.svg | 3116 ++++++++++++++++++ templates/ghost.html | 2 +- templates/readme.md | 15 + 5 files changed, 3137 insertions(+), 4 deletions(-) create mode 100644 profile001.svg create mode 100644 templates/readme.md diff --git a/internal/cli/serve/command.go b/internal/cli/serve/command.go index a1f0f79..ddcd170 100644 --- a/internal/cli/serve/command.go +++ b/internal/cli/serve/command.go @@ -316,6 +316,8 @@ func (cmd *command) Run(ctx context.Context, log *logger.Logger, cfg *config.Con // ![Used times](https://img.shields.io/badge/dynamic/json? // url=https%3A%2F%2Ferror-pages.goatcounter.com%2Fcounter%2F%2Fuse-template%2Flost-in-space.json // &query=%24.count&label=Used%20times) + // + // if you wish, you may view the collected statistics at any time here - https://error-pages.goatcounter.com/ go func() { var tpl = url.QueryEscape(cfg.TemplateName) @@ -327,7 +329,7 @@ func (cmd *command) Run(ctx context.Context, log *logger.Logger, cfg *config.Con return } - req.Header.Set("User-Agent", "error-pages") // by default, the User-Agent is "Go-http-client/x.x" + req.Header.Set("User-Agent", fmt.Sprintf("Mozilla/5.0 (error-pages, rnd:%d)", time.Now().UnixNano())) resp, respErr := (&http.Client{Timeout: 10 * time.Second}).Do(req) //nolint:mnd // don't care about the response if respErr != nil { diff --git a/internal/http/handlers/error_page/handler.go b/internal/http/handlers/error_page/handler.go index 64dd62e..d70871d 100644 --- a/internal/http/handlers/error_page/handler.go +++ b/internal/http/handlers/error_page/handler.go @@ -12,10 +12,10 @@ import ( "gh.tarampamp.am/error-pages/internal/template" ) -const contentTypeHeader = "Content-Type" - // New creates a new handler that returns an error page with the specified status code and format. func New(cfg *config.Config, log *logger.Logger) http.Handler { //nolint:funlen,gocognit,gocyclo + const contentTypeHeader = "Content-Type" + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var code uint16 diff --git a/profile001.svg b/profile001.svg new file mode 100644 index 0000000..73459fd --- /dev/null +++ b/profile001.svg @@ -0,0 +1,3116 @@ + + + + + + +error-pages + + +cluster_L + + + + +File: error-pages + + +File: error-pages +Type: cpu +Time: Jun 28, 2024 at 8:51pm (+04) +Duration: 35.93s, Total samples = 116.95s (325.54%) +Showing nodes accounting for 63.69s, 54.46% of 116.95s total +Dropped 934 nodes (cum <= 0.58s) +Dropped 112 edges (freq <= 0.12s) +Showing top 80 nodes out of 254 +See https://git.io/JfYMW for how to read the graph + + + + + +N1 + + +http +(*conn) +serve +0.29s (0.25%) +of 72.80s (62.25%) + + + + + +N2 + + +http +HandlerFunc +ServeHTTP +0.06s (0.051%) +of 59.60s (50.96%) + + + + + +N1->N2 + + + + + + + 59.60s + + + + + +N34 + + +bufio +(*Writer) +Flush +0.06s (0.051%) +of 7.58s (6.48%) + + + + + +N1->N34 + + + + + + + 5.95s + + + + + +N44 + + +http +(*conn) +readRequest +0.09s (0.077%) +of 3.84s (3.28%) + + + + + +N1->N44 + + + + + + + 3.84s + + + + + +N8 + + +http +(*Server) +Register +New +func4 +0.11s (0.094%) +of 52.49s (44.88%) + + + + + +N2->N8 + + + + + + + 52.49s + + + + + +N10 + + +http +(*Server) +Register +(*Server) +Register +New +func6 +func7 +0.06s (0.051%) +of 59.56s (50.93%) + + + + + +N2->N10 + + + + + + + 59.56s + + + + + +N3 + + +template +Render +0.07s (0.06%) +of 45.06s (38.53%) + + + + + +N7 + + +template +(*state) +walk +0.17s (0.15%) +of 13.77s (11.77%) + + + + + +N3->N7 + + + + + + + 13.77s + + + + + +N42 + + +template +(*Template) +Parse +0.05s (0.043%) +of 20.68s (17.68%) + + + + + +N3->N42 + + + + + + + 20.68s + + + + + +N68 + + +template +(*Template) +Funcs +0.04s (0.034%) +of 6.15s (5.26%) + + + + + +N3->N68 + + + + + + + 6.15s + + + + + +N4 + + +runtime +systemstack +0.03s (0.026%) +of 40.57s (34.69%) + + + + + +N46 + + +runtime +wbBufFlush1 +0.80s (0.68%) +of 3.66s (3.13%) + + + + + +N4->N46 + + + + + + + 3.28s + + + + + +N57 + + +runtime +futex +1.90s (1.62%) + + + + + +N4->N57 + + + + + + + 0.18s + + + + + +N66 + + +runtime +(*sweepLocked) +sweep +0.55s (0.47%) +of 1.84s (1.57%) + + + + + +N4->N66 + + + + + + + 0.60s + + + + + +N80 + + +runtime +gcBgMarkWorker +func2 +0 of 31.60s (27.02%) + + + + + +N4->N80 + + + + + + + 31.60s + + + + + +N5 + + +runtime +mallocgc +2.43s (2.08%) +of 14.73s (12.60%) + + + + + +N5->N4 + + + + + + + 3.13s + + + + + +N24 + + +runtime +(*mspan) +base +4.83s (4.13%) + + + + + +N5->N24 + + + + + + + 0.98s + (inline) + + + + + +N63 + + +runtime +memclrNoHeapPointers +1.56s (1.33%) + + + + + +N5->N63 + + + + + + + 1.10s + + + + + +N6 + + +runtime +gcDrain +1.28s (1.09%) +of 31.59s (27.01%) + + + + + +N11 + + +runtime +scanobject +2.72s (2.33%) +of 14.96s (12.79%) + + + + + +N6->N11 + + + + + + + 13.35s + + + + + +N48 + + +runtime +markroot +0.17s (0.15%) +of 14.97s (12.80%) + + + + + +N6->N48 + + + + + + + 14.78s + + + + + +N56 + + +runtime +wbBufFlush +0.01s (0.0086%) +of 3.58s (3.06%) + + + + + +N6->N56 + + + + + + + 0.25s + + + + + +N22 + + +runtime +memmove +3.50s (2.99%) + + + + + +N7->N22 + + + + + + + 0.49s + + + + + +N29 + + +template +(*state) +evalPipeline +0.16s (0.14%) +of 9.16s (7.83%) + + + + + +N7->N29 + + + + + + + 7.04s + + + + + +N51 + + +template +(*state) +walkIfOrWith +0.06s (0.051%) +of 9.31s (7.96%) + + + + + +N7->N51 + + + + + + + 9.31s + + + + + +N77 + + +strings +(*Builder) +Write +0.10s (0.086%) +of 2.50s (2.14%) + + + + + +N7->N77 + + + + + + + 2.50s + + + + + +N8->N3 + + + + + + + 45.06s + + + + + +N67 + + +error_page +write[go +shape +string] +0.01s (0.0086%) +of 5.78s (4.94%) + + + + + +N8->N67 + + + + + + + 5.78s + + + + + +N9 + + +runtime +gcBgMarkWorker +0.05s (0.043%) +of 32.91s (28.14%) + + + + + +N9->N4 + + + + + + + 32.71s + + + + + +N10->N2 + + + + + + + 52.73s + + + + + +N50 + + +slog +(*commonHandler) +handle +0.11s (0.094%) +of 5.38s (4.60%) + + + + + +N10->N50 + + + + + + + 5.38s + + + + + +N21 + + +runtime +greyobject +0.74s (0.63%) +of 8.17s (6.99%) + + + + + +N11->N21 + + + + + + + 7.01s + + + + + +N26 + + +runtime +findObject +4.50s (3.85%) +of 6.05s (5.17%) + + + + + +N11->N26 + + + + + + + 3.21s + + + + + +N12 + + +parse +(*Tree) +pipeline +0.25s (0.21%) +of 9.50s (8.12%) + + + + + +N19 + + +parse +(*Tree) +nextNonSpace +1.07s (0.91%) +of 7.65s (6.54%) + + + + + +N12->N19 + + + + + + + 0.63s + + + + + +N30 + + +parse +(*Tree) +command +0.19s (0.16%) +of 6.69s (5.72%) + + + + + +N12->N30 + + + + + + + 6.69s + + + + + +N52 + + +parse +(*Tree) +peekNonSpace +0.29s (0.25%) +of 3.45s (2.95%) + + + + + +N12->N52 + + + + + + + 0.93s + (inline) + + + + + +N13 + + +parse +(*Tree) +textOrAction +0.20s (0.17%) +of 16.52s (14.13%) + + + + + +N16 + + +parse +(*Tree) +action +0.14s (0.12%) +of 15.67s (13.40%) + + + + + +N13->N16 + + + + + + + 15.67s + + + + + +N59 + + +runtime +stringtoslicebyte +0.05s (0.043%) +of 2.44s (2.09%) + + + + + +N13->N59 + + + + + + + 0.83s + + + + + +N14 + + +syscall +Syscall6 +10.51s (8.99%) + + + + + +N15 + + +runtime +newobject +0.34s (0.29%) +of 6.43s (5.50%) + + + + + +N15->N5 + + + + + + + 6.08s + + + + + +N16->N12 + + + + + + + 6.40s + + + + + +N16->N19 + + + + + + + 2.42s + + + + + +N39 + + +parse +(*Tree) +parseControl +0.02s (0.017%) +of 12.92s (11.05%) + + + + + +N16->N39 + + + + + + + 12.92s + + + + + +N17 + + +runtime +mapassign_faststr +1.30s (1.11%) +of 6.46s (5.52%) + + + + + +N17->N15 + + + + + + + 0.61s + (inline) + + + + + +N61 + + +runtime +evacuate_faststr +0.63s (0.54%) +of 2.40s (2.05%) + + + + + +N17->N61 + + + + + + + 2.40s + + + + + +N18 + + +parse +(*lexer) +nextItem +1.16s (0.99%) +of 7.70s (6.58%) + + + + + +N53 + + +runtime +bulkBarrierPreWrite +0.45s (0.38%) +of 1.93s (1.65%) + + + + + +N18->N53 + + + + + + + 0.70s + + + + + +N74 + + +parse +lexIdentifier +0.25s (0.21%) +of 2.31s (1.98%) + + + + + +N18->N74 + + + + + + + 2.31s + + + + + +N65 + + +parse +(*Tree) +next +0.47s (0.4%) +of 6.64s (5.68%) + + + + + +N19->N65 + + + + + + + 6.57s + (inline) + + + + + +N20 + + +runtime +scanstack +0.10s (0.086%) +of 13.45s (11.50%) + + + + + +N27 + + +runtime +scanblock +0.86s (0.74%) +of 4.74s (4.05%) + + + + + +N20->N27 + + + + + + + 0.53s + + + + + +N28 + + +runtime +scanframeworker +0.21s (0.18%) +of 7.75s (6.63%) + + + + + +N20->N28 + + + + + + + 7.75s + + + + + +N60 + + +runtime +(*lfstack) +push +1.83s (1.56%) + + + + + +N20->N60 + + + + + + + 1.45s + + + + + +N75 + + +runtime +(*unwinder) +resolveInternal +0.90s (0.77%) +of 2.68s (2.29%) + + + + + +N20->N75 + + + + + + + 2.58s + + + + + +N21->N24 + + + + + + + 3.49s + (inline) + + + + + +N43 + + +runtime +(*gcBits) +bitp +3.16s (2.70%) +of 3.22s (2.75%) + + + + + +N21->N43 + + + + + + + 2.77s + (inline) + + + + + +N23 + + +parse +(*Tree) +parse +0.23s (0.2%) +of 19.28s (16.49%) + + + + + +N23->N13 + + + + + + + 16.52s + + + + + +N23->N19 + + + + + + + 1.18s + + + + + +N73 + + +parse +(*Tree) +peek +0.30s (0.26%) +of 2.25s (1.92%) + + + + + +N23->N73 + + + + + + + 0.89s + + + + + +N25 + + +runtime +growslice +0.29s (0.25%) +of 3.94s (3.37%) + + + + + +N25->N5 + + + + + + + 3.03s + + + + + +N25->N22 + + + + + + + 0.21s + + + + + +N25->N63 + + + + + + + 0.24s + + + + + +N26->N24 + + + + + + + 0.23s + (inline) + + + + + +N27->N21 + + + + + + + 1.15s + + + + + +N27->N26 + + + + + + + 0.62s + + + + + +N36 + + +runtime +getempty +0.49s (0.42%) +of 4.60s (3.93%) + + + + + +N27->N36 + + + + + + + 2.08s + + + + + +N28->N27 + + + + + + + 3.66s + + + + + +N41 + + +runtime +pcvalue +1.50s (1.28%) +of 3.27s (2.80%) + + + + + +N28->N41 + + + + + + + 1.41s + + + + + +N64 + + +template +(*state) +evalCommand +0.14s (0.12%) +of 8.86s (7.58%) + + + + + +N29->N64 + + + + + + + 8.86s + + + + + +N30->N25 + + + + + + + 0.75s + + + + + +N32 + + +gcWriteBarrier +0.33s (0.28%) +of 2.48s (2.12%) + + + + + +N30->N32 + + + + + + + 0.13s + + + + + +N30->N52 + + + + + + + 1.12s + (inline) + + + + + +N69 + + +parse +(*Tree) +operand +0.11s (0.094%) +of 4.27s (3.65%) + + + + + +N30->N69 + + + + + + + 4.27s + + + + + +N31 + + +runtime +findRunnable +0.28s (0.24%) +of 6.08s (5.20%) + + + + + +N31->N14 + + + + + + + 0.55s + + + + + +N31->N66 + + + + + + + 0.23s + + + + + +N32->N56 + + + + + + + 2.15s + + + + + +N33 + + +bufio +(*Writer) +Write +0.07s (0.06%) +of 4.22s (3.61%) + + + + + +N33->N22 + + + + + + + 0.14s + + + + + +N33->N34 + + + + + + + 1.63s + + + + + +N45 + + +http +(*chunkWriter) +Write +0.02s (0.017%) +of 5.26s (4.50%) + + + + + +N33->N45 + + + + + + + 4.06s + + + + + +N54 + + +http +checkConnErrorWriter +Write +0.06s (0.051%) +of 8.12s (6.94%) + + + + + +N33->N54 + + + + + + + 1.80s + + + + + +N34->N45 + + + + + + + 1.20s + + + + + +N34->N54 + + + + + + + 6.32s + + + + + +N35 + + +Value +call +1.08s (0.92%) +of 5.62s (4.81%) + + + + + +N35->N5 + + + + + + + 1.32s + + + + + +N35->N22 + + + + + + + 0.12s + + + + + +N35->N32 + + + + + + + 0.20s + + + + + +N40 + + +runtime +(*lfstack) +pop +4.24s (3.63%) + + + + + +N36->N40 + + + + + + + 4.03s + (inline) + + + + + +N37 + + +template +(*state) +evalCall +0.19s (0.16%) +of 6.98s (5.97%) + + + + + +N37->N29 + + + + + + + 1.18s + + + + + +N37->N35 + + + + + + + 5.62s + + + + + +N38 + + +parse +(*Tree) +itemList +0.06s (0.051%) +of 10.48s (8.96%) + + + + + +N38->N13 + + + + + + + 8.88s + + + + + +N38->N52 + + + + + + + 1.40s + (inline) + + + + + +N39->N12 + + + + + + + 3.10s + + + + + +N39->N38 + + + + + + + 10.48s + + + + + +N42->N17 + + + + + + + 0.48s + + + + + +N42->N23 + + + + + + + 19.28s + + + + + +N44->N17 + + + + + + + 0.20s + + + + + +N45->N33 + + + + + + + 3.62s + + + + + +N72 + + +runtime +mapiternext +0.75s (0.64%) +of 1.35s (1.15%) + + + + + +N45->N72 + + + + + + + 0.24s + + + + + +N46->N26 + + + + + + + 2.20s + + + + + +N46->N43 + + + + + + + 0.43s + (inline) + + + + + +N47 + + +runtime +mcall +0.03s (0.026%) +of 6.72s (5.75%) + + + + + +N78 + + +runtime +schedule +0.16s (0.14%) +of 6.95s (5.94%) + + + + + +N47->N78 + + + + + + + 6.36s + + + + + +N48->N11 + + + + + + + 0.18s + + + + + +N48->N20 + + + + + + + 13.45s + + + + + +N48->N27 + + + + + + + 0.55s + + + + + +N49 + + +runtime +mapaccess1_faststr +1.14s (0.97%) +of 2s (1.71%) + + + + + +N58 + + +slog +(*handleState) +appendAttr +0.16s (0.14%) +of 2.95s (2.52%) + + + + + +N50->N58 + + + + + + + 2.95s + + + + + +N62 + + +poll +(*FD) +Write +0.04s (0.034%) +of 9.03s (7.72%) + + + + + +N50->N62 + + + + + + + 1.08s + + + + + +N51->N7 + + + + + + + 7.49s + + + + + +N51->N29 + + + + + + + 2.12s + + + + + +N52->N19 + + + + + + + 3.14s + + + + + +N53->N56 + + + + + + + 1.09s + + + + + +N54->N62 + + + + + + + 7.95s + + + + + +N55 + + +parse +(*Tree) +term +0.31s (0.27%) +of 2.96s (2.53%) + + + + + +N55->N12 + + + + + + + 1.33s + + + + + +N55->N15 + + + + + + + 0.71s + + + + + +N55->N19 + + + + + + + 0.17s + + + + + +N55->N49 + + + + + + + 0.61s + + + + + +N56->N4 + + + + + + + 3.28s + + + + + +N58->N5 + + + + + + + 0.34s + + + + + +N58->N32 + + + + + + + 0.16s + + + + + +N59->N5 + + + + + + + 1.12s + + + + + +N59->N22 + + + + + + + 1.14s + + + + + +N61->N32 + + + + + + + 0.26s + + + + + +N61->N53 + + + + + + + 0.55s + + + + + +N71 + + +poll +ignoringEINTRIO +0 of 10.50s (8.98%) + + + + + +N62->N71 + + + + + + + 8.88s + (inline) + + + + + +N70 + + +template +(*state) +evalFunction +0.06s (0.051%) +of 7.43s (6.35%) + + + + + +N64->N70 + + + + + + + 7.43s + + + + + +N65->N18 + + + + + + + 5.85s + + + + + +N66->N4 + + + + + + + 0.23s + + + + + +N67->N33 + + + + + + + 4.10s + + + + + +N67->N59 + + + + + + + 1.60s + + + + + +N68->N17 + + + + + + + 4.38s + + + + + +N68->N72 + + + + + + + 0.75s + + + + + +N69->N55 + + + + + + + 2.96s + + + + + +N69->N73 + + + + + + + 1.33s + + + + + +N70->N37 + + + + + + + 6.63s + + + + + +N70->N49 + + + + + + + 0.48s + + + + + +N79 + + +syscall +Syscall +0.05s (0.043%) +of 10.43s (8.92%) + + + + + +N71->N79 + + + + + + + 10.43s + + + + + +N72->N32 + + + + + + + 0.38s + + + + + +N73->N18 + + + + + + + 1.85s + + + + + +N74->N49 + + + + + + + 0.54s + + + + + +N76 + + +parse +(*lexer) +next +0.71s (0.61%) +of 1.63s (1.39%) + + + + + +N74->N76 + + + + + + + 0.76s + + + + + +N75->N41 + + + + + + + 1.77s + + + + + +N77->N22 + + + + + + + 0.97s + + + + + +N77->N25 + + + + + + + 1.33s + + + + + +N78->N31 + + + + + + + 6.08s + + + + + +N79->N14 + + + + + + + 9.86s + + + + + +N80->N6 + + + + + + + 31.59s + + + + + diff --git a/templates/ghost.html b/templates/ghost.html index 7b8794e..ca77551 100644 --- a/templates/ghost.html +++ b/templates/ghost.html @@ -43,7 +43,7 @@ @media screen and (min-width: 2000px) { html, body { - font-size: 22px; + font-size: 20px; } } diff --git a/templates/readme.md b/templates/readme.md new file mode 100644 index 0000000..4063a14 --- /dev/null +++ b/templates/readme.md @@ -0,0 +1,15 @@ +# Templates + +Creating templates is a straightforward process, even for those unfamiliar +with [Go Template](https://pkg.go.dev/text/template). Here are a few things to keep in mind: + +- The template should be a single page, without additional `css` or `js` files. However, you can load them from a + CDN or other GitHub repositories using [jsdelivr.com](https://www.jsdelivr.com/) +- Be sure to include the `` tag in the header +- You can use special "placeholders" (wrapped in `{{` and `}}`) for the rendering error code, message, and other + details + +Built-in "placeholders" and functions with their examples can be found in the following files: + +- [props.go](../internal/template/props.go) +- [template.go](../internal/template/template.go)