<s> from django import forms <EOL> from django . contrib . admin import widgets as admin_widgets <EOL> from django . forms . widgets import flatatt <EOL> from django . utils . html import conditional_escape <EOL> from django . template import Context , loader <EOL> from pagedown import settings as pagedown_settings <EOL> from pagedown . utils import compatible_staticpath <EOL> try : <EOL> from django . utils . encoding import force_unicode <EOL> except ImportError : <EOL> from django . utils . encoding import force_text as force_unicode <EOL> class PagedownWidget ( forms . Textarea ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> self . show_preview = kwargs . pop ( "<STR_LIT>" , pagedown_settings . SHOW_PREVIEW ) <EOL> self . template = kwargs . pop ( "<STR_LIT>" , pagedown_settings . WIDGET_TEMPLATE ) <EOL> self . css = kwargs . pop ( "<STR_LIT>" , pagedown_settings . WIDGET_CSS ) <EOL> super ( PagedownWidget , self ) . __init__ ( * args , ** kwargs ) <EOL> def _media ( self ) : <EOL> return forms . Media ( <EOL> css = { <EOL> "<STR_LIT:all>" : self . css <EOL> } , <EOL> js = ( <EOL> compatible_staticpath ( "<STR_LIT>" ) , <EOL> compatible_staticpath ( '<STR_LIT>' ) , <EOL> compatible_staticpath ( "<STR_LIT>" ) , <EOL> compatible_staticpath ( "<STR_LIT>" ) , <EOL> compatible_staticpath ( '<STR_LIT>' ) , <EOL> compatible_staticpath ( "<STR_LIT>" ) , <EOL> ) ) <EOL> media = property ( _media ) <EOL> def render ( self , name , value , attrs = None ) : <EOL> if value is None : <EOL> value = "<STR_LIT>" <EOL> final_attrs = self . build_attrs ( attrs , name = name ) <EOL> if "<STR_LIT:class>" not in final_attrs : <EOL> final_attrs [ "<STR_LIT:class>" ] = "<STR_LIT>" <EOL> final_attrs [ "<STR_LIT:class>" ] += "<STR_LIT>" <EOL> template = loader . get_template ( self . template ) <EOL> context = Context ( { <EOL> "<STR_LIT>" : flatatt ( final_attrs ) , <EOL> "<STR_LIT:body>" : conditional_escape ( force_unicode ( value ) ) , <EOL> "<STR_LIT:id>" : final_attrs [ "<STR_LIT:id>" ] , <EOL> "<STR_LIT>" : self . show_preview , <EOL> } ) <EOL> return template . render ( context ) <EOL> class AdminPagedownWidget ( PagedownWidget , admin_widgets . AdminTextareaWidget ) : <EOL> class Media : <EOL> css = { <EOL> "<STR_LIT:all>" : ( compatible_staticpath ( "<STR_LIT>" ) , ) <EOL> } <EOL> js = ( <EOL> compatible_staticpath ( "<STR_LIT>" ) , <EOL> ) </s>
