func Truncate(length int, value string) string {
	if length > len(value) {
		length = len(value)
	}
	return value[0:length]
}
Truncate truncates the value string to maximum of the given length, and returns it.
package gostatic
import (
	"fmt"
	"hash/adler32"
	"io"
	"os"
	"os/exec"
	"path/filepath"
	"regexp"
	"strings"
	"text/template"
)
var inventory = map[string]interface{}{}
func HasChanged(name string, value interface{}) bool {
	changed := true
	if inventory[name] == value {
		changed = false
	} else {
		inventory[name] = value
	}
	return changed
}
func Cut(begin, end, value string) (string, error) {
	bre, err := regexp.Compile(begin)
	if err != nil {
		return "", err
	}
	ere, err := regexp.Compile(end)
	if err != nil {
		return "", err
	}
	bloc := bre.FindIndex([]byte(value))
	if bloc == nil {
		return "", nil
	}
	value = value[bloc[1]:]
	eloc := ere.FindIndex([]byte(value))
	if eloc == nil {
		return "", nil
	}
	return value[:eloc[0]], nil
}
func Hash(value string) string {
	h := adler32.New()
	io.WriteString(h, value)
	return fmt.Sprintf("%x", h.Sum(nil))
}
func Versionize(current *Page, value string) (string, error) {
	page := current.Site.Pages.ByPath(value)
	if page == nil {
		errhandle(fmt.Errorf(
			"trying to versionize page which does not exist: %s, current: %s",
			value, current.Path))
	}
	_, err := page.Process()
	if err != nil {
		return "", err
	}
	c := page.Content()
	h := Hash(c)
	return current.UrlTo(page) + "?v=" + h, nil
}