admin: introducing new page

This commit is contained in:
nemunaire 2018-02-16 11:42:41 +01:00
parent 08fb2ad37c
commit 185262b2e7
3 changed files with 49 additions and 0 deletions

View File

@ -91,6 +91,15 @@ func main() {
GetNextImage,
)))
mux.HandleFunc("/admin/", func(w http.ResponseWriter, r *http.Request) {
if authFunc(r) == nil {
w.Header().Set("WWW-Authenticate", "Basic realm=\"YouP0m Admin\"")
http.Error(w, "You are not allowed to perform this request.", http.StatusUnauthorized)
} else {
http.ServeFile(w, r, filepath.Join(staticDir, "admin.html"))
}
})
log.Println("Ready, listening on", *bind)
if err := http.ListenAndServe(*bind, mux); err != nil {
log.Fatal("Unable to listen and serve: ", err)

23
static/admin.html Normal file
View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<title>YouP0m Administration</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" media="all" href="/css/style.css">
<script type="text/javascript" src="/js/prototype.js"></script>
<script type="text/javascript" src="/js/youp0m.js"></script>
<script type="text/javascript" src="/js/youp0m-admin.js"></script>
</head>
<body>
<h1>Welcome on YouP0m!</h1>
<noscript>
<p>
You need a JavaScript capable browser to use this website.<br>
Please enable-it or switch to a JavaScript capable browser.
</p>
</noscript>
<script type="text/javascript">
document.write("<h2>We are loading the newest cute pictures for you, please wait&hellip;</h2>");
</script>
</body>
</html>

17
static/js/youp0m-admin.js Normal file
View File

@ -0,0 +1,17 @@
api_url = "/api/next/";
img_url = "/images/next/";
function admin_ctrl(figure) {
var menu = document.createElement("ul");
var item = document.createElement("li", "test");
menu.appendChild(item);
figure.appendChild(menu)
}
function sync() {
path = window.location.pathname.replace(/.*\/([^\/]*)/, "$1");
if (path == "" || path == "all")
show_mozaic(admin_ctrl);
else
show_picture(path);
}