-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml.go
43 lines (38 loc) · 1.05 KB
/
html.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// html.go contains functions concerned with rendering web pages.
package main
// getPageForKey returns a rendered HTML page containing the contents
// of the paste identified by key. Any errors encountered while trying
// to open the paste file are returned.
func getPageForKey(key string) (string, error) {
text, textErr := getTextForKey(key)
if textErr != nil {
return "", textErr
}
escapedTextString := escape(text)
page := "<!DOCTYPE html>\n" +
"<head>\n\t" +
"<meta charset=\"UTF-8\">\n\t" +
"<title>GoPaste</title>\n" +
"</head>\n\n" +
"<body>\n\t" +
"<pre><tt>" +
escapedTextString +
"\t</tt></pre>\n" +
"</body>"
return page, nil
}
func getNewPastePage() string {
page := "<!DOCTYPE html>\n" +
"<head>\n\t" +
"<meta charset=\"UTF-8\">\n\t" +
"<title>GoPaste</title>\n" +
"</head>\n\n" +
"<body>\n\t" +
"<form action=\"/\" method=\"post\">" +
"<textarea autofocus required rows=\"32\" cols=\"80\" name=\"paste\"></textarea>" +
"<br>" +
"<input type=\"submit\" value=\"Save\">" +
"</form>" +
"</body>"
return page
}