source: trunk/lib/Node.cc @ 120

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

fixed bug. anchor is now closed see Ref #53

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1// $Id: Node.cc 120 2006-07-03 13:47:06Z 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_.lines() << "</td>\n"
54       << "<td>" << stats_.code() << "</td>\n"
55       << "<td>" << stats_.comments() << "</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</div>\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       << "<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</a></li>"
98       << "</ul></div>"
99       << "<div id=\"main\">"
100       << "<h2>" << output_name() << "</h2>\n";
101  }
102
103}} // end of namespace svnstat and namespace theplu
Note: See TracBrowser for help on using the repository browser.