1234567891011121314151617181920212223242526272829 |
- from django import template
- import pygal
-
- register = template.Library()
-
-
- @register.simple_tag(name='tag_pos_x')
- def tag_pos_x(tag, wrapper_instance):
- return 100. * (tag.topleft_x) / wrapper_instance.width
-
-
- @register.simple_tag(name='tag_pos_y')
- def tag_pos_y(tag, wrapper_instance):
- return 100. * (tag.topleft_y) / wrapper_instance.height
-
-
- @register.simple_tag(name='tag_width')
- def tag_width(tag, wrapper_instance):
- return 100. * (tag.bottomright_x - tag.topleft_x) / wrapper_instance.width
-
-
- @register.simple_tag(name='tag_height')
- def tag_height(tag, wrapper_instance):
- return 100. * (tag.bottomright_y - tag.topleft_y) / wrapper_instance.height
-
-
- @register.simple_tag(name='tag_editurl', takes_context=True)
- def tag_editurl(context, tag):
- return pygal.url_tagedit(context['request'], tag.id)
|