source: trunk/lib/Trac.cc @ 287

Last change on this file since 287 was 287, checked in by Peter Johansson, 14 years ago

remove debug code

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1// $Id: Trac.cc 287 2007-05-07 16:14:30Z peter $
2
3/*
4  Copyright (C) 2007 Peter Johansson
5
6  This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest
7
8  svndigest is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12
13  svndigest is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "Trac.h"
25
26#include "Configuration.h"
27#include "HtmlStream.h"
28#include "html_utility.h"
29
30namespace theplu{
31namespace svndigest{
32
33  Trac::Trac(HtmlStream& hs)
34    : hs_(hs) 
35  {}
36
37  void Trac::print(std::string str)
38  {
39    std::string::const_iterator first(str.begin());
40    while (first!=str.end()) {
41      std::string::const_iterator begin(first);
42      if (ticket(first, str.end()))
43        continue;
44      hs_ << *first;
45      ++first;
46    }
47  }
48
49
50  bool Trac::ticket(std::string::const_iterator& first, 
51                    const std::string::const_iterator& last)
52  {
53    if (first==last)
54      return false;
55
56    const std::string::const_iterator first_orig(first);
57    if (*first != '#')
58      return false;
59    ++first;
60    std::string ticket;
61    for (;first!=last && isdigit(*first); ++first) 
62      ticket.append(1,*first);
63
64    if (ticket.empty())
65      return false;
66
67    Configuration* conf = Configuration::instance();
68    hs_.stream() << anchor(conf->trac_ticket()+ticket,"#"+ticket); 
69    return true;
70  }
71
72}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.