Contents
CategoryCloud
Description
Output a tag cloud of most used category pages
Download & Release Notes
Download ' |
Release Version |
Moin Version |
Release Notes |
0.3.2 BETA |
1.8.5-7, 1.9.3 |
optimized regex for category, thanks to RyoSato |
|
0.3.1 BETA |
1.8.5-7, 1.9.3 |
second release, with some patch/help from KrzysztofStryjek |
|
0.2 ALPHA |
1.8.5 |
first alpha release |
Usage
Attributes for the macro are (all optional):
- maxTags = default is 30
- fontSize = default is 0.65 (in em; and this is the font-size for the smallest tags, the highest ist +1.05em)
- categoryKey = defaul is Category, used to define what is a category (future should be taken from the config class)
- tagSplit = default is ","
Example
<<CategoryCloud>>
Copyright
copyright: 2009 by MarcelHäfner (http://moinmo.in/MarcelHäfner)
(some part from the code are taken from the MacroMarket/TagCloud by Christian Groh and also including some utf-8 fixes by WenliangLu)
License
GNU GPL, see COPYING for details.
I modified the original code (MacroMarket/TagCloud) and changed some functionality, but don't know if this is enough to put my new macro under gnu gpl licence here. well the original macro does not have any licence information and the original author seems to be "lost" :-)
ToDos
Use some better caching like the origin macro did (just using for now the Dependencies = [] stuff)
I have around 1'800 pages and it needs 2-3s for generating first time a tag cloud, after that it stays around 0.1s - 0.05s, thats for me now ok (without this every request would need 2-3s)
maybe the function getPageList or the regex can be optimized to do it faster. otherwise using some real cache stuff in memory or file-system would be better.- Maybe I can even avoid the regex stuff and use some feature from xapian (linkto:, cat).
- For now "category" is default and with categoryKey changeable, but not taken per default form the config class, this could be optimized, too.
- The final output should be optimized and not using that much repeating code
- make a function instead of that large elif
Discussion
Hi
nice idea, I like it
Thanks should go also to the original author of the macro../TagCloud I just needed this for my personal "bookmark/blog" http://lotek.heavy.ch/ -- MarcelHäfner 2010-04-22 22:18:33
i have some comments about the code
better use category_regex here, otherwise your macro works only for default setup http://moinmo.in/MacroMarket/CategoryCloud?action=AttachFile&do=view&target=CategoryCloud.py#CA-a70c41986e79ed4004c89843b8d65912a17faa44_49
in http://moinmo.in/MacroMarket/CategoryCloud?action=AttachFile&do=view&target=CategoryCloud.py#CA-a70c41986e79ed4004c89843b8d65912a17faa44_74 there is much duplication in this section and only the font size changes. May be use a relative offset by a factor or a tuple in levels. Also you don't need to call str for str(fontSize+0.0)) if you do a substitution of %s
can become a list comprehensive http://moinmo.in/MacroMarket/CategoryCloud?action=AttachFile&do=view&target=CategoryCloud.py#CA-a70c41986e79ed4004c89843b8d65912a17faa44_62
please also have a look at PEP8 (whitespace) only some E501 stayed
This is very cool, but for me it's not including a few of my categories...it's very puzzling since I can't figure out what might be different about these categories to cause them to be missed and they are some of the most populated categories on my wiki. -- DavidCramer 2010-05-25 14:13:21
sorry for late answert, but I have no clue... you may publish a link were I can have a look -- MarcelHäfner 2010-06-03 17:25:22
When a Category is not written in CamelCase (e.g. CategoryWWW) it will be inserted into the page like this (v1.9):
[[CategoryWWW]]
Please consider this or else categories will appear like this: WWW]] . -- MatthiasFelsche 2010-08-30 16:18:29
I use this macro by fixing the regular expression pattern. Maybe it will help. -- RyoSato 2011-05-12 23:28:49 Integrated in the latest Version, Thanks!
match = re.search(ur'(?m)(^-----*\s*\r?\n)(^##.*\r?\n)*^(?!##)(.*)(?P<all>' + categoryKey + ur'(?P<category>[^ \s\]]+))', body)
see http://lotek.heavy.ch (1)