source: trunk/lib/Node.cc @ 199

Last change on this file since 199 was 199, checked in by Peter Johansson, 16 years ago

refs #87 moved print_header function to html_utility

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1// $Id: Node.cc 199 2006-09-09 10:42:09Z peter $
2
3/*
4  Copyright (C) 2005, 2006 Jari Häkkinen, 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 "Node.h"
25#include "html_utility.h"
26#include "SVNproperty.h"
27#include "utility.h"
28#include <config.h> // this header file is created by configure
29
30#include <ctime>
31#include <fstream>
32#include <sstream>
33
34namespace theplu{
35namespace svndigest{
36
37  Node::Node(const u_int level, const std::string& path, 
38             const std::string& output="")
39    : level_(level), path_(path), stats_(path), svninfo_(path)
40  { 
41    SVNproperty property(path);
42    binary_=property.binary();
43    svndigest_ignore_=property.svndigest_ignore();
44    output_name_ = output+file_name(path_); 
45  }
46
47
48  bool Node::dir(void) const
49  {
50    return false;
51  }
52
53
54  void Node::path_anchor(std::ostream& os) const
55  {
56    os << "<h2 class=\"path\">\n";
57    std::vector<std::string> words;
58    words.reserve(level_+1);
59    std::string word;
60    std::stringstream ss(output_name());
61    while(getline(ss,word,'/'))
62      words.push_back(word);
63    for (size_t i=0; i<words.size()-1; ++i){
64      anchor(os,"index.html", words[i], level_-i, "View " + words[i]);
65      os << "<span class=\"sep\">/</span>\n";
66    }
67    anchor(os,href(), words.back(), level_+2-words.size(), 
68           "View " + words.back()); 
69    os << "\n</h2>\n";
70  }
71
72
73  void Node::html_tablerow(std::ostream& os, 
74                           const std::string& css_class) const
75  {
76    os << "<tr class=\"" << css_class << "\">\n"
77       << "<td class=\"" << node_type() << "\">";
78    if (svndigest_ignore())
79      os << name() << " (<i>svndigest:ignore</i>)";
80    else if (binary())
81      os << name() << " (<i>binary</i>)";
82    else
83      anchor(os,href(), name()); 
84    os << "</td>\n" 
85       << "<td>" << stats_.lines() << "</td>\n"
86       << "<td>" << stats_.code() << "</td>\n"
87       << "<td>" << stats_.comments() << "</td>\n"
88       << "<td>" << stats_.last_changed_rev() << "</td>\n"
89       << "<td>" << author() << "</td>\n"
90       << "</tr>\n";
91  }
92
93
94  void Node::print_footer(std::ostream& os) const
95  {
96    time_t rawtime;
97    struct tm * timeinfo;
98    time ( &rawtime );
99    timeinfo =  gmtime ( &rawtime );
100    os << "<p align=center><font size=-2>\nGenerated on "
101       << asctime (timeinfo) << " (UTC) by ";
102    anchor(os, "http://lev.thep.lu.se/trac/svndigest/", PACKAGE_STRING);
103    os << "</font>\n</p>\n</div>\n</body>\n</html>\n";
104  }
105
106
107}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.