Changeset 289 for trunk/lib/Trac.cc


Ignore:
Timestamp:
May 8, 2007, 2:48:07 PM (14 years ago)
Author:
Peter Johansson
Message:

fixed trac link problem. fixes #178 and refs #180. Also changed format of config file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Trac.cc

    r288 r289  
    2727#include "HtmlStream.h"
    2828#include "html_utility.h"
     29#include "utility.h"
    2930
    3031namespace theplu{
     
    5960      return false;
    6061    ++first;
    61     std::string ticket;
    62     for (;first!=last && isdigit(*first); ++first)
    63       ticket.append(1,*first);
     62    std::string ticket = match(first, last, Digit());
    6463
    65     if (ticket.empty())
     64    if (ticket.empty()) {
     65      first = first_orig;
    6666      return false;
     67    }
    6768
    68     Configuration* conf = Configuration::instance();
    69     hs_.stream() << anchor(conf->trac_ticket()+ticket,"#"+ticket);
     69    const Configuration& conf = Configuration::instance();
     70    hs_.stream() << anchor(conf.trac_root()+"ticket/"+ticket,"#"+ticket);
    7071    return true;
    7172  }
     
    7980
    8081    const std::string::const_iterator first_orig(first);
    81     if (*first != '#')
     82
     83    const std::string log_str("log:");
     84    if (!match_begin(first, last, log_str)) {
     85      first = first_orig;
    8286      return false;
     87    }
     88    first += log_str.size();
     89    std::string node = match(first, last, not2Char('#', '@'));
    8390    ++first;
    84     std::string ticket;
    85     for (;first!=last && isdigit(*first); ++first)
    86       ticket.append(1,*first);
    87 
    88     if (ticket.empty())
     91    std::string stop_rev = match(first, last, Digit());
     92    if (stop_rev.empty() || first == last || *first != ':') {
     93      first = first_orig;
    8994      return false;
    90 
    91     Configuration* conf = Configuration::instance();
    92     hs_.stream() << anchor(conf->trac_ticket()+ticket,"#"+ticket);
     95    }
     96    ++first;
     97    std::string rev = match(first, last, Digit());
     98    std::string href(Configuration::instance().trac_root()+"log"+node+
     99                     "?rev="+rev+"&stop_rev="+stop_rev);
     100    std::string str(first_orig, first);
     101    hs_.stream() << anchor(href, str);
    93102    return true;
    94103  }
Note: See TracChangeset for help on using the changeset viewer.