示例#1
0
// TODO: Place at the bottom of the content instead of at the bottom of the window
func AddFooter(page *onthefly.Page, footerText, footerTextColor, footerColor string, elapsed time.Duration) (*onthefly.Tag, error) {
	body, err := page.GetTag("body")
	if err != nil {
		return nil, err
	}
	div := body.AddNewTag("div")
	div.AddAttrib("id", "notice")
	div.AddStyle("position", "fixed")
	div.AddStyle("bottom", "0")
	div.AddStyle("left", "0")
	div.AddStyle("width", "100%")
	div.AddStyle("display", "block")
	div.AddStyle("padding", "0")
	div.AddStyle("margin", "0")
	div.AddStyle("background-color", footerColor)
	div.AddStyle("font-size", "0.6em")
	div.AddStyle("text-align", "right")
	div.AddStyle("box-shadow", "1px -2px 3px rgba(0,0,0, .5)")

	innerdiv := div.AddNewTag("div")
	innerdiv.AddAttrib("id", "innernotice")
	innerdiv.AddStyle("padding", "0 2em 0 0")
	innerdiv.AddStyle("margin", "0")
	innerdiv.AddStyle("color", footerTextColor)
	innerdiv.AddContent("Generated in " + elapsed.String() + " | " + footerText)

	return div, nil
}
示例#2
0
// Takes a page and a colon-separated string slice of text:url, hiddenlinks is just a list of the url part
func AddMenuBox(page *onthefly.Page, darkBackgroundTexture string, customSansSerif string) (*onthefly.Tag, error) {
	body, err := page.GetTag("body")
	if err != nil {
		return nil, err
	}

	div := body.AddNewTag("div")
	div.AddAttrib("id", "menubox")
	div.AddStyle("display", "block")
	div.AddStyle("width", "100%")
	div.AddStyle("margin", "0")
	div.AddStyle("padding", "0.1em 0 0.2em 0")
	div.AddStyle("position", "absolute")
	div.AddStyle("top", "4.3em")
	div.AddStyle("left", "0")
	div.AddStyle("background-color", "#0c0c0c") // dark gray, fallback
	div.AddStyle("background", "url('"+darkBackgroundTexture+"')")
	div.AddStyle("position", "fixed")
	div.AddStyle("box-shadow", "1px 3px 5px rgba(0,0,0, .8)")
	if customSansSerif != "" {
		div.AddStyle("font-family", customSansSerif)
	}

	div.AddLastContent("{{{menu}}}")

	return div, nil
}
示例#3
0
func AddTopBox(page *onthefly.Page, title, subtitle, searchURL, searchButtonText, backgroundTextureURL string, roundedLook bool, cs *ColorScheme, addSearchBox bool) (*onthefly.Tag, error) {
	body, err := page.GetTag("body")
	if err != nil {
		return nil, err
	}

	div := body.AddNewTag("div")
	div.AddAttrib("id", "topbox")
	div.AddStyle("display", "block")
	div.AddStyle("width", "100%")
	div.AddStyle("margin", "0")
	div.AddStyle("padding", "0 0 1em 0")
	div.AddStyle("top", "0")
	div.AddStyle("left", "0")
	div.AddStyle("background-color", cs.Darkgray)
	div.AddStyle("position", "fixed")
	div.AddStyle("display", "block")

	titlebox := AddTitleBox(div, title, subtitle, cs)
	titlebox.AddAttrib("id", "titlebox")
	titlebox.AddStyle("margin", "0 0 0 0")
	// Padding-top + height should be about 5em, padding decides the position
	titlebox.AddStyle("padding", "1.2em 0 0 1.8em")
	titlebox.AddStyle("height", "3.1em")
	titlebox.AddStyle("width", "100%")
	titlebox.AddStyle("position", "fixed")
	//titlebox.AddStyle("background-color", cs.Darkgray) // gray, could be a gradient
	if backgroundTextureURL != "" {
		titlebox.AddStyle("background", "url('"+backgroundTextureURL+"')")
	}
	//titlebox.AddStyle("z-index", "2") // 2 is above the search box which is 1

	if addSearchBox {
		searchbox := AddSearchBox(titlebox, searchURL, searchButtonText, roundedLook)
		searchbox.AddAttrib("id", "searchbox")
		searchbox.AddStyle("position", "relative")
		searchbox.AddStyle("float", "right")
		// The padding decides the position for this one
		searchbox.AddStyle("padding", "0.4em 3em 0 0")
		searchbox.AddStyle("margin", "0")
		//searchbox.AddStyle("min-width", "10em")
		//searchbox.AddStyle("line-height", "10em")
		//searchbox.AddStyle("z-index", "1") // below the title
	}

	return div, nil
}
示例#4
0
func AddContent(page *onthefly.Page, contentTitle, contentHTML string) (*onthefly.Tag, error) {
	body, err := page.GetTag("body")
	if err != nil {
		return nil, err
	}

	div := body.AddNewTag("div")
	div.AddAttrib("id", "content")
	div.AddStyle("z-index", "-1")
	div.AddStyle("color", "black") // content headline color
	div.AddStyle("min-height", "80%")
	div.AddStyle("min-width", "60%")
	div.AddStyle("float", "left")
	div.AddStyle("position", "relative")
	div.AddStyle("margin-left", "4%")
	div.AddStyle("margin-top", "9.5em")
	div.AddStyle("margin-right", "5em")
	div.AddStyle("padding-left", "4em")
	div.AddStyle("padding-right", "5em")
	div.AddStyle("padding-top", "1em")
	div.AddStyle("padding-bottom", "2em")
	div.AddStyle("background-color", "rgba(255,255,255,0.92)")                                                                               // light gray. Transparency with rgba() doesn't work in IE
	div.AddStyle("filter", "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#dcffffff', endColorstr='#dcffffff');") // for transparency in IE

	div.AddStyle("text-align", "justify")
	div.RoundedBox()

	h2 := div.AddNewTag("h2")
	h2.AddAttrib("id", "textheader")
	h2.AddContent(contentTitle)
	h2.CustomSansSerif("Armata")

	p := div.AddNewTag("p")
	p.AddAttrib("id", "textparagraph")
	p.AddStyle("margin-top", "0.5em")
	//p.CustomSansSerif("Junge")
	p.SansSerif()
	p.AddStyle("font-size", "1.0em")
	p.AddStyle("color", "black") // content text color
	p.AddContent(contentHTML)

	return div, nil
}
示例#5
0
// Render a page by inserting data at the {{{placeholders}}} for both html and css
func RenderPage(page *onthefly.Page, templateContents map[string]string) (string, string) {
	// Note that the whitespace formatting of the generated html matter for the menu layout!
	return mustache.Render(page.String(), templateContents), mustache.Render(page.GetCSS(), templateContents)
}
示例#6
0
// Create a web.go compatible function that returns a string that is the HTML for this page
func GenerateHTMLwithTemplate(page *onthefly.Page, tvg webhandle.TemplateValueGenerator) func(*web.Context) string {
	return func(ctx *web.Context) string {
		values := tvg(ctx)
		return mustache.Render(page.GetXML(true), values)
	}
}