2024-01-15 22:26:51 +00:00
|
|
|
// Code generated by templ - DO NOT EDIT.
|
|
|
|
|
2024-10-11 21:02:34 +00:00
|
|
|
// templ: version: v0.2.786
|
2024-01-15 22:26:51 +00:00
|
|
|
package html
|
|
|
|
|
|
|
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
|
|
|
|
|
|
import "github.com/a-h/templ"
|
2024-10-11 21:02:34 +00:00
|
|
|
import templruntime "github.com/a-h/templ/runtime"
|
2024-01-15 22:26:51 +00:00
|
|
|
|
|
|
|
type RepoFileContext struct {
|
|
|
|
BaseContext
|
|
|
|
RepoHeaderComponentContext
|
2024-06-27 04:23:41 +00:00
|
|
|
RepoBreadcrumbComponentContext
|
2024-01-15 22:26:51 +00:00
|
|
|
Code string
|
|
|
|
}
|
|
|
|
|
|
|
|
func RepoFile(rfc RepoFileContext) templ.Component {
|
2024-10-11 21:02:34 +00:00
|
|
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
|
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
|
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
|
|
return templ_7745c5c3_CtxErr
|
|
|
|
}
|
|
|
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
2024-01-15 22:26:51 +00:00
|
|
|
if !templ_7745c5c3_IsBuffer {
|
2024-10-11 21:02:34 +00:00
|
|
|
defer func() {
|
|
|
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
|
|
if templ_7745c5c3_Err == nil {
|
|
|
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
|
|
}
|
|
|
|
}()
|
2024-01-15 22:26:51 +00:00
|
|
|
}
|
|
|
|
ctx = templ.InitializeContext(ctx)
|
|
|
|
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
|
|
|
if templ_7745c5c3_Var1 == nil {
|
|
|
|
templ_7745c5c3_Var1 = templ.NopComponent
|
|
|
|
}
|
|
|
|
ctx = templ.ClearChildren(ctx)
|
2024-10-11 21:02:34 +00:00
|
|
|
templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
|
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
|
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
2024-01-15 22:26:51 +00:00
|
|
|
if !templ_7745c5c3_IsBuffer {
|
2024-10-11 21:02:34 +00:00
|
|
|
defer func() {
|
|
|
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
|
|
if templ_7745c5c3_Err == nil {
|
|
|
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
|
|
}
|
|
|
|
}()
|
2024-01-15 22:26:51 +00:00
|
|
|
}
|
2024-10-11 21:02:34 +00:00
|
|
|
ctx = templ.InitializeContext(ctx)
|
2024-01-15 22:26:51 +00:00
|
|
|
templ_7745c5c3_Err = repoHeaderComponent(rfc.RepoHeaderComponentContext).Render(ctx, templ_7745c5c3_Buffer)
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
2024-06-27 04:23:41 +00:00
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" <div class=\"mt-2 text-text\">")
|
2024-01-15 22:26:51 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
2024-06-27 04:23:41 +00:00
|
|
|
templ_7745c5c3_Err = repoBreadcrumbComponent(rfc.RepoBreadcrumbComponentContext).Render(ctx, templ_7745c5c3_Buffer)
|
2024-01-15 22:26:51 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
2024-06-27 04:23:41 +00:00
|
|
|
var templ_7745c5c3_Var3 string
|
|
|
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(" - ")
|
2024-01-15 22:26:51 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
2024-10-11 21:02:34 +00:00
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/html/repo_file.templ`, Line: 15, Col: 10}
|
2024-01-15 22:26:51 +00:00
|
|
|
}
|
2024-06-27 04:23:41 +00:00
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
2024-01-15 22:26:51 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
2024-10-22 17:25:23 +00:00
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" <a class=\"text-text underline decoration-text/50 decoration-dashed hover:decoration-solid\" href=\"?raw\">raw</a><div class=\"code relative\">")
|
2024-01-15 22:26:51 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
|
|
|
templ_7745c5c3_Err = templ.Raw(rfc.Code).Render(ctx, templ_7745c5c3_Buffer)
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
2024-10-22 17:25:23 +00:00
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<button id=\"copy\" class=\"absolute top-0 right-0 rounded bg-base hover:bg-surface0\"></button></div></div>")
|
2024-01-15 22:26:51 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
})
|
|
|
|
templ_7745c5c3_Err = base(rfc.BaseContext).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
2024-10-22 17:25:23 +00:00
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script>\n\t\tconst lineRe = /#L(\\d+)(?:-L(\\d+))?/g\n\t\tconst $lineLines = document.querySelectorAll(\".chroma .lntable .lnt\");\n\t\tconst $codeLines = document.querySelectorAll(\".chroma .lntable .line\");\n\t\tconst $copyButton = document.getElementById('copy');\n\t\tconst $copyIcon = \"📋\";\n\t\tconst $copiedIcon = \"✅\";\n\t\tlet $code = \"\"\n\t\tfor (let codeLine of $codeLines) $code += codeLine.innerText;\n\t\tlet start = 0;\n\t\tlet end = 0;\n\n\t\tconst results = [...location.hash.matchAll(lineRe)];\t\t\n\t\tif (0 in results) {\n\t\t\tstart = results[0][1] !== undefined ? parseInt(results[0][1]) : 0;\n\t\t\tend = results[0][2] !== undefined ? parseInt(results[0][2]) : 0;\n\t\t}\n\t\tif (start != 0) {\n\t\t\tdeactivateLines();\n\t\t\tactivateLines(start, end);\n\t\t\t$lineLines[start-1].scrollIntoView(true);\n\t\t}\n\n\t\tfor (let line of $lineLines) {\n\t\t\tline.addEventListener(\"click\", (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tdeactivateLines();\n\t\t\t\tconst n = parseInt(line.id.substring(1));\n\t\t\t\tlet anchor = \"\";\n\t\t\t\tif (event.shiftKey) {\n\t\t\t\t\tend = n;\n\t\t\t\t\tanchor = `#L${start}-L${end}`;\n\t\t\t\t} else {\n\t\t\t\t\tstart = n;\n\t\t\t\t\tend = 0;\n\t\t\t\t\tanchor = `#L${start}`;\n\t\t\t\t}\n\t\t\t\thistory.replaceState(null, null, anchor);\n\t\t\t\tactivateLines(start, end);\n\t\t\t});\n\t\t}\n\n\t\tif (navigator.clipboard && navigator.clipboard.writeText) {\n\t\t\t$copyButton.innerText = $copyIcon;\n\t\t\t$copyButton.classList.remove(\"hidden\");\n }\n\t\t$copyButton.addEventListener(\"click\", () => {\n navigator.clipboard.writeText($code);\n\t\t\t$copyButton.innerText = $copiedIcon;\n\t\t\tsetTimeout(() => {\n\t\t\t\t$copyButton.innerText = $copyIcon;\n\t\t\t}, 1000);\n });\n\n\t\tfunction activateLines(start, end) {\n\t\t\tif (end < start) end = start;\n\t\t\tfor (let idx = start - 1; idx < end; idx++) {\n\t\t\t\t$codeLines[idx].classList.add(\"active\");\n\t\t\t}\n\t\t}\n\n\t\tfunction deactivateLines() {\n\t\t\tfor (let code of $codeLines) {\n\t\t\t\tcode.classList.remove(\"active\");\n\t\t\t}\n\t\t}\n\n\t\t\n\t\t\n\t</script>")
|
2024-01-15 22:26:51 +00:00
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
})
|
|
|
|
}
|
2024-10-11 21:02:34 +00:00
|
|
|
|
|
|
|
var _ = templruntime.GeneratedTemplate
|