diff options
author | florent <florent.pigout@gmail.com> | 2011-07-09 00:33:26 (GMT) |
---|---|---|
committer | florent <florent.pigout@gmail.com> | 2011-07-09 00:33:26 (GMT) |
commit | 0767eedcd06485f30ee6b00df348b22847c7c7ad (patch) | |
tree | de339586453b0b638889ec607f4ded7de2edc05a /templates | |
parent | 89198c864831bea0a17f136b897aebc59f606166 (diff) |
make the flask based tools more clean for a nicer use -> move requirement to lib dir + limit import code to the minimumHEADmaster
Diffstat (limited to 'templates')
-rw-r--r-- | templates/_helpers.html | 51 | ||||
-rw-r--r-- | templates/layout.html | 13 | ||||
-rw-r--r-- | templates/nutriweb/eating.html | 15 | ||||
-rw-r--r-- | templates/nutriweb/spare-time.html | 12 |
4 files changed, 91 insertions, 0 deletions
diff --git a/templates/_helpers.html b/templates/_helpers.html new file mode 100644 index 0000000..f541437 --- /dev/null +++ b/templates/_helpers.html @@ -0,0 +1,51 @@ +{% macro link_to(text, endpoint) -%} + <a href="{{ url_for(endpoint, **kwargs) }}">{{ text }}</a> +{%- endmacro %} + +{% macro options(_, name, option_list, current, action) -%} + <div class='{{ name }}'> + <h1>{{ _(name) }}</h1> + <form name='{{ name }}' action='{{ action }}' method="post"> + {% for opt in option_list %} + <input type='radio' name='{{ name }}' value='{{ opt }}' {% if opt == current %}checked{% endif %} />{{ _(opt) }}<br /> + {% endfor %} + </form> + <script> + <!-- + $(document).ready(function() { + $(".{{ name }} input[type='radio']").change( function() { + $(".{{ name }} form").submit(); + }); + }); + --> + </script> + </div> +{%- endmacro %} + +{% macro options_ajax(_, name, option_list, current, action) -%} + <div class='{{ name }}'> + <h1>{{ _(name) }}</h1> + <form name='{{ name }}'> + {% for opt in option_list %} + <input type='radio' name='{{ name }}' value='{{ opt }}' {% if opt == current %}checked{% endif %} />{{ _(opt) }}<br /> + {% endfor %} + </form> + <script> + <!-- + $(document).ready(function() { + $(".{{ name }} input[type='radio']").change( function() { + $.ajax({ + url: '{{ action }}', + type: 'POST', + data: ({ '{{ name }}' : $(this).val()}), + success: function(data) { + var _el = $('#result'); + _el.html(data.word); + } + }); + }); + }); + --> + </script> + </div> +{%- endmacro %} diff --git a/templates/layout.html b/templates/layout.html new file mode 100644 index 0000000..a00af4d --- /dev/null +++ b/templates/layout.html @@ -0,0 +1,13 @@ +<!doctype html> +{% from "_helpers.html" import link_to %} +{% from "_helpers.html" import options %} +{% from "_helpers.html" import options_ajax %} +<head> + <title>{{ title }}</title> + <script src='/static/js/jquery.js' }}" type="text/javascript"></script> + {% block head %}{% endblock %} +</head> + +<body> + {% block content %}{% endblock %} +</body> diff --git a/templates/nutriweb/eating.html b/templates/nutriweb/eating.html new file mode 100644 index 0000000..78d9dcd --- /dev/null +++ b/templates/nutriweb/eating.html @@ -0,0 +1,15 @@ +{% extends "layout.html" %} +{% block content %} + +{{ other_dict.word1 }} + +<div id='result'> +</div> + +<div id='difficulty'> + {{ options(_, 'difficutly', ['easy', 'advanced'], '', '/eating') }} +<div> +<div id='difficulty-ajax'> + {{ options_ajax(_, 'difficutly-ajax', ['easy', 'advanced'], '', '/eating') }} +<div> +{% endblock %} diff --git a/templates/nutriweb/spare-time.html b/templates/nutriweb/spare-time.html new file mode 100644 index 0000000..07af6bd --- /dev/null +++ b/templates/nutriweb/spare-time.html @@ -0,0 +1,12 @@ +{% extends "layout.html" %} +{% block title %}{{ _('Story') }}{% endblock %} +{% block content %} +<h1>{{ _('Story') }}</h1> +<div id='helo'> +</div> +<script> +<!-- +$('#helo').html( {{ _('JQuery is working ...') }}); +--> +</script> +{% endblock %} |