Added generation scripts for contacts, move script for presskits.
authorJosh Berkus <josh@pgexperts.com>
Sun, 8 Sep 2013 19:31:07 +0000 (12:31 -0700)
committerJosh Berkus <josh@pgexperts.com>
Sun, 8 Sep 2013 19:31:07 +0000 (12:31 -0700)
scripts/copypresskits.py [new file with mode: 0644]
scripts/gencontacts.pl [new file with mode: 0644]
scripts/gencontacts_html.pl [new file with mode: 0644]

diff --git a/scripts/copypresskits.py b/scripts/copypresskits.py
new file mode 100644 (file)
index 0000000..67a643c
--- /dev/null
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+
+import os
+import re
+import argparse
+import string
+import shutil
+
+parser = argparse.ArgumentParser(description="Copy presskits from press repo to pgweb repo")
+
+parser.add_argument('--pressdir', default=".")
+parser.add_argument('--pgweb', default='/home/josh/git/pgweb')
+parser.add_argument('--release', default='9.3')
+args = parser.parse_args()
+
+pgwebdir = args.pgweb + '/templates/pages/about/press/presskit' + string.replace(args.release,'.','')
+pkitname = 'presskit' + string.replace(args.release,'.','') + '.html'
+
+for root, dirs, files in os.walk(args.pressdir):
+    print root
+    redir = re.search(r'/(\w{2}(_\w{2})?)$', root, re.UNICODE | re.I)
+    if not redir:
+        continue
+
+    dgrp = redir.groups()
+    langd = dgrp[0]
+    if pkitname in files:
+        shutil.copyfile(root + '/' + pkitname, pgwebdir + '/' + langd + '.html')
+        print langd
+
+
+
+
+
+
+
+
diff --git a/scripts/gencontacts.pl b/scripts/gencontacts.pl
new file mode 100644 (file)
index 0000000..6812383
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/perl -w
+#use strict;
+
+use DBI ;
+my $user = "josh" ;
+my $passwd = "" ;
+
+my $pdbh = DBI->connect("dbi:Pg:dbname=contacts host=127.0.0.1 port=5432", $user, $passwd);
+
+$action = $pdbh->prepare("SELECT name, pgemail, office_phone, cell_phone, xtra_line, UPPER(continent) as con, region,
+                         url FROM contacts WHERE verified ORDER BY continent, region, name;") ;
+$action->execute() ;
+$action->bind_columns( undef, \$name, \$pgemail, \$office, \$cell, \$xtra, \$continent, \$region, \$url );
+
+
+open (CONTACTS, ">", $ARGV[0]) ;
+print CONTACTS "List As Of: ". `date`;
+
+
+my $last_region;
+my $last_continent;
+
+while ( $action->fetch ) {
+    if ( $continent ne $last_continent ) {
+        print CONTACTS "\n$continent\n";
+        $last_continent = $continent;
+    }
+    if ( $region ne $last_region ) {
+        print CONTACTS "$region\n";
+        $last_region = $region;
+    }
+    print CONTACTS "$name\n";
+    print CONTACTS "$pgemail\n";
+    $office and print CONTACTS "Phone: $office\n";
+    $cell and print CONTACTS "Cell: $cell\n";
+    $url and print CONTACTS "$url\n";
+    $xtra and print CONTACTS "$xtra\n";
+    print CONTACTS "\n";
+}
+
+$pdbh->disconnect;
+close CONTACTS;
+
+exit(0);
diff --git a/scripts/gencontacts_html.pl b/scripts/gencontacts_html.pl
new file mode 100644 (file)
index 0000000..62b65a8
--- /dev/null
@@ -0,0 +1,65 @@
+#!/usr/bin/perl -w
+#use strict;
+
+use DBI ;
+my $user = "josh" ;
+my $passwd = "" ;
+
+my $pdbh = DBI->connect("dbi:Pg:dbname=contacts host=127.0.0.1", $user, $passwd);
+
+$action = $pdbh->prepare("SELECT name, pgemail, office_phone, cell_phone, xtra_line, continent as con, region,
+                         url FROM contacts WHERE verified ORDER BY continent, region, name;") ;
+$action->execute() ;
+$action->bind_columns( undef, \$name, \$pgemail, \$office, \$cell, \$xtra_line, \$continent, \$region, \$url );
+
+
+open CONTACTS, ">contact.html";
+print CONTACTS '{%extends "base/page.html"%}
+{%block title%}PostgreSQL Regional Contacts{%endblock%}
+{%block contents%}
+
+<div id="pgPressContacts">
+<h1>Press Contacts</h1>
+
+<p>Please refer to the list of country contacts below for press enquiries.</p>
+<p>For general press enquiries in English, see <a href="#USA">USA &amp; General Enquiries</a>.</p>';
+print CONTACTS "\n";
+
+my $last_region;
+my $last_continent;
+
+while ( $action->fetch ) {
+    if ( $continent ne $last_continent ) {
+        if ( defined $last_continent ) {
+            print CONTACTS "</dl>\n";
+        }
+        print CONTACTS "\n<h2>$continent</h2>\n";
+        print CONTACTS "<dl>\n";
+        $last_continent = $continent;
+    }
+
+    if ( $region ne $last_region ) {
+        print CONTACTS "<dt>";
+        if ( $region =~ "USA" ) {
+            print CONTACTS "<a name=\"USA\"></a>";
+        }
+       print CONTACTS "$region</dt>\n";
+        $last_region = $region;
+    }
+    print CONTACTS "<dd>$name\n";
+    print CONTACTS "<br /><a href=\"mailto:$pgemail\">$pgemail</a>\n";
+    $office and print CONTACTS "<br />Phone: $office\n";
+    $cell and print CONTACTS "<br />Cell: $cell\n";
+    $xtra_line and print CONTACTS "<br />$xtra_line\n";
+    $url and print CONTACTS "<br /><a href=\"$url\">$url</a>\n";
+    print CONTACTS "</dd>\n";
+}
+
+print CONTACTS "</dl>\n</div>\n";
+
+print CONTACTS "{%endblock%}\n";
+
+$pdbh->disconnect;
+close CONTACTS;
+
+exit(0);