Skip to content

Commit

Permalink
Bug fix release with updated dependancies
Browse files Browse the repository at this point in the history
  • Loading branch information
robrotheram committed May 5, 2023
1 parent 0c3d30b commit e9f58d1
Show file tree
Hide file tree
Showing 23 changed files with 1,559 additions and 1,311 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"mode": "auto",
"cwd": "${workspaceFolder}",
"program": "main.go",
"args": ["build"]
"args": ["deploy"]
}
]
}
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ docker-publish:
docker push robrotheram/gogallery:latest

install:
cp build/bin/gogallery /home/robertfletcher/.local/bin/gogallery
cp build/bin/gogallery /home/robertfletcher/.local/bin/gogallery

update:
go get -u
go mod tidy
8 changes: 1 addition & 7 deletions backend/datastore/albumCollection.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ func (a *AlumnCollectioins) GetAll() []models.Album {

func (a *AlumnCollectioins) FindByID(id string) models.Album {
var alb models.Album
a.FindByFeild("id", id, alb)
return alb
}

func (a *AlumnCollectioins) FindOneFeild(id string) models.Album {
var alb models.Album
a.FindByFeild("id", id, alb)
a.DB.One("Id", id, &alb)
return alb
}

Expand Down
4 changes: 2 additions & 2 deletions backend/datastore/models/Exif.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

type Exif struct {
FStop float64 `json:"f_stop"`
FocalLength float64 `json:"focal_length"`
FStop string `json:"f_stop"`
FocalLength string `json:"focal_length"`
ShutterSpeed string `json:"shutter_speed"`
ISO string `json:"iso"`
Dimension string `json:"dimension"`
Expand Down
44 changes: 12 additions & 32 deletions backend/datastore/models/Picture.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,44 +35,24 @@ func (u *Picture) CreateExif() error {
defer f.Close()
u.Exif = Exif{}

m, err := imagemeta.Parse(f)
if err != nil {
return err
}
exif, err := m.Exif()
meta, err := imagemeta.Decode(f)
if err != nil {
return err
}

if a, err := exif.Aperture(); err == nil {
u.Exif.FStop = float64(a)
}
if a, err := exif.FocalLength(); err == nil {
u.Exif.FocalLength = float64(a)
}
if a, err := exif.ShutterSpeed(); err == nil {
u.Exif.ShutterSpeed = fmt.Sprintf("%d/%d", a[0], a[1])
}
if a, err := exif.ISOSpeed(); err == nil {
u.Exif.ISO = fmt.Sprint(a)
}
if a := exif.CameraModel(); a != "" {
u.Exif.Camera = a
}
if a, err := exif.LensModel(); err == nil {
u.Exif.LensModel = a
}
if a, err := exif.DateTime(nil); err == nil {
u.Exif.DateTaken = a
u.Exif.FStop = meta.FNumber.String()
u.Exif.FocalLength = meta.FocalLength.String()
u.Exif.ShutterSpeed = meta.ExposureTime.String()
u.Exif.ISO = fmt.Sprintf("%d", meta.ISOSpeed)
u.Exif.Dimension = fmt.Sprintf("%d/%d", meta.ImageWidth, meta.ImageHeight)
u.Exif.Camera = meta.CameraMake.String()
u.Exif.LensModel = meta.LensModel
u.Exif.DateTaken = meta.CreateDate()
u.Exif.GPS = GPS{
Lat: meta.GPS.Latitude(),
Lng: meta.GPS.Latitude(),
}

lat, long, err := exif.GPSCoords()
if err != nil {
u.Exif.GPS = GPS{
Lat: lat,
Lng: long,
}
}
return nil
}

Expand Down
5 changes: 4 additions & 1 deletion backend/datastore/picturesCollection.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ func (p *PictureCollection) GetAll() []models.Picture {
defer p.Unlock()

var pics []models.Picture
p.DB.All(&pics)
err := p.DB.All(&pics)
if err != nil {
return []models.Picture{}
}
return pics
}

Expand Down
17 changes: 17 additions & 0 deletions backend/embeds/embeds.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io/fs"
"os"
"path/filepath"
"strings"
)

var DashboardFS embed.FS
Expand All @@ -28,6 +29,22 @@ func CopyTheme(templatePath string) {

}

func CopyThemeAssets(templatePath string) {
os.MkdirAll(templatePath, os.ModePerm)
root := "themes/eastnor/assets"
fs.WalkDir(ThemeFS, root, func(path string, d fs.DirEntry, err error) error {
newPath := filepath.Join(templatePath, strings.Replace(path, root, "", -1))
if d.IsDir() {
os.MkdirAll(newPath, os.ModePerm)
} else {
file, _ := ThemeFS.ReadFile(path)
os.WriteFile(newPath, file, os.ModePerm)
}
return nil
})

}

func Untar(dst string, r io.Reader) error {

gzr, err := gzip.NewReader(r)
Expand Down
8 changes: 7 additions & 1 deletion backend/pipeline/IndexPagePipeluine.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/robrotheram/gogallery/backend/config"
"github.com/robrotheram/gogallery/backend/datastore"
"github.com/robrotheram/gogallery/backend/datastore/models"
"github.com/robrotheram/gogallery/backend/embeds"
templateengine "github.com/robrotheram/gogallery/backend/templateEngine"
)

Expand Down Expand Up @@ -94,5 +95,10 @@ func build() {
fmt.Println(err)
os.Exit(1)
}
templateengine.Dir(filepath.Join(config.Config.Gallery.Theme, "assets"), filepath.Join(root, "assets"))
if config.Config.Gallery.Theme == "default" {
embeds.CopyThemeAssets(filepath.Join(root, "assets"))
} else {
templateengine.Dir(filepath.Join(config.Config.Gallery.Theme, "assets"), filepath.Join(root, "assets"))
}

}
8 changes: 4 additions & 4 deletions backend/templateEngine/templateEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ func (te *TemplateEngine) LoadFromEmbed() error {

te.Cache = newTeamplateCache()

base, err := template.ParseFS(embeds.ThemeFS, "eastnor/default.hbs")
base, err := template.ParseFS(embeds.ThemeFS, "themes/eastnor/default.hbs")
if err != nil {
return err
}
base.Funcs(template.FuncMap{"ImgSizes": func() map[string]int { return ImageSizes }})
base, _ = base.ParseFS(embeds.ThemeFS, "eastnor/partials/*.hbs")
base, _ = base.ParseFS(embeds.ThemeFS, "themes/eastnor/partials/*.hbs")

items, err := embeds.ThemeFS.ReadDir("eastnor/pages")
items, err := embeds.ThemeFS.ReadDir("themes/eastnor/pages")
if err != nil {
return err
}
for _, item := range items {
name := strings.TrimSuffix(item.Name(), filepath.Ext(item.Name()))
pageTemplate := template.Must(base.Clone())
pageTemplate = template.Must(pageTemplate.ParseFS(embeds.ThemeFS, "eastnor/pages/"+item.Name()))
pageTemplate = template.Must(pageTemplate.ParseFS(embeds.ThemeFS, "themes/eastnor/pages/"+item.Name()))
te.Cache.Add(name, pageTemplate)
}
return nil
Expand Down
17 changes: 5 additions & 12 deletions config_sample.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
database:
baseurl: "/tmp/gallery/"

server:
port: ":8800"
deploy:
authtoken: netify-auth-token
siteid: netify site-id

gallery:
name: "Gallery"
imagesPerPage: 50
basepath: "/run/user/1000/gvfs/dav:host=cloud.exceptionerror.io,ssl=true,user=robrotheram,prefix=%2Fremote.php%2Fwebdav/Photos"
url: "https://your.url.here"
theme: "default"
theme: "default" #default uses embeded theme. change to path to use a differnt theme
#Limit that when thumbnail que reaches it the gallery will throw a warning to allow it to catch up an generate the thumbnails.
QueThreshold: 50

Expand All @@ -25,9 +23,4 @@ about:
blog: "https://blog.example.com"
website: "https://example.com"
description: "Hello there, here is my gallery containing a number of photos from a number of years"
footer: "Photos ©photographer"

admin:
enable: false
username: admin
password: <<GENERATED PASSWORD>>
footer: "Photos ©photographer"
19 changes: 8 additions & 11 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
<meta charset="UTF-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>gogallery</title>
<link
rel='stylesheet'
href='https://unpkg.com/leaflet@1.8.0/dist/leaflet.css'
integrity='sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ=='
crossorigin=''
/>
<script
src='https://unpkg.com/leaflet@1.8.0/dist/leaflet.js'
integrity='sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ=='
crossorigin=''
></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
crossorigin=""></script>


</head>
<body style="margin: 0px;">
<div id="app_root"></div>
Expand Down
Loading

0 comments on commit e9f58d1

Please sign in to comment.