Commits

Atsushi Odagiri committed 3835522

apply stylesheet.

Comments (0)

Files changed (7)

src/alchemyadmin/__init__.py

         return values
 
 
-    def url_for(self, endpoint, values, method="GET"):
+    def url_for(self, endpoint, values={}, method="GET"):
         return url_for(endpoint, values, method)
 
 

src/alchemyadmin/demo/__init__.py

 from sqlalchemy.orm import *
 from sqlalchemy.ext.declarative import declarative_base
 from datetime import datetime
+from werkzeug import SharedDataMiddleware
 
 Base = declarative_base()
 metadata = Base.metadata
     session.commit()
 
     app = Application(conf, User)
+    import os
+    app = SharedDataMiddleware(app, {
+            '/css':os.path.join(os.path.dirname(__file__), 'static', 'css')
+            })
     return app
 

src/alchemyadmin/demo/static/css/default.css

+html, body {
+    padding:0;
+    margin:0;
+}
+
+body {
+    background:silver;
+}
+
+#content {
+    width:80%;
+    margin-left:auto;
+    margin-right:auto;
+    background:white;
+    padding: 10px;
+}
+
+#header {
+    background: green;
+    color: white;
+    padding: 10px;
+}
+
+#header a {
+    color: white;
+}
+
+thead {
+    background:silver;
+}
+
+table {
+    width: 100%;
+}

src/alchemyadmin/templates/base.html

+<html>
+  <head>
+    {%block head %}
+    <meta http-equiv="content-type" content="text/html;charset=utf8" />
+    {%block style %}
+    <link rel="stylesheet" href="{{request.url_root}}css/default.css" />
+    {%endblock %}
+    {%endblock %}
+  </head>
+  <body>
+    <div id="header">
+      <a href="{{url_for('index')}}">Top</a>
+      {%block header %}
+      {%endblock %}
+    </div>
+    <div id="content">
+      {%block content %}
+      {%endblock %}
+    </div>
+  </body>
+</html>

src/alchemyadmin/templates/index.html

+{%extends "base.html" %}
+{%block content %}
 <ul>
   {%for m in models%}
   <li><a href="{{url_for('model_index', values={'model':m})}}">{{m}}</a></li>
   {%endfor %}
 </ul>
+{%endblock %}

src/alchemyadmin/templates/model/edit.html

+{%extends "base.html" %}
+{%block content %}
 {{model}}
 <form action="{{post_url}}" method="post">
 {{form.render()}}
 <button type="submit">Save</button>
 </form>
+{%endblock%}
 
-

src/alchemyadmin/templates/model/index.html

+{%extends "base.html" %}
+{%block content %}
 {{model}}
 <table>
 {{grid.render()}}
 </table>
+{%endblock %}