diff options
| author | Christine Dodrill <xena@yolo-swag.com> | 2015-06-06 10:13:33 -0700 |
|---|---|---|
| committer | Christine Dodrill <xena@yolo-swag.com> | 2015-06-06 10:13:33 -0700 |
| commit | 5d4e0aae410f4c04bc5e93ce13ef1233b12c360b (patch) | |
| tree | ac692abc28409b21df4471e4eb09e1b91bb29884 | |
| parent | 06c09db5f3109ac8fc84ddaeca317c55dea826d1 (diff) | |
| download | x-5d4e0aae410f4c04bc5e93ce13ef1233b12c360b.tar.xz x-5d4e0aae410f4c04bc5e93ce13ef1233b12c360b.zip | |
Add manifest gen tool
| -rw-r--r-- | dbupload/dbmanifestgen/.gitignore | 1 | ||||
| l--------- | dbupload/dbmanifestgen/db.go | 1 | ||||
| -rw-r--r-- | dbupload/dbmanifestgen/main.go | 56 |
3 files changed, 58 insertions, 0 deletions
diff --git a/dbupload/dbmanifestgen/.gitignore b/dbupload/dbmanifestgen/.gitignore new file mode 100644 index 0000000..fb82ff6 --- /dev/null +++ b/dbupload/dbmanifestgen/.gitignore @@ -0,0 +1 @@ +dbmanifestgen diff --git a/dbupload/dbmanifestgen/db.go b/dbupload/dbmanifestgen/db.go new file mode 120000 index 0000000..18b3e05 --- /dev/null +++ b/dbupload/dbmanifestgen/db.go @@ -0,0 +1 @@ +../db.go
\ No newline at end of file diff --git a/dbupload/dbmanifestgen/main.go b/dbupload/dbmanifestgen/main.go new file mode 100644 index 0000000..38347e5 --- /dev/null +++ b/dbupload/dbmanifestgen/main.go @@ -0,0 +1,56 @@ +package main + +import ( + "encoding/json" + "flag" + "fmt" + "io/ioutil" + "log" + "os" + "path/filepath" + "strings" +) + +var ( + serverloc = flag.String("serverloc", "http://static.xeserv.us/", "server to prepend to url paths") + sourceloc = flag.String("sourceloc", "", "source URL for metadata generation") +) + +func main() { + flag.Parse() + + if flag.NArg() == 0 { + fmt.Printf("%s: <dir>\n", os.Args[0]) + flag.Usage() + } + + if *sourceloc == "" { + log.Fatal("Need a source location") + } + + images, err := ioutil.ReadDir(flag.Arg(0)) + if err != nil { + panic(err) + } + + for _, image := range images { + if strings.HasSuffix(image.Name(), ".json") { + log.Printf("Skipped %s...", image) + continue + } + + fout, err := os.Create(image.Name() + ".json") + + var i UploadImage + i.Image.SourceURL = *sourceloc + i.Image.ImageURL = *serverloc + filepath.Base(image.Name()) + + outdata, err := json.MarshalIndent(&i, "", "\t") + if err != nil { + panic(err) + } + + fout.Write(outdata) + fout.Close() + } +} |
