Esempio n. 1
0
func registerPlugins(plugins []interfaces.Plugin) {
	var err error
	menus = make(map[template.URL]string, len(plugins))
	allPluginsData = make([]func() template.HTML, 0)
	mainTemplate, err = template.New("mainTemplate").Parse(string(utils.ReadHTML("\\static\\template.html")))
	if err != nil {
		log.Fatal(err)
	}
	for _, p := range plugins {
		for _, ep := range p.GetHandlers() {
			switch ep.Type() {
			case interfaces.EndPointAPI:
				handleRequest("/api/v1"+ep.Path(), ep.Handler())
			case interfaces.EndPointContent:
				handleRequest(ep.Path(), ep.Handler())
			default:
				log.Println("Incorrect plugin endpoint type: ", ep)
			}
		}
		for _, static := range p.GetMainContent() {
			menus[static.Path()] = static.Title()
			allPluginsData = append(allPluginsData, static.Data)
			handleStatic(static.Path(), static.Data, static.Title)
		}
	}

	mainPageData := func() template.HTML {
		html := template.HTML("")
		for _, v := range allPluginsData {
			html += v()
		}
		return html
	}

	handleStatic("/", mainPageData, func() string { return "Remote Control" })
}
Esempio n. 2
0
func init() {
	pageContent = utils.ReadHTML("\\static\\plugins\\mouse\\index.html")
}