예제 #1
0
파일: example.go 프로젝트: Palats/stdweb
func main() {
	stdweb.ParseAndRun()
	defer stdweb.Stop()

	stdweb.Page.SetTitle("Plop")

	stdweb.Page.CSS("main").Set("body { background: #fcecec; }")
	body := bodyTpl.New(stdweb.Page.Body())

	go func() {
		ui := body.Slot("ev")

		for ev := range body.Events("foo").Chan() {
			ui.Set(fmt.Sprintf("%+v", ev))
		}
	}()

	i := 0
	counter := counterTpl.New(body.Slot("count"))
	for {
		i++
		stdweb.Page.SetTitle(fmt.Sprintf("Example %d", i))
		counter.SetData(i)
		time.Sleep(time.Second)
	}
}
예제 #2
0
파일: bootstrap.go 프로젝트: Palats/stdweb
func main() {
	stdweb.ParseAndRun()
	defer stdweb.Stop()

	widget.Bootstrap3_3(stdweb.Page)

	// The Bootstrap starter template has actually a lot of extra CSS and HTML.
	stdweb.Page.CSS("bootstrap").Set(`
        body {
            padding-top: 50px;
        }
        .starter-template {
            padding: 40px 15px;
            text-align: center;
        }
    `)
	stdweb.Page.Body().Set(`
        <nav class="navbar navbar-inverse navbar-fixed-top">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">Project name</a>
                </div>
                <div id="navbar" class="collapse navbar-collapse">
                    <ul class="nav navbar-nav">
                        <li class="active"><a href="#">Home</a></li>
                        <li><a href="#about">About</a></li>
                        <li><a href="#contact">Contact</a></li>
                    </ul>
                </div><!--/.nav-collapse -->
            </div>
        </nav>

        <div class="container">
            <div class="starter-template">
                <h1>Bootstrap starter template</h1>
                <p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p>
            </div>
        </div><!-- /.container -->
    `)

	select {}
}