Changeset 223 for trunk


Ignore:
Timestamp:
Mar 9, 2007, 9:44:35 AM (15 years ago)
Author:
Peter Johansson
Message:

Refs #87

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/svndigest.cc

    r213 r223  
    33/*
    44  Copyright (C) 2006 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2007 Peter Johansson
    56
    67  This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest
     
    143144                                 +tree.name()+"'");
    144145  print_css("svndigest.css");
    145   print_main_page(tree.name(), commit_dates);
     146  print_main_page(tree.name(), commit_dates, stats);
    146147  mkdir("all");
    147148  for (std::set<std::string>::const_iterator i = stats.authors().begin();
  • trunk/lib/html_utility.cc

    r216 r223  
    22
    33/*
    4   Copyright (C) 2006 Peter Johansson
     4  Copyright (C) 2006, 2007 Peter Johansson
    55
    66  This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest
     
    2323
    2424#include "html_utility.h"
     25#include "Stats.h"
    2526#include "utility.h"
    2627#include <config.h> // this header file is created by configure
     
    9798    s << "<-- svndigest.css generated by " << PACKAGE_STRING << "\n"
    9899
    99       << "Copyright (C) 2006 Peter Johansson\n\n"
     100      << "Copyright (C) 2006, 2007 Peter Johansson\n\n"
    100101      << "This file is part of svndigest, "
    101102      << "http://lev.thep.lu.se/trac/svndigest\n\n"
     
    188189    s << "\n";
    189190    s << "div.main {\n";
    190     s << " text-align: center\n";
    191     s << "}\n";
     191    s << "margin-top: 50px;\n";         
     192    s << "margin-left: 50px;\n";
     193    s << " \n";
     194    s << "}\n";
     195    s << "table.main {\n";
     196    s << " text-align: left;\n";
     197    s << " padding: 0 1em .1em 0;\n";
     198    s << "}\n";
     199    s << "table.main th {\n";
     200    s << " text-align: left;\n";
     201    s << " padding: 0 1em 0.5em 0;\n";
     202    s << " font-size: 150%;\n";
     203    s << " font-wheight: bold;\n";
     204    s << "}\n";
     205    s << "table.main td {\n";
     206    s << " padding: 0 1em .1em 0;\n";
     207    s << "}\n";
     208
     209
     210
     211
    192212    s << "table.listings {\n";
    193213    s << " clear: both;\n";
     
    242262
    243263  void print_main_page(const std::string& dir,
    244                        const std::vector<std::string>& commit_dates)
     264                       const std::vector<std::string>& commit_dates,
     265                       const Stats& stats)
    245266  {
    246267    std::string filename="index.html";
    247268    std::ofstream os(filename.c_str());
    248269    print_header(os, dir, 0, "main", "index.html");
    249     time_t now;
    250     time (&now);
    251     u_int n7=0;
    252     u_int n30=0;
    253     u_int n365=0;
    254     for (size_t i=1; i<commit_dates.size(); ++i){
    255       double diff = difftime(now,str2time(commit_dates[i]));
    256       if (diff<365*24*3600){
    257         n365++;
    258         if (diff<30*24*3600){
    259           n30++;
    260           if (diff<7*24*3600)
    261             n7++;
    262         }
     270    time_t first = str2time(commit_dates[0]);
     271    time_t last = str2time(commit_dates.back());
     272   
     273    u_int years = 0;
     274    u_int months  = 0;
     275    u_int days = 0;
     276    // No support in std for diffing two tm structs
     277    time_t now = time(NULL);
     278    tm* timeinfo = gmtime(&now);
     279    while (difftime(now,first)>0){
     280      --timeinfo->tm_year;
     281      now = mktime(timeinfo);
     282      ++years;
     283    }
     284    --years;
     285    ++timeinfo->tm_year;
     286    now = mktime(timeinfo);
     287   
     288    while (difftime(now,first)>0){
     289      if (timeinfo->tm_mon>0)
     290        --timeinfo->tm_mon;
     291      else{
     292        timeinfo->tm_mon=11;
     293        --timeinfo->tm_year;
    263294      }
     295      now = mktime(timeinfo);
     296      ++months;
    264297    }
     298    --months;
     299    ++timeinfo->tm_mon;
     300    if (timeinfo->tm_mon>11){
     301      timeinfo->tm_mon=0;
     302      ++timeinfo->tm_year;
     303    }
     304    now = mktime(timeinfo);
     305   
     306    days = (now - first)/60/60/24;
     307
     308    now = time(NULL);
    265309    os << "<div class=\"main\">\n"
    266        << "<table><thead><tr><th>Statistics for " << dir
     310       << "<table class=\"main\"><thead><tr><th colspan=\"2\">"
     311       << "General Information"
    267312       << "</th></tr><thead>\n"
    268        << "<tr><td>Total number of commits</td><td>"
    269        << commit_dates.size()-1 << "</td></tr>\n"
    270        << "<tr><td>Commits last year</td><td>" << n365 << "</td></tr>\n"
    271        << "<tr><td>Commits last month</td><td>" << n30 << "</td></tr>\n"
    272        << "<tr><td>Commits last week</td><td>" << n7 << "</td></tr>\n"
     313       << "<tr><td>First Revision:</td><td>"
     314       << asctime(gmtime(&first)) << "</td></tr>\n"
     315       << "<tr><td>Latest Revision:</td><td>"
     316       << asctime(gmtime(&last)) << "</td></tr>\n"
     317       << "<tr><td>Report Generated:</td><td>"
     318       << asctime(gmtime(&now)) << "</td></tr>\n"
     319       << "<tr><td>Repository Age:</td><td>";
     320    if (years){
     321      os << years << " year";
     322      if (years>1)
     323        os << "s";
     324      os << " ";
     325    }
     326    if (months){
     327      os << months << " month";
     328      if (months>1)
     329        os << "s";
     330      os << " ";
     331    }
     332    if (months || years)
     333      os << "and ";
     334    os << days << " day";
     335    if (days>1)
     336      os << "s";
     337     
     338    os << "</td></tr>\n"
     339       << "<tr><td>Number of Authors:</td><td>" << stats.authors().size()
     340       << "</td></tr>\n"
     341       << "<tr><td>Revisions:</td><td>" << commit_dates.size()-1
     342       << "</td></tr>\n"
    273343       << "</table></div>\n";
     344    os << "<hr width=100% />";
    274345   
    275346       
     
    281352  void print_footer(std::ostream& os)
    282353  {
     354   
    283355    time_t rawtime;
    284356    struct tm * timeinfo;
  • trunk/lib/html_utility.h

    r211 r223  
    3434namespace svndigest{
    3535
     36  class Stats;
    3637  ///
    3738  /// @brief send anchor to stream @a os
     
    6061  /// @brief print main page
    6162  ///
    62   void print_main_page(const std::string&, const std::vector<std::string>&);
     63  void print_main_page(const std::string&, const std::vector<std::string>&,
     64                       const Stats&);
    6365   
    6466  ///
Note: See TracChangeset for help on using the changeset viewer.