source: trunk/lib/Node.cc @ 112

Last change on this file since 112 was 112, checked in by Peter Johansson, 17 years ago

fixes #27 and added some beauty

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1// $Id: Node.cc 112 2006-06-29 09:30:54Z peter $
2
3/*
4  Copyright (C) 2005, 2006 Jari Häkkinen, Peter Johansson
5
6  This file is part of svnstat, http://lev.thep.lu.se/trac/svnstat
7
8  svnstat 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  svnstat 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 "Node.h"
25#include "utility.h"
26#include <config.h> // this header file is created by configure
27
28#include <ctime>
29#include <fstream>
30#include <iostream>
31#include <sstream>
32
33namespace theplu{
34namespace svnstat{
35
36  Node::Node(const u_int level, const std::string& path, 
37             const std::string& output="")
38    : level_(level), path_(path), stats_(path)
39  { 
40    output_name_ = output+file_name(path_); 
41  }
42
43  bool Node::dir(void) const
44  {
45    return false;
46  }
47
48  std::string Node::html_tablerow(const std::string& css_class) const
49  {
50    std::stringstream ss;
51    ss << "<tr class=\"" << css_class << "\">\n"
52       << "<td" << html_link() << "</td>\n" 
53       << "<td>" << stats_.rows() << "</td>\n"
54       << "<td>" << "---" << "</td>\n"
55       << "<td>" << "---" << "</td>\n"
56       << "<td>" << stats_.last_changed_rev() << "</td>\n"
57       << "<td>" << author() << "</td>\n"
58       << "</tr>\n";
59    return ss.str();
60  }
61
62  void Node::print_footer(std::ostream& os) const
63  {
64    time_t rawtime;
65    struct tm * timeinfo;
66    time ( &rawtime );
67    timeinfo = localtime ( &rawtime );
68    os << "<p align=center><font size=-2>\nGenerated on "
69       << asctime (timeinfo) 
70       << "by <a href=http://lev.thep.lu.se/trac/svnstat/>"
71       << PACKAGE_STRING << "</a>"
72       << "</font>\n</p>\n</body>\n</html>\n";
73  }
74
75
76  void Node::print_header(std::ostream& os) const
77  {
78    os << "<!DOCTYPE html\n"
79       << "PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
80       << "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
81       << "<html xmlns=\"http://www.w3.org/1999/xhtml\""
82       << " xml:lang=\"en\" lang=\"en\"><head>\n"
83       << "<head>\n"
84       << "<title> svnstat " << name() << "</title>\n"
85       << "</head>\n"
86       << "<link rel=\"stylesheet\" "
87       << "href=\"";
88    for (u_int i=0; i<level_; ++i)
89      os << "../";
90    os << "svnstat.css\" type=\"text/css\" />\n";
91  }
92
93}} // end of namespace svnstat and namespace theplu
Note: See TracBrowser for help on using the repository browser.