Sphene Community Tools

Community

Copyright © 2007-2018 by Herbert Poul

You are not logged in.
Login
Register

Change Language:



AddThis Social Bookmark Button

A Django site.

Powered by Sphene Community Tools
Board » General » Wiki Links

I'm currently using the wiki, I've written a bunch of CSS and stuff and it looks great now but I'm having some question about using it, in particular the Markdown language.

When linking to another wiki page, you have to enclose the link brackets like this, Newpage but I've found that if I have spaces it does not parse into a new page. It must be one word, which may look ugly in some cases.

The fix I assumed, was to simply use [Text to Display](Newpage) to display the text in brackets and link to the Newpage in the parens. While this works it actually links to wiki/show/Start/Newpage instead of simply wiki/edit/Newpage.

I've searched the forums and found fixes for getting stuff to work like CamelCase but not anything for links with spaces. If I wanted to include this functionality where would I want to start? I found a slightly relevant thread through the search function from 2 years ago with someone posting their changes which allowed some things which sound great, but trying to use his stuff just produces errors due to the age of his code. The link to his thread is below:

http://sct.sphene.net/board/thread/226/some-sphwiki-extensions/?page=1#post-226
all you have to do is set a SPH_SETTINGS['wikilink_regexp'] in your settings(_local).py

the default is:

WIKILINK_RE = r'''((?P<urls><a .*?>.*?</a)|(?P<escape>\\|\b)?(?P<wholeexpression>(((?P<camelcase>(A-Z+a-z- 0-9+){2,})\b)|\[(?P<snipname>A-Za-z- /0-9+)(\|(?P<sniplabel>.+?))?\])))'''


so you could change that to allow spaces in the 'snipname' (just add a space there)


btw. one question though, since you are using the wiki .. i wonder what your opinion is about wysiwyg editors: http://sct.sphene.net/board/thread/1736/why-markdown/?page=1#post-1736 - would your usecase require handwritten markup, or would a wysiwyg editor be more suitable?
Hey, we have Signatures !!! Great, isn't it ? ;)
A WYSIWYG editor would be more suitable honestly, I think expecting users to learn markdown just for the wiki may not be suitable for all cases, but it isn't really that hard, most of the stuff is pretty basic.

I tried setting the SPH_SETTINGS variable but don't want to have to set it in the django.conf.settings.py so I added the following to the sph_settings_defaults:
'wiki_rss_url': 'serebro/ia/project/(?P<groupName>\w+)/wiki/feeds/',
    'wikilink_regexp': r'''((?P<urls><a .*?>.*?</a)|(?P<escape>\\|\b)?(?P<wholeexpression>(((?P<camelcase>(A-Z+a-z- 0-9+){2,})\b)|\[(?P<snipname>A-Za-z- /0-9+)(\|(?P<sniplabel>.+?))?\])))''',
}


The wiki not working was something I figured was an error with my url, which is a bit odd due to me attempting to make it work with the fix you implemented awhile back for the url with the group name in it.

However, I am still seeing [Text to display] on the wiki page instead of a link to the 'text to display' snip. I'm probably settings the variable wrong, or my regex is wrong. I have no idea how to properly format regex so if what you provided was actually the default without spaces and it's working as intended, I simply don't know how to add spaces to be acceptable. Also, once spaces are allowed would the link have spaces and the snip name concatenate it all into one word?

I also tried adding a space in what appears to be a space in the code you posted, you said "just a space here" so I assume you meant between the z- and 0 where the text appears to be red, it's also got some weird ? characters on my end which I think are supposed to be brackets? Maybe it's not displaying properly?

Thanks for the quick response as always,
Noah

--- Last Edited by Noah Jorgenson at 2009-07-16 01:15:51 ---
you should define it in your own settings_local.py - the same place you have defined your database settings..

weird, this regexp should work i guess.. i will have to try it out myself.. in effect when you are using spaces in the snip name.. the space should also be in the URL .. something like /wiki/show/Some+Snip+With+Spaces/

Hey, we have Signatures !!! Great, isn't it ? ;)
I added the space to the end of the range 0-9 in the snipname section
of the regex just before the closing bracket( ] ) and got this error
which I think is good because it means it's trying to treat it as a
URL but can't do it for some reason:

Environment:

Request Method: GET
Request URL: http://129.244.55.157/serebro/ia/project/18/wiki/show/Start/
Django Version: 1.0-final-SVN-8450
Python Version: 2.5.1
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'iaproto.ideaarcade',
 'iaproto.registration',
 'voting',
 'django_evolution',
 'sphene.community',
 'sphene.sphboard',
 'sphene.sphwiki']
Installed Middleware:
('sphene.community.middleware.ThreadLocals',
 'sphene.community.middleware.GroupMiddleware',
 'sphene.community.middleware.PermissionDeniedMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Traceback:
File "c:\python25\lib\site-packages\django\core\handlers\base.py" in get_response
  86.                 response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\sphwiki\views.py" in showSnip
  64.             snip_rendered_body = snip.render()
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\sphwiki\models.py" in render
  64.                                              'redirect': wikimacros.RedirectMacro( ),
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\community\templatetags\sph_extras.py" in sph_markdown
  170.         ret = md.toString()
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\contrib\libs\markdown\markdown.py" in __str__
  1481.         doc = self._transform()
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\contrib\libs\markdown\markdown.py" in _transform
  1064.                 self._processSection(self.top_element, buffer)
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\contrib\libs\markdown\markdown.py" in _processSection
  1194.             self._processSection(parent_elem, theRest, inList)
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\contrib\libs\markdown\markdown.py" in _processSection
  1194.             self._processSection(parent_elem, theRest, inList)
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\contrib\libs\markdown\markdown.py" in _processSection
  1173.                 list = self._handleInlineWrapper2("\n".join(paragraph))
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\contrib\libs\markdown\markdown.py" in _handleInlineWrapper2
  1380.                     result = self._applyPattern(x, pattern)
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\contrib\libs\markdown\markdown.py" in _applyPattern
  1461.         node = pattern.handleMatch(m, self.doc)
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\contrib\libs\markdown\mdx_wikilink.py" in handleMatch
  97.         wikilink = wikilink_utils.handle_wikilinks_match(m.groupdict())
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\sphwiki\wikilink_utils.py" in handle_wikilinks_match
  55.         href = snip.get_absolute_editurl()
File "C:\Python25\Lib\site-packages\django\iaproto\..\..\sphene\communitytools\sphenecoll\sphene\community\sphpermalink.py" in inner
  38.         return reverse(bits0, urlconf, *bits[1:3])
File "c:\python25\lib\site-packages\django\core\urlresolvers.py" in reverse
  252.             *args, **kwargs)))
File "c:\python25\lib\site-packages\django\core\urlresolvers.py" in reverse
  241.                 "arguments '%s' not found." % (lookup_view, args, kwargs))

Exception Type: NoReverseMatch at /serebro/ia/project/18/wiki/show/Start/
Exception Value: Reverse for '<function editSnip at 0x02CF9030>' with arguments '()' and keyword arguments '{'groupName': u'18', 'snipName': u'Text to display'}' not found.


--- Last Edited by Noah Jorgenson at 2009-07-16 21:17:47 ---

Please login to post a reply.



Powered by Sphene Community Tools