Final commit before submit (comments only)

master
Toerd@480 5 years ago
parent 7ee0ebe302
commit 37530806af

@ -1,2 +1,8 @@
# exhibit
# What is this for
This is a fun little project for the course digital garphics 1 at LNU.
The goal was to create an interactive portfolio.
# What
*Go*: *Backend*, a really shitty implementation of a "webserver" with really simple routing.
*HTML, CSS*: Structure and look of the website. The HTML part gets generated by the backend, to provide higher flexibility and maintainability. CSS is written as minimal and efficient as possible (for me (; ).
*JS*: Mostly used to animate the avatar (still with css animation/transitions in the background) and for the implementation of the zoom in the info field.

@ -1,3 +1,5 @@
// author: phga
// backend for the portfolio
package main
import (
@ -10,21 +12,28 @@ import (
"regexp"
)
// could be enabled after the implementation is complete.
// var t = template.Must(template.ParseFiles("tmpl/layouts/base.html", "tmpl/index.html", "tmpl/blog.html", "tmpl/about.html", "tmpl/contact.html", ))
// A regex used to identify valid Img requests
var validImg = regexp.MustCompile("^/info/([\\w_\\- ]+)")
var exhibit Exhibition
func main() {
// initialize the map (otherwise runtime error)
exhibit.Pics = make(map[string]Picture)
// cheap routing
http.HandleFunc("/", handleIndex)
http.HandleFunc("/blog", handleBlog)
http.HandleFunc("/about", handleAbout)
http.HandleFunc("/contact", handleContact)
http.HandleFunc("/info/", handleInfo)
// provide the inc directory to the useragent
http.Handle("/inc/", http.StripPrefix("/inc/", http.FileServer(http.Dir("inc"))))
// listen on port 8080 (I use nginx to proxy this local server)
log.Fatalln(http.ListenAndServe(":8080", nil))
}
// A picture
type Picture struct {
Name string
Author string
@ -39,8 +48,11 @@ type Exhibition struct {
Pics map[string]Picture
}
// Funcions follow that handle the requests
func handleIndex(w http.ResponseWriter, r *http.Request) {
// that should also be somewhere else when there is another gallery
exhibit.parseExhibitions("./data")
// Parses all required html files to provide the actual html that is shipped.
t, _ := template.ParseFiles("tmpl/layouts/index.html", "tmpl/gallery.html", "tmpl/header.html")
t.Execute(w, exhibit)
}
@ -60,6 +72,8 @@ func handleContact(w http.ResponseWriter, r *http.Request) {
t.Execute(w, nil)
}
// get the img from the exhibiton and write the json encoded
// object to the responsewriter
func handleInfo(w http.ResponseWriter, r *http.Request) {
imgName := validImg.FindStringSubmatch(r.URL.Path)
if imgName == nil {
@ -76,7 +90,7 @@ func handleInfo(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// set the correct content typ (json)
w.Header().Set("Content-Type", "application/json")
w.Write(info)
}

@ -1,3 +1,5 @@
# author: phga
# req: epeg
#!/bin/bash
in_dir=$1
out_dir=$2

@ -1,14 +0,0 @@
<html>
<head>
<meta charset="UTF-8"/>
<title>{{.Title}}</title>
</head>
<body>
<form method="post" action="/test/arnold/eckern">
<input name="text" type="text" value=""/>
<input name="pw" type="password" value=""/>
<input name="mail" type="email" value=""/>
<button>SEND</button>
</form>
</body>
</html>
Loading…
Cancel
Save