shrink_main should work again.
This commit is contained in:
parent
75668db3ea
commit
25846d8942
|
@ -748,6 +748,10 @@ func initDefaultTmplFuncMap() {
|
||||||
return template.HTML(BuildWidget(dock.(string), headerInt.(*Header)))
|
return template.HTML(BuildWidget(dock.(string), headerInt.(*Header)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmap["hasWidgets"] = func(dock interface{}, headerInt interface{}) interface{} {
|
||||||
|
return HasWidgets(dock.(string), headerInt.(*Header))
|
||||||
|
}
|
||||||
|
|
||||||
fmap["elapsed"] = func(startedAtInt interface{}) interface{} {
|
fmap["elapsed"] = func(startedAtInt interface{}) interface{} {
|
||||||
return time.Since(startedAtInt.(time.Time)).String()
|
return time.Since(startedAtInt.(time.Time)).String()
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,22 +85,23 @@ func NewCTemplateSet(in string) *CTemplateSet {
|
||||||
baseImportMap: map[string]string{},
|
baseImportMap: map[string]string{},
|
||||||
overridenRoots: map[string]map[string]bool{},
|
overridenRoots: map[string]map[string]bool{},
|
||||||
funcMap: map[string]interface{}{
|
funcMap: map[string]interface{}{
|
||||||
"and": "&&",
|
"and": "&&",
|
||||||
"not": "!",
|
"not": "!",
|
||||||
"or": "||",
|
"or": "||",
|
||||||
"eq": "==",
|
"eq": "==",
|
||||||
"ge": ">=",
|
"ge": ">=",
|
||||||
"gt": ">",
|
"gt": ">",
|
||||||
"le": "<=",
|
"le": "<=",
|
||||||
"lt": "<",
|
"lt": "<",
|
||||||
"ne": "!=",
|
"ne": "!=",
|
||||||
"add": "+",
|
"add": "+",
|
||||||
"subtract": "-",
|
"subtract": "-",
|
||||||
"multiply": "*",
|
"multiply": "*",
|
||||||
"divide": "/",
|
"divide": "/",
|
||||||
"dock": true,
|
"dock": true,
|
||||||
"elapsed": true,
|
"hasWidgets": true,
|
||||||
"lang": true,
|
"elapsed": true,
|
||||||
|
"lang": true,
|
||||||
//"langf":true,
|
//"langf":true,
|
||||||
"level": true,
|
"level": true,
|
||||||
"abstime": true,
|
"abstime": true,
|
||||||
|
@ -1040,6 +1041,30 @@ ArgLoop:
|
||||||
// TODO: Refactor this
|
// TODO: Refactor this
|
||||||
litString("common.BuildWidget("+leftParam+","+rightParam+")", false)
|
litString("common.BuildWidget("+leftParam+","+rightParam+")", false)
|
||||||
break ArgLoop
|
break ArgLoop
|
||||||
|
case "hasWidgets":
|
||||||
|
// TODO: Implement string literals properly
|
||||||
|
leftOperand := node.Args[pos+1].String()
|
||||||
|
rightOperand := node.Args[pos+2].String()
|
||||||
|
if len(leftOperand) == 0 || len(rightOperand) == 0 {
|
||||||
|
panic("The left or right operand for function dock cannot be left blank")
|
||||||
|
}
|
||||||
|
leftParam := leftOperand
|
||||||
|
if leftOperand[0] != '"' {
|
||||||
|
leftParam, _ = c.compileIfVarSub(con, leftParam)
|
||||||
|
}
|
||||||
|
if rightOperand[0] == '"' {
|
||||||
|
panic("The right operand for function dock cannot be a string")
|
||||||
|
}
|
||||||
|
rightParam, val3 := c.compileIfVarSub(con, rightOperand)
|
||||||
|
if !val3.IsValid() {
|
||||||
|
panic("val3 is invalid")
|
||||||
|
}
|
||||||
|
val = val3
|
||||||
|
|
||||||
|
// TODO: Refactor this
|
||||||
|
out = "common.HasWidgets(" + leftParam + "," + rightParam + ")"
|
||||||
|
literal = true
|
||||||
|
break ArgLoop
|
||||||
case "lang":
|
case "lang":
|
||||||
// TODO: Implement string literals properly
|
// TODO: Implement string literals properly
|
||||||
leftOperand := node.Args[pos+1].String()
|
leftOperand := node.Args[pos+1].String()
|
||||||
|
|
|
@ -137,6 +137,42 @@ func HasDock(dock string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Find a more optimimal way of doing this...
|
||||||
|
func HasWidgets(dock string, header *Header) bool {
|
||||||
|
if !header.Theme.HasDock(dock) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Let themes forcibly override this slot
|
||||||
|
sbody := header.Theme.BuildDock(dock)
|
||||||
|
if sbody != "" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
var widgets []*Widget
|
||||||
|
switch dock {
|
||||||
|
case "leftOfNav":
|
||||||
|
widgets = Docks.LeftOfNav
|
||||||
|
case "rightOfNav":
|
||||||
|
widgets = Docks.RightOfNav
|
||||||
|
case "rightSidebar":
|
||||||
|
widgets = Docks.RightSidebar.Items
|
||||||
|
case "footer":
|
||||||
|
widgets = Docks.Footer.Items
|
||||||
|
}
|
||||||
|
|
||||||
|
wcount := 0
|
||||||
|
for _, widget := range widgets {
|
||||||
|
if !widget.Enabled {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if widget.Allowed(header.Zone) {
|
||||||
|
wcount++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wcount > 0
|
||||||
|
}
|
||||||
|
|
||||||
func BuildWidget(dock string, header *Header) (sbody string) {
|
func BuildWidget(dock string, header *Header) (sbody string) {
|
||||||
var widgets []*Widget
|
var widgets []*Widget
|
||||||
if !header.Theme.HasDock(dock) {
|
if !header.Theme.HasDock(dock) {
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
{{/**<!--</div>-->**/}}
|
{{/**<!--</div>-->**/}}
|
||||||
<div class="midRow">
|
<div class="midRow">
|
||||||
<div class="midLeft"></div>
|
<div class="midLeft"></div>
|
||||||
<div id="back" class="zone_{{.Header.Zone}}{{if .Header.Widgets.RightSidebar}} shrink_main{{end}}">
|
<div id="back" class="zone_{{.Header.Zone}}{{if hasWidgets "rightSidebar" .Header }} shrink_main{{end}}">
|
||||||
<div id="main" >
|
<div id="main" >
|
||||||
<div class="alertbox initial_alertbox">{{range .Header.NoticeList}}
|
<div class="alertbox initial_alertbox">{{range .Header.NoticeList}}
|
||||||
{{template "notice.html" . }}{{end}}
|
{{template "notice.html" . }}{{end}}
|
||||||
|
|
Loading…
Reference in New Issue