served is a simple web server written in Go. It serves three kinds of content:
In addition to a great HTTP library, the Go authors provided some very useful libraries and code for blogging:
served puts a framework around these that allows you to configure servers that respond on different ports, hosts, and paths.
served's configuration file is a simple JSON file. Servers can be defined to listen on unique addresses. Each server can support responding to multiple host names.
Static sites need to specify a web root ending in "/" and a folder on disk:
"VDirs": [ { "Root": "/", "Folder": "/Users/michael/web/skyegg" }, { "Root": "/gopher/static/", "Folder": "/Users/michael/gocode/src/github.com/ancientlore/served/static" } ],
In addition to the settings for a static site, blogs need to specify the number of articles to show on the home page, the number of articles to list in the atom feed, and the feed title:
"Blogs": [ { "Root": "/gopher/", "Folder": "/Users/michael/gocode/src/github.com/ancientlore/served", "HomeArticles": 5, "FeedArticles": 10, "FeedTitle": "served" } ],
The blog folder must have a template folder (for the go templates for the site) and a content folder (for articles, slides, and other content). Additionally, there should be a static folder configured as a VDir to hold some web content needed by the templates. Sames of these are available on GitHub.
If you enable play mode, users can compile and execute Go code from the web page! This should probably not be enabled on a public web site, however. served has not been particularly hardened.
"PlayEnabled": true, "NativeClient": false }
When a blog is configured, you can view articles and slide shows in an alternate format by using the "slides" URL:
The following sections show some of the things you can do with present format.
Simply indent to get preformatted text.
This is preformatted.
.code puzz.go /^const/,/^\)/
const ( K = "GOTHACK" C = "SBARATMLHGLLUGISQDNDSGJGZDLKBGTF" A1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" A2 = "GOTHACKBDEFIJLMNPQRSUVWXYZ" )
- bullets - more bullets
.image gopher640.jpg 400 400
.play puzz.go
package main import ( "fmt" "strings" ) const ( K = "GOTHACK" C = "SBARATMLHGLLUGISQDNDSGJGZDLKBGTF" A1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" A2 = "GOTHACKBDEFIJLMNPQRSUVWXYZ" ) func main() { for _, c := range C { fmt.Printf("%c", A1[strings.Index(A2, string(c))]) } fmt.Println() }
.iframe puzz.go 500 500
.link http://www.yahoo.com/ Yahoo!
Another format is [[http://www.google.com/][Google]]
Another format is Google
.html table.html
Column 1 | Column 2 |
---|---|
Regular | 3.52ms |
Optimized | 2.03ms |
See the index for more articles.