source: trunk/lib/Node.cc @ 118

Last change on this file since 118 was 118, checked in by Peter Johansson, 15 years ago

fixes #46 #45 #26 #40

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
RevLine 
[7]1// $Id: Node.cc 118 2006-07-03 07:44:49Z peter $
[4]2
[84]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
[4]24#include "Node.h"
25#include "utility.h"
[100]26#include <config.h> // this header file is created by configure
[4]27
[23]28#include <ctime>
[4]29#include <fstream>
30#include <iostream>
31#include <sstream>
32
33namespace theplu{
34namespace svnstat{
35
[112]36  Node::Node(const u_int level, const std::string& path, 
37             const std::string& output="")
38    : level_(level), path_(path), stats_(path)
[100]39  { 
40    output_name_ = output+file_name(path_); 
[23]41  }
[4]42
[101]43  bool Node::dir(void) const
44  {
45    return false;
46  }
47
[112]48  std::string Node::html_tablerow(const std::string& css_class) const
[101]49  {
50    std::stringstream ss;
[112]51    ss << "<tr class=\"" << css_class << "\">\n"
52       << "<td" << html_link() << "</td>\n" 
[118]53       << "<td>" << stats_.lines() << "</td>\n"
54       << "<td>" << stats_.code() << "</td>\n"
55       << "<td>" << stats_.comments() << "</td>\n"
[112]56       << "<td>" << stats_.last_changed_rev() << "</td>\n"
57       << "<td>" << author() << "</td>\n"
58       << "</tr>\n";
[101]59    return ss.str();
60  }
61
[23]62  void Node::print_footer(std::ostream& os) const
63  {
[47]64    time_t rawtime;
65    struct tm * timeinfo;
66    time ( &rawtime );
67    timeinfo = localtime ( &rawtime );
[101]68    os << "<p align=center><font size=-2>\nGenerated on "
[47]69       << asctime (timeinfo) 
[100]70       << "by <a href=http://lev.thep.lu.se/trac/svnstat/>"
71       << PACKAGE_STRING << "</a>"
[118]72       << "</font>\n</p>\n</div>\n</body>\n</html>\n";
[23]73  }
74
75
76  void Node::print_header(std::ostream& os) const
77  {
[102]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"
[23]83       << "<head>\n"
[74]84       << "<title> svnstat " << name() << "</title>\n"
[23]85       << "</head>\n"
[112]86       << "<link rel=\"stylesheet\" "
87       << "href=\"";
88    for (u_int i=0; i<level_; ++i)
89      os << "../";
[118]90    os << "svnstat.css\" type=\"text/css\" />\n"
91       << "<body>\n"
92       << "<div id=\"menu\">"
93       << "<ul><li></li>"
94       << "<li><a href=\"";
95    for (u_int i=0; i<level_; ++i)
96      os << "../";
97    os << "index.html\">Home</li>"
98       << "</ul></div>"
99       << "<div id=\"main\">"
100       << "<h2>" << output_name() << "</h2>\n";
[23]101  }
102
[4]103}} // end of namespace svnstat and namespace theplu
Note: See TracBrowser for help on using the repository browser.