Changeset 289


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

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

Location:
trunk
Files:
4 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/.svndigest/config

    r274 r289  
    1212### Section for setting trac environment
    1313[trac]
    14 # If trac-ticket is set, svndigest will create anchors for
    15 # ticket to the Trac page.
    16 trac-ticket = http://lev.thep.lu.se/trac/svndigest/ticket/
    17 # If trac-revision is set, svndigest will create anchors for
    18 # revisions to the Trac page.
    19 trac-revision = http://lev.thep.lu.se/trac/svndigest/changeset/
     14# If trac-root is set, svndigest will create anchors to # the Trac page.
     15# trac-root = http://lev.thep.lu.se/trac/svndigest/
     16trac-root = http://lev.thep.lu.se/trac/svndigest/
    2017
  • trunk/bin/svndigest.cc

    r285 r289  
    6262
    6363  // Reading configuration file
    64   Configuration* config = Configuration::instance();
     64  Configuration& config = Configuration::instance();
    6565  if (node_exist(option->config_file())) {
    6666    std::ifstream is(option->config_file().c_str());
     
    7171      exit(-1);
    7272    }
    73     config->load(is);
     73    config.load(is);
    7474    is.close();
    7575  }
    7676  else
    77     config->load();
    78   assert(config);
     77    config.load();
    7978 
    8079  // write configuration
    8180  if (option->generate_config()) {
    82     std::cout << *config;
     81    std::cout << config;
    8382    exit(0);
    8483  }
     
    9291  }
    9392  catch (SVNException e) {
    94     std::cerr << "\nsvndigest: " << e.what() << "\nsvndigest: " << option->root()
     93    std::cerr << "\nsvndigest: " << e.what() << "\nsvndigest: "
     94              << option->root()
    9595              << " is not under subversion control\n" << std::endl;
    9696    exit(-1);
     
    180180      if (option->verbose())
    181181        std::cout << "Updating copyright statements" << std::endl;
    182       std::map<std::string, std::string> alias(config->copyright_alias());
     182      std::map<std::string, std::string> alias(config.copyright_alias());
    183183      tree.print_copyright(alias);
    184184    }
  • trunk/lib/Configuration.cc

    r274 r289  
    7979        getline(ss, tmp);
    8080        std::string value = trim(tmp);
    81         if (key=="trac-ticket")
    82           trac_ticket_=value;
    83         if (key=="trac-revision")
    84           trac_revision_=value;
    85        
     81        if (key=="trac-ticket"){
     82          std::cerr << "svndigest: warning: config variable trac-ticket "
     83                    << "is deprecated. Use trac-root instead.\n";
     84          trac_root_ = value.substr(0,value.size()-7);
     85        }
     86        if (key=="trac-revision"){
     87          std::cerr << "svndigest: warning: config variable trac-revision "
     88                    << "is deprecated. Use trac-root instead.\n";
     89          trac_root_ = value.substr(0,value.size()-10);
     90        }
     91        if (key=="trac-root")
     92          trac_root_=value;
    8693      }
    8794    }
     
    8996
    9097
    91   Configuration* Configuration::instance(void)
     98  Configuration& Configuration::instance(void)
    9299  {
    93100    if (!instance_)
    94101      instance_ = new Configuration;
    95     return instance_;
     102    return *instance_;
    96103  }
    97104
     
    100107  {
    101108    copyright_alias_.clear();
    102     trac_ticket_ = "";
    103     trac_revision_ = "";
     109    trac_root_ = "";
     110  }
     111
     112
     113  std::string Configuration::trac_root(void) const
     114  {
     115    return trac_root_;
    104116  }
    105117
     
    124136       << "### Section for setting trac environment\n"
    125137       << "[trac]\n"
    126        << "# If trac-ticket is set, svndigest will create anchors for\n"
    127        << "# ticket to the Trac page.\n"
    128        << "trac-ticket = " << conf.trac_ticket() << "\n";
    129     os << "# If trac-revision is set, svndigest will create anchors for\n"
    130        << "# revisions to the Trac page.\n"
    131        << "trac-revision = " << conf.trac_revision() << "\n";
     138       << "# If trac-root is set, svndigest will create anchors to "
     139       << "the Trac page.\n"
     140       << "# trac-root = http://lev.thep.lu.se/trac/svndigest/\n";
     141    if (!conf.trac_root().empty())
     142      os << "trac-root = " << conf.trac_root() << "\n";
    132143
    133144    return os;
  • trunk/lib/Configuration.h

    r274 r289  
    4040  {
    4141  public:
    42     static Configuration* instance(void);
     42    static Configuration& instance(void);
    4343
    4444    ///
     
    6060    ///
    6161    /// @return root for the trac envrionment, e.g.,
    62     /// http://lev.thep.lu.se/trac/svndigest/ticket/
     62    /// http://lev.thep.lu.se/trac/svndigest/
    6363    ///
    64     inline std::string trac_ticket(void) const { return trac_ticket_; }
    65 
    66     ///
    67     /// @return root for the trac envrionment, e.g.,
    68     /// http://lev.thep.lu.se/trac/svndigest/ticket/
    69     ///
    70     std::string trac_revision(void) const { return trac_revision_; }
     64    std::string trac_root(void) const;
    7165
    7266  private:
     
    7973    // Copy Constructor not implemented
    8074    Configuration(const Configuration&);
     75    // assignment not implemented because assignment is always self-assignment
     76    Configuration& operator=(const Configuration&);
    8177
    8278    void clear(void);
     
    8884    std::map<std::string, std::string> copyright_alias_;
    8985
    90     std::string trac_ticket_;
    91     std::string trac_revision_;
    92    
     86    std::string trac_root_;
    9387  };
    9488
  • 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  }
  • trunk/lib/first_page.cc

    r286 r289  
    164164    std::string timefmt("%b %d %H:%M:%S %Y");
    165165    const size_t maxlength = 80;
    166     const Configuration* conf = Configuration::instance();
     166    const Configuration& conf = Configuration::instance();
    167167    for (size_t i=0; i<10 && a!=log.author().rend(); ++i) {
    168168      os << "<tr><td>" << anchor(*a+"/total/index.html",*a) << "</td>";
     
    181181        mess = mess.substr(0,maxlength-3) + "...";
    182182
    183       if (conf->trac_ticket().empty())
     183      if (conf.trac_root().empty())
    184184        hs << mess;
    185185      else {// make anchors to trac
  • trunk/lib/html_utility.cc

    r285 r289  
    130130  std::string trac_revision(size_t r)
    131131  {
    132     Configuration* conf = Configuration::instance();
     132    const Configuration& conf = Configuration::instance();
    133133    std::stringstream ss;
    134     if (conf->trac_revision().empty())
     134    if (conf.trac_root().empty())
    135135      ss << r;
    136136    else {
    137137      std::stringstream rev;
    138138      rev << r;
    139       ss << anchor(conf->trac_revision()+rev.str(), rev.str());
     139      ss << anchor(conf.trac_root()+"changeset/"+rev.str(), rev.str());
    140140    }
    141141    return ss.str();
  • trunk/lib/utility.cc

    r274 r289  
    165165
    166166
     167  notChar::notChar(char c)
     168    : char_(c)
     169  {}
     170
     171
     172  not2Char::not2Char(char c1, char c2)
     173    : char1_(c1), char2_(c2)
     174  {}
     175   
     176
    167177}} // end of namespace svndigest and namespace theplu
  • trunk/lib/utility.h

    r274 r289  
    132132  ///
    133133  inline std::string trim(std::string str) { return htrim(ltrim(str)); }
     134
     135
     136  template <class T>
     137  std::string match(std::string::const_iterator& first,
     138                    const std::string::const_iterator& last,
     139                    const T& func)
     140  {
     141    std::string res;
     142    for (;first!=last && func(*first); ++first)
     143      res.append(1,*first);
     144    return res;
     145  }
     146
     147  struct Digit
     148  {
     149    inline bool operator()(char c) const { return isdigit(c); }
     150  };
     151
     152  class notChar
     153  {
     154  public:
     155    notChar(char);
     156    inline bool operator()(char c) const { return c!=char_; }
     157  private:
     158    char char_;
     159  };
     160
     161  class not2Char
     162  {
     163  public:
     164    not2Char(char, char);
     165    inline bool operator()(char c) const
     166    { return c!=char1_ && c!=char2_; }
     167  private:
     168    const char char1_;
     169    const char char2_;
     170  };
    134171
    135172  ///
  • trunk/test/repo/db/current

    r270 r289  
    1 47 1i 1
     149 1i 1
Note: See TracChangeset for help on using the changeset viewer.