work in progress: link processing - add handling of external links, make target links basically work
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3259 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
072334486f
commit
bd6ee8be20
6 changed files with 37 additions and 45 deletions
|
@ -539,7 +539,11 @@ view for rendering.)
|
||||||
|
|
||||||
>>> doc1.contentType = 'text/restructured'
|
>>> doc1.contentType = 'text/restructured'
|
||||||
>>> doc1.data = u'Test data\n\nAnother `paragraph <para>`_'
|
>>> doc1.data = u'Test data\n\nAnother `paragraph <para>`_'
|
||||||
|
|
||||||
>>> from loops.wiki.base import wikiLinksActive
|
>>> from loops.wiki.base import wikiLinksActive
|
||||||
|
>>> wikiLinksActive(loopsRoot)
|
||||||
|
True
|
||||||
|
|
||||||
>>> view.renderTarget()
|
>>> view.renderTarget()
|
||||||
u'<p>Test data</p>\n<p>Another <a class="reference" href="para">paragraph</a></p>\n'
|
u'<p>Test data</p>\n<p>Another <a class="reference" href="para">paragraph</a></p>\n'
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ from cybertools.text.html import HtmlTransform
|
||||||
from cybertools.typology.interfaces import IType
|
from cybertools.typology.interfaces import IType
|
||||||
from cybertools.wiki.base.config import WikiConfiguration
|
from cybertools.wiki.base.config import WikiConfiguration
|
||||||
from cybertools.wiki.dcu.html import Writer as DocutilsHTMLWriter
|
from cybertools.wiki.dcu.html import Writer as DocutilsHTMLWriter
|
||||||
|
from cybertools.wiki.dcu import process
|
||||||
from cybertools.wiki.dcu.rstx import Parser as DocutilsRstxParser
|
from cybertools.wiki.dcu.rstx import Parser as DocutilsRstxParser
|
||||||
from cybertools.wiki.tracking.link import LinkManager
|
from cybertools.wiki.tracking.link import LinkManager
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ from loops.security.setter import BaseSecuritySetter
|
||||||
from loops.setup import SetupManager, addObject
|
from loops.setup import SetupManager, addObject
|
||||||
from loops.type import LoopsType, ConceptType, ResourceType, TypeConcept
|
from loops.type import LoopsType, ConceptType, ResourceType, TypeConcept
|
||||||
from loops.view import Node, NodeAdapter
|
from loops.view import Node, NodeAdapter
|
||||||
from loops.wiki.link import LoopsLinkProcessor
|
#from loops.wiki.link import LoopsLinkProcessor
|
||||||
from loops.wiki.setup import SetupManager as WikiSetupManager
|
from loops.wiki.setup import SetupManager as WikiSetupManager
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,7 +186,8 @@ class TestSite(object):
|
||||||
component.provideAdapter(LinkManager)
|
component.provideAdapter(LinkManager)
|
||||||
component.provideUtility(DocutilsHTMLWriter(), name='docutils.html')
|
component.provideUtility(DocutilsHTMLWriter(), name='docutils.html')
|
||||||
component.provideUtility(DocutilsRstxParser(), name='docutils.rstx')
|
component.provideUtility(DocutilsRstxParser(), name='docutils.rstx')
|
||||||
component.provideAdapter(LoopsLinkProcessor, name='loops')
|
#component.provideAdapter(LoopsLinkProcessor, name='loops')
|
||||||
|
component.provideAdapter(process.Reference, name='default')
|
||||||
|
|
||||||
loopsRoot = self.site['loops'] = Loops()
|
loopsRoot = self.site['loops'] = Loops()
|
||||||
setup = SetupManager(loopsRoot)
|
setup = SetupManager(loopsRoot)
|
||||||
|
|
25
wiki/base.py
25
wiki/base.py
|
@ -43,7 +43,7 @@ class LoopsWikiManager(WikiManager):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
linkManager = 'tracking'
|
linkManager = 'tracking'
|
||||||
nodeProcessors = dict(reference=['loops'])
|
#nodeProcessors = dict(reference=['loops'])
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
super(LoopsWikiManager, self).__init__()
|
super(LoopsWikiManager, self).__init__()
|
||||||
|
@ -58,14 +58,22 @@ class LoopsWikiManager(WikiManager):
|
||||||
return util.getUidForObject(obj)
|
return util.getUidForObject(obj)
|
||||||
|
|
||||||
def getObject(self, uid):
|
def getObject(self, uid):
|
||||||
return util.getObjectForUid(uid)
|
obj = self.resolveUid(uid)
|
||||||
|
if obj is None:
|
||||||
|
return LoopsWikiPage(util.getObjectForUid(uid))
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
class LoopsWiki(Wiki):
|
class LoopsWiki(Wiki):
|
||||||
|
|
||||||
def getPage(self, name):
|
def getPage(self, name):
|
||||||
if name.startswith('.target'):
|
if name.startswith('.target'):
|
||||||
|
if '?' in name: # TODO: handle this on a general level
|
||||||
|
name, params = name.split('?', 1)
|
||||||
|
if '#' in name:
|
||||||
|
name, anchor = name.split('#', 1)
|
||||||
return self.getManager().getObject(int(name[7:]))
|
return self.getManager().getObject(int(name[7:]))
|
||||||
|
return super(LoopsWiki, self).getPage(name)
|
||||||
|
|
||||||
|
|
||||||
class LoopsWikiPage(WikiPage):
|
class LoopsWikiPage(WikiPage):
|
||||||
|
@ -76,5 +84,16 @@ class LoopsWikiPage(WikiPage):
|
||||||
self.context = context
|
self.context = context
|
||||||
self.name = getName(context)
|
self.name = getName(context)
|
||||||
|
|
||||||
def getUid(self):
|
# IWebResource
|
||||||
|
|
||||||
|
@property
|
||||||
|
def uid(self):
|
||||||
return util.getUidForObject(self.context)
|
return util.getUidForObject(self.context)
|
||||||
|
|
||||||
|
def getURI(self, request):
|
||||||
|
ann = request.annotations.get('loops.view', {})
|
||||||
|
nodeView = ann.get('nodeView')
|
||||||
|
if nodeView is not None:
|
||||||
|
return nodeView.getUrlForTarget(self.context)
|
||||||
|
return super(LoopsWikiPage, self).getURI(request)
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,11 @@
|
||||||
|
|
||||||
<zope:adapter factory="cybertools.wiki.tracking.link.LinkManager" />
|
<zope:adapter factory="cybertools.wiki.tracking.link.LinkManager" />
|
||||||
|
|
||||||
<zope:adapter factory="loops.wiki.link.LoopsLinkProcessor"
|
<!--<zope:adapter factory="loops.wiki.link.LoopsLinkProcessor"
|
||||||
name="loops" />
|
name="loops" />-->
|
||||||
|
|
||||||
|
<zope:adapter factory="cybertools.wiki.dcu.process.Reference"
|
||||||
|
name="default" />
|
||||||
|
|
||||||
<zope:adapter factory="loops.wiki.setup.SetupManager"
|
<zope:adapter factory="loops.wiki.setup.SetupManager"
|
||||||
name="wiki" />
|
name="wiki" />
|
||||||
|
|
36
wiki/link.py
36
wiki/link.py
|
@ -1,36 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
|
||||||
Link manager implementation for loops.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
|
||||||
|
|
||||||
from cybertools.wiki.dcu.process import Reference
|
|
||||||
|
|
||||||
|
|
||||||
class LoopsLinkProcessor(Reference):
|
|
||||||
|
|
||||||
def getTargetUri(self, obj):
|
|
||||||
ann = self.request.annotations.get('loops.view', {})
|
|
||||||
nodeView = self.viewAnnotations.get('nodeView')
|
|
||||||
if nodeView is not None:
|
|
||||||
return nodeView.getUrlForTarget(obj)
|
|
||||||
return super(LoopsLinkProcessor, self).getTargetUri(obj)
|
|
||||||
|
|
|
@ -31,5 +31,5 @@ class SetupManager(BaseSetupManager):
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
records = self.context.getRecordManager()
|
records = self.context.getRecordManager()
|
||||||
links = self.addObject(records, TrackingStorage, 'links',
|
if 'links' not in records:
|
||||||
trackFactory=Link)
|
records['links'] = TrackingStorage(trackFactory=Link)
|
||||||
|
|
Loading…
Add table
Reference in a new issue