mirror of
https://github.com/gmemstr/pogo.git
synced 2024-09-19 17:21:10 +01:00
Custom CSS support
Admins can now set custom CSS in the admin interface - next up is to add classes to all elements for easier theming.
This commit is contained in:
parent
ad69559c1e
commit
973ad0e72e
|
@ -7,6 +7,7 @@
|
|||
|
||||
</head>
|
||||
<body>
|
||||
<div class="admin">
|
||||
<h1>White Rabbit Publish</h1>
|
||||
|
||||
<form enctype="multipart/form-data" action="/admin/publish" method="post">
|
||||
|
@ -21,9 +22,16 @@
|
|||
<input type="submit" value="Publish">
|
||||
</form>
|
||||
|
||||
<form action="/admin/css" method="post" enctype="multipart/form-data">
|
||||
<label for="css">Custom CSS</label>
|
||||
<textarea name="css" id="css" cols="30" rows="10"></textarea>
|
||||
<input type="submit">
|
||||
</form>
|
||||
|
||||
<footer>
|
||||
<p>White Rabbit licensed under the GPLv3</p>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -4,11 +4,15 @@
|
|||
<meta charset="UTF-8">
|
||||
<title>CMS Loading</title>
|
||||
<link rel="stylesheet" href="/assets/styles.css">
|
||||
<!-- Custom CSS stylings from admin -->
|
||||
<link rel="stylesheet" href="/assets/custom.css">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1 id="title" class="title">Loading</h1>
|
||||
<h3><a href="/admin">Admin</a></h3>
|
||||
|
||||
<div id="podcasts">
|
||||
|
||||
|
|
3
assets/static/custom.css
Normal file
3
assets/static/custom.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
body {
|
||||
background-color:red;
|
||||
}
|
|
@ -15,4 +15,10 @@ h1,h2,h3,h4,h5 {
|
|||
|
||||
.podcast {
|
||||
width:70%;
|
||||
}
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
.admin {
|
||||
text-align: center;
|
||||
}
|
||||
|
|
23
src/admin.go
23
src/admin.go
|
@ -15,6 +15,29 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
func CustomCss(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == "POST" {
|
||||
r.ParseMultipartForm(32 << 20)
|
||||
css := strings.Join(r.Form["css"], "")
|
||||
|
||||
filename := "custom.css"
|
||||
|
||||
err := ioutil.WriteFile("./assets/static/" + filename, []byte(css), 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
w.Write([]byte("success"))
|
||||
}
|
||||
} else {
|
||||
css,err := ioutil.ReadFile("./assets/static/custom.css")
|
||||
if err != nil {
|
||||
panic (err)
|
||||
} else {
|
||||
w.Write(css)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func CreateEpisode(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == "POST" {
|
||||
r.ParseMultipartForm(32 << 20)
|
||||
|
|
|
@ -114,6 +114,7 @@ func main() {
|
|||
r.HandleFunc("/json", JsonHandler)
|
||||
r.HandleFunc("/admin", BasicAuth(AdminHandler, viper.GetString("AdminUsername"), viper.GetString("AdminPassword"), "Login to White Rabbit admin interface"))
|
||||
r.HandleFunc("/admin/publish", CreateEpisode)
|
||||
r.HandleFunc("/admin/css", CustomCss)
|
||||
|
||||
// We're live!
|
||||
log.Fatal(http.ListenAndServe(":8000", r))
|
||||
|
|
Loading…
Reference in a new issue