Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First implementation, without apps descriptions.

  • Loading branch information...
commit 9f0c066c900bcc14a70a238b4f9eebd29635c2dc 1 parent 63f37ff
Alexander Artemenko authored
5 .gitignore
View
@@ -0,0 +1,5 @@
+*.pyc
+.*.swp
+django_apps.egg-info
+build
+dist
24 LICENSE
View
@@ -0,0 +1,24 @@
+Copyright (c) 2008, Alexander Artemenko
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the django_apps nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY ALEXANDER ARTEMENKO ''AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL ALEXANDER ARTEMENKO BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1  MANIFEST.in
View
@@ -0,0 +1 @@
+recursive-include django_apps/templates *.html
38 README.md
View
@@ -0,0 +1,38 @@
+django-apps
+===========
+
+Installation
+------------
+
+As usual. Place django_apps somewhere in your python path or install it using easy_install:
+
+ easy_install django-apps
+
+Then, add `django_apps` to the `INSTALLED_APPS`.
+
+Usage
+-----
+
+In the any template use template tag `installed_apps` to receive a list
+of installed apps along with some information about them.
+
+I use following code in my template, to show apps names along with
+their versions and descriptions.
+
+ {% load apps_tags %}
+ {% installed_apps as apps %}
+ <table class="apps">
+ {% for app in apps %}
+ <tr>
+ <td>{{ app.name }}</td>
+ <td>{{ app.version }}</td>
+ <td>{{ app.description }}</td>
+ </tr>
+ {% endfor %}
+ </table>
+
+You can find an example result at my own 'Installed Apps' page:
+http://aartemenko.com/about/apps/
+
+Please, note, that descriptions are hardcoded into the code of the `django_apps`.
+
2  django_apps/__init__.py
View
@@ -0,0 +1,2 @@
+VERSION = (0, 1, 0)
+__version__ = '.'.join(map(str, VERSION))
0  django_apps/templatetags/__init__.py
View
No changes.
41 django_apps/templatetags/apps_tags.py
View
@@ -0,0 +1,41 @@
+import re
+from django import template
+from django.conf import settings
+import pdb
+
+register = template.Library()
+
+class InstalledAppsNode(template.Node):
+ def __init__(self, var_name):
+ self.var_name = var_name
+
+ def render(self, context):
+ def get_info(module_name):
+ mod = __import__(module_name)
+ version = getattr(mod, '__version__',
+ getattr(mod, 'VERSION', ''))
+ if isinstance(version, (tuple, list)):
+ version = '.'.join(map(str, version))
+ return dict(name = module_name,
+ version = version,
+ description = '')
+
+ try:
+ context[self.var_name] = [get_info(mod) for mod in settings.INSTALLED_APPS]
+ except Exception, e:
+ context[self.var_name] = e
+ print context[self.var_name]
+ return ''
+
+def installed_apps(parser, token):
+ try:
+ tag_name, arg = token.contents.split(None, 1)
+ except ValueError:
+ raise template.TemplateSyntaxError, "%r tag requires arguments" % token.contents.split()[0]
+ m = re.search(r'as (\w+)', arg)
+ if not m:
+ raise template.TemplateSyntaxError, "%r tag had invalid arguments" % tag_name
+ var_name = m.groups()[0]
+ return InstalledAppsNode(var_name)
+
+register.tag(installed_apps)
26 setup.py
View
@@ -0,0 +1,26 @@
+from setuptools import setup, find_packages
+
+setup(
+ name = 'django-apps',
+ version = __import__('django_apps').__version__,
+ description = 'Django application which provides an information about installed applications.',
+ keywords = 'django apps',
+ license = 'New BSD License',
+ author = 'Alexander Artemenko',
+ author_email = 'svetlyak.40wt@gmail.com',
+ url = 'http://github.com/svetlyak40wt/django-apps/',
+ install_requires = [],
+ dependency_links = ['http://pypi.aartemenko.com'],
+ classifiers=[
+ 'Development Status :: 2 - Pre-Alpha',
+ 'Environment :: Plugins',
+ 'Framework :: Django',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: BSD License',
+ 'Programming Language :: Python',
+ 'Topic :: Software Development :: Libraries :: Python Modules',
+ ],
+ packages = find_packages(),
+ include_package_data = True,
+)
+
Please sign in to comment.
Something went wrong with that request. Please try again.