Isn't it flat!
") 55 | 56 | def test_fallback_flatpage(self): 57 | response = self.client.get('/flat01/') 58 | self.assertEqual(response.status_code, 200) 59 | self.assertContains(response, 60 | ' ') 61 | 62 | response = self.client.get('/flat01/flat02/') 63 | self.assertEqual(response.status_code, 200) 64 | self.assertContains(response, 65 | ' ') 66 | -------------------------------------------------------------------------------- /breadcrumbs/tests/singleton_tests.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | from django.test import TestCase 4 | 5 | from breadcrumbs.breadcrumbs import Singleton 6 | 7 | 8 | class Foo(Singleton): 9 | """ 10 | Class used in singleton tests 11 | """ 12 | pass 13 | 14 | 15 | class SingletonTest(TestCase): 16 | 17 | def test_singleton(self): 18 | """ 19 | Test singleton implementation with values 20 | """ 21 | a = Foo() 22 | a.attr_1 = 1 23 | 24 | b = Foo() 25 | 26 | self.assertEqual(b.attr_1, 1) 27 | self.assertTrue(a is b, "'a' isn't 'b', Singleton not works") 28 | 29 | def test_singleton_destruction(self): 30 | """ 31 | Test singleton imsinplementation with values and than destroy it 32 | """ 33 | a = Foo() 34 | id_a = id(a) 35 | a.attr_1 = 1 36 | 37 | b = Foo() 38 | id_b = id(b) 39 | 40 | self.assertEqual(id_a, id_b) 41 | self.assertEqual(b.attr_1, 1) 42 | self.assertTrue(a is b, "'a' isn't 'b', Singleton not works") 43 | 44 | a._drop_it() 45 | 46 | c = Foo() 47 | id_c = id(c) 48 | self.assertNotEqual(id_a, id_c) 49 | self.assertNotEqual(getattr(c,'attr_1',None), 1) 50 | 51 | -------------------------------------------------------------------------------- /breadcrumbs/tests/templates/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |{{ flatpage.content }}
4 | {% endblock body %} 5 | -------------------------------------------------------------------------------- /breadcrumbs/tests/templates/page1.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block body %} 3 | Page 1 :) 4 | {% endblock body %} 5 | -------------------------------------------------------------------------------- /breadcrumbs/tests/urls.py: -------------------------------------------------------------------------------- 1 | import django 2 | if django.get_version().startswith('1.4'): 3 | from django.conf.urls import patterns 4 | else: 5 | from django.conf.urls.defaults import patterns 6 | from .views import page1 7 | # special urls for flatpage test cases 8 | urlpatterns = patterns('', 9 | (r'^page1/', page1), 10 | ) 11 | 12 | -------------------------------------------------------------------------------- /breadcrumbs/tests/views.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from django.shortcuts import render_to_response 4 | from django.template import RequestContext 5 | 6 | def page1(request): 7 | request.breadcrumbs("Page 1", request.get_full_path()) 8 | return render_to_response('page1.html', {}, 9 | context_instance=RequestContext(request)) 10 | -------------------------------------------------------------------------------- /breadcrumbs/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import patterns 2 | 3 | urlpatterns = patterns('breadcrumbs.views', 4 | (r'^(?PBreadcrumb: {% for b in request.breadcrumbs %}{{ b.name }}{% if not forloop.last %} / {% endif %}{% endfor %}
13 |Links: Home | Breadcrumb in view | Flatpages 14 |
Content: Breadcrumb: {% for b in request.breadcrumbs %}{{ b.name }}{% if not forloop.last %} / {% endif %}{% endfor %} Links: Home | Breadcrumb in view | Flatpages
14 | Content:
15 | {% if text %}{{ text }}{% endif %}
16 | {% if flatpage %}{{ flatpage.content }}{% endif %}
17 |
18 |
19 |
--------------------------------------------------------------------------------
/breadcrumbs_sample/webui/tests.py:
--------------------------------------------------------------------------------
1 | """
2 | This file demonstrates two different styles of tests (one doctest and one
3 | unittest). These will both pass when you run "manage.py test".
4 |
5 | Replace these with more appropriate tests for your application.
6 | """
7 |
8 | from django.test import TestCase
9 |
10 | class SimpleTest(TestCase):
11 | def test_basic_addition(self):
12 | """
13 | Tests that 1 + 1 always equals 2.
14 | """
15 | self.failUnlessEqual(1 + 1, 2)
16 |
17 | __test__ = {"doctest": """
18 | Another way to test that 1 + 1 is equal to 2.
19 |
20 | >>> 1 + 1 == 2
21 | True
22 | """}
23 |
24 |
--------------------------------------------------------------------------------
/breadcrumbs_sample/webui/views.py:
--------------------------------------------------------------------------------
1 | # Create your views here.
2 |
3 | from django.shortcuts import render_to_response
4 | from django.template.context import RequestContext
5 |
6 |
7 | def home(request):
8 | print request.breadcrumbs
9 | return render_to_response('home.html',
10 | {'text': 'Hello, this is home!'},
11 | context_instance=RequestContext(request))
12 |
13 |
14 | def someview(request):
15 | request.breadcrumbs('just a view to show some url', request.path)
16 |
17 | return render_to_response('home.html',
18 | {'text': 'Hello, this is some second view'},
19 | context_instance=RequestContext(request))
20 |
--------------------------------------------------------------------------------
/dist/django-breadcrumbs-1.1.0.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/felipe-prenholato/django-breadcrumbs/2ff5104733099a9a4d2f5156c1453e231b164b25/dist/django-breadcrumbs-1.1.0.tar.gz
--------------------------------------------------------------------------------
/dist/django-breadcrumbs-1.1.2.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/felipe-prenholato/django-breadcrumbs/2ff5104733099a9a4d2f5156c1453e231b164b25/dist/django-breadcrumbs-1.1.2.tar.gz
--------------------------------------------------------------------------------
/flatpages.json:
--------------------------------------------------------------------------------
1 | [{"pk": 1, "model": "flatpages.flatpage", "fields": {"registration_required": false, "title": "Flat page 1", "url": "/flat01/", "template_name": "", "sites": [1], "content": "Flat page 1\r\n\r\n\r\nFlat page links: Flat 1 | Flat 2 | Flat 3", "enable_comments": false}}, {"pk": 2, "model": "flatpages.flatpage", "fields": {"registration_required": false, "title": "Flat page 2", "url": "/flat01/flat02/", "template_name": "", "sites": [1], "content": "Flag page 2\r\n\r\n\r\nFlat page links: Flat 1 | Flat 2 | Flat 3", "enable_comments": false}}, {"pk": 3, "model": "flatpages.flatpage", "fields": {"registration_required": false, "title": "Flat page 3", "url": "/flat01/flat02/flat03/", "template_name": "", "sites": [1], "content": "Flat page 3\r\n\r\nFlat page links: Flat 1 | Flat 2 | Flat 3", "enable_comments": false}}]
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | Django>=1.3.4
2 |
--------------------------------------------------------------------------------
/runtests.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import os, sys
4 |
5 | from django.conf import settings
6 |
7 |
8 | if not settings.configured:
9 | settings_dict = dict(
10 | SITE_ID=1,
11 | ROOT_URLCONF='breadcrumbs.tests.urls',
12 | INSTALLED_APPS=(
13 | 'django.contrib.contenttypes',
14 | 'django.contrib.sites',
15 | 'django.contrib.flatpages',
16 | 'breadcrumbs',
17 | ),
18 | DATABASES={
19 | "default": {
20 | "ENGINE": "django.db.backends.sqlite3"
21 | }
22 | },
23 | )
24 |
25 | settings.configure(**settings_dict)
26 |
27 |
28 | def runtests(*test_args):
29 |
30 | if not test_args:
31 | test_args = ['breadcrumbs']
32 |
33 | # try to set more used args to django test
34 | test_kwargs = {
35 | 'verbosity': 1,
36 | 'noinput': False,
37 | 'failfast': False,
38 | }
39 | for i,arg in enumerate(sys.argv):
40 | if arg.startswith('-v'):
41 | _value = arg.replace('-v','')
42 | if len(_value):
43 | test_kwargs['verbosity'] = int(_value)
44 | else:
45 | test_kwargs['verbosity'] = int(sys.argv[i+1])
46 | if arg == '--noinput':
47 | test_kwargs['noinput'] = True
48 | if arg == '--failfast':
49 | test_kwargs['failfast'] =True
50 |
51 | parent = os.path.dirname(os.path.abspath(__file__))
52 | sys.path.insert(0, parent)
53 |
54 | from django.test.simple import DjangoTestSuiteRunner
55 | failures = DjangoTestSuiteRunner(
56 | interactive=True, **test_kwargs).run_tests(test_args)
57 | sys.exit(failures)
58 |
59 |
60 | if __name__ == '__main__':
61 | runtests()
62 |
--------------------------------------------------------------------------------
/runtests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "This is a helper script to test breadcrumbs against many environ versions."
4 | echo "This script test against Django 1.3.x and 1.4.x using sqlite. It depends of pip."
5 |
6 | OLD_DJANGO="$(pip freeze | grep Django)"
7 |
8 | test_13() {
9 | echo "Testing against Django 1.3.x ..."
10 | pip install -q -U --use-mirrors Django\<1.4.0
11 | python runtests.py --failfast --noinput -v0 && return 0 || return 1
12 | }
13 |
14 | test_14() {
15 | echo "Testing against Django 1.4.x ..."
16 | pip install -q -U --use-mirrors Django\<1.5.0
17 | python runtests.py --failfast --noinput -v0 && return 0 || return 1
18 | }
19 |
20 | test_13 && test_14
21 |
22 | result=$?
23 |
24 | if [[ "$OLD_DJANGO" ]];
25 | then
26 | pip install -q -U --use-mirrors "$OLD_DJANGO"
27 | echo "$OLD_DJANGO reinstalled"
28 | else
29 | pip uninstall Django
30 | fi
31 |
32 | exit $result
33 |
--------------------------------------------------------------------------------
/sample_d14/dev.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/felipe-prenholato/django-breadcrumbs/2ff5104733099a9a4d2f5156c1453e231b164b25/sample_d14/dev.db
--------------------------------------------------------------------------------
/sample_d14/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sample_d14.settings")
7 |
8 | from django.core.management import execute_from_command_line
9 |
10 | execute_from_command_line(sys.argv)
11 |
--------------------------------------------------------------------------------
/sample_d14/requirements.txt:
--------------------------------------------------------------------------------
1 | Django>=1.4.1
2 | pylibmc>=1.2.3
3 |
--------------------------------------------------------------------------------
/sample_d14/sample_d14/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/felipe-prenholato/django-breadcrumbs/2ff5104733099a9a4d2f5156c1453e231b164b25/sample_d14/sample_d14/__init__.py
--------------------------------------------------------------------------------
/sample_d14/sample_d14/settings.py:
--------------------------------------------------------------------------------
1 | # Django settings for sample_d14 project.
2 |
3 | DEBUG = True
4 | TEMPLATE_DEBUG = DEBUG
5 |
6 | ADMINS = (
7 | # ('Your Name', 'your_email@example.com'),
8 | )
9 |
10 | MANAGERS = ADMINS
11 |
12 | DATABASES = {
13 | 'default': {
14 | 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
15 | 'NAME': 'dev.db', # Or path to database file if using sqlite3.
16 | 'USER': '', # Not used with sqlite3.
17 | 'PASSWORD': '', # Not used with sqlite3.
18 | 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
19 | 'PORT': '', # Set to empty string for default. Not used with sqlite3.
20 | }
21 | }
22 |
23 | # Local time zone for this installation. Choices can be found here:
24 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
25 | # although not all choices may be available on all operating systems.
26 | # In a Windows environment this must be set to your system time zone.
27 | TIME_ZONE = 'America/Chicago'
28 |
29 | # Language code for this installation. All choices can be found here:
30 | # http://www.i18nguy.com/unicode/language-identifiers.html
31 | LANGUAGE_CODE = 'en-us'
32 |
33 | SITE_ID = 1
34 |
35 | # If you set this to False, Django will make some optimizations so as not
36 | # to load the internationalization machinery.
37 | USE_I18N = True
38 |
39 | # If you set this to False, Django will not format dates, numbers and
40 | # calendars according to the current locale.
41 | USE_L10N = True
42 |
43 | # If you set this to False, Django will not use timezone-aware datetimes.
44 | USE_TZ = True
45 |
46 | # Absolute filesystem path to the directory that will hold user-uploaded files.
47 | # Example: "/home/media/media.lawrence.com/media/"
48 | MEDIA_ROOT = ''
49 |
50 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a
51 | # trailing slash.
52 | # Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
53 | MEDIA_URL = ''
54 |
55 | # Absolute path to the directory static files should be collected to.
56 | # Don't put anything in this directory yourself; store your static files
57 | # in apps' "static/" subdirectories and in STATICFILES_DIRS.
58 | # Example: "/home/media/media.lawrence.com/static/"
59 | STATIC_ROOT = ''
60 |
61 | # URL prefix for static files.
62 | # Example: "http://media.lawrence.com/static/"
63 | STATIC_URL = '/static/'
64 |
65 | # Additional locations of static files
66 | STATICFILES_DIRS = (
67 | # Put strings here, like "/home/html/static" or "C:/www/django/static".
68 | # Always use forward slashes, even on Windows.
69 | # Don't forget to use absolute paths, not relative paths.
70 | )
71 |
72 | # List of finder classes that know how to find static files in
73 | # various locations.
74 | STATICFILES_FINDERS = (
75 | 'django.contrib.staticfiles.finders.FileSystemFinder',
76 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
77 | # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
78 | )
79 |
80 | # Make this unique, and don't share it with anybody.
81 | SECRET_KEY = '14i6-n-!v*w07gyx4is-j3z)ou2^%8u+i5t0(3$^wyme1odalz'
82 |
83 | # List of callables that know how to import templates from various sources.
84 | TEMPLATE_LOADERS = (
85 | 'django.template.loaders.filesystem.Loader',
86 | 'django.template.loaders.app_directories.Loader',
87 | # 'django.template.loaders.eggs.Loader',
88 | )
89 |
90 | MIDDLEWARE_CLASSES = (
91 | 'django.middleware.common.CommonMiddleware',
92 | 'django.contrib.sessions.middleware.SessionMiddleware',
93 | 'django.middleware.csrf.CsrfViewMiddleware',
94 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
95 | 'django.contrib.messages.middleware.MessageMiddleware',
96 | # Uncomment the next line for simple clickjacking protection:
97 | # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
98 | 'breadcrumbs.middleware.BreadcrumbsMiddleware',
99 | 'breadcrumbs.middleware.FlatpageFallbackMiddleware',
100 | )
101 |
102 | TEMPLATE_CONTEXT_PROCESSORS = (
103 | 'django.contrib.auth.context_processors.auth',
104 | 'django.core.context_processors.debug',
105 | 'django.core.context_processors.i18n',
106 | 'django.core.context_processors.media',
107 | 'django.core.context_processors.static',
108 | 'django.core.context_processors.tz',
109 | 'django.contrib.messages.context_processors.messages',
110 | 'django.core.context_processors.request'
111 | )
112 |
113 | ROOT_URLCONF = 'sample_d14.urls'
114 |
115 | # Python dotted path to the WSGI application used by Django's runserver.
116 | WSGI_APPLICATION = 'sample_d14.wsgi.application'
117 |
118 | TEMPLATE_DIRS = (
119 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
120 | # Always use forward slashes, even on Windows.
121 | # Don't forget to use absolute paths, not relative paths.
122 | )
123 |
124 | INSTALLED_APPS = (
125 | 'django.contrib.auth',
126 | 'django.contrib.contenttypes',
127 | 'django.contrib.sessions',
128 | 'django.contrib.sites',
129 | 'django.contrib.messages',
130 | 'django.contrib.staticfiles',
131 | 'django.contrib.flatpages',
132 | # Uncomment the next line to enable the admin:
133 | 'django.contrib.admin',
134 | # Uncomment the next line to enable admin documentation:
135 | # 'django.contrib.admindocs',
136 | 'webui',
137 | 'breadcrumbs',
138 | )
139 |
140 | BREADCRUMBS_AUTO_HOME = True
141 |
142 | CACHES = {
143 | 'default': {
144 | 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
145 | 'LOCATION': '127.0.0.1:11211',
146 | }
147 | }
148 |
149 | # A sample logging configuration. The only tangible logging
150 | # performed by this configuration is to send an email to
151 | # the site admins on every HTTP 500 error when DEBUG=False.
152 | # See http://docs.djangoproject.com/en/dev/topics/logging for
153 | # more details on how to customize your logging configuration.
154 | LOGGING = {
155 | 'version': 1,
156 | 'disable_existing_loggers': False,
157 | 'filters': {
158 | 'require_debug_false': {
159 | '()': 'django.utils.log.RequireDebugFalse'
160 | }
161 | },
162 | 'handlers': {
163 | 'mail_admins': {
164 | 'level': 'ERROR',
165 | 'filters': ['require_debug_false'],
166 | 'class': 'django.utils.log.AdminEmailHandler'
167 | }
168 | },
169 | 'loggers': {
170 | 'django.request': {
171 | 'handlers': ['mail_admins'],
172 | 'level': 'ERROR',
173 | 'propagate': True,
174 | },
175 | }
176 | }
177 |
--------------------------------------------------------------------------------
/sample_d14/sample_d14/urls.py:
--------------------------------------------------------------------------------
1 | from django.conf.urls import patterns, include, url
2 |
3 | # Uncomment the next two lines to enable the admin:
4 | from django.contrib import admin
5 | admin.autodiscover()
6 |
7 | urlpatterns = patterns('',
8 | # Examples:
9 | # url(r'^$', 'sample_d14.views.home', name='home'),
10 | # url(r'^sample_d14/', include('sample_d14.foo.urls')),
11 |
12 | # Uncomment the admin/doc line below to enable admin documentation:
13 | # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
14 |
15 | # Uncomment the next line to enable the admin:
16 | url(r'^admin/', include(admin.site.urls)),
17 | url(r'^$', 'webui.views.home', name='home'),
18 | url(r'^someview/$', 'webui.views.someview', name='someview'),
19 | (r'^pages/', include('breadcrumbs.urls')),
20 | )
21 |
22 | urlpatterns += patterns('breadcrumbs.views',
23 | (r'^pages2/(?P
15 | {% if text %}{{ text }}{% endif %}
16 | {% if flatpage %}{{ flatpage.content }}{% endif %}
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample_d14/webui/tests.py:
--------------------------------------------------------------------------------
1 | """
2 | This file demonstrates writing tests using the unittest module. These will pass
3 | when you run "manage.py test".
4 |
5 | Replace this with more appropriate tests for your application.
6 | """
7 |
8 | from django.test import TestCase
9 |
10 |
11 | class SimpleTest(TestCase):
12 | def test_basic_addition(self):
13 | """
14 | Tests that 1 + 1 always equals 2.
15 | """
16 | self.assertEqual(1 + 1, 2)
17 |
--------------------------------------------------------------------------------
/sample_d14/webui/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render_to_response
2 | from django.template.context import RequestContext
3 |
4 |
5 | def home(request):
6 | return render_to_response('home.html',
7 | {'text': 'Hello, this is home!'},
8 | context_instance=RequestContext(request))
9 |
10 |
11 | def someview(request):
12 | request.breadcrumbs('just a view to show some url', request.path)
13 |
14 | return render_to_response('home.html',
15 | {'text': 'Hello, this is some second view'},
16 | context_instance=RequestContext(request))
17 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup, find_packages
2 | setup(
3 | name="django-breadcrumbs",
4 | version="1.1.4a1",
5 | packages=find_packages(exclude=('breadcrumbs_sample*', 'sample_d14*')),
6 | author="Felipe 'chronos' Prenholato",
7 | author_email="philipe.rp@gmail.com",
8 | maintainer="Felipe 'chronos' Prenholato",
9 | maintainer_email="philipe.rp@gmail.com",
10 | url="http://github.com/chronossc/django-breadcrumbs",
11 | license='NEW BSD LICENSE: http://www.opensource.org/licenses/bsd-license.php',
12 | description="Easy to use generic breadcrumbs system for Django framework.",
13 | long_description="*django-breadcrumbs* is a breadcrumb system to Django "
14 | "framework that allow you to add custom breadcrumbs for simple views, "
15 | "generic views and support Django FlatPages app. It works as a "
16 | "pluggable middleware that add a breadcrumbs callable/iterable in your "
17 | "request object, allowing you to set breadcrumbs (one or more) in "
18 | "each view accepting objects, lists or tuples added from "
19 | "request.breadcrumbs and is iterable, easy to use in templates "
20 | "providing a object with name and url attributes.",
21 | classifiers=[
22 | "Development Status :: 5 - Production/Stable",
23 | "Environment :: Web Environment",
24 | "Framework :: Django",
25 | "Intended Audience :: Developers",
26 | "License :: OSI Approved :: BSD License",
27 | "Operating System :: OS Independent",
28 | "Programming Language :: Python",
29 | ],
30 | install_requires=["Django>=1.3.4", "six"],
31 | )
32 |
--------------------------------------------------------------------------------