Skip to content

Commit

Permalink
fixed template with themes
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Oct 20, 2012
1 parent d599a45 commit 2ef1572
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 50 deletions.
10 changes: 5 additions & 5 deletions blockd3_tests/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def make_app(env="dev"):

url_root = {
"dev": "/",
"prod": "/dist/"
"prod": "/dist/",
"test": "/dist/"
}[env]

app_home = os.path.dirname(__file__)
Expand All @@ -33,13 +34,12 @@ def make_app(env="dev"):
static_url_path="/dist",
template_folder="..",
static_folder=opa(opj(app_home, "..", "dist"))
)
),
"test": dict(
static_url_path="/dist",
template_folder="../dist",
static_folder=opa(opj(app_home, "..", "dist"))
)
)
}[env]

app = Flask(__name__, **cfg)
Expand All @@ -52,15 +52,15 @@ def home():

kwargs = {}
if env != "test":
kwargs(assets())
kwargs.update(assets())

return render_template("index.html", env=env, **kwargs)

@app.route(url_root + "frame/")
def frame():
kwargs = {}
if env != "test":
kwargs(assets())
kwargs.update(assets("../frame/"))

return render_template("frame/index.html", env=env, **kwargs)

Expand Down
14 changes: 13 additions & 1 deletion fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,22 @@ def serve_dev():
def serve_prod():
serve("prod")

@task
def serve_test():
serve("test")


def serve(env):
blockd3_path = os.path.abspath(os.path.dirname(__file__))
sys.path.append(blockd3_path)

from blockd3_tests.app import make_app
app = make_app(env)
app.run(port=[5000, 5001][env=="prod"])

port = {
"dev": 5000,
"prod": 5001,
"test": 5002
}[env]

app.run(port=port)
8 changes: 4 additions & 4 deletions frame/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

<body id="frame">
{% if env == "dev" %}
{% for script in scripts %}
<script type="text/javascript" src="../{{ script }}"></script>
{% endfor %}
{% for script in scripts %}
<script type="text/javascript" src="../{{ script }}"></script>
{% endfor %}
{% else %}
<script type="text/javascript" src="../js/blockd3-min.js"></script>
<script type="text/javascript" src="../js/blockd3-min.js"></script>
{% endif %}

<script type="text/javascript">
Expand Down
56 changes: 16 additions & 40 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<link rel="shortcut icon" href="./favicon.ico" />

{% if env == "dev" %}
{% for style in styles %}
<link rel="stylesheet" href="./{{ style }}">
{% endfor %}
{% for style in styles %}
<link rel="stylesheet" href="./{{ style }}">
{% endfor %}
{% else %}
<link rel="stylesheet" href="./css/blockd3-min.css">
<link rel="stylesheet" href="./css/blockd3-min.css">
{% endif %}

<link rel="stylesheet" id="theme_link">
Expand Down Expand Up @@ -60,18 +60,12 @@
<ul class="dropdown-menu">
<li><a id="load_xml" href="#">From XML File</a></li>
<li class="nav-header">Examples</li>
<!--###EXAMPLES-->
{% for example_name, example in examples %}
<li>
<a href="#example" data-blockd3-example="simplest">Simplest
<a href="#example" data-blockd3-example="example">{{ example_name }}
</a>
</li>
<li>
<a href="#example" data-blockd3-example="kitchen_sink">Kitchen Sink</a>
</li>
<li>
<a href="#example" data-blockd3-example="spreadsheet">Spreadsheet</a>
</li>
<!--EXAMPLES###-->
{% endfor %}
</ul>
<form id="file_form">
<input type="file" id="load"/>
Expand Down Expand Up @@ -103,31 +97,13 @@
<i>Default</i>
</a>
</li>
<!--###THEMES-->

{% for theme_name, theme in themes %}
<li>
<a href="#theme" data-blockd3-theme="Amelia">Amelia</a>
<a href="#theme" data-blockd3-theme="{{ theme_name }}">{{ theme_name }}</a>
</li>
<li>
<a href="#theme" data-blockd3-theme="Cerulean">Cerulean</a></li>
<li>
<a href="#theme" data-blockd3-theme="Cyborg">Cyborg</a></li>
<li>
<a href="#theme" data-blockd3-theme="Journal">Journal</a></li>
<li>
<a href="#theme" data-blockd3-theme="Readable">Readable</a></li>
<li>
<a href="#theme" data-blockd3-theme="Slate">Slate</a></li>
<li>
<a href="#theme" data-blockd3-theme="Spacelab">Spacelab</a></li>
<li>
<a href="#theme" data-blockd3-theme="Spruce">Spruce</a></li>
<li>
<a href="#theme" data-blockd3-theme="Superhero">Superhero</a></li>
<li>
<a href="#theme" data-blockd3-theme="United">United</a></li>
<li>
<a href="#theme" data-blockd3-theme="simplex">simplex</a></li>
<!--THEMES###-->
{% endfor %}

</ul>
</div>
<a id="show_about" href="#about" role="button" class="btn" data-toggle="modal">
Expand Down Expand Up @@ -239,11 +215,11 @@ <h3>Confirm Discard</h3>
</div> <!-- /container -->

{% if env == "dev" %}
{% for script in scripts %}
<script type="text/javascript" src="./{{ script }}"></script>
{% endfor %}
{% for script in scripts %}
<script type="text/javascript" src="./{{ script }}"></script>
{% endfor %}
{% else %}
<script type="text/javascript" src="./js/blockd3-min.js"></script>
<script type="text/javascript" src="./js/blockd3-min.js"></script>
{% endif %}

</body>
Expand Down

0 comments on commit 2ef1572

Please sign in to comment.