
cherokee at cherokee-project
Feb 8, 2010, 8:34 AM
Post #1 of 1
(113 views)
Permalink
|
|
[4212] CTK/trunk: Adds a new PropsTable.
|
|
Revision: 4212 http://svn.cherokee-project.com/changeset/4212 Author: alo Date: 2010-02-08 17:34:42 +0100 (Mon, 08 Feb 2010) Log Message: ----------- Adds a new PropsTable. It's the same, without the need of a table. It is still WIP. Modified Paths: -------------- CTK/trunk/CTK/PropsTable.py CTK/trunk/CTK/__init__.py Added Paths: ----------- CTK/trunk/static/css/CTK.css Modified: CTK/trunk/CTK/PropsTable.py =================================================================== --- CTK/trunk/CTK/PropsTable.py 2010-02-08 13:01:40 UTC (rev 4211) +++ CTK/trunk/CTK/PropsTable.py 2010-02-08 16:34:42 UTC (rev 4212) @@ -21,6 +21,7 @@ # from Table import Table +from Widget import Widget, RenderResponse from RawHTML import RawHTML from Submitter import Submitter from Container import Container @@ -66,3 +67,65 @@ def AddConstant (self, key, val): self.constants[key] = val + + +HTML_TABLE = """ +<div class="propstable">%s</div> +""" + +HTML_ENTRY = """ +<div class="entry"> + <div class="title">%(title)s</div> + <div class="widget">%(widget_html)s</div> + <div class="comment">%(comment)s</div> + <div class="after"></div> +</div> +""" + +HEADERS = ['<link rel="stylesheet" type="text/css" href="/CTK/css/CTK.css" />'] + + +class PropsAuto (Widget): + def __init__ (self, url, **kwargs): + Widget.__init__ (self, **kwargs) + self._url = url + self.constants = {} + self.entries = [] + + def AddConstant (self, key, val): + self.constants[key] = val + + def Add (self, title, widget, comment): + # No constants, just the widget + if not self.constants: + self.entries.append ((title, widget, comment)) + return + + # Wrap it + box = Container() + box += widget + for key in self.constants: + box += HiddenField ({'name': key, 'value': self.constants[key]}) + self.entries.append ((title, box, comment)) + + def Render (self): + render = RenderResponse() + + for e in self.entries: + title, widget, comment = e + + submit = Submitter (self._url) + submit += widget + + widget_r = submit.Render() + widget_html = widget_r.html + + html = HTML_ENTRY %(locals()) + + render.html += html + render.js += widget_r.js + render.headers += widget_r.headers + + render.html = HTML_TABLE %(render.html) + render.headers += HEADERS + return render Modified: CTK/trunk/CTK/__init__.py =================================================================== --- CTK/trunk/CTK/__init__.py 2010-02-08 13:01:40 UTC (rev 4211) +++ CTK/trunk/CTK/__init__.py 2010-02-08 16:34:42 UTC (rev 4212) @@ -33,7 +33,7 @@ from TextField import TextField, TextFieldPassword, TextCfg from Checkbox import Checkbox, CheckCfg from Combobox import Combobox, ComboCfg -from PropsTable import PropsTable, PropsTableAuto +from PropsTable import PropsTable, PropsTableAuto, PropsAuto from Template import Template from Server import Server, run, publish, cookie, post, request, cfg from Proxy import Proxy Added: CTK/trunk/static/css/CTK.css =================================================================== --- CTK/trunk/static/css/CTK.css (rev 0) +++ CTK/trunk/static/css/CTK.css 2010-02-08 16:34:42 UTC (rev 4212) @@ -0,0 +1,41 @@ +/* CTK: Cherokee Toolkit + * + * Authors: + * Alvaro Lopez Ortega <alvaro [at] alobbs> + * + * Copyright (C) 2001-2010 Alvaro Lopez Ortega + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + + +/* Styles for CTK/PropsTable.py + */ + +.propstable { + width: 100%; +} + +.propstable .entry .title { + white-space: nowrap; + float: left; + width: 50%; +} + +.propstable .entry .comment { + text-align: left; + color: #888; + font: small "Courier New", Courier, mono; +}
|