served

You've been served.

Introduction

What is served?

served is a simple web server written in Go. It serves three kinds of content:

  • Static files
  • Blog articles written in present format
  • Slideshows written in present format

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.

The configuration file

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.

Setting up a static site

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" }
                    ],

Setting up a blog

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.

Enabling "play" mode

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
                }

Slideshows

When a blog is configured, you can view articles and slide shows in an alternate format by using the "slides" URL:

Present markup

The following sections show some of the things you can do with present format.

Preformatted text

Simply indent to get preformatted text.

This is preformatted.

Showing code from another file

.code puzz.go /^const/,/^\)/
const (
    K = "GOTHACK"
    C = "SBARATMLHGLLUGISQDNDSGJGZDLKBGTF"
    A1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    A2 = "GOTHACKBDEFIJLMNPQRSUVWXYZ"
)

Bullets

- bullets
- more bullets
  • bullets
  • more bullets

Images

.image gopher640.jpg 400 400

Play Code

.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()
}

Use an iframe

.iframe puzz.go 500 500

Links

.link http://www.yahoo.com/ Yahoo!
Another format is [[http://www.google.com/][Google]]

Another format is Google

HTML

.html table.html
Column 1Column 2
Regular3.52ms
Optimized2.03ms

See the index for more articles.