-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Starting point #1
Changes from all commits
de57be4
9409127
2b1d222
423b57d
5f23779
54c8dea
5d6dee4
dcf2070
26f7e43
cd359ae
8f0d987
c3ffe15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,3 @@ | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
[568vq].out | ||
|
||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
_testmain.go | ||
|
||
*.exe | ||
*.test | ||
*.prof | ||
vendor/ | ||
out/ | ||
sally |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.PHONY: install | ||
install: | ||
glide --version || go get github.com/Masterminds/glide | ||
glide install | ||
go get -u github.com/jteeuwen/go-bindata/... | ||
|
||
|
||
.PHONY: run | ||
run: | ||
go generate && go build && ./sally |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# sally | ||
|
||
A canonical import path static site generator for Go |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package: github.com/uber-go/sally | ||
import: | ||
- package: gopkg.in/yaml.v2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
) | ||
|
||
//go:generate go-bindata templates/ | ||
|
||
func main() { | ||
yml := flag.String("yml", "sally.yaml", "yaml file to read config from") | ||
dir := flag.String("dir", "out", "directory to write html files to") | ||
flag.Parse() | ||
|
||
c, err := Parse(*yml) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
if err := Write(c, *dir); err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
|
||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
// Config represents the structure of the yaml file | ||
type Config struct { | ||
URL string `yaml:"url"` | ||
Packages map[string]Package `yaml:"packages"` | ||
} | ||
|
||
// Package details the options available for each repo | ||
type Package struct { | ||
Repo string `yaml:"repo"` | ||
} | ||
|
||
// Parse takes a path to a yaml file and produces a parsed Config | ||
func Parse(path string) (Config, error) { | ||
var c Config | ||
|
||
data, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
return c, err | ||
} | ||
|
||
if err := yaml.Unmarshal(data, &c); err != nil { | ||
return c, err | ||
} | ||
|
||
return c, err | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
url: go.uber.org | ||
|
||
packages: | ||
thriftrw: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i like the config, it's really clean. Can package names contain a |
||
repo: github.com/thriftrw/thriftrw-go | ||
yarpc: | ||
repo: github.com/yarpc/yarpc-go |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<ul> | ||
{{ range $key, $value := .Packages }} | ||
<li>{{ $key }} - {{ $value.Repo }}</li> | ||
{{ end }} | ||
</ul> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think our templates are trivial enough that we can just have .go files with the templates inlined rather than adding a dependency on go-bindata. We could use separate files, so we could have
index_tpl.go
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair, at least to start.
Might have to return to this approach once/if the sites start to collect images/css.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think I'll keep it like this for now - I like having the templates in their own .tpl for syntax highlighting reasons.