diff --git a/.gitignore b/.gitignore index 17ac108..6314dad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Compiled Object files, Static and Dynamic libs (Shared Objects) transmet db/dbconf.yml +.Rhistory .project *~ *.o diff --git a/templates.go b/templates.go index 1552cbc..f5b9974 100644 --- a/templates.go +++ b/templates.go @@ -44,7 +44,7 @@ func stringTimes(times int, str string) string { // Turns a Time into a formated string func dateFormat(t time.Time) string { - return t.Format(time.ANSIC) + return t.Format("2006.01.02 15:04:05") } // takes a category_id and returns "Root / Parent / Category" @@ -56,6 +56,14 @@ func fullCategoryPath(categoriesFlat map[int]*categories.Category, category_id i return strings.Join(categoryNames, " / ") } +// truncate a string +func truncate(str string, maxLen int) string { + if len(str) <= maxLen { + return str + } + return str[0:maxLen] + "..." +} + // Tempalte helper functions var funcMap = template.FuncMap { "add": func (x, y int) int { return x + y }, @@ -64,6 +72,7 @@ var funcMap = template.FuncMap { "stringTimes": stringTimes, "dateFormat": dateFormat, "fullCategoryPath": fullCategoryPath, + "truncate": truncate, } diff --git a/templates/pages/news.html b/templates/pages/news.html index 37e768e..0d727d5 100644 --- a/templates/pages/news.html +++ b/templates/pages/news.html @@ -13,19 +13,27 @@ {{define "row-news"}}
-
-

{{.post.Title}}

+
+ {{fullCategoryPath .categories .post.Category_id}}
-
+
+ {{truncate .post.Title 100}} +
+
{{dateFormat .post.Date}}
- -
- Category: {{fullCategoryPath .categories .post.Category_id}} +
+
+
 
+ +
 
+
+
+
 
+
{{truncate .post.Notes 500}}
+
 
-
{{.post.Notes}}
{{end}}