Permalink
Browse files

index page works

  • Loading branch information...
1 parent 84e3364 commit 369983d1e3dac1ede63f14f119ba8477e50a5e2c @bytbox bytbox committed Aug 23, 2010
Showing with 20 additions and 7 deletions.
  1. +2 −0 blog/templates/excerpt.html
  2. +5 −0 blog/templates/index.html
  3. +3 −1 compile.go
  4. +2 −2 input.go
  5. +8 −4 tidy.go
View
2 blog/templates/excerpt.html
@@ -0,0 +1,2 @@
+<h2><a href="{URL}" title="{Title}">{Title}</a></h2>
+{Excerpt}
View
5 blog/templates/index.html
@@ -0,0 +1,5 @@
+{.repeated section Posts}
+{CompiledExcerpt}
+{.or}
+<p><b>No posts found!</b></p>
+{.end}
View
4 compile.go
@@ -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,
View
4 input.go
@@ -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
@@ -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
View
12 tidy.go
@@ -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)
@@ -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.