#2877 closed enhancement (fixed)
Spaces in WikiNames
Reported by: | 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 )
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)
Change History (16)
comment:1 by , 19 years ago
Cc: | added |
---|
comment:2 by , 19 years ago
Component: | general → wiki |
---|---|
Keywords: | CamelCase WikiPageNames added |
Priority: | normal → low |
Severity: | normal → minor |
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 , 19 years ago
Component: | wiki → general |
---|---|
Priority: | low → normal |
Severity: | minor → normal |
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 , 19 years ago
Component: | general → wiki |
---|---|
Priority: | normal → low |
Severity: | normal → minor |
Oops sorry, don't know how those things changed. I put them back now ;)
comment:5 by , 19 years ago
Owner: | changed from | to
---|
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 , 19 years ago
Attachment: | wiki_insert_spaces_r3013.diff added |
---|
A slightly refined patches, with a TracIni setting for the feature.
comment:6 by , 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 , 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 , 19 years ago
Attachment: | wiki_insert_spaces-0.9.diff added |
---|
Same as the other one, but for Trac 0.9.4
comment:9 by , 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 , 19 years ago
So was there any decision on whether to keep this functionality or not?
comment:11 by , 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 , 19 years ago
Status: | new → assigned |
---|
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 , 19 years ago
Description: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Implemented in r3297.
comment:14 by , 18 years ago
Milestone: | → 0.10 |
---|
I suppose I should have said WikiPageNames? (so that they look like Wiki Page Names)