[SCM] watchdog branch, master, updated. 1058f8ab69ac33a70dd4ade7d58fb6e520328c9a

1 view
Skip to first unread message

aaronsw

unread,
Jul 30, 2009, 11:20:55 PM7/30/09
to watchdo...@googlegroups.com
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "watchdog".

The branch, master has been updated
via 1058f8ab69ac33a70dd4ade7d58fb6e520328c9a (commit)
via e5a9f4401bfc742cf883f4b5b88b3d7860ae42f9 (commit)
via bf8fea8a335c49acddde682330e5163f9418645b (commit)
via 4982793b315ab1a100796771405b71fcdc9acf3f (commit)
via 11274c53b6b504e168d153739f3d1bc1417b3288 (commit)
from 39b1c6dd533fca5f7fa694e36be9ab1d3fdc227a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1058f8ab69ac33a70dd4ade7d58fb6e520328c9a
Author: Aaron Swartz <aar...@watchdog.net>
Date: Fri Jul 31 03:20:02 2009 +0000

thanks pages, occupation caching, turn off errors, no blank corps

commit e5a9f4401bfc742cf883f4b5b88b3d7860ae42f9
Author: Aaron Swartz <aar...@watchdog.net>
Date: Fri Jul 31 03:18:19 2009 +0000

add fullpath

commit bf8fea8a335c49acddde682330e5163f9418645b
Author: Aaron Swartz <aar...@watchdog.net>
Date: Fri Jul 31 03:17:48 2009 +0000

add backlinks for occupation

commit 4982793b315ab1a100796771405b71fcdc9acf3f
Author: Aaron Swartz <aar...@watchdog.net>
Date: Fri Jul 31 03:17:24 2009 +0000

add ads and tracking codes and whatnot

commit 11274c53b6b504e168d153739f3d1bc1417b3288
Author: Aaron Swartz <aar...@watchdog.net>
Date: Fri Jul 31 03:16:51 2009 +0000

add uris for rolls

-----------------------------------------------------------------------

Summary of changes:
config.py | 1 +
schema.py | 3 +
templates/base.html | 177 +++++++++++++++++++++++++++++++++-
templates/index.html | 2 -
templates/occupation_candidates.html | 4 +
templates/occupation_committees.html | 6 +-
utils/helpers.py | 2 +
webapp.py | 29 +++++-
8 files changed, 212 insertions(+), 12 deletions(-)

diff --git a/config.py b/config.py
index 966ae92..9cfb12c 100644
--- a/config.py
+++ b/config.py
@@ -9,3 +9,4 @@ maildir_path = '/home/wathdog/Maildir'
send_errors_to = 'bu...@watchdog.net'
test_email = 'te...@watchdog.net' #wyr test emails to go to this
production_test_email = 'wyr_...@watchdog.net' #all production wyr msgs and their responses go here
+cache_dir = '/home/watchdog/cache'
diff --git a/schema.py b/schema.py
index c164eff..c78e339 100644
--- a/schema.py
+++ b/schema.py
@@ -343,6 +343,9 @@ class Roll(sql.Table):
result = sql.String()
bill = sql.Reference(Bill)

+ @property
+ def _uri_(self):
+ return 'http://watchdog.net/r/us/%s#it' % self.id
#@@@@@ DON'T REPEAT YOURSELF
@property
def votes_by_party(self):
diff --git a/templates/base.html b/templates/base.html
index 51cf07e..c5a3c2d 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -2,14 +2,77 @@ $def with (page)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
+ <script>
+ function utmx_section(){}function utmx(){}
+ (function(){var k='2347546721',d=document,l=d.location,c=d.cookie;function f(n){
+ if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.indexOf(';',i);return c.substring(i+n.
+ length+1,j<0?c.length:j)}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;
+ d.write('<sc'+'ript src="'+
+ 'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.google-analytics.com'
+ +'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='
+ +new Date().valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
+ '" type="text/javascript" charset="utf-8"></sc'+'ript>')})();
+ </script>
+
$if page.get('front'):
<title>watchdog.net: $:page.title.strip()</title>
+ <meta name="verify-v1" content="V7KJtoWCZfItupnGhaoUY6gwX1aVkrFszhCOoM0qgbg=" />
+ <meta name="verify-v1" content="H+m5dkTl7hRG+Yp3hrB/2XuoZO4O1TAaq7IxTwRzjpk=" />
$else:
<title>$:page.title.strip() (watchdog.net)</title>

