forked from Cromlech/dolmen.breadcrumbs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
410 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
recursive-include src *.txt *.py *.zcml *.pt *.po *.mo | ||
recursive-include docs *.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2006 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. | ||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
# FOR A PARTICULAR PURPOSE. | ||
# | ||
############################################################################## | ||
"""Bootstrap a buildout-based project | ||
Simply run this script in a directory containing a buildout.cfg. | ||
The script accepts buildout command-line options, so you can | ||
use the -c option to specify an alternate configuration file. | ||
$Id: bootstrap.py 90478 2008-08-27 22:44:46Z georgyberdyshev $ | ||
""" | ||
|
||
import os, shutil, sys, tempfile, urllib2 | ||
|
||
tmpeggs = tempfile.mkdtemp() | ||
|
||
is_jython = sys.platform.startswith('java') | ||
|
||
try: | ||
import pkg_resources | ||
except ImportError: | ||
ez = {} | ||
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' | ||
).read() in ez | ||
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) | ||
|
||
import pkg_resources | ||
|
||
if sys.platform == 'win32': | ||
def quote(c): | ||
if ' ' in c: | ||
return '"%s"' % c # work around spawn lamosity on windows | ||
else: | ||
return c | ||
else: | ||
def quote (c): | ||
return c | ||
|
||
cmd = 'from setuptools.command.easy_install import main; main()' | ||
ws = pkg_resources.working_set | ||
|
||
if is_jython: | ||
import subprocess | ||
|
||
assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd', | ||
quote(tmpeggs), 'zc.buildout'], | ||
env=dict(os.environ, | ||
PYTHONPATH= | ||
ws.find(pkg_resources.Requirement.parse('setuptools')).location | ||
), | ||
).wait() == 0 | ||
|
||
else: | ||
assert os.spawnle( | ||
os.P_WAIT, sys.executable, quote (sys.executable), | ||
'-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout', | ||
dict(os.environ, | ||
PYTHONPATH= | ||
ws.find(pkg_resources.Requirement.parse('setuptools')).location | ||
), | ||
) == 0 | ||
|
||
ws.add_entry(tmpeggs) | ||
ws.require('zc.buildout') | ||
import zc.buildout.buildout | ||
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap']) | ||
shutil.rmtree(tmpeggs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[buildout] | ||
develop = . | ||
parts = test | ||
find-links = http://pypi.dolmen-project.org/find-links | ||
|
||
[test] | ||
recipe = z3c.recipe.scripts | ||
initialization = | ||
import pytest | ||
if __name__ == '__main__': sys.exit(pytest.main('src')) | ||
sys.argv.append('--doctest-modules') | ||
eggs = | ||
dolmen.breadcrumbs [test] | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Changelog | ||
========= | ||
|
||
0.1 (2012-01-20) | ||
---------------- | ||
|
||
* Initial release : forked out of ``dolmen.app.breadcrumbs``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from setuptools import setup, find_packages | ||
from os.path import join | ||
|
||
name = 'dolmen.breadcrumbs' | ||
version = '0.1' | ||
readme = open(join('src', 'dolmen', 'breadcrumbs', 'README.txt')).read() | ||
history = open(join('docs', 'HISTORY.txt')).read() | ||
|
||
install_requires = [ | ||
'cromlech.browser >= 0.4', | ||
'cromlech.io', | ||
'dolmen.location >= 0.1', | ||
'dolmen.template', | ||
'grokcore.component', | ||
'setuptools', | ||
'zope.dublincore', | ||
'zope.interface', | ||
] | ||
|
||
tests_require = [ | ||
'cromlech.browser [test]', | ||
'zope.location', | ||
] | ||
|
||
setup(name = name, | ||
version = version, | ||
description = 'Breadcrumbs navigation for the Cromlech framework.', | ||
long_description = readme + '\n\n' + history, | ||
keywords = 'Cromlech Dolmen', | ||
author = 'Souheil Chelfouh', | ||
author_email = '[email protected]', | ||
url = 'http://gitweb.dolmen-project.org', | ||
download_url = '', | ||
license = 'ZPL', | ||
packages=find_packages('src', exclude=['ez_setup']), | ||
package_dir={'': 'src'}, | ||
namespace_packages = ['dolmen'], | ||
include_package_data = True, | ||
platforms = 'Any', | ||
zip_safe = False, | ||
tests_require = tests_require, | ||
install_requires = install_requires, | ||
extras_require = {'test': tests_require}, | ||
classifiers = [ | ||
'Environment :: Web Environment', | ||
'Intended Audience :: Other Audience', | ||
'License :: OSI Approved :: Zope Public License (GPL)', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
try: | ||
__import__('pkg_resources').declare_namespace(__name__) | ||
except ImportError: | ||
from pkgutil import extend_path | ||
__path__ = extend_path(__path__, __name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
================== | ||
dolmen.breadcrumbs | ||
================== | ||
|
||
`dolmen.breadcrumbs` provides a breadcrumbs navigation for Cromlech. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from dolmen.breadcrumbs.crumbs import breadcrumbs | ||
from dolmen.breadcrumbs.renderer import BreadcrumbsRenderer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<configure xmlns="http://namespaces.zope.org/zope" | ||
xmlns:i18n="http://namespaces.zope.org/i18n"> | ||
<include package="zope.i18n" file="meta.zcml" /> | ||
<i18n:registerTranslations directory="locales" /> | ||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import urllib | ||
from cromlech.io import IPublicationRoot | ||
from dolmen.location import get_absolute_url, lineage_chain | ||
from zope.dublincore.interfaces import IDCDescriptiveProperties | ||
|
||
|
||
_safe = '@+' # Characters that we don't want to have quoted | ||
|
||
|
||
def resolve_name(item): | ||
"""Choose a display name for the current context. | ||
This method has been splitted out for convenient overriding. | ||
""" | ||
name = getattr(item, '__name__', None) | ||
if name is None and not IPublicationRoot.providedBy(item): | ||
raise KeyError('Object name (%r) could not be resolved.' % item) | ||
dc = IDCDescriptiveProperties(item, None) | ||
if dc is not None and dc.title: | ||
return name, dc.title | ||
return name, name | ||
|
||
|
||
def breadcrumbs(item, request): | ||
kin = lineage_chain(item) | ||
if kin: | ||
kin.reverse() | ||
root = kin.pop(0) | ||
base_url = get_absolute_url(root, request) | ||
name, title = resolve_name(root) | ||
yield {'name': title, 'url': base_url} | ||
|
||
for sibling in kin: | ||
name, title = resolve_name(sibling) | ||
base_url += '/' + urllib.quote(name.encode('utf-8'), _safe) | ||
yield {'name': title, 'url': base_url} |
Binary file added
BIN
+566 Bytes
src/dolmen/breadcrumbs/locales/de/LC_MESSAGES/dolmen.breadcrumbs.mo
Binary file not shown.
18 changes: 18 additions & 0 deletions
18
src/dolmen/breadcrumbs/locales/de/LC_MESSAGES/dolmen.breadcrumbs.po
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: dolmen.breadcrumbs\n" | ||
"POT-Creation-Date: 2010-08-05 12:15+0100\n" | ||
"PO-Revision-Date: 2012-01-20 12:50+0100\n" | ||
"Last-Translator: Christian Klinger <[email protected]>\n" | ||
"Language-Team: Souheil CHELFOUH <[email protected]>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=utf-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=1; plural=0;\n" | ||
"Language-Code: de\n" | ||
"Language-Name: German\n" | ||
"Preferred-Encodings: utf-8\n" | ||
"Domain: dolmen.breadcrumbs\n" | ||
|
||
msgid "You are here :" | ||
msgstr "Sie sind hier :" |
Binary file added
BIN
+624 Bytes
src/dolmen/breadcrumbs/locales/fr/LC_MESSAGES/dolmen.breadcrumbs.mo
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
src/dolmen/breadcrumbs/locales/fr/LC_MESSAGES/dolmen.breadcrumbs.po
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: dolmen.breadcrumbs\n" | ||
"POT-Creation-Date: 2010-06-31 12:15+0100\n" | ||
"PO-Revision-Date: 2012-01-20 12:50+0100\n" | ||
"Last-Translator: Souheil CHELFOUH <[email protected]>\n" | ||
"Language-Team: Souheil CHELFOUH <[email protected]>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=utf-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=1; plural=0;\n" | ||
"Language-Code: fr\n" | ||
"Language-Name: Français\n" | ||
"Preferred-Encodings: utf-8\n" | ||
"Domain: dolmen.breadcrumbs\n" | ||
"X-Is-Fallback-For: fr-be fr-ca fr-lu fr-mc fr-ch fr-fr\n" | ||
|
||
msgid "You are here :" | ||
msgstr "Vous êtes ici :" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from os import path | ||
from cromlech.browser import IRenderer | ||
from dolmen.breadcrumbs import breadcrumbs | ||
from dolmen.template import TALTemplate | ||
from zope.interface import implements | ||
|
||
|
||
TEMPLATES_DIR = path.join(path.dirname(__file__), 'templates') | ||
template = TALTemplate(path.join(TEMPLATES_DIR, 'breadcrumbs.pt')) | ||
|
||
|
||
def render_breadcrumbs(renderer, crumbs, separator="→"): | ||
return template.render(renderer, breadcrumbs=crumbs, separator=separator) | ||
|
||
|
||
class BreadcrumbsRenderer(object): | ||
implements(IRenderer) | ||
|
||
def __init__(self, context, request): | ||
self.context = context | ||
self.request = request | ||
|
||
def namespace(self): | ||
return {} | ||
|
||
def update(self): | ||
self.breadcrumbs = list(breadcrumbs(self.context, self.request)) | ||
|
||
def render(self): | ||
return render_breadcrumbs(self, self.breadcrumbs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="breadcrumb" i18n:domain="dolmen.breadcrumbs"> | ||
<span class="you-are-here" i18n:translate="">You are here :</span> | ||
<tal:loop repeat="crumb breadcrumbs"> | ||
<span class="crumb" tal:condition="crumb['name']"> | ||
<a href="" | ||
tal:attributes="href crumb['url']" | ||
tal:content="crumb['name']">name</a> | ||
<span tal:condition="not: repeat['crumb'].end" | ||
class="divider" tal:content="structure separator" /> | ||
</span> | ||
</tal:loop> | ||
</div> |
Oops, something went wrong.