~jheckt/PhotographyWebsite

36852d0365ea023d34f83176e2cf18ae4be50f3a — turnipsoup 1 year, 10 months ago d0873e6 + 18181fe
Merge branch 'working' into main
10 files changed, 95 insertions(+), 13 deletions(-)

M go.mod
M go.sum
M html/collection.html
M html/css/main.css
M html/home.html
M html/photo.html
M main.go
M photos.go
M routing.go
A rss.go
M go.mod => go.mod +4 -1
@@ 7,4 7,7 @@ require (
	github.com/yuin/goldmark v1.4.13
)

require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
require (
	github.com/gorilla/feeds v1.1.1 // indirect
	golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
)

M go.sum => go.sum +2 -0
@@ 1,5 1,7 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gorilla/feeds v1.1.1 h1:HwKXxqzcRNg9to+BbvJog4+f3s/xzvtZXICcQGutYfY=
github.com/gorilla/feeds v1.1.1/go.mod h1:Nk0jZrvPFZX1OBe5NPiddPw7CfwF6Q9eqzaBbaightA=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=

M html/collection.html => html/collection.html +3 -9
@@ 6,21 6,15 @@
{{ template "bar" .}}
<br><br>


<div class="photo-box">
{{range $index, $element := .DataInfo}} 
    
<a href="{{$element}}">

    <div class="photo-box">
        <img class="thumbnail-image" src="{{$element}}.jpg">
    </div>

    <br>

    <img class="thumbnail-image" src="{{$element}}.jpg">
</a>

{{end}} 

</div>
{{ template "footer" .}}



M html/css/main.css => html/css/main.css +16 -3
@@ 2,6 2,13 @@ html,body{
    height: 100%
}

/* Home Page */
.avatar {
    border-radius: 50%;
    width: 200px;
    margin: 0 auto;
}

/* Navbar */
.navbar {
    background-color: black;


@@ 83,15 90,21 @@ html,body{
/* Collection Page */

.photo-box {
    display: block;
    margin: auto;
    width: 80%;
    max-width: 63%;
    display:flex;
    flex-wrap: wrap;
    justify-content: center;
}

.thumbnail-image {
    max-width: 55%;
    max-width: 30vw;
    min-width: 100px;
    flex-basis: 100px;
    flex-shrink: 1;
    margin: auto;
    display: block;
    padding: 6px;
}



M html/home.html => html/home.html +3 -0
@@ 8,6 8,9 @@
<br><br>

<div class='blurb'>

    <img class="avatar" src="https://letseatlabs-data.nyc3.digitaloceanspaces.com/data/blog/photo/avatar.jpg" />

    <p>Jeremy Heckt is located in the beautiful Pacific Northwest. He is taking photos of society, human interactions with nature, time, and bugs.</p>
    <p>He is a maker, a creator, a photographer, and a writer. He is a maker of things that are not only beautiful, but also useful.</p>
    <br>

M html/photo.html => html/photo.html +2 -0
@@ 26,6 26,8 @@
    <h5 style="display: inline;">{{ .CameraModel }}</h5>
    <br>
    <h5 style="display: inline;">{{ .Details }}</h5>
    <br>
    <h5 style="display: inline;">{{ .PhotoTech }}</h5>
    <br><br>
    {{ .Desc }}
</div>

M main.go => main.go +3 -0
@@ 33,6 33,9 @@ func main() {
	// Serve the blog
	http.HandleFunc("/blog/", serveBlog)

	// Serve the blog rss
	http.HandleFunc("/rss/", serveRSS)

	// Serve static files from the static directory
	http.HandleFunc("/css/main.css", handleCSS)


M photos.go => photos.go +12 -0
@@ 21,6 21,7 @@ type Photo struct {
	PhotoDate   string        // Date of photo
	Details     string        // Lens, fstop, ISO, etc
	CameraModel string        // Camera model
	PhotoTech   string        // Photo technical information  (e.g. shutter speed, aperture, focal length, etc)
	LowRezLoc   string        // Where the image is stored for the <img> tag for easy displaying
	HighRezLoc  string        // Where the image is stored for the <img> tag for high res requests
	AverageLoc  string        // Where the averages palette is stored for the <img> tag


@@ 72,6 73,7 @@ func generatePhotoPage(collection string, filename string) (*template.Template, 
		PhotoDate:   "No date available",
		Details:     "No lens information",
		CameraModel: "No camera information",
		PhotoTech:   "",
		LowRezLoc:   fmt.Sprintf("/collections/%s/%s.jpg", collection, filename),
		HighRezLoc:  fmt.Sprintf("/collections/%s/%s.png", collection, filename),
		AverageLoc:  fmt.Sprintf("/collections/%s/%s", collection, fmt.Sprintf("%s.png.average.png", filename))}


@@ 98,6 100,16 @@ func generatePhotoPage(collection string, filename string) (*template.Template, 
		if exif[0]["DateTimeOriginal"] != nil {
			photo.PhotoDate = exif[0]["DateTimeOriginal"].(string)
		}

		if exif[0]["ExposureTime"] != nil {
			photo.PhotoTech = fmt.Sprintf("%s %s ", photo.PhotoTech, exif[0]["ExposureTime"].(string))
		}
		if exif[0]["FNumber"] != nil {
			photo.PhotoTech = fmt.Sprintf("%s f/%.1f ", photo.PhotoTech, exif[0]["FNumber"].(float64))
		}
		if exif[0]["ISO"] != nil {
			photo.PhotoTech = fmt.Sprintf("%s %.0f ", photo.PhotoTech, exif[0]["ISO"].(float64))
		}
	}

	// Load the photo page template

M routing.go => routing.go +8 -0
@@ 205,3 205,11 @@ func splitRequestURI(uri string) PathInfo {

	return PathInfo{PathVariables: params, Length: plength}
}

// Serves a blog post given a filename
func serveRSS(w http.ResponseWriter, r *http.Request) {
	rss := rss()
	w.Header().Set("Content-Type", "application/xml")
	w.Write([]byte(rss))

}

A rss.go => rss.go +42 -0
@@ 0,0 1,42 @@
// Makes an RSS feed to seve at /blog-rss.xml

package main

import (
	"fmt"

	"github.com/gorilla/feeds"

	log "github.com/sirupsen/logrus"
)

func rss() string {
	log.Debug("Starting RSS feed generation")
	feed := feeds.Feed{
		Title:       "Jeremy Heckt's Photography Blog",
		Link:        &feeds.Link{Href: "https://photography.jeremyheckt.com/blog/"},
		Description: "Let's talk about photos and stuff",
		Author: &feeds.Author{Name: "Jeremy Heckt",
			Email: "jeremy@jeremyheckt.com"},
	}

	feed.Items = make([]*feeds.Item, 0)

	blog := loadBlogPosts()

	for _, filename := range blog.SortedPosts {
		item := feeds.Item{
			Title: blog.PostFiles[filename],
			Link:  &feeds.Link{Href: "https://photography.jeremyheckt.com/blog/" + filename},
		}
		feed.Items = append(feed.Items, &item)
	}

	rss, err := feed.ToRss()
	if err != nil {
		log.Error("Error processing RSS feed: ", err)
	}

	fmt.Println(rss)
	return rss
}