Edgewall Software
Modify

Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#2877 closed enhancement (fixed)

Spaces in WikiNames

Reported by: mladen@… Owned by: Christian Boos
Priority: low Milestone: 0.10
Component: wiki system Version: 0.9.4
Severity: minor Keywords: CamelCase WikiPageNames
Cc: mladen@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Christian Boos)

Could you please add the ability for WikiPageNames to automatically be displayed with spaces? So when entering WikiPageNames it would come out as Wiki Page Names. I suppose this could also be configurable.

Attachments (2)

wiki_insert_spaces_r3013.diff (1.5 KB ) - added by Christian Boos 19 years ago.
A slightly refined patches, with a TracIni setting for the feature.
wiki_insert_spaces-0.9.diff (1.6 KB ) - added by Christian Boos 19 years ago.
Same as the other one, but for Trac 0.9.4

Download all attachments as: .zip

Change History (16)

comment:1 by anonymous, 19 years ago

Cc: mladen@… added

I suppose I should have said WikiPageNames? (so that they look like Wiki Page Names)

comment:2 by Christian Boos, 19 years ago

Component: generalwiki
Keywords: CamelCase WikiPageNames added
Priority: normallow
Severity: normalminor

Interesting approach. I think a lot of people would like this increased readability. The only drawback I see is the small discrepance that this would introduce between visualizing and editing WikiPageNames.

Is that idea already in use in some other wikis?

comment:3 by anonymous, 19 years ago

Component: wikigeneral
Priority: lownormal
Severity: minornormal

Yes it is in WackoWiki. Works brilliantly, and a wiki page then tends to look more like a proper document. They made it configurable but it's on by default.

comment:4 by mladen@…, 19 years ago

Component: generalwiki
Priority: normallow
Severity: normalminor

Oops sorry, don't know how those things changed. I put them back now ;)

comment:5 by Christian Boos, 19 years ago

Owner: changed from Jonas Borgström to Christian Boos

If you want to play a bit with a proof-of-concept implementation:

Index: trac/wiki/api.py
===================================================================
--- trac/wiki/api.py	(revision 3013)
+++ trac/wiki/api.py	(working copy)
@@ -199,13 +199,18 @@
         ignore_missing = self.config.getbool('wiki', 'ignore_missing_pages')
         yield (r"!?(?<!/)\b[A-Z][a-z]+(?:[A-Z][a-z]*[a-z/])+"
                 "(?:#[A-Za-z0-9]+)?(?=:?\Z|:?\s|[.,;!?\)}\]])",
-               lambda x, y, z: self._format_link(x, 'wiki', y, y,
-                                                 ignore_missing))
+               lambda x, y, z: self._format_short_link(x, 'wiki', y,
+                                                       ignore_missing))
 
     def get_link_resolvers(self):
-        yield ('wiki', self._format_fancy_link)
+        yield ('wiki', self._format_long_link)
 
-    def _format_fancy_link(self, f, n, p, l):
+    def _format_short_link(self, formatter, ns, page, ignore_missing):
+        words = re.split(r"([A-Z])", page)
+        label = ' '.join([a+b for a, b in zip(words[1::2], words[::2][1:])])
+        return self._format_link(formatter, ns, page, label, ignore_missing)
+
+    def _format_long_link(self, f, n, p, l):
         return self._format_link(f, n, p, l, False)
 
     def _format_link(self, formatter, ns, page, label, ignore_missing):

by Christian Boos, 19 years ago

A slightly refined patches, with a TracIni setting for the feature.

comment:6 by anonymous, 19 years ago

Brilliant thanks. i'm not a python developer and I'm only running Trac 0.9.4. so I don't know how to implement this. But anyway, I guess I'll just wait for the next release :)

What did you think of the results?

comment:7 by Christian Boos, 19 years ago

Well, I liked it, the wiki pages becomes more readable IMO. But that's not a guarantee that this feature will make it into the next release :)

I'd like to have some feedback from other Trac devs on this.

In the meantime, you can try to apply a 0.9 specific patch (attachment:wiki_insert_spaces-0.9.diff) on top of your 0.9.4 package:

$ cd src/trac-0.9.4
$ ls
... 
trac/
...
$ patch -p0 < wiki_insert_spaces-0.9.diff
$ python setup.py install #optional --prefix=/where/to/install

by Christian Boos, 19 years ago

Attachment: wiki_insert_spaces-0.9.diff added

Same as the other one, but for Trac 0.9.4

comment:8 by Mladen Mihajlovic <mladen@…>, 19 years ago

Works very well. Thanks a lot.

comment:9 by Christian Boos, 19 years ago

I just realized that we don't care if there's also an additional space in front of the Wiki page names, so the "tricky" code above that computes the label can be replaced by a simple
label = re.sub(r"([A-Z])", r" \1", label)

comment:10 by mladen@…, 19 years ago

So was there any decision on whether to keep this functionality or not?

comment:11 by Christopher Lenz, 19 years ago

  • I'd prefer the option name (and the parameter) being called split_page_names to be more intuitively understandable.
  • The name splitting should be done everywhere the name is displayed, for example in timeline event titles, search results, the window title, title index, etc.
  • I assume the option defaults to false, right?

comment:12 by Christian Boos, 19 years ago

Status: newassigned

We just talked a bit about this on IRC, and cmlenz suggested that in order to not be inconsistent, this style of display should also be applied in other places where we show WikiPageNames (e.g. the TitleIndex, the Timeline, etc.)

So I'll update the patch and it'll probably get in when ready.

…and to answer to cmlenz who was quicker than me at saving changes:

  • ok with split_page_names
  • …agreed, as said above
  • right, business as usual for those unaware of this nice feature :)

comment:13 by Christian Boos, 19 years ago

Description: modified (diff)
Resolution: fixed
Status: assignedclosed

Implemented in r3297.

comment:14 by Christian Boos, 18 years ago

Milestone: 0.10

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.