# HG changeset patch # User sean # Date 1438773865 -7200 # Node ID 3a9cb396905f103faadc5870444085a4d396b798 # Parent 63b9f41c3008d8cb725fd2571fec2bc11c379f1d made a template how to use the web_view module diff -r 63b9f41c3008 -r 3a9cb396905f dash.conf --- a/dash.conf Wed Aug 05 12:37:33 2015 +0200 +++ b/dash.conf Wed Aug 05 13:24:25 2015 +0200 @@ -19,7 +19,7 @@ # hint: the top-bar has got a height of 5%! [settings] -show_top_bar=True +show_top_bar=False # Tiles: # example: @@ -70,3 +70,8 @@ type=d3js div_name=techintern script=display_issues_techintern + +[tile5] +type=d3js +div_name=webview_test +script=webview_template diff -r 63b9f41c3008 -r 3a9cb396905f dash.py --- a/dash.py Wed Aug 05 12:37:33 2015 +0200 +++ b/dash.py Wed Aug 05 13:24:25 2015 +0200 @@ -78,7 +78,7 @@ # hint: the top-bar has got a height of 5%! [settings] -show_top_bar=True +show_top_bar=False # Tiles: # example: @@ -103,16 +103,22 @@ # status: (up / down) [required] # ONLY FOR DEBUGGING PURPOSE - WILL BE REMOVED LATER # simulates up and down events for mon-type-tiles +# +# div_name: (identifier) [required for d3js-types] +# +# script: (name of a script without extension) [required for d3js-types0] +# + [tile1] type=mon source=192.168.0.2 -status=up +status=down [tile2] type=mon source=192.168.2.3 -status=down +status=up [tile3] type=mon @@ -120,9 +126,9 @@ status=up [tile4] -type=mon -source=192.168.4.3 -status=down +type=d3js +div_name=techintern +script=display_issues_techintern """) file.close() diff -r 63b9f41c3008 -r 3a9cb396905f modules/roundup_cc/roundup_content_data/tech_intern.db Binary file modules/roundup_cc/roundup_content_data/tech_intern.db has changed diff -r 63b9f41c3008 -r 3a9cb396905f modules/roundup_cc/roundup_content_data/test_reference.db Binary file modules/roundup_cc/roundup_content_data/test_reference.db has changed diff -r 63b9f41c3008 -r 3a9cb396905f modules/roundup_cc/webview_template.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/roundup_cc/webview_template.py Wed Aug 05 13:24:25 2015 +0200 @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 + +""" Simple Template to use the Web-View Module + +author: Sean Engelhardt + +(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 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 = """ + + +
+ Hello World! +
+ """ % target_div_name + + return html_string diff -r 63b9f41c3008 -r 3a9cb396905f views/hello_template.tpl --- a/views/hello_template.tpl Wed Aug 05 12:37:33 2015 +0200 +++ b/views/hello_template.tpl Wed Aug 05 13:24:25 2015 +0200 @@ -29,7 +29,7 @@ "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember")[today.month-1] - number_of_rows = 2 + number_of_rows = 1 ################# # viewport size # @@ -194,7 +194,7 @@ end elif tile["type"] == "d3js" : type = "chart" - status = "techintern" + status = tile["div_name"] tile_content = roundup_cc.make_chart(tile["script"], tile["div_name"]) end %>