Django Library PyGal
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

tag_help.py 819B

1234567891011121314151617181920212223242526272829
  1. from django import template
  2. import pygal
  3. register = template.Library()
  4. @register.simple_tag(name='tag_pos_x')
  5. def tag_pos_x(tag, wrapper_instance):
  6. return 100. * (tag.topleft_x) / wrapper_instance.width
  7. @register.simple_tag(name='tag_pos_y')
  8. def tag_pos_y(tag, wrapper_instance):
  9. return 100. * (tag.topleft_y) / wrapper_instance.height
  10. @register.simple_tag(name='tag_width')
  11. def tag_width(tag, wrapper_instance):
  12. return 100. * (tag.bottomright_x - tag.topleft_x) / wrapper_instance.width
  13. @register.simple_tag(name='tag_height')
  14. def tag_height(tag, wrapper_instance):
  15. return 100. * (tag.bottomright_y - tag.topleft_y) / wrapper_instance.height
  16. @register.simple_tag(name='tag_editurl', takes_context=True)
  17. def tag_editurl(context, tag):
  18. return pygal.url_tagedit(context['request'], tag.id)