diff modules/web_view/webview_template.py @ 16:f89ad628f831

adding the renamed files
author sean
date Wed, 05 Aug 2015 13:33:15 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/web_view/webview_template.py	Wed Aug 05 13:33:15 2015 +0200
@@ -0,0 +1,62 @@
+#!/usr/bin/env python3
+
+""" Simple Template to use the Web-View Module
+
+author: Sean Engelhardt <sean.engelhardt@intevation.de>
+
+(c) 2010,2015 by Intevation GmbH
+
+This is Free Software unter the terms of the
+GNU GENERAL PUBLIC LICENSE Version 3 or later.
+See http://www.gnu.org/licenses/gpl-3.0.txt for details
+
+---
+How to write a web-view module?
+---
+
+declare a specific tile in the dash.conf. for example:
+
+---
+[tile5]
+type=d3js
+div_name=webview_test
+script=webview_template
+---
+(this will work for this file, see dash.conf for details)
+
+bottledash will look for a "get_chart(target_div_name)"-methode wich shall
+return valid HTML-code (as string!).
+
+the "target_div_name" is the "div_name" you delared in the dash.conf-file.
+In our case, "tile5" would be in the css-class "webview_test". You can use
+the "target_div_name" for dynamic DOM-Manipulations (like with d3js and jQuery)
+
+If you want to use a python import, please use "importlib" inside the
+get_chart-function.
+
+see <https://docs.python.org/3/library/importlib.html> for details
+
+To not try to import your own modules using the regular
+python import-keyword! You can however import every regular
+python-standard-library using the "import" keyword
+
+"""
+
+import importlib
+
+def get_chart(target_div_name):
+    html_string = """
+<style type = text/css>
+
+.%s {
+    color: red;
+}
+
+</style>
+
+<div id = "hello">
+    Hello World!
+</div>
+    """ % target_div_name
+
+    return html_string
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)