def render(self, req, content, new=False): html = """ <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("td").click(paint_square); $("input[name=brush]")[0].checked = true; }); %s </script></head><body>""" % lib_js() if new is True: html += render_addform(req.GET.get('h'), req.GET.get('w')) html += draw(req, content, self.props) html += render_controls(some_colors) html += """ <form method="POST" onsubmit="serialize();"> <input type="hidden" id="resource_body" name="svenweb.resource_body" value="%s"></textarea> <label for="svenweb.commit_message">Commit message</label> <input name="svenweb.commit_message"></input> <input name="svenweb.mimetype" type="hidden" value="text/csv+hbmp" /> <input type="submit" /> </form> </body></html>""" % (content) return Response(html)
def __call__(self, environ, start_response): req = Request(environ) res = req.get_response(self.app) if res.status_int != 200: return res(environ, start_response) if res.content_type != 'text/html': return res(environ, start_response) d = pq(res.body) match = d("pre.hbmp") if not len(match): return res(environ, start_response) props = RequestProperties() for i in range(len(match)): el = match.eq(i) content = el.html() rendered = draw(req, content, props) el.html(rendered) res.body = str(d) return res(environ, start_response)
def render(self, req, content): html = ( """ <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("td").click(go); }); %s </script></head><body>""" % lib_js() ) html += draw(req, content, self.props) html += "</body></html>" return Response(html)