Browse Source

Stop re-processing images and add simple HTTP server

master
Devin Dooley 1 year ago
parent
commit
1f38575463
5 changed files with 30 additions and 2 deletions
  1. +4
    -1
      Makefile
  2. BIN
      build/image-processing/image-processing
  3. +9
    -1
      build/image-processing/image-processing.go
  4. BIN
      build/server/server
  5. +17
    -0
      build/server/server.go

+ 4
- 1
Makefile View File

@ -4,7 +4,10 @@ hugo_build:
hugo -v --gc
process_images:
./build/image-processing/image-processing --dir public/photos
./build/image-processing/image-processing -d public/photos
server:
./build/server/server -p 1314 -d public
deploy:
rsync -avh -zz -e ssh --progress --delete ~/workspaces/devinadooley/public/ devinadooley.com:/var/www/devinadooley.com


BIN
build/image-processing/image-processing View File


+ 9
- 1
build/image-processing/image-processing.go View File

@ -72,6 +72,14 @@ func getAllPaths(photosDir string) ([][]string, error) {
return nil
}
// Skip any files with the extensions we add to compressed images
if strings.Contains(info.Name(), "_thumbnail") {
return nil
}
if strings.Contains(info.Name(), "_compressed") {
return nil
}
pathSplit := strings.Split(path, "/")
var workingPath string
for i, dir := range pathSplit {
@ -136,7 +144,7 @@ func main() {
var dir string
// Script will search recursively from the directory given
flag.StringVar(&dir, "dir", "./public/photos", "directory where photos are kept")
flag.StringVar(&dir, "d", "./public/photos", "directory where photos are kept")
flag.Parse()
err := processImages(dir)


BIN
build/server/server View File


+ 17
- 0
build/server/server.go View File

@ -0,0 +1,17 @@
package main
import (
"flag"
"log"
"net/http"
)
func main() {
port := flag.String("p", "1314", "port to serve on")
directory := flag.String("d", "public", "file directory to serve from")
flag.Parse()
http.Handle("/", http.FileServer(http.Dir(*directory)))
log.Fatal(http.ListenAndServe(":"+*port, nil))
}

Loading…
Cancel
Save