annotate modules/roundup_cc/webview_template.py @ 16:f89ad628f831

adding the renamed files
author sean
date Wed, 05 Aug 2015 13:33:15 +0200
parents 3a9cb396905f
children
rev   line source
14
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
1 #!/usr/bin/env python3
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
2
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
3 """ Simple Template to use the Web-View Module
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
4
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
5 author: Sean Engelhardt <sean.engelhardt@intevation.de>
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
6
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
7 (c) 2010,2015 by Intevation GmbH
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
8
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
9 This is Free Software unter the terms of the
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
10 GNU GENERAL PUBLIC LICENSE Version 3 or later.
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
11 See http://www.gnu.org/licenses/gpl-3.0.txt for details
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
12
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
13 ---
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
14 How to write a web-view module?
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
15 ---
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
16
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
17 declare a specific tile in the dash.conf. for example:
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
18
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
19 ---
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
20 [tile5]
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
21 type=d3js
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
22 div_name=webview_test
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
23 script=webview_template
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
24 ---
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
25 (this will work for this file, see dash.conf for details)
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
26
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
27 bottledash will look for a "get_chart(target_div_name)"-methode wich shall
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
28 return valid HTML-code (as string!).
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
29
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
30 the "target_div_name" is the "div_name" you delared in the dash.conf-file.
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
31 In our case, "tile5" would be in the css-class "webview_test". You can use
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
32 the "target_div_name" for dynamic DOM-Manipulations (like with d3js and jQuery)
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
33
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
34 If you want to use a python import, please use "importlib" inside the
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
35 get_chart-function.
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
36
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
37 see <https://docs.python.org/3/library/importlib.html> for details
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
38
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
39 To not try to import your own modules using the regular
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
40 python import-keyword! You can however import every regular
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
41 python-standard-library using the "import" keyword
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
42
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
43 """
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
44
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
45 import importlib
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
46
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
47 def get_chart(target_div_name):
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
48 html_string = """
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
49 <style type = text/css>
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
50
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
51 .%s {
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
52 color: red;
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
53 }
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
54
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
55 </style>
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
56
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
57 <div id = "hello">
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
58 Hello World!
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
59 </div>
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
60 """ % target_div_name
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
61
3a9cb396905f made a template how to use the web_view module
sean
parents:
diff changeset
62 return html_string
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)