$if page.get('noindex'): <meta name="robots" content="noindex, nofollow">
<link href="/static/css/style.css" type="text/css" rel="stylesheet" />
- <script type="text/javascript" src="/static/js/jquery.js"></script>
+ <style type="text/css">
+ #dialog { display: none;}
+ .ui-dialog { border: 1px solid gray; background-color: black; padding: 1em; color: white;}
+ .ui-dialog-titlebar { background-color: #222;}
+ </style>
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
+ <script type="text/javascript">
+ function clickclear(thisfield, defaulttext) {
+ if (thisfield.value == defaulttext) {thisfield.value = "";}
+ }
+ function clickrecall(thisfield, defaulttext) {
+ if (thisfield.value == "") {thisfield.value = defaulttext;}
+ }
+ function createCookie(name,value,days) {
+ if (days) {
+ var date = new Date();
+ date.setTime(date.getTime()+(days*24*60*60*1000));
+ var expires = "; expires="+date.toGMTString();
+ }
+ else var expires = "";
+ document.cookie = name+"="+value+expires+"; path=/";
+ }
+
+ function readCookie(name) {
+ var nameEQ = name + "=";
+ var ca = document.cookie.split(';');
+ for(var i=0;i < ca.length;i++) {
+ var c = ca[i];
+ while (c.charAt(0)==' ') c = c.substring(1,c.length);
+ if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
+ }
+ }
+
+ \$(document).ready(function() {
+ if (readCookie("wd_dialog") == "fin") { return; }
+ createCookie("wd_dialog", "start", 1);
+ if (readCookie("wd_dialog") == "start") {
+ \$("#dialog").dialog({width: 500});
+ createCookie("wd_dialog", "fin", 1000);
+ }
+ })
+ function validate(form) {
+ if (form.Email.value == "email") {
+ \$("#dialog_error")[0].innerHTML = "please enter a valid email";
+ return false;
+ }
+ return true;
+ }
+ </script>
$:page.get('head')
</head><body>
$if page.get('map'):
@@ -59,7 +122,18 @@ $else:

<!-- /header -->
<div id="main">
-
+$if not page.get('map') and not page.get('front') and not page.get('maxi'):
+ <div style="float: right">
+ <script type="text/javascript"><!--
+ google_ad_client = "pub-4591221763003403";
+ /* 120x600, sidebar */
+ google_ad_slot = "0522736308";
+ google_ad_width = 120;
+ google_ad_height = 600;
+ //-->
+ </script>
+ <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
+ </div>

$:page.get('pretext')

@@ -71,6 +145,19 @@ $if msg:

$:page

+$if not page.get('map') and not page.get('front') and not page.get('maxi'):
+ <script type="text/javascript"><!--
+ google_ad_client = "pub-4591221763003403";
+ /* 728x90, bottom */
+ google_ad_slot = "2707019958";
+ google_ad_width = 728;
+ google_ad_height = 90;
+ //-->
+ </script>
+ <script type="text/javascript"
+ src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+ </script>
+
$if not page.get('maxi'):
</div>

@@ -101,10 +188,85 @@ $else:
<div id="footer\
$if not page.get('front'):-leaf\
">
- <div id="left_footer">What do you think? <a href="/about/feedback"><strong>Send us your feedback.</strong></a></div>
+ <div id="left_footer">
+ <form action="http://salsa.wiredforchange.com/dia/processEditValues.jsp" method="post" >
+ <input type="hidden" name="redirect" value="http://watchdog.net/thanks?url=$urlquote(getfullpath())" />
+ <input type="hidden" name="table" value="supporter"/>
+ <input type="hidden" name="tag" value="wd_bottom1" />
+ <input type="hidden" name="Receive_Email" value="3" />
+ <input type="hidden" name="organization_KEY" value="5649" />
+ <input type="hidden" name="link" value="custom" />
+ <input type="hidden" name="linkKey" value="0" />
+ <input type="hidden" name="link" value="groups" />
+ <input type="hidden" name="linkKey" value="40117" />
+ <input type="hidden" name="link" value="groups" />
+ <input type="hidden" name="linkKey" value="39103" />
+ <input type="hidden" name="link" value="groups" />
+ <input type="hidden" name="linkKey" value="38203" />
+ <strong>Help make a difference:</strong>
+ Sign up for our occasional email list:<br />
+ <input type="text" name="First_Name" value="first name"
+ onclick="clickclear(this, 'first name')"
+ onblur="clickrecall(this, 'first name')"/>
+ <input type="text" name="Last_Name" value="last name"
+ onclick="clickclear(this, 'last name')"
+ onblur="clickrecall(this, 'last name')" /><br />
+ <input type="text" name="Email" value="email"
+ onclick="clickclear(this, 'email')"
+ onblur="clickrecall(this, 'email')" />
+ <input type="text" name="Zip" value="zip code"
+ onclick="clickclear(this, 'zip code')"
+ onblur="clickrecall(this,'zip code')" />
+ <button type="submit">Go</button>
+ </form>
+ </div>
+ <div id="dialog">
+ <form name="dialogform" action="http://salsa.wiredforchange.com/dia/processEditValues.jsp" method="post" onsubmit="return validate(this);">
+ <input type="hidden" name="redirect" value="http://watchdog.net/thanks?url=$urlquote(getfullpath())" />
+ <input type="hidden" name="table" value="supporter"/>
+ <input type="hidden" name="tag" value="wd_dialog1" />
+ <input type="hidden" name="Receive_Email" value="3" />
+ <input type="hidden" name="organization_KEY" value="5649" />
+ <input type="hidden" name="link" value="custom" />
+ <input type="hidden" name="linkKey" value="0" />
+ <input type="hidden" name="link" value="groups" />
+ <input type="hidden" name="linkKey" value="40117" />
+ <input type="hidden" name="link" value="groups" />
+ <input type="hidden" name="linkKey" value="39103" />
+ <input type="hidden" name="link" value="groups" />
+ <input type="hidden" name="linkKey" value="38203" />
+ <p>
+ <script>utmx_section("Headline")</script>
+ <strong>Help make a difference:</strong>
+ </noscript>
+ <script>utmx_section("Body")</script>
+ Sign up for our occasional email list:
+ </noscript></p>
+ <p id="dialog_error" style="color: red"></p>
+ <p>
+ <script>utmx_section("Name ask")</script>
+ <input type="text" name="First_Name" value="first name"
+ onclick="clickclear(this, 'first name')"
+ onblur="clickrecall(this, 'first name')"/>
+ <input type="text" name="Last_Name" value="last name"
+ onclick="clickclear(this, 'last name')"
+ onblur="clickrecall(this, 'last name')" /><br />
+ </noscript>
+ <input type="text" name="Email" value="email"
+ onclick="clickclear(this, 'email')"
+ onblur="clickrecall(this, 'email')" />
+ <input type="text" name="Zip" value="zip code"
+ onclick="clickclear(this, 'zip code')"
+ onblur="clickrecall(this,'zip code')" />
+ <button type="submit">Go</button>
+ </p>
+ </form>
+ </div>
<div style="text-align: right; margin-top: -4px; width: 100%;"><img src="/static/images/${page.get('color')}.talkbubble.png" width="103" height="135" alt="Talk Bubble" /><a href="/" class="logo"><img src="/static/images/watchdog.talk.gif" width="255" height="135" alt="Watchdog sez -" /></a></div>
</div></div><!-- /footer -->
+<p style="position: fixed; right: 1em; bottom:0;"><a href="http://watchdog.net/static/index/index.html">index</a></p>
</div>
+
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
@@ -114,5 +276,14 @@ try {
var pageTracker = _gat._getTracker("UA-7198052-1");
pageTracker._trackPageview();
} catch(err) {}</script>
+<script type="text/javascript">
+if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+
+(document.location.protocol=='https:'?'s://ssl':'://www')+
+'.google-analytics.com/ga.js"></sc'+'ript>')</script>
+<script type="text/javascript">
+try {
+var pageTracker=_gat._getTracker("UA-7198052-2");
+pageTracker._trackPageview("/2347546721/test");
+}catch(err){}</script>
</body>
</html>
diff --git a/templates/index.html b/templates/index.html
index 35be019..2609af0 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -31,5 +31,3 @@ $var title: the good government site with teeth

