Skip to content

Instantly share code, notes, and snippets.

@podhmo
Created June 18, 2014 13:32
Show Gist options
  • Save podhmo/c9c45080aa32571e3b85 to your computer and use it in GitHub Desktop.
Save podhmo/c9c45080aa32571e3b85 to your computer and use it in GitHub Desktop.
<%namespace file="./widget.html" name="w"/>
<!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<style type="text/css">
body > .container {padding:40px;}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="span9">
<!-- drop down widget -->
<%w:dropdown name="DropDown" id="dropdownMenu1">
<%w:menu id="first" href="#">Action</%w:menu>
<%w:menu href="#">Another Action</%w:menu>
<%w:menu href="#">Something else here</%w:menu>
<li role="presentation" class="divider"></li>
<%w:menu href="#">Separated link</%w:menu>
</%w:dropdown>
</div>
</div>
</div>
</body>
</html>
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
import os.path
def top_view(request):
from js.bootstrap import bootstrap_css; bootstrap_css.need()
from js.bootstrap import bootstrap_js; bootstrap_js.need()
return {}
if __name__ == '__main__':
here = os.path.dirname(os.path.abspath(__file__))
settings = {"mako.directories": here,
"pyramid.reload_all": True}
config = Configurator(settings=settings)
config.include("pyramid_mako")
config.include("pyramid_fanstatic")
config.add_mako_renderer(".html")
config.add_route('top', '/')
config.add_view(top_view, route_name='top', renderer="bootstrap.html")
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 7654, app)
server.serve_forever()
<%def name="dropdown(name='dropdown',id='')">
<div class="dropdown">
<button class="btn dropdown-toggle" type="button" ${"id={}".format(id) if id else ""} data-toggle="dropdown">
${name}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
${caller.body()}
</ul>
</div>
</%def>
<%def name="menu(href='#', id='')">
<li role="presentation"><a ${"id={}".format(id) if id else ""} role="menuitem" tabindex="-1" href="#">${caller.body()}</a></li>
</%def>
@podhmo
Copy link
Author

podhmo commented Jun 18, 2014

こういう表示になる

<!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<style type="text/css">
  body > .container {padding:40px;}
</style>
<link rel="stylesheet" type="text/css" href="/fanstatic/bootstrap/dist/css/bootstrap.css" />
<script type="text/javascript" src="/fanstatic/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="/fanstatic/bootstrap/dist/js/bootstrap.js"></script></head>
<body>
  <div class="container">
    <div class="row">
    <div class="span9">

<!-- drop down widget -->

<div class="dropdown">
  <button class="btn dropdown-toggle" type="button" id=dropdownMenu1 data-toggle="dropdown">
    DropDown
    <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">


    <li role="presentation"><a id=first role="menuitem" tabindex="-1" href="#">Action</a></li>


    <li role="presentation"><a  role="menuitem" tabindex="-1" href="#">Another Action</a></li>


    <li role="presentation"><a  role="menuitem" tabindex="-1" href="#">Something else here</a></li>

 <li role="presentation" class="divider"></li>

    <li role="presentation"><a  role="menuitem" tabindex="-1" href="#">Separated link</a></li>


  </ul>
</div>


    </div>
    </div>
  </div>
</body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment