diff --git a/README.md b/README.md index c3465f1..89d6b79 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/exhibit.go b/exhibit.go index 2286fdc..c641230 100644 --- a/exhibit.go +++ b/exhibit.go @@ -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) } diff --git a/gthumbs.sh b/gthumbs.sh index 3e4e161..4174f0d 100755 --- a/gthumbs.sh +++ b/gthumbs.sh @@ -1,3 +1,5 @@ +# author: phga +# req: epeg #!/bin/bash in_dir=$1 out_dir=$2 diff --git a/tmpl/form.html b/tmpl/form.html deleted file mode 100644 index 6fa1915..0000000 --- a/tmpl/form.html +++ /dev/null @@ -1,14 +0,0 @@ - -
- -