Django Library PyGal
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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)