Skip to content

Commit

Permalink
Add version flag (v0.7.0), create proper release
Browse files Browse the repository at this point in the history
* Add -version flag, set to v0.7,0
* Add build script
* Remove old releases
* Update readme
  • Loading branch information
mkaz committed Apr 18, 2019
1 parent ae71cda commit 6ef0998
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 166 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
hastie
hastie-*.tar.gz
test/public/
213 changes: 47 additions & 166 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
## Hastie - Static Site Generator in Go

Created by [Marcus Kazmierczak](http://mkaz.com/) and contributions by [Fredrik Steen](http://github.com/stone)

Started: Feb 13, 2012

License: MIT, see [LICENSE](https://github.com/mkaz/hastie/blob/master/LICENSE)

**About**
## Hastie - Static Site Generator in Go

Hastie is a simple static site generator in Go. I use it as a replacement of jekyll on [mkaz.com](http://mkaz.com/). I wanted a project to play with and learn Go and jekyll was starting to slow and ruby dependencies give me a headache. I think I switched systems and everything broke and I couldn't publish. The Go binary is completely portable and all includes all dependencies.
Hastie is a simple static site generator in Go. I created it as a replacement of Jekyll. I wanted a project to play with and learn Go and Jekyll was slow and Ruby dependencies give me a headache. The Go binary is completely portable and includes all dependencies, so once built makes it easy in the future.

If you are looking for a tool to tweak and play with the Go language, then this might be fun. Most customizations will probably require code changes. The reason I created the tool was to learn Go, I'm open sourcing to hopefully help others play with Go.

If you just want simple blogging and no headaches, setup a hosted blog on [WordPress.com](http://wordpress.com) easiest platform and you'll be up in minutes.
If you just want simple blogging and no headaches, setup a hosted blog on [WordPress.com](http://wordpress.com) it's an easy platform and you'll be up in minutes.

Note: The name Hastie is from a character in the novel Dr. Jekyll and Mr. Hyde

Expand All @@ -24,34 +17,38 @@ Install Go: <http://golang.org/doc/install.html#fetch>

Get Hastie: `go get github.com/mkaz/hastie`

If you have your Go environment setup, `go get` will automatically create the binary in $GOPATH/bin.
If you have your Go environment setup, `go get` will automatically create the binary in `$GOPATH/bin`.

My setup is
I set GOPATH to my home directory, so binaries go in `bin`

```bash
mkdir -p $HOME/gocode/src
mkdir -p $HOME/gocode/bin
### Binaries

export GOPATH="$HOME/gocode"
export PATH="$GOPATH/bin:$PATH"
```

#### Libraries

Uses **blackfriday** for markdown conversion. `go get github.com/russross/blackfriday`
Download binaries for Linux, Mac, and Windows from [Github releases tab](https://github.com/mkaz/hastie/releases).


--------------------------------------------------------------------------------

## Usage

usage: hastie [flags]
-c="hastie.json": Config file
-h=false: show this help
-http="": HTTP service address (e.g., ':8080')
-m=false: do not use markdown conversion
-t=false: display timing
-v=false: verbose output
```
$ hastie [-flags]
Flags:
-config string
Config file (default "hastie.json")
-debug
Debug output (verbose)
-help
show this help
-nomarkdown
do not use markdown conversion
-verbose
Show info level
-version
Display version and quit
```


Configuration file format (default ./hastie.json)

Expand All @@ -62,9 +59,7 @@ Configuration file format (default ./hastie.json)
"UseMarkdown": true
}

UseMarkdown is optional parameter, by default it will convert documents to
markdown. If you don't want documents to be converted globally, you can specify
it false on the command-line or here in the config. If you want to disable markdown on a per document basis, you can put "markdown: no" in the front matter of the document.
UseMarkdown is optional parameter, by default it will convert documents to markdown. If you don't want documents to be converted globally, you can specify it false on the command-line or here in the config. If you want to disable markdown on a per document basis, you can put "markdown: no" in the front matter of the document.

Hastie walks through a templates directory and generates HTML files to a publish directory. It uses Go's template language for templates and markdown for content.

Expand Down Expand Up @@ -92,11 +87,13 @@ A few current limitations:

* all files must be have .md or .html extension

The usage of hastie is just as a template engine, it does not copy over any images, does not have a built-in web server or any of the other features that jekyll has.
The usage of hastie is mainly a template engine, it does not have a built-in web server or watch, or many of the features that jekyll has.

I keep the `public` directory full with all of the assets for the site such as images, stylesheets, etc and hastie copies in the html files. So if you delete a template it won't be removed from `public`
If a directory named `static` exists in the Layout Directory, Hastie will copy it over to the root of the Publis Directory as `static`


### Template Variables

Data available to templates:

.Title -- Page Title
Expand All @@ -122,22 +119,30 @@ Data available to templates:

Functions Available:

.Reverse -- will reverse sort order of list
.Recent.Limit n -- will limit recent list to n items
.Categories.Get CATEGORY -- will fetch category list CATEGORY, useful for dynamic categories


Examples:
#### Examples:

Show 3 most recent titles:

Show 3 most recent titles:
{{ range .Recent.Limit 3 }}
{{ .Title }}
{{ end }}

Show 3 most recent from math category:
Show 3 most recent from math category:

{{ range .CategoryList.math }}
{{ .Title }}
{{ end }}

Show oldest items first:

{{ range .Recent.Reverse }}
{{.Title }}
{{ end }}

### Using Filters (Example: Less CSS, CoffeeScript)

Expand All @@ -151,138 +156,14 @@ Add follow configuration to hastie.json

So the above example any files with the extension `.less` will be converted to `.css` using lessc binary and copied to the public directory at the same spot in the directory tree as the original less file.

## Contributions

--------------------------------------------------------------------------------

### TODO
* Create syntax highlighting blocks
* Add ability to support rss.xml

* Read .html files and apply template, no markdown
* Add Less and Filter processing of static files

#### Bugs
* Add nicer error message/detection when no config found
* Add nicer error detection when error with template
* Should template variables work in source files ??

--------------------------------------------------------------------------------

### CHANGE LOG

ver 0.5.2 - Aug 2014

* Add ability to parse all .html files in source directory

* Add global flag to config file to skip markdown


ver 0.5.1 - Feb 2014

* Rename ThemeDir back to LayoutDir
- wrong direction, confusing name

* Alter markdown rendering so allows `<script>` tags
- hastie is used on personal site, so does not need to be so strict


ver 0.5.0 - June 2013

* Change LayoutDir to ThemeDir parameter

* Add copying of {ThemeDir}/static directory to {PublishDir}/static
This allows you to create a theme with static assets, such as css

* Use category if specified in file



ver 0.?.? - June 2013

* Reverted branch changes which monitor and served the site
This was adding too much complexity and not core to the tool

* If you want a web server to test, do the following from public directory
$ python -m SimpleHTTPServer
$ open http://localhost:8000/


ver 0.4.4 - March 23, 2012

* Add BaseURL config parameter
* Update Test Site


ver 0.4.3 - March 22, 2012

* Speed optimizations improved rendering of mkaz.com time by 75% from 2sec down to 500ms
* Pass more objects by reference to reduce copying of large arrays
* Moved template parsing out of loop of pages, only needed to do once
* Added Timing flag to see what areas take most time ( -t )


ver 0.4.2 - March 20, 2012

* Run file through "go fmt" for proper formating
* Convert fmt.Sprintf to simple "+" for string concat


ver 0.4.1 - March 15, 2012

* Categories under subdirected changed to _ instead of / in index
* Cleaned up code comments
* Updated documentation to include all new features
* Add Extension to Template Parameter to Support RSS

ver 0.4.0 - March 14, 2012

* Add Process Filters allows processing using any third party such as Less CSS or Coffee Script


ver 0.3.5 - March 12, 2012

* Add Prev-Next Links by Category
* Add Parameters to Header, allows user created parameters, stored in .Params
* Removed skip if empty content, can build page based on parameters


ver 0.3.4 - March 10, 2012

* Add Recent List by Category
* Switched Config from string map to struct
* Created new config element called CategoryMash which allows
the combination of multiple categories into a single category.
This allows for displaying a list of combined categories


ver 0.3.3 - March 9, 2012

* Add Limit function to PagesSlice, available in templates
* Removed Pages data, since duplicated


ver 0.3.2 - March 8, 2012

* Add Prev-Next Links to Page Object


ver 0.3.1 - March 7, 2012

* Change category to include full directory path
* Trimmed begin-end quotes from passed in parameters
no need to quote parameters in template files


ver 0.3.0 - March 2, 2012
Thanks to all [the contributors](https://github.com/mkaz/hastie/graphs/contributors)!

* Merged Fredrik Steen changes in github.com/stone/hastie
* Switched config to json format
- removed dependency on old config
* Moved to Go1 support
Any contributions are welcome, be it in feature requests, bug reports, documentation, or pull requests.


ver 0.2 (unreleased)
* In config, renamed `template_dir` to `source` This more accurately describes the directory, what I was thinking was templates to be expanded are really the source files for the site.
## License

* Added Url parameter to templates
Licensed under MIT see [LICENSE](https://github.com/mkaz/hastie/blob/master/LICENSE) file.

20 changes: 20 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Build Script for creating multiple architecture releases

# Requires:
# go get github.com/mitchellh/gox

## get version from self to include in file names
go build
VERSION=`hastie --version | sed -e 's/hastie v//'`

echo "Building $VERSION"
gox -osarch="linux/amd64 darwin/amd64 windows/amd64" -output "{{.Dir}}-$VERSION-{{.OS}}/{{.Dir}}"

for arch in linux darwin windows; do
tar cf hastie-$VERSION-$arch.tar hastie-$VERSION-$arch
gzip hastie-$VERSION-$arch.tar
rm -rf hastie-$VERSION-$arch
done

7 changes: 7 additions & 0 deletions hastie.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"bytes"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"os/exec"
Expand Down Expand Up @@ -89,6 +90,7 @@ var site = &SiteStruct{}
func main() {

var helpFlag = flag.Bool("help", false, "show this help")
var versionFlag = flag.Bool("version", false, "Display version and quit")
var noMarkdown = flag.Bool("nomarkdown", false, "do not use markdown conversion")
var configFile = flag.String("config", "hastie.json", "Config file")
flag.BoolVar(&log.DebugLevel, "debug", false, "Debug output (verbose)")
Expand All @@ -100,6 +102,11 @@ func main() {
os.Exit(0)
}

if *versionFlag {
fmt.Println("hastie v0.7.0")
os.Exit(0)
}

setupConfig(*configFile)
if *noMarkdown {
config.UseMarkdown = false
Expand Down
Binary file removed release/hastie-darwin-amd64
Binary file not shown.
Binary file removed release/hastie-linux-amd64
Binary file not shown.
Binary file removed release/hastie.exe
Binary file not shown.

0 comments on commit 6ef0998

Please sign in to comment.