<s> import re <EOL> from django import template <EOL> from django . utils . safestring import mark_safe <EOL> from django . conf import settings <EOL> from microblogging . templatetags . microblogging_tags import ( <EOL> render_tweet_text as _render_tweet_text , <EOL> user_ref_re , <EOL> make_user_link , <EOL> smilize <EOL> ) <EOL> from tagging . templatetags . tagging_tags import tag_ref_re , make_tag_link <EOL> register = template . Library ( ) <EOL> register . filter ( "<STR_LIT>" , smilize ) <EOL> @ register . simple_tag <EOL> def render_markup_name ( post ) : <EOL> return dict ( settings . MARKUP_CHOICES ) . get ( post . markup , '<STR_LIT>' ) <EOL> @ register . simple_tag <EOL> def render_tweet_text ( tweet ) : <EOL> """<STR_LIT>""" <EOL> text = _render_tweet_text ( tweet ) <EOL> text = template . defaultfilters . urlize ( text ) <EOL> return text <EOL> @ register . inclusion_tag ( "<STR_LIT>" ) <EOL> def profile_link ( member ) : <EOL> return { '<STR_LIT>' : member } <EOL> @ register . inclusion_tag ( "<STR_LIT>" ) <EOL> def avatar_link ( member , avatar_size ) : <EOL> return { '<STR_LIT>' : member , '<STR_LIT>' : avatar_size } <EOL> @ register . filter <EOL> def profilize ( text ) : <EOL> """<STR_LIT>""" <EOL> text = user_ref_re . sub ( make_user_link , text ) <EOL> return mark_safe ( text ) <EOL> @ register . filter <EOL> def tagalize ( text ) : <EOL> """<STR_LIT>""" <EOL> text = tag_ref_re . sub ( make_tag_link , text ) <EOL> return mark_safe ( text ) <EOL> class_converter = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } <EOL> @ register . filter <EOL> def is_checkbox ( field ) : <EOL> return field . field . widget . __class__ . __name__ . lower ( ) == "<STR_LIT>" <EOL> @ register . filter <EOL> def is_fileinput ( field ) : <EOL> return field . field . widget . __class__ . __name__ . lower ( ) . endswith ( "<STR_LIT>" ) <EOL> @ register . filter <EOL> def with_class ( field ) : <EOL> class_name = field . field . widget . __class__ . __name__ . lower ( ) <EOL> class_name = class_converter . get ( class_name , class_name ) <EOL> if "<STR_LIT:class>" in field . field . widget . attrs : <EOL> field . field . widget . attrs [ '<STR_LIT:class>' ] += "<STR_LIT>" % class_name <EOL> else : <EOL> field . field . widget . attrs [ '<STR_LIT:class>' ] = class_name <EOL> field . field . widget . attrs [ '<STR_LIT:class>' ] += "<STR_LIT>" <EOL> return unicode ( field ) </s>
