source: trunk/lib/Trac.cc @ 286

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

moved trac link detection to separate file. refs #178

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.8 KB
RevLine 
[286]1// $Id: Trac.cc 286 2007-05-07 16:07:23Z 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    int test=0;
41    while (first!=str.end() && test<10) {
42      std::string::const_iterator begin(first);
43      ++test;
44      if (ticket(first, str.end()))
45        continue;
46      hs_ << *first;
47      ++first;
48    }
49  }
50
51
52  bool Trac::ticket(std::string::const_iterator& first, 
53                    const std::string::const_iterator& last)
54  {
55    if (first==last)
56      return false;
57
58    const std::string::const_iterator first_orig(first);
59    if (*first != '#')
60      return false;
61    ++first;
62    std::string ticket;
63    for (;first!=last && isdigit(*first); ++first) 
64      ticket.append(1,*first);
65
66    if (ticket.empty())
67      return false;
68
69    Configuration* conf = Configuration::instance();
70    hs_.stream() << anchor(conf->trac_ticket()+ticket,"#"+ticket); 
71    return true;
72  }
73
74}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.