Skip to content

Commit

Permalink
index page works
Browse files Browse the repository at this point in the history
  • Loading branch information
bytbox committed Aug 23, 2010
1 parent 84e3364 commit 369983d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions blog/templates/excerpt.html
@@ -0,0 +1,2 @@
<h2><a href="{URL}" title="{Title}">{Title}</a></h2>
{Excerpt}
5 changes: 5 additions & 0 deletions blog/templates/index.html
@@ -0,0 +1,5 @@
{.repeated section Posts}
{CompiledExcerpt}
{.or}
<p><b>No posts found!</b></p>
{.end}
4 changes: 3 additions & 1 deletion compile.go
Expand Up @@ -84,7 +84,9 @@ func CompileIndex() {
// compile list of all pages against the "index" template
tmpl := Templates["index"]
w := &stringWriter{}
tmpl.Execute(Pages, w)
tmpl.Execute(map[string]interface{}{
"Posts": Posts,
}, w)
Pages["/"] = &Page {
URL: "/",
Content: w.buff,
Expand Down
4 changes: 2 additions & 2 deletions input.go
Expand Up @@ -80,7 +80,7 @@ func ReadPost(content string, path string) *Post {
ind := strings.Index(line, ":")
if ind != -1 {
key, value := line[0:ind], strings.TrimSpace(line[ind+1:])
post.Meta[strings.ToLower(key)] = value
post.Meta[strings.Title(key)] = value
}
}
post.URL = path
Expand Down Expand Up @@ -146,7 +146,7 @@ func ReadPage(content string, path string) *Page {
ind := strings.Index(line, ":")
if ind != -1 {
key, value := line[0:ind], strings.TrimSpace(line[ind+1:])
page.Meta[strings.ToLower(key)] = value
page.Meta[strings.Title(key)] = value
}
}
page.URL = path
Expand Down
12 changes: 8 additions & 4 deletions tidy.go
Expand Up @@ -28,7 +28,7 @@ func Tidy(str string) (html string, err os.Error) {
// bit by indenting
indent := 0 // the current indent level
token, err := parser.Token()
for err != os.EOF {
for err == nil {
switch token.(type) {
case xml.StartElement:
elem := token.(xml.StartElement)
Expand Down Expand Up @@ -63,11 +63,15 @@ func Tidy(str string) (html string, err os.Error) {
directive := token.(xml.Directive)
html += "<!"+bytes.NewBuffer(directive).String()+">"
default:
// yikes! Note the crisis, but pretend to keep working
os.Stderr.WriteString("Unknown token type\n")
// yikes! Not much to do about this...
}
token, err = parser.Token()
}
return
if err != os.EOF {
// return the original string
return str, err
}
err = nil
return
}

0 comments on commit 369983d

Please sign in to comment.