source: trunk/lib/Node.cc @ 213

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

fixes #41 and refs #87 added output for individual developers. Links should be added from the main page.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1// $Id: Node.cc 213 2006-09-15 15:05:45Z 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
29#include <cassert>
30#include <ctime>
31#include <fstream>
32#include <sstream>
33
34namespace theplu{
35namespace svndigest{
36
37  std::string Node::project_=std::string();
38
39  Node::Node(const u_int level, const std::string& path, 
40             const std::string& local_path)
41    : level_(level), path_(path), stats_(path), 
42      svninfo_(path)
43  { 
44    SVNproperty property(path);
45    binary_=property.binary();
46    svndigest_ignore_=property.svndigest_ignore();
47    if (Node::project_==std::string()) // no root directory in local path
48      Node::project_ = file_name(path);
49    else if (local_path.empty())
50      local_path_ = file_name(path);
51    else
52      local_path_ = local_path + "/" + file_name(path);
53  }
54
55
56  bool Node::dir(void) const
57  {
58    return false;
59  }
60
61
62  void Node::path_anchor(std::ostream& os) const
63  {
64
65    os << "<h2 class=\"path\">\n";
66    std::vector<std::string> words;
67    words.reserve(level_+1);
68    std::string word;
69    words.push_back(Node::project_);
70    std::stringstream ss(local_path());
71    while(getline(ss,word,'/'))
72      if (!word.empty()) // ignore double slash in path
73        words.push_back(word);
74    if (words.size()==1)
75      anchor(os, "index.html", Node::project_,0, "View " + Node::project_);
76    else {
77      for (size_t i=0; i<words.size()-1; ++i){
78        anchor(os,"index.html", words[i], level_-i, "View " + words[i]);
79        os << "<span class=\"sep\">/</span>\n";
80      }
81      anchor(os,href(), words.back(), level_+2-words.size(), 
82             "View " + words.back()); 
83    }
84    os << "\n</h2>\n";
85  }
86
87
88  void Node::html_tablerow(std::ostream& os, 
89                           const std::string& css_class,
90                           const std::string& user) const
91  {
92    os << "<tr class=\"" << css_class << "\">\n"
93       << "<td class=\"" << node_type() << "\">";
94    if (svndigest_ignore())
95      os << name() << " (<i>svndigest:ignore</i>)";
96    else if (binary())
97      os << name() << " (<i>binary</i>)";
98    else
99      anchor(os,href(), name()); 
100    os << "</td>\n"; 
101    if (user=="all") {
102      os << "<td>" << stats_.lines() << "</td>\n"
103         << "<td>" << stats_.code() << "</td>\n"
104         << "<td>" << stats_.comments() << "</td>\n"
105         << "<td>" << stats_.empty() << "</td>\n";
106    }
107    else {
108      os << "<td>" << stats_.lines(user) << "</td>\n"
109         << "<td>" << stats_.code(user) << "</td>\n"
110         << "<td>" << stats_.comments(user) << "</td>\n"
111         << "<td>" << stats_.empty(user) << "</td>\n";
112    }
113    os << "<td>" << stats_.last_changed_rev() << "</td>\n"
114       << "<td>" << author() << "</td>\n"
115       << "</tr>\n";
116  }
117
118
119}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.