113 lines
2.0 KiB
Go
113 lines
2.0 KiB
Go
package cethttp
|
|
|
|
import (
|
|
"html/template"
|
|
"strings"
|
|
|
|
"github.com/senaduka/cetvorke/database"
|
|
)
|
|
|
|
const editorTemplate = `
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>IslamBosna</title>
|
|
<style>
|
|
html, body {
|
|
background-color: #171714;
|
|
color: #f9f5c3;
|
|
font-family: sans-serif;
|
|
justify-content: center;
|
|
}
|
|
|
|
header {
|
|
width: 100%;
|
|
padding-top: 0.5em;
|
|
padding-bottom: 0.5em;
|
|
font-family: sans-serif;
|
|
font-size: 3em;
|
|
background-color: #0f1115;
|
|
justify-content: center;
|
|
}
|
|
|
|
header div, content div {
|
|
max-width: 800px;
|
|
margin: auto;
|
|
}
|
|
|
|
a:link, a:visited {
|
|
color: #f9f5c3;
|
|
}
|
|
header a:link {
|
|
color: #f9f5c3;
|
|
text-decoration: none;
|
|
}
|
|
|
|
header a:visited {
|
|
color: #f9f5c3;
|
|
text-decoration: none;
|
|
}
|
|
|
|
h1 {
|
|
color: #e6fbfb;
|
|
}
|
|
|
|
textarea
|
|
{
|
|
border:1px solid #999999;
|
|
width:98%;
|
|
margin:5px 0;
|
|
padding:1%;
|
|
}
|
|
|
|
|
|
#editorcontainer {
|
|
background-color: #ffffff;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<header>
|
|
<div>
|
|
<a href="/">☙ IslamBosna</a>
|
|
</div>
|
|
</header>
|
|
<content>
|
|
<div>
|
|
<form method="POST">
|
|
<input type="text" name="title" placeholder="Naslov" value="{{.Title}}" />
|
|
<input name="ID" type="hidden" value="{{.ID}}" />
|
|
<div id="editorcontainer">
|
|
<textarea id="editor" name="editor" rows="40" columns="80">{{.GemtextContent.String}}</textarea>
|
|
</div>
|
|
<input type="submit" value="Sačuvaj" />
|
|
</form>
|
|
</div>
|
|
</content>
|
|
<footer>
|
|
|
|
</footer>
|
|
</body>
|
|
</html>
|
|
`
|
|
|
|
func editorHtml5Page(post *database.Post) string {
|
|
if post.GemtextContent.Valid {
|
|
if strings.HasPrefix(post.GemtextContent.String, "{") {
|
|
post.GemtextContent.String = strings.TrimPrefix(post.GemtextContent.String, "{")
|
|
}
|
|
if strings.HasSuffix(post.GemtextContent.String, "true}") {
|
|
post.GemtextContent.String = strings.TrimSuffix(post.GemtextContent.String, "true}")
|
|
}
|
|
} else {
|
|
post.GemtextContent.String = ""
|
|
}
|
|
t1 := template.New("editorHtml5Page")
|
|
t1, _ = t1.Parse(editorTemplate)
|
|
result := new(strings.Builder)
|
|
t1.Execute(result, post)
|
|
return result.String()
|
|
}
|