Created
November 13, 2012 14:47
-
-
Save techniq/4066098 to your computer and use it in GitHub Desktop.
Flask-Admin WTForms boostrap-wysihtml5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script> | |
<link href='/static/bootstrap/css/bootstrap.css' rel='stylesheet' type='text/css' /> | |
<link href='/static/wysihtml5/bootstrap-wysihtml5.css' rel='stylesheet' type='text/css' /> | |
</head> | |
<body> | |
... | |
<script src="/static/wysihtml5/wysihtml5-0.3.0.min.js"></script> | |
<script type="text/javascript"> | |
$('[data-role="wysihtml5"]').wysihtml5(); | |
</script> | |
<script type="text/javascript">if (!NREUMQ.f) { NREUMQ.f=function() { | |
NREUMQ.push(["load",new Date().getTime()]); | |
var e=document.createElement("script"); | |
e.type="text/javascript"; | |
e.src=(("http:"===document.location.protocol)?"http:":"https:") + "//" + | |
"d1ros97qkrwjf5.cloudfront.net/42/eum/rum.js"; | |
document.body.appendChild(e); | |
if(NREUMQ.a)NREUMQ.a(); | |
}; | |
NREUMQ.a=window.onload;window.onload=NREUMQ.f; | |
}; | |
NREUMQ.push(["nrfj","beacon-3.newrelic.com","5fea191aea","2478111","dVdXRUsJXllcERtQEl8XXlhKEh1HWBQ=",17,189,new Date().getTime(),"","","","",""]);</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask.ext.admin.contrib.sqlamodel import ModelView | |
from application.helpers.forms.fields import WysiHtml5TextAreaField | |
class ExampleModelView(AdminModelView): | |
form_overrides = dict( | |
body=WysiHtml5TextAreaField | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from wtforms import fields | |
from .widgets import WysiHtml5Widget | |
class WysiHtml5TextAreaField(fields.TextAreaField): | |
widget = WysiHtml5Widget() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from wtforms.widgets import TextArea, HTMLString, html_params | |
from cgi import escape | |
class WysiHtml5Widget(TextArea): | |
def __call__(self, field, **kwargs): | |
kwargs['data-role'] = u'wysihtml5' | |
kwargs['class'] = u'span8' | |
kwargs['rows'] = 10 | |
return super(WysiHtml5Widget, self).__call__(field, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this would be so much easier to read without all that newrelic tracking crud in it