Ignore:
Timestamp:
Sep 9, 2006, 7:36:34 PM (15 years ago)
Author:
Peter Johansson
Message:

fixes #76 and refs #87 new output file structure and draft to new main page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/html_utility.cc

    r200 r201  
    2222*/
    2323
     24#include "html_utility.h"
    2425#include "utility.h"
    2526#include <config.h> // this header file is created by configure
     
    3233#include <sys/param.h>
    3334#include <unistd.h>
     35#include <vector>
    3436
    3537namespace theplu{
     
    9092 
    9193
    92   void print_css(std::ostream& s)
    93   {
     94  void print_css(const std::string& str)
     95  {
     96    std::ofstream s(str.c_str());
    9497    s << "body {\n";
    9598    s << " background: #fff; \n";
     
    128131    s << "}\n";
    129132    s << "\n";
     133    s << "div.main {\n";
     134    s << " text-align: center\n";
     135    s << "}\n";
    130136    s << "table.listings {\n";
    131137    s << " clear: both;\n";
     
    175181    s << "\n";
    176182    s << "\n";
     183    s.close();
     184  }
     185
     186
     187  void print_main_page(const std::string& dir,
     188                       const std::vector<std::string>& commit_dates)
     189  {
     190    std::string filename=dir+"/index.html";
     191    std::ofstream os(filename.c_str());
     192    print_header(os, dir, 0);
     193    time_t now;
     194    time (&now);
     195    u_int n7=0;
     196    u_int n30=0;
     197    u_int n365=0;
     198    for (size_t i=1; i<commit_dates.size(); ++i){
     199      double diff = difftime(now,str2time(commit_dates[i]));
     200      if (diff<365*24*3600){
     201        n365++;
     202        if (diff<30*24*3600){
     203          n30++;
     204          if (diff<7*24*3600)
     205            n7++;
     206        }
     207      }
     208    }
     209    os << "<div class=\"main\">\n"
     210       << "<table><thead><tr><th>Statistics for " << dir
     211       << "</th></tr><thead>\n"
     212       << "<tr><td>Commits last year</td><td>" << n365 << "</td></tr>\n"
     213       << "<tr><td>Commits last month</td><td>" << n30 << "</td></tr>\n"
     214       << "<tr><td>Commits last week</td><td>" << n7 << "</td></tr>\n"
     215       << "</table></div>\n";
     216   
     217       
     218    print_footer(os);
     219    os.close();
    177220  }
    178221
     
    199242       << " xml:lang=\"en\" lang=\"en\"><head>\n"
    200243       << "<head>\n"
    201        << "<title> svndigest " << title << "</title>\n"
     244       << "<title> " << title << " - svndigest</title>\n"
    202245       << "</head>\n"
    203246       << "<link rel=\"stylesheet\" "
     
    212255    anchor(os, "index.html", "Home", level, "Main page");
    213256    os << "</li>"
     257       << "<li>";
     258    anchor(os, "all/total/index.html", "Browse", level, "Browser");
     259    os << "</li>"
    214260       << "</ul></div>"
    215261       << "<div id=\"main\">\n";
Note: See TracChangeset for help on using the changeset viewer.