# HG changeset patch # User Paul Boddie # Date 1236451432 -3600 # Node ID 8048fa9c38e9d19217e1bf2863ad740d39e13fab # Parent c935e9f0e746f4046b101359773329d124173e59 Fixed and improved the scripts. Added MoinMoin 1.8.x compatibility. Made displayed page names prettier. Added recommended software and troubleshooting documentation. Fixed variable naming (page_in_category vs. page_is_in_category). Updated release and copyright information. diff -r c935e9f0e746 -r 8048fa9c38e9 README.txt --- a/README.txt Tue Feb 10 01:19:49 2009 +0100 +++ b/README.txt Sat Mar 07 19:43:52 2009 +0100 @@ -54,6 +54,13 @@ Recommended Software -------------------- +The Xapian search software is highly recommended, if not technically +essential, for the acceptable performance of the CategoryMenu macro since the +macro makes use of search routines in MoinMoin that can dominate the time +spent processing requests. + +See the following page for information on Xapian and MoinMoin: + http://moinmo.in/HelpOnXapian Troubleshooting @@ -69,14 +76,29 @@ Contact, Copyright and Licence Information ------------------------------------------ -No Web page has yet been made available for this work, but the author can be -contacted at the following e-mail address: +See the following Web page for more information about this work: + +http://moinmo.in/MacroMarket/CategoryMenu + +The author can be contacted at the following e-mail address: paul@boddie.org.uk Copyright and licence information can be found in the docs directory - see docs/COPYING.txt and docs/LICENCE.txt for more information. +New in CategoryMenu 0.2 (Changes since CategoryMenu 0.1) +-------------------------------------------------------- + + * Improved category and page discovery, preventing needless inspection of + all categories, and using the category search method when searching for + categories. + * Removed unnecessary page name sorting. + * Fixed and improved the scripts. + * Added MoinMoin 1.8.x compatibility. + * Made displayed page names prettier. + * Added recommended software and troubleshooting documentation. + Release Procedures ------------------ @@ -85,4 +107,4 @@ Update the release notes (see above). Tag, export. Archive, upload. -Update the MacroMarket (http://moinmo.in/MacroMarket). +Update the MacroMarket (see above for the URL). diff -r c935e9f0e746 -r 8048fa9c38e9 docs/COPYING.txt --- a/docs/COPYING.txt Tue Feb 10 01:19:49 2009 +0100 +++ b/docs/COPYING.txt Sat Mar 07 19:43:52 2009 +0100 @@ -1,7 +1,7 @@ Licence Agreement ----------------- -Copyright (C) 2008 Paul Boddie +Copyright (C) 2008, 2009 Paul Boddie Some pieces of MoinMoin code were used in this work - specifically the category regular expression code from diff -r c935e9f0e746 -r 8048fa9c38e9 instmacros --- a/instmacros Tue Feb 10 01:19:49 2009 +0100 +++ b/instmacros Sat Mar 07 19:43:52 2009 +0100 @@ -1,7 +1,7 @@ #!/bin/bash if [[ ! $1 ]] ; then - echo "Please specify a directory such as ../mysite or /tmp/mysite." + echo "Please specify a directory such as ../mysite/wiki or /tmp/mysite/wiki." echo "This should be the root of your Wiki installation and contain the data" echo "directory." echo diff -r c935e9f0e746 -r 8048fa9c38e9 insttheme --- a/insttheme Tue Feb 10 01:19:49 2009 +0100 +++ b/insttheme Sat Mar 07 19:43:52 2009 +0100 @@ -12,9 +12,18 @@ echo "The specified directory may be called htdocs, but sometimes it is called" echo "something like moin_static160." echo + echo "In more recent versions of MoinMoin, the htdocs directory is found within" + echo "a shared directory such as ../moin/share/moin or /tmp/moin/share/moin," + echo "and you should specify the htdocs directory in this location instead." + echo "For example: ../moin/share/moin/htdocs" + echo echo "You may wish to uncomment and modify the chown command in this script." exit fi -cp css/*.css $1/$2/css/ -#chown www-data: $1/htdocs/$2/css/ +cp -i css/*.css $1/$2/css/ +#chown www-data: $1/$2/css/ +echo "Don't forget to update the screen.css file:" +echo $1/$2/css/screen.css +echo +echo "See the README.txt file for details." diff -r c935e9f0e746 -r 8048fa9c38e9 macros/CategoryMenu.py --- a/macros/CategoryMenu.py Tue Feb 10 01:19:49 2009 +0100 +++ b/macros/CategoryMenu.py Sat Mar 07 19:43:52 2009 +0100 @@ -2,7 +2,7 @@ """ MoinMoin - CategoryMenu Macro - @copyright: 2008 by Paul Boddie + @copyright: 2008, 2009 by Paul Boddie @copyright: 2000-2004 Juergen Hermann , 2005-2008 MoinMoin:ThomasWaldmann. @license: GNU GPL (v2 or later), see COPYING.txt for details. @@ -12,7 +12,7 @@ from MoinMoin import wikiutil, search, version import re -__version__ = "0.1" +__version__ = "0.2" Dependencies = ['pages'] @@ -90,6 +90,12 @@ pages.append(page) return pages +def getPrettyPageName(page): + + "Return a nicely formatted title/name for the given 'page'." + + return page.split_title(force=1).replace("_", " ").replace("/", u" » ") + def execute(macro, args): """ @@ -104,7 +110,7 @@ # Interpret the arguments. try: - selected_category_names = wikiutil.parse_quoted_separated(args, name_value=False) + selected_category_names = args and wikiutil.parse_quoted_separated(args, name_value=False) or [] except AttributeError: selected_category_names = args.split(",") @@ -125,14 +131,16 @@ for category in categories: category_name, category_pagename = category + # Work out whether the current page belongs to this category. + page_is_category = page.page_name == category_pagename category_membership_regexp = re.compile(category_membership_regexp_str % category_pagename) - page_in_category = category_membership_regexp.search(page.get_raw_body()) + page_is_in_category = category_membership_regexp.search(page.get_raw_body()) # Generate the submenu where appropriate. if selected_category_names and category_name in selected_category_names or \ - not selected_category_names and (page_is_category or page_in_category): + not selected_category_names and (page_is_category or page_is_in_category): if page_is_category: output.append(fmt.listitem(on=1, attr={"class" : "selected current"})) @@ -148,7 +156,6 @@ # Get the pages and page names in the category. pages_in_category = getPages(category_pagename, request) - pagenames_in_category = [p.page_name for p in pages_in_category] # Visit each page in the category. @@ -157,11 +164,18 @@ for page_in_category in pages_in_category: pagename = page_in_category.page_name + # Get a real page, not a result page. + + real_page_in_category = Page(request, pagename) + + # Get a pretty version of the page name. + + pretty_pagename = getPrettyPageName(real_page_in_category) + if page.page_name == pagename: output.append(fmt.listitem(on=1, attr={"class" : "selected"})) else: output.append(fmt.listitem(on=1)) - output.append(fmt.pagelink(on=1, pagename=pagename)) # Abbreviate long hierarchical names. @@ -178,8 +192,11 @@ prefix = u"\u2014" * common suffix = "/".join(parts[common:]) - output.append(fmt.text("%s %s" % (prefix, suffix))) - output.append(fmt.pagelink(on=0, pagename=pagename)) + output.append(fmt.text(prefix)) + + # Link to the page using the pretty name. + + output.append(real_page_in_category.link_to_raw(request, wikiutil.escape(pretty_pagename))) output.append(fmt.listitem(on=0)) last_parts = parts