</form>

-<p style="position: fixed; right: 1em; bottom:0;"><a href="http://watchdog.net/static/index/index.html">index</a></p>
-
diff --git a/templates/occupation_candidates.html b/templates/occupation_candidates.html
index 7f86c28..7b2f41d 100644
--- a/templates/occupation_candidates.html
+++ b/templates/occupation_candidates.html
@@ -7,6 +7,8 @@ $var title: $occupation

<h1>$occupation.title()</h1>

+<p><a href="/occupation/$occupation">&larr; Back to $occupation</a></p>
+
<h2>Candidates</h2>

<table class="structure" width="500">
@@ -23,3 +25,5 @@ $for c in candidates:
</tr>

</table>
+
+<p><a href="/occupation/$occupation">&larr; Back to $occupation</a></p>
diff --git a/templates/occupation_committees.html b/templates/occupation_committees.html
index b8815d7..7b7b8ab 100644
--- a/templates/occupation_committees.html
+++ b/templates/occupation_committees.html
@@ -7,6 +7,8 @@ $var title: $occupation

<h1>$occupation.title()</h1>

+<p><a href="/occupation/$occupation">&larr; Back to $occupation</a></p>
+
<h2>Committees</h2>

<table class="structure" width="500">
@@ -22,4 +24,6 @@ $for c in committees:
<td style="text-align: right;">\$$commify(int(c.amt))</td>
</tr>

