Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
# GopherJS.org

## Generating

```bash
go generate github.com/gopherjs/gopherjs.github.io/...
```

## Todo

* Tweak look and feel, logo, etc.
Expand Down
6 changes: 6 additions & 0 deletions doc.go
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
// Package gopherjswebsite is the www.gopherjs.org website source.
//
// It should be updated with `go generate github.com/gopherjs/gopherjs.github.io/...`.
package gopherjswebsite

//go:generate go run generate.go
68 changes: 68 additions & 0 deletions generate.go
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
// +build generate

package main

import (
"bytes"
"fmt"
"io/ioutil"
"log"
"net/http"
"text/template"
)

func t(text string) *template.Template{
return template.Must(template.New("").Parse(text))
}

// Filename -> Template.
var templates = map[string]*template.Template{

"index.md": t(`---
# generated by generate.go; DO NOT EDIT
layout: index
title: Home
permalink: /
---

{{.HTTPGet "https://raw.githubusercontent.com/gopherjs/gopherjs/master/README.md"}}`),
}

type data struct{}

// HTTPGet fetches the contents at the given url.
func (data) HTTPGet(url string) (string, error){
resp, err := http.Get(url)
if err != nil{
return "", err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil{
return "", err
}
return string(body), nil
}

func gen() error{
for filename, t := range templates{
var buf bytes.Buffer
err := t.Execute(&buf, data{})
if err != nil{
return err
}
fmt.Println("writing", filename)
err = ioutil.WriteFile(filename, buf.Bytes(), 0644)
if err != nil{
return err
}
}
return nil
}

func main(){
err := gen()
if err != nil{
log.Fatalln(err)
}
}
4 changes: 4 additions & 0 deletions index.md
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
---
# generated by generate.go; DO NOT EDIT
layout: index
title: Home
permalink: /
Expand All@@ -7,6 +8,8 @@ permalink: /
GopherJS - A compiler from Go to JavaScript
-------------------------------------------

[![Circle CI](https://circleci.com/gh/gopherjs/gopherjs.svg?style=svg)](https://circleci.com/gh/gopherjs/gopherjs)

GopherJS compiles Go code ([golang.org](http://golang.org/)) to pure JavaScript code. Its main purpose is to give you the opportunity to write front-end code in Go which will still run in all browsers. Give GopherJS a try on the [GopherJS Playground](http://gopherjs.github.io/playground/).

### What is supported?
Expand All@@ -31,6 +34,7 @@ Now you can use `gopherjs build [files]` or `gopherjs install [package]` which
- Use `float64` instead of `float32`.

### Community
- [#gopherjs Channel on Gophers Slack](https://gophers.slack.com/messages/gopherjs/) (invites to Gophers Slack are available [here](http://blog.gopheracademy.com/gophers-slack-community/#how-can-i-be-invited-to-join:2facdc921b2310f18cb851c36fa92369))
- [Google Group](https://groups.google.com/d/forum/gopherjs)
- [Bindings to JavaScript APIs and libraries](https://github.com/gopherjs/gopherjs/wiki/bindings)
- [GopherJS on Twitter](https://twitter.com/GopherJS)
Expand Down