commit 255abfa819e666d225f9ff9642cd7aafce05118b
parent 7f704585dad6e327ce659dc1b04394e4c37963b7
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 8 Jun 2023 20:37:03 -0700
cleanup
Diffstat:
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/pkg/web/handlers/streamModals/codeModal.go b/pkg/web/handlers/streamModals/codeModal.go
@@ -78,28 +78,34 @@ func getCodeModalHTML(codeModalIdx int, roomName, csrf string, msgTyp database.C
<div class="controls">
<button type="submit">send</button>
<select name="lang">
- <option value=""{{ if eq .SyntaxHighlightCode "" }} selected{{ end }}>Raw text</option>
- <option value="go"{{ if eq .SyntaxHighlightCode "go" }} selected{{ end }}>Golang</option>
- <option value="rs"{{ if eq .SyntaxHighlightCode "rs" }} selected{{ end }}>Rust</option>
- <option value="cpp"{{ if eq .SyntaxHighlightCode "cpp" }} selected{{ end }}>C++</option>
- <option value="c"{{ if eq .SyntaxHighlightCode "c" }} selected{{ end }}>C</option>
- <option value="py"{{ if eq .SyntaxHighlightCode "py" }} selected{{ end }}>Python</option>
- <option value="js"{{ if eq .SyntaxHighlightCode "js" }} selected{{ end }}>Javascript</option>
- <option value="php"{{ if eq .SyntaxHighlightCode "php" }} selected{{ end }}>PHP</option>
- <option value="css"{{ if eq .SyntaxHighlightCode "css" }} selected{{ end }}>CSS</option>
- <option value="sql"{{ if eq .SyntaxHighlightCode "sql" }} selected{{ end }}>SQL</option>
- <option value="c#"{{ if eq .SyntaxHighlightCode "C#" }} selected{{ end }}>C#</option>
- <option value="rb"{{ if eq .SyntaxHighlightCode "rb" }} selected{{ end }}>Ruby</option>
- <option value="html"{{ if eq .SyntaxHighlightCode "html" }} selected{{ end }}>HTML</option>
- <option value="bash"{{ if eq .SyntaxHighlightCode "bash" }} selected{{ end }}>Bash</option>
+ {{ range .Langs }}
+ <option value="{{ index . 0 }}"{{ if eq $.SyntaxHighlightCode (index . 0) }} selected{{ end }}>{{ index . 1 }}</option>
+ {{ end }}
</select>
</div>
</form>
</div>`
+ langs := [][]string{
+ {"", "Raw text"},
+ {"go", "Golang"},
+ {"rs", "Rust"},
+ {"cpp", "C++"},
+ {"c", "C"},
+ {"py", "Python"},
+ {"js", "Javascript"},
+ {"php", "PHP"},
+ {"css", "CSS"},
+ {"sql", "SQL"},
+ {"c#", "C#"},
+ {"rb", "Ruby"},
+ {"html", "HTML"},
+ {"bash", "Bash"},
+ }
data := map[string]any{
"IsMod": msgTyp.IsMod,
"ToUserUsername": msgTyp.ToUserUsername,
"SyntaxHighlightCode": syntaxHighlightCode,
+ "Langs": langs,
}
var buf bytes.Buffer
_ = utils.Must(template.New("").Parse(htmlTmpl)).Execute(&buf, data)