Development of an internal social media platform with personalised dashboards for students
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.

METADATA 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. Metadata-Version: 2.0
  2. Name: django-taggit-templatetags2
  3. Version: 1.6.1
  4. Summary: Templatetags for django-taggit.
  5. Home-page: https://github.com/fizista/django-taggit-templatetags2
  6. Author: Wojciech Banas
  7. Author-email: fizista@gmail.com
  8. License: BSD
  9. Keywords: django taggit tags tagcloud taglist tagging tag
  10. Platform: UNKNOWN
  11. Classifier: Development Status :: 5 - Production/Stable
  12. Classifier: Programming Language :: Python
  13. Classifier: Programming Language :: Python :: 3
  14. Classifier: Environment :: Web Environment
  15. Classifier: Intended Audience :: Developers
  16. Classifier: License :: OSI Approved :: BSD License
  17. Classifier: Operating System :: OS Independent
  18. Classifier: Framework :: Django
  19. Requires-Dist: django (>=1.5)
  20. Requires-Dist: django-classy-tags (>=0.5.1)
  21. Requires-Dist: django-taggit (>=0.12)
  22. Provides-Extra: test
  23. Requires-Dist: tox (>=1.7); extra == 'test'
  24. ============
  25. Instructions
  26. ============
  27. This is a reusable django app which adds some templatetags to django-taggit_.
  28. This is a fork the application "django-taggit-templatetags".
  29. django-taggit-templatetags2 requires Django 1.6 or greater.
  30. The application works well under python 2.7 and 3.x
  31. Installation
  32. ============
  33. Just install ``django-taggit-templatetags2`` via ``pip``::
  34. $ pip install django-taggit-templatetags2
  35. After installing and configuring django-taggit_, just add ``taggit_templatetags2`` to your ``INSTALLED_APPS`` in your ``settings.py``::
  36. INSTALLED_APPS = (
  37. ...
  38. 'taggit_templatetags2',
  39. ...
  40. )
  41. Usage
  42. =====
  43. Now there are some templatetags enabled, at the moment only to create lists of
  44. tags and tag-clouds.
  45. In your templates, you need to load ``taggit_templatetags2_tags``::
  46. ...
  47. {% load taggit_templatetags2_tags %}
  48. ...
  49. ---------
  50. Tagdetail
  51. ---------
  52. List of tags for the selected object::
  53. {% get_tags_for_object <some_model_object> as "tags" %}
  54. --------
  55. Taglists
  56. --------
  57. After loading ``taggit_templatetags2_tags`` you can create a list of tags for the
  58. whole project (in the sense of djangoproject), for an app (in the sense of djangoapp),
  59. for a model-class (to get a list for an instance of a model, just use its tag-field).
  60. For the tags of a project, just do::
  61. {% get_taglist as tags %}
  62. For the tags of an app, just do::
  63. {% get_taglist as tags for 'yourapp' %}
  64. For the tags of a model, just do::
  65. {% get_taglist as tags for 'yourapp.yourmodel' %}
  66. You can also customize the name of the tags manager in your model (the default is *tags*)::
  67. {% get_taglist as tags for 'yourapp.yourmodel:yourtags' %}
  68. No matter what you do, you have a list of tags in the ``tags`` template variable.
  69. You can now iterate over it::
  70. <ul>
  71. {% for tag in tags %}
  72. <li>{{tag}} ({{tag.num_times}})</li>
  73. {% endfor %}
  74. </ul>
  75. As you can see, each tag has an attribute ``num_times`` which declares how many
  76. times it was used. The list of tags is sorted descending by ``num_times``.
  77. Inclusion-Tag
  78. -------------
  79. For convenience, there's an inclusion-tag. It's used analogue. For example,
  80. for a taglist of a model, just do::
  81. {% include_taglist 'yourapp.yourmodel' %}
  82. ---------
  83. Tagclouds
  84. ---------
  85. A very popular way to navigate through tags is a tagcloud_. This app provides
  86. some tags for that::
  87. {% get_tagcloud as tags %}
  88. or::
  89. {% get_tagcloud as tags for 'yourapp' %}
  90. or::
  91. {% get_tagcloud as tags for 'yourapp.yourmodel' %}
  92. respectivly. The resulting list of tags is ordered by their ``name`` attribute.
  93. Besides the ``num_items`` attribute, there's a ``weight`` attribute. Its maximum
  94. and minimum may be specified as the settings_ section reads.
  95. Inclusion-Tag: tag cloud
  96. ------------------------
  97. Even for the tagcloud there's an inclusion-tag. For example, for a tagcloud
  98. of a model, just do::
  99. {% include_tagcloud 'yourapp.yourmodel' %}
  100. Inclusion-Tag: tag canvas
  101. -------------------------
  102. TagCanvas_ is a Javascript class which will draw and animate a HTML5 canvas
  103. based tag cloud. You can use this library in your application as follows::
  104. <!-- Somewhere before the tag include_tagcanvas. For example, in the "head". -->
  105. {% include "taggit_templatetags2/tagcanvas_include_js_static.html" %}
  106. {% include_tagcanvas 'element_id' 'width px' 'height px' 'some-url-name' 'yourapp.yourmodel' %}
  107. - element_id - name to create identifiers for html tags
  108. - some-url-name - url to view a list of objects for the selected tag. Default: *tagcanvas-list*.
  109. For example, some-url-name='myurlname', then it must be an entry in urls.py
  110. file like this::
  111. from taggit_templatetags2.views import TagCanvasListView
  112. urlpatterns = patterns(
  113. ...
  114. url(r'^tag-list/(?P<tag_id>.*)/(?P<tag_slug>.*)/',
  115. TagCanvasListView.as_view(), name='myurlname'),
  116. )
  117. Or you can use the default view, and then you have to add the following things:
  118. - in urls.py::
  119. from taggit_templatetags2 import urls as taggit_templatetags2_urls
  120. urlpatterns = patterns(
  121. ...
  122. url(r'^tags/', include('taggit_templatetags2.urls')),
  123. )
  124. - override template "taggit_templatetags2/tagcanvas_base.html" and
  125. - override template "taggit_templatetags2/tagcanvas_list_item.html" to customize the look
  126. To use this inclusion-tag, make sure that 'django.core.context_processors.static'
  127. appears somewhere in your TEMPLATE_CONTEXT_PROCESSORS setting.
  128. .. _settings:
  129. Settings
  130. ========
  131. There are a few settings to be set:
  132. TAGGIT_TAGCLOUD_MIN (default: 1.0)
  133. This specifies the minimum of the weight attribute of a tagcloud's tags.
  134. TAGGIT_TAGCLOUD_MAX (default: 6.0)
  135. This specifies the maximum of the weight attribute of a tagcloud's tags.
  136. If you want to use the weight as font-sizes, just do as follows::
  137. <font size={{tag.weight|floatformat:0}}>{{tag}}</font>
  138. So the weights are converted to integer values.
  139. If you're using your own Tag and/or TaggedItem models rather than the default
  140. ones (`Custom Tagging`_), you can specify a tuple for each model (app,model_name)
  141. TAGGIT_TAG_MODEL = ('myapp','MyTag')
  142. default: ('taggit', 'Tag')
  143. TAGGIT_TAGGED_ITEM_MODEL = ('myapp','MyTaggedItem')
  144. default: ('taggit', 'TaggedItem')
  145. TAGGIT_LIMIT = 234
  146. Number items for tag cloud.
  147. default: 10
  148. TAGGIT_TAG_LIST_ORDER_BY = 'name'
  149. Order for the queryset used to generate the list.
  150. default: -num_times
  151. TAGGIT_TAG_CLOUD_ORDER_BY = '-num_times'
  152. Order for the queryset used to generate the list.
  153. default: name
  154. Testing
  155. =======
  156. Clone code repository::
  157. $ git clone https://github.com/fizista/django-taggit-templatetags.git
  158. Installation dependencies needed to test the application::
  159. $ pip install -e <path to the application>[tests]
  160. Starting tests::
  161. $ python ./develop.py test
  162. Starting test coverage::
  163. $ python ./develop.py manage test
  164. Starting tox tests::
  165. $ tox
  166. Thanks
  167. ======
  168. Thanks to the python- and django-community, in particular to `Alex Gaynor`_,
  169. the inventor of django-taggit_ and a wonderful guy to argue with.
  170. Thanks to `Mathijs de Bruin`_ as well for his helpful pull requests.
  171. .. _django-taggit: http://pypi.python.org/pypi/django-taggit
  172. .. _tagcloud: http://www.wikipedia.org/wiki/Tagcloud
  173. .. _Alex Gaynor: http://alexgaynor.net/
  174. .. _Mathijs de Bruin: http://github.com/dokterbob
  175. .. _Custom Tagging: http://django-taggit.readthedocs.org/en/latest/custom_tagging.html
  176. .. _TagCanvas: http://www.goat1000.com/tagcanvas.php