On Mon, Jul 7, 2008 at 11:01 AM, Ted Gifford <[EMAIL PROTECTED]> wrote:
>
>
> Maxim Khitrov wrote:
>>>> What I need then is a way to rewrite the documentation urls via Genshi
>>>> site.html template. This is where my knowledge is lacking a bit. I've
>>>> spent a few hours trying to come up with a rule that works, but so far
>>>> no luck. Can this be done in an elegant way (i.e. a regular expression
>>>> match and replace on the href attribute similar to my RedirectMatch
>>>> rule)? The 'class="missing wiki"' also needs to be removed if it is
>>>> present, and so does the '?' at the end of the page name.
>>>>
>>>> ...
>> If possible, however, I'd rather use the template since that would be
>> a universal solution for all the hosted sites. Everything keeps
>> working as before and I don't need to mess with the database or the
>> source code.
>>
>
> Another solution would be to create a patch and plugin for the wiki
> formatter that would look at wiki/default-pages and render links to some
> default pages as external links. Sort of like a Wiki Preprocessor.
> Obviously WikiStart and a few others would need to be considered (and
> skipped).
>
> Ted
If the only way is through a patch, then the following works for wiki/api.py:
--- api.py.dist 2008-07-07 12:00:51.000000000 -0400
+++ api.py 2008-07-07 12:33:45.000000000 -0400
@@ -314,6 +314,10 @@
if self.has_page(pagename):
return tag.a(label, href=href, class_='wiki')
else:
+ if label[:4] in ['Wiki', 'Trac'] or \
+ label in ['CamelCase', 'InterTrac', 'InterWiki',
'SandBox']:
+ return tag.a(label, href="/doc/wiki/"+label, class_='wiki')
+
if ignore_missing:
return label
return tag.a(label+'?', href=href, class_='missing wiki',
It's a hack, but I'm fine with this. All of the removed pages are
correctly rewritten to the /doc url. I'll have to apply this patch
every time trac is updated, but it doesn't look like what I want to do
is possible via a template.
In case anyone else is interested, here's the script that I use to
create clean trac environments:
#!/bin/sh
root=/srv/trac
timestamp=`date "+%Y-%m-%d %H:%M:%S"`
site=$1
admin=$2
cd $root/sites
if [ -z "$site" ]; then
echo "Usage: `basename $0` <name> [admin]"
exit 1
fi
if [ -d "$site" ]; then
echo "Error: An environment with this name already exists"
exit 1
fi
trac-admin "$site" initenv "New Project ($timestamp)" "sqlite:db/trac.db" "" \
"" --inherit=$root/common/trac.ini
chown -R trac:trac "$site"
cd "$site"
rm templates/site.html
ln -Fs ../../common/htdocs
sqlite3 db/trac.db " \
DELETE FROM component; \
DELETE FROM milestone; \
DELETE FROM permission; \
DELETE FROM version; \
DELETE FROM wiki WHERE \
name LIKE 'Trac%' OR name LIKE 'Wiki%' OR \
name IN ('CamelCase', 'InterTrac', 'InterWiki', 'SandBox'); \
"
if [ ! -z "$admin" ]; then
trac-admin . permission add "$admin" TRAC_ADMIN
fi
echo "All done. Remember to use the admin to configure user permissions."
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---