Tags:
create new tag
, view all tags

Bug: matching and substituting %EDITTOPIC%

when viewing a previous version of a topic, the view script substitutes only one occurrence of the variable %EDITTOPIC%.

this works fine if you don't modify the view.tmpl. on the other hand, if you want for example an 'edit' link also at the top of the page, then only this one is matched and substituted, while the bottom one remains untouched. this behaviour would be consistent with a resulting on one single line...

the correction is extremely simple: at view:197

-        $tmpl =~ s/%EDITTOPIC%/<strike>Edit<\/strike>/o;
+        $tmpl =~ s/%EDITTOPIC%/<strike>Edit<\/strike>/go;

which would be in line with the two matches and substitutions a few lines after:

        $tmpl =~ s/%REVTITLE%/\(r1.$rev\)/go;
        $tmpl =~ s/%REVARG%/&rev=1.$rev/go;

Test case

this is a snippet from my view.tmpl. the only changes are in the title, notice headtitleaction, which is defined a few lines below, and in the definition of titleaction. It is this which causes %EDITTOPIC% to be used twice in the resulting page and shows the error on my system.

%TMPL:INCLUDE{"twiki"}%
%TMPL:P{"htmldoctype"}%
<head>
 <title> %WIKITOOLNAME% . %WEB% . %TOPIC% %TMPL:P{"headtitleaction"}%</title>
 <meta http-equiv="Content-Type" content="text/html; charset=%CHARSET%" /> <meta name="robots" content="noindex" /> %HTTP_EQUIV_ON_VIEW%
 <base href="%SCRIPTURL%/view%SCRIPTSUFFIX%/%WEB%/%TOPIC%" />
</head>
<body bgcolor="%BODYBGCOLOR%">
#PageTop
<form name="main" action="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/%INTURLENCODE{"%WEB%/%TOPIC%"}%">
%TMPL:DEF{"headtitleaction"}% %REVTITLE% %TMPL:END%
%TMPL:DEF{"webaction"}% %WEBTOPICLIST% %TMPL:END%
%TMPL:DEF{"titleaction"}% %REVTITLE%
    <font size="-1">. {<font size="-2">%EDITTOPIC%</font>}</font>
%TMPL:END%
%TMPL:P{"standardheader"}%
</form>

Environment

TWiki version: TWikiRelease01Feb2003
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Slackware 8.0, kernel 2.4.22
Web server: Apache/1.3.20
Perl version: 5.6.1
Client OS: Slackware 8.0, kernel 2.4.22
Web Browser: Mozilla 1.2.1

-- MarioFrasca - 03 Nov 2003

Follow up

Fix record

I fixed this on the specified location and in a few other places. Is in TWikiAlphaRelease and at TWiki.org.

*** old/bin/view  2003-10-25 17:25:09.000000000 -0700
--- new/bin/view  2003-11-22 23:04:54.000000000 -0800
***************
*** 188,195 ****
      if( $mirrorSiteName ) {
          # disable edit and attach
        # FIXME: won't work with non-default skins, see %EDITURL%
!         $tmpl =~ s/%EDITTOPIC%/$mirrorLink | <strike>Edit<\/strike>/o;
!         $tmpl =~ s/<a [^>]*?>Attach<\/a>/<strike>Attach<\/strike>/oi;
          if( $topicExists ) {
              # remove the NOINDEX meta tag
              $tmpl =~ s/<meta name="robots"[^>]*>//goi;
--- 188,195 ----
      if( $mirrorSiteName ) {
          # disable edit and attach
        # FIXME: won't work with non-default skins, see %EDITURL%
!         $tmpl =~ s/%EDITTOPIC%/$mirrorLink | <strike>Edit<\/strike>/go;
!         $tmpl =~ s/<a [^>]*?>Attach<\/a>/<strike>Attach<\/strike>/goi;
          if( $topicExists ) {
              # remove the NOINDEX meta tag
              $tmpl =~ s/<meta name="robots"[^>]*>//goi;
***************
*** 201,209 ****
      } elsif( $rev < $maxrev ) {
          # disable edit of previous revisions - FIXME consider change to use two templates
        # FIXME: won't work with non-default skins, see %EDITURL%
!         $tmpl =~ s/%EDITTOPIC%/<strike>Edit<\/strike>/o;
!         $tmpl =~ s/<a [^>]*?>Attach<\/a>/<strike>Attach<\/strike>/oi;
!         $tmpl =~ s|<a [^>]*?>Rename/move<\/a>|<strike>Rename/move<\/strike>|oi;
          $tmpl =~ s/%REVTITLE%/\(r1.$rev\)/go;
          $tmpl =~ s/%REVARG%/&rev=1.$rev/go;
      } else {
--- 201,209 ----
      } elsif( $rev < $maxrev ) {
          # disable edit of previous revisions - FIXME consider change to use two templates
        # FIXME: won't work with non-default skins, see %EDITURL%
!         $tmpl =~ s/%EDITTOPIC%/<strike>Edit<\/strike>/go;
!         $tmpl =~ s/<a [^>]*?>Attach<\/a>/<strike>Attach<\/strike>/goi;
!         $tmpl =~ s|<a [^>]*?>Rename/move<\/a>|<strike>Rename/move<\/strike>|goi;
          $tmpl =~ s/%REVTITLE%/\(r1.$rev\)/go;
          $tmpl =~ s/%REVARG%/&rev=1.$rev/go;
      } else {

-- PeterThoeny - 23 Nov 2003

WebForm
TopicClassification BugResolved
TopicSummary When viewing a previous version of a topic, the view script substitutes only one occurrence of the variable %EDITTOPIC%.
InterestedParties

AssignedTo

AssignedToCore PeterThoeny
ScheduledFor CairoRelease
RelatedTopics

SpecProgress 100%
ImplProgress 100%
DocProgress 100%
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2004-08-20 - CrawfordCurrie
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.