Changeset 3026 for trac


Ignore:
Timestamp:
08/22/05 11:00:57 (8 years ago)
Author:
hauma
Message:
  • Incorporated suggestion from argh@…
  • Fixed behaviour for external links.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trac/trunk/wiki-macros/redirect.py

    r2985 r3026  
    2020 
    2121    if args: 
    22         link = fmt._expand_module_link(args) 
    23         if link[0] != None: 
    24             out.write('<div class="system-message">') 
    25             out.write('<strong>Redirect: </strong>') 
    26             out.write('You are redirected to ') 
    27             out.write('<a href="' + link[0] + '">') 
    28             out.write(args) 
    29             out.write('</a>') 
    30             out.write('.') 
    31             if shouldRedirect: 
    32                 out.write('Since redirection doesn\'t seem to work, please click ') 
    33                 out.write('<a href="' + link[0] + '">') 
    34                 out.write('here') 
    35                 out.write('</a>') 
    36                 out.write('.') 
     22        link, _, missing, _ = fmt._expand_module_link(args) 
    3723 
    38             out.write('</div>') 
     24    if not link and not missing: 
     25        # This is an external non-trac link 
     26        link = args 
    3927 
    40             if shouldRedirect: 
    41                 out.write('<form id="redirect" method="POST" action="' + link[0] + '">') 
    42                 out.write('<input type="hidden" name="redirectedfrom" value="' + curpage + '">') 
    43                 out.write('</form>') 
     28    if link and not missing: 
     29        out.write('<div class="system-message">') 
     30        out.write('<strong>Redirect: </strong>') 
     31        out.write("This page is an alias for the real page located at ") 
     32        out.write('<a href="') 
     33        out.write(link) 
     34        out.write('">') 
     35        out.write(args) 
     36        out.write('</a>') 
     37        out.write('</div>') 
    4438 
    45                 out.write(NL) 
    46                 out.write('<script language="JavaScript">' + NL) 
    47                 out.write('document.forms["redirect"].submit();' + NL) 
    48                 # out.write('document.location="' + link[0] + '?redirectedfrom=' + curpage + '";' + NL) 
    49                 out.write('</script>' + NL) 
    50         else: 
    51             out.write('<div class="system-message">') 
    52             out.write('<strong>Redirection Error: </strong>') 
    53             out.write('Redirection target not found.') 
    54             out.write('</div>') 
     39        if shouldRedirect: 
     40            out.write('<form id="redirect" method="POST" action="' + link + '">') 
     41            out.write('<input type="hidden" name="redirectedfrom" value="' + curpage + '">') 
     42            out.write('</form>') 
     43 
     44            out.write(NL) 
     45            out.write('<script language="JavaScript">' + NL) 
     46            out.write('document.forms["redirect"].submit();' + NL) 
     47            out.write('</script>' + NL) 
     48 
     49    elif link and missing: 
     50        # Internal link to a non-existing page 
     51        out.write('<div class="system-message">') 
     52        out.write('<strong>Redirection Error: </strong>') 
     53        out.write('Redirection target not found: ') 
     54        out.write('<a href="') 
     55        out.write(link) 
     56        out.write('">') 
     57        out.write(args) 
     58        out.write('</a>') 
     59        out.write('</div>') 
    5560 
    5661    else: 
     62        # No arguments given to the redirect macro 
    5763        out.write('<div class="system-message">') 
    5864        out.write('<strong>Redirection Error: </strong>') 
Note: See TracChangeset for help on using the changeset viewer.