Exemple #1
0
func AddTitleBox(tag *onthefly.Tag, title, subtitle string, cs *ColorScheme) *onthefly.Tag {

	div := tag.AddNewTag("div")
	div.AddAttrib("id", "titlebox")
	div.AddStyle("display", "block")
	div.AddStyle("position", "fixed")

	word1 := title
	word2 := ""
	if strings.Contains(title, " ") {
		word1 = strings.SplitN(title, " ", 2)[0]
		word2 = strings.SplitN(title, " ", 2)[1]
	}

	a := div.AddNewTag("a")
	a.AddAttrib("id", "homelink")
	a.AddAttrib("href", "/")
	a.AddStyle("text-decoration", "none")

	font0 := a.AddNewTag("div")
	font0.AddAttrib("id", "whitetitle")
	font0.AddAttrib("class", "titletext")
	font0.AddStyle("color", cs.TitleText)
	//font0.CustomSansSerif("Armata")
	font0.SansSerif()
	font0.AddStyle("font-size", "2.0em")
	font0.AddStyle("font-weight", "bolder")
	font0.AddContent(word1)

	font1 := a.AddNewTag("div")
	font1.AddAttrib("id", "bluetitle")
	font1.AddAttrib("class", "titletext")
	font1.AddStyle("color", cs.Nicecolor)
	//font1.CustomSansSerif("Armata")
	font1.SansSerif()
	font1.AddStyle("font-size", "2.0em")
	font1.AddStyle("font-weight", "bold")
	font1.AddStyle("overflow", "hidden")
	font1.AddContent(word2)

	font2 := a.AddNewTag("div")
	font2.AddAttrib("id", "graytitle")
	font2.AddAttrib("class", "titletext")
	font2.AddStyle("font-size", "0.5em")
	font2.AddStyle("color", "#707070")
	font2.CustomSansSerif("Armata")
	font2.AddStyle("font-size", "1.25em")
	font2.AddStyle("font-weight", "normal")
	font2.AddStyle("overflow", "hidden")
	font2.AddContent(subtitle)

	return div
}
Exemple #2
0
// Add a search box to the page, actionURL is the url to use as a get action,
// buttonText is the text on the search button
func AddSearchBox(tag *onthefly.Tag, actionURL, buttonText string, roundedLook bool) *onthefly.Tag {

	div := tag.AddNewTag("div")
	div.AddAttrib("id", "searchboxdiv")
	div.AddStyle("text-align", "right")
	div.AddStyle("display", "inline-block")

	form := div.AddNewTag("form")
	form.AddAttrib("id", "search")
	form.AddAttrib("method", "get")
	form.AddAttrib("action", actionURL)

	innerDiv := form.AddNewTag("div")
	innerDiv.AddAttrib("id", "innerdiv")
	innerDiv.AddStyle("overflow", "hidden")
	innerDiv.AddStyle("padding-right", "0.5em")
	innerDiv.AddStyle("display", "inline-block")

	inputText := innerDiv.AddNewTag("input")
	inputText.AddAttrib("id", "inputtext")
	inputText.AddAttrib("name", "q")
	inputText.AddAttrib("size", "40")
	inputText.AddStyle("padding", "0.25em")
	inputText.CustomSansSerif("Armata")
	inputText.AddStyle("background-color", "#f0f0f0")
	if roundedLook {
		inputText.RoundedBox()
	} else {
		inputText.AddStyle("border", "none")
	}

	// inputButton := form.AddNewTag("input")
	// inputButton.AddAttrib("id", "inputbutton")
	// // The position is in the margin
	// inputButton.AddStyle("margin", "0.08em 0 0 0.4em")
	// inputButton.AddStyle("padding", "0.2em 0.6em 0.2em 0.6em")
	// inputButton.AddStyle("float", "right")
	// inputButton.AddAttrib("type", "submit")
	// inputButton.AddAttrib("value", buttonText)
	// inputButton.SansSerif()
	// //inputButton.AddStyle("overflow", "hidden")
	// if roundedLook {
	// 	inputButton.RoundedBox()
	// } else {
	// 	inputButton.AddStyle("border", "none")
	// }

	return div
}
Exemple #3
0
// Generate tags for the menu based on a list of "MenuDescription:/menu/url"
func MenuSnippet(menuEntries MenuEntries) *onthefly.Page {
	var a, li, sep *onthefly.Tag

	page, ul := onthefly.StandaloneTag("ul")
	ul.AddAttrib("class", "menuList")
	//ul.AddStyle("list-style-type", "none")
	//ul.AddStyle("float", "left")
	//ul.AddStyle("margin", "0")

	for i, menuEntry := range menuEntries {

		li = ul.AddNewTag("li")
		li.AddAttrib("class", "menuEntry")

		// TODO: Make sure not duplicate ids are added for two menu entries named "Hi there" and "Hi you". Add i to string?
		menuId := "menu" + menuEntry.id
		li.AddAttrib("id", menuId)

		// All menu entries are now hidden by default!
		//li.AddStyle("display", "none")
		//li.AddStyle("display", "inline")

		li.SansSerif()
		//li.CustomSansSerif("Armata")

		// For every element, except the first one
		if i > 0 {
			// Insert a '|' character in a div
			sep = li.AddNewTag("div")
			sep.AddContent("|")
			sep.AddAttrib("class", "separator")
		}

		a = li.AddNewTag("a")
		a.AddAttrib("class", "menulink")
		a.AddAttrib("href", menuEntry.url)
		a.AddContent(menuEntry.text)

	}

	return page
}