Modify

Opened 18 years ago

Closed 18 years ago

#383 closed defect (fixed)

0.10-incompatibility: No TOCs on main wiki page, and preview mode oddities.

Reported by: Dinko Korunic <dinko.korunic@…> Owned by: Alec Thomas
Priority: normal Component: TocMacro
Severity: normal Keywords: review
Cc: Trac Release: 0.10

Description

TocMacro (0.9, checkouted from SVN) stopped working with latest Trac SVN r3326. When user visits http://site/wiki and TocMacro is in WikiStart, TOC is not displayed. However, TOC reappears when URL is corrected to http://site/wiki/WikiStart.

You can check the said behaviour on Hybserv Trac site. Compare the following URI:

TIA.

Attachments (0)

Change History (14)

comment:1 Changed 18 years ago by Alec Thomas

Resolution: invalid
Status: newclosed

Works? Weird.

comment:2 Changed 18 years ago by Alec Thomas

Resolution: invalid
Status: closedreopened

Scratch that, not awake yet.

comment:3 Changed 18 years ago by Max Bowsher

Interestingly, it's not the WikiStart bit of the URL that matters:

comment:4 Changed 18 years ago by Dinko Korunic <dinko.korunic@…>

Actually yes, you're right. I've later found out that '/' at the end of URL affects it to. And as a side bonus, whole TOC gets selected (that didn't use to work like that) :-)

comment:5 Changed 18 years ago by Dinko Korunic <dinko.korunic@…>

Rather crude fix:

Index: macro.py
===================================================================
--- macro.py    (revision 867)
+++ macro.py    (working copy)
@@ -106,6 +107,9 @@
             if req.path_info.startswith('/wiki/'):
                 current_page = req.path_info[6:]
                 in_preview = True
+            elif req.path_info == '/wiki':
+                current_page = '/wiki/'
+                in_preview = True
             else:
                 return ''

And actually that seems a Trac bug, since it doesn't set wiki.page_name..

comment:6 Changed 18 years ago by Max Bowsher

Keywords: review added

A different fix:

Index: tractoc/macro.py
===================================================================
--- tractoc/macro.py    (revision 871)
+++ tractoc/macro.py    (working copy)
@@ -99,15 +99,9 @@
         if 'macro_no_float' in req.hdf:
             return ''

-        # If this is a page preview, try to figure out where its from
+        # Find our invoking page, and whether we are a preview
         current_page = req.hdf.getValue('wiki.page_name','WikiStart')
-        in_preview = False
-        if not req.hdf.has_key('wiki.page_name'):
-            if req.path_info.startswith('/wiki/'):
-                current_page = req.path_info[6:]
-                in_preview = True
-            else:
-                return ''
+        in_preview = req.args.has_key('text')

         def get_page_text(pagename):
             """Return a tuple of (text, exists) for a page, taking into account previews."""

This won't work with 0.9, but seems a fairly clean way to work with 0.10.

The current semantics of 0.10 seem to be:

  • Set wiki.page_name always (view and preview), except for _view_ of WikiStart.
  • Never set wiki.action in time for macros to see it - which would enable us to explicitly test whether we were previewing or not. Fortunately, we can manage an acceptable substitute by just checking to see if req.args['text'] exists.

comment:7 Changed 18 years ago by Dinko Korunic <dinko.korunic@…>

Seems fairly clean. Too bad for backwards compatibility, though :/

comment:8 Changed 18 years ago by Noah Kantrowitz

There are 0.9 and 0.10 branches of most plugins and macros for that reason ;-)

comment:9 Changed 18 years ago by Max Bowsher

Trac Release: 0.90.10

comment:10 Changed 18 years ago by Max Bowsher

Summary: Stopped working with trac trunk on main Wiki page0.10-incompatibility: No TOCs on main wiki page, and preview mode oddities.

Just as clarification, the symptoms being fixed here are:

  • When accessed as http://server/trac/wiki or http://server/trac, all TOCs are not rendered.
  • When accessed as http://server/trac/wiki/WikiStart, TOCs show a title but links.
  • Preview mode doesn't preview, it produces a TOC based on the unedited page contents.

comment:11 Changed 18 years ago by Noah Kantrowitz

Resolution: fixed
Status: reopenedclosed

Possibly fixed in [931]. Can someone test this out and reopen the ticket if needed?

comment:12 Changed 18 years ago by Max Bowsher

Resolution: fixed
Status: closedreopened

[931] fixed the preview mode, but also completely broke TOCs on WikiStart.

Apply this patch:

-        current_page = req.hdf['wiki.page_name']
+        current_page = req.hdf.getValue('wiki.page_name','WikiStart')

reverting part of [931], to fix this ticket.

comment:13 Changed 18 years ago by Max Bowsher

Alternatively, wait for #t3294 to be fixed, at which point the current TocMacro code will be correct, and start working again.

comment:14 Changed 18 years ago by Noah Kantrowitz

Resolution: fixed
Status: reopenedclosed

Fixed for now

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Alec Thomas.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.