Skip to content
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

Merged
merged 12 commits into from Sep 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 3 additions & 24 deletions .gitignore
@@ -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
10 changes: 10 additions & 0 deletions Makefile
@@ -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/...

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:

package main

var _indexTpl = `
<html>
 [..]
</html>
`

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.



.PHONY: run
run:
go generate && go build && ./sally
1 change: 1 addition & 0 deletions README.md
@@ -1,2 +1,3 @@
# sally

A canonical import path static site generator for Go
260 changes: 260 additions & 0 deletions bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions glide.yaml
@@ -0,0 +1,3 @@
package: github.com/uber-go/sally
import:
- package: gopkg.in/yaml.v2
23 changes: 23 additions & 0 deletions main.go
@@ -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)
}
}
34 changes: 34 additions & 0 deletions parse.go
@@ -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
}
7 changes: 7 additions & 0 deletions sally.yaml
@@ -0,0 +1,7 @@
url: go.uber.org

packages:
thriftrw:

Choose a reason for hiding this comment

The 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 /? I wonder if we'll want multiple levels underneath the URL for related projects (e.g., go.uber.org/io/[..])

repo: github.com/thriftrw/thriftrw-go
yarpc:
repo: github.com/yarpc/yarpc-go
10 changes: 10 additions & 0 deletions templates/index.tpl
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<body>
<ul>
{{ range $key, $value := .Packages }}
<li>{{ $key }} - {{ $value.Repo }}</li>
{{ end }}
</ul>
</body>
</html>