Changeset 547 in ProjectBuilder


Ignore:
Timestamp:
Sep 18, 2008, 1:56:00 AM (16 years ago)
Author:
Bruno Cornec
Message:

First coding of pb_web_news2html which generates news from the announces DB in order to be used on the Website

Location:
devel/pb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r545 r547  
    1818use File::stat;
    1919use File::Temp qw(tempdir);
     20use Time::localtime qw(localtime);
    2021use POSIX qw(strftime);
    2122use lib qw (lib);
     
    445446
    446447    pb_announce();
     448} elsif ($action =~ /^webnews2html$/) {
     449    # For news handling only. Require avoids the systematic load of these modules
     450    require DBI;
     451
     452    pb_web_news2html();
    447453} else {
    448454    pb_log(0,"\'$action\' is not available\n");
     
    19291935        }
    19301936
     1937        # TODO: use virtual/real names here now
    19311938        $findstr .= "-name \'$pbpkg-$pbver-$pbtag\.*.rpm\' -o -name \'$pbpkg"."_$pbver*\.deb\' -o -name \'$pbpkg-$pbver\.ebuild\' ";
    19321939
     
    20912098}
    20922099
     2100#
     2101# Creates a set of HTML file containing the news for the project
     2102# based on what has been generated by the pb_announce function
     2103#
     2104sub pb_web_news2html {
     2105
     2106    # Get all required parameters
     2107    my ($pkgv, $pkgt, $testver) = pb_conf_get_if("pkgver","pkgtag","testver");
     2108
     2109    # DB of announces for external usage (Web pages generation)
     2110    my $db = "$ENV{'PBCONFDIR'}/announces3.sql";
     2111
     2112    my $dbh = DBI->connect("dbi:SQLite:dbname=$db","","",
     2113                        { RaiseError => 1, AutoCommit => 1 })
     2114                        || die "Unable to connect to $db";
     2115    # For date handling
     2116    $ENV{LANGUAGE}="C";
     2117    my $firstjan = strftime("%Y-%m-%d", 0, 0, 1, 1, localtime->year(), 0, 0, -1);
     2118    my $oldfirst = strftime("%Y-%m-%d", 0, 0, 1, 1, localtime->year()-1, 0, 0, -1);
     2119    my $all = $dbh->selectall_arrayref("SELECT id,date,announce FROM announces ORDER BY date DESC");
     2120    my $ynews = "";     # year's news
     2121    my $lynews = "";    # last year news
     2122    my $pynews = "";    # previous years news
     2123    my $fpnews = "";    # first page news
     2124    my $cpt = 4;        # how many news for first page
     2125    # Extract info from DB
     2126    foreach my $row (@$all) {
     2127        my ($id, $date, $announce) = @$row;
     2128        $ynews = $ynews."<p><B>$date</B> $announce\n" if (("$date" le $pbdate) && ($firstjan le "$date"));
     2129        $lynews = $lynews."<p><B>$date</B> $announce\n" if (("$date" le $firstjan) && ($oldfirst le "$date"));
     2130        $pynews = $pynews."<p><B>$date</B> $announce\n" if ("$date" le $oldfirst);
     2131        $fpnews = $fpnews."<p><B>$date</B> $announce\n" if ($cpt > 0);
     2132        $cpt--;
     2133    }
     2134    pb_log(1,"fpnews: $fpnews\n");
     2135    $dbh->disconnect;
     2136}
     2137
    20932138# Return the SSH key file to use
    20942139# Potentially create it if needed
  • devel/pb/lib/ProjectBuilder/Env.pm

    r540 r547  
    224224# return values in that case are useless
    225225#
    226 if (($action =~ /^cms2/) || ($action =~ /^newver$/) || ($action =~ /pbinit/) || ($action =~ /^newproj$/) || ($action =~ /^announce/)) {
     226if (($action =~ /^cms2/) || ($action =~ /^newver$/) || ($action =~ /pbinit/) || ($action =~ /^newproj$/) || ($action =~ /^announce/) || ($action =~ /^web/)) {
    227227
    228228    #
Note: See TracChangeset for help on using the changeset viewer.