-</table>
\ No newline at end of file
+</table>
+
+<p><a href="/occupation/$occupation">&larr; Back to $occupation</a></p>
diff --git a/utils/helpers.py b/utils/helpers.py
index 33b8312..fcd5430 100644
--- a/utils/helpers.py
+++ b/utils/helpers.py
@@ -164,6 +164,8 @@ def striphtml(x):
return r_html.sub('', x).replace('\n', ' ')
g['striphtml'] = striphtml
g['getpath'] = lambda : web.ctx.homepath + web.ctx.path
+g['getfullpath'] = lambda : web.ctx.homepath + web.ctx.fullpath
+
g['cookies_on'] = lambda : True #bool(web.cookies().get('webpy_session_id')) #@@@ fix this
g['get_user_id'] = lambda: get_loggedin_userid() or get_unverified_userid()
g['get_user_name'] = get_user_name
diff --git a/webapp.py b/webapp.py
index cec8513..4879172 100755
--- a/webapp.py
+++ b/webapp.py
@@ -10,7 +10,7 @@ import settings
from settings import db, render, production_mode
import schema
import config
-import os, simplejson
+import os, simplejson, cPickle as pickle

if not production_mode:
web.config.debug = True
@@ -56,6 +56,7 @@ urls = (
r'/about/help', 'abouthelp',
r'/about/api', 'aboutapi',
r'/about/feedback', 'feedback',
+ r'/thanks', 'email_thanks',
r'/contribute(/?)', 'contribute',
r'/blog', blog.app,
r'/share', 'petition.share',
@@ -105,6 +106,11 @@ class feedback:

return render.feedback_thanks()

+class email_thanks:
+ def GET(self):
+ i = web.input(url='/')
+ return render.email_thanks(i.url)
+
class find:
def GET(self, format=None):
i = web.input(address=None)
@@ -364,20 +370,30 @@ class occupation:

def GET(self, occupation):
if occupation != occupation.lower(): raise web.seeother('/occupation/%s' % occupation.lower())
- candidates = candidates_by_occupation(occupation, 5)
- committees = committees_by_occupation(occupation, 5)
+ if os.path.exists(config.cache_dir + '/occupation/' + occupation):
+ candidates, committees = pickle.load(file(config.cache_dir + '/occupation/' + occupation))
+ candidates, committees = candidates[:5], committees[:5]
+ else:
+ candidates = candidates_by_occupation(occupation, 5)
+ committees = committees_by_occupation(occupation, 5)
return render.occupation(candidates, committees, occupation)

class occupation_candidates:
#index done in occupation
def GET(self, occupation):
- candidates = candidates_by_occupation(occupation)
+ if os.path.exists(config.cache_dir + '/occupation/' + occupation):
+ candidates = pickle.load(file(config.cache_dir + '/occupation/' + occupation))[0]
+ else:
+ candidates = candidates_by_occupation(occupation)
return render.occupation_candidates(candidates, occupation)

class occupation_committees:
#index done in occupation
def GET(self, occupation):
- committees = committees_by_occupation(occupation)
+ if os.path.exists(config.cache_dir + '/occupation/' + occupation):
+ committees = pickle.load(file(config.cache_dir + '/occupation/' + occupation))[1]
+ else:
+ committees = committees_by_occupation(occupation)
return render.occupation_committees(committees, occupation)

class contributions:
@@ -417,6 +433,7 @@ class employer:
for c in db.query('select distinct(employer_stem) from contribution'))

def GET(self, corp_id, format=None):
+ if corp_id == '': raise web.notfound()
corp_id = corp_id.lower().replace('_', ' ')
contributions = db.query("""SELECT count(*) as how_many,
sum(amount) as how_much, p.firstname, p.lastname, p.id as polid
@@ -905,6 +922,6 @@ def congress_ranges(congresses):

app.notfound = notfound
if production_mode:
- app.internalerror = web.emailerrors(config.send_errors_to, internalerror)
+ pass#app.internalerror = web.emailerrors(config.send_errors_to, internalerror)

if __name__ == "__main__": app.run()


hooks/post-receive
--
watchdog

Reply all
Reply to author
Forward
0 new messages