clean up news display
This commit is contained in:
parent
a4abe1424a
commit
470b011ded
|
@ -1,6 +1,7 @@
|
|||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
transmet
|
||||
db/dbconf.yml
|
||||
.Rhistory
|
||||
.project
|
||||
*~
|
||||
*.o
|
||||
|
|
11
templates.go
11
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,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,19 +13,27 @@
|
|||
{{define "row-news"}}
|
||||
<div class="news-row">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<h3>{{.post.Title}}</h3>
|
||||
<div class="col-xs-2">
|
||||
{{fullCategoryPath .categories .post.Category_id}}
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
<div class="col-xs-8">
|
||||
<strong>{{truncate .post.Title 100}}</strong>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
{{dateFormat .post.Date}}
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
<a href="{{.post.Url}}">{{.post.Url}}</a>
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
Category: {{fullCategoryPath .categories .post.Category_id}}
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-2"> </div>
|
||||
<div class="col-xs-8">
|
||||
<a href="{{.post.Url}}">{{truncate .post.Url 100}}</a>
|
||||
</div>
|
||||
<div class="col-xs-2"> </div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-2"> </div>
|
||||
<div class="col-xs-8">{{truncate .post.Notes 500}}</div>
|
||||
<div class="col-xs-2"> </div>
|
||||
</div>
|
||||
<div>{{.post.Notes}}</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
Loading…
Reference in New Issue