Skip to content

Commit

Permalink
Merge pull request #5 from klrkdekira/master
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
klrkdekira committed Oct 10, 2014
2 parents 0c32f47 + f248593 commit f8e3abe
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 74 deletions.
4 changes: 4 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
billwatcher README
==================

The Billwatcher site is hosted at

http://billwatcher.sinarproject.org

Getting Started
---------------

Expand Down
4 changes: 2 additions & 2 deletions billwatcher/templates/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="col-sm-9">
<div class="container">
<h1>Who We Are</h1>
<img src="{{request.static_url('billwatcher:static/img/sinar.png')}}" />
<img src="{{request.static_url('billwatcher:static/img/sinar.png')}}" alt="Sinar Project" />
<p>We are a group of concerned Citizen that hope to see more transparency in govt.</p>

<hr />
Expand All @@ -25,7 +25,7 @@ <h2>Contacts</h2>
<hr />

<h2>This is an open source project</h2>
<p>Our Code is in github you can help us by fork and contribute code, or report bug to us.</p>
<p>Our source code is on GitHub, you can help us by forking and contributing codes or reporting bugs to us.</p>
</div>
</div>
</div>
Expand Down
22 changes: 14 additions & 8 deletions billwatcher/templates/bill/detail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{% extends "template.html" %}
{% block title %}{{bill['name']}} - {{bill['description']}}{% endblock %}
{% block ogp %}
<meta property="og:title" content="{{bill['name']}}" />
<meta property="og:type" content="parliament.bill" />
<meta property="og:url" content="{{request.url}}" />
<meta property="og:description" content="{{bill['description']}}" />
{% endblock %}
{% block css %}
<style>
.fb-comments, .fb-comments span[style], .fb-comments iframe[style] {width: 100% !important;}
Expand All @@ -17,10 +23,10 @@
</div>
<div class="panel-body">
<dl>
<dt>Code:</dt><dd>{{bill['name']}}</dd>
<dt>Name:</dt><dd>{{bill['description']}}</dd>
<dt>Year:</dt><dd>{{bill['year'] or ''}}</dd>
<dt>Status:</dt><dd>{{bill['status'].capitalize() if bill['status']}}</dd>
<dt>Code:</dt><dd>{{bill['name']}}</dd>
<dt>Name:</dt><dd>{{bill['description']}}</dd>
<dt>Year:</dt><dd>{{bill['year'] or ''}}</dd>
<dt>Status:</dt><dd>{{bill['status'].capitalize() if bill['status']}}</dd>
<dt>Presented by:</dt><dd>{{bill['presented_by']}}</dd>
</dl>
</div>
Expand All @@ -31,9 +37,9 @@
</div>
<div class="panel-body">
<dl>
<dt>First Reading:</dt><dd>{{bill['history']['first_reading']}}</dd>
<dt>Second Reading:</dt><dd>{{bill['history']['second_reading']}}</dd>
<dt>Passed At:</dt><dd>{{bill['history']['passed_at']}}</dd>
<dt>First Reading:</dt><dd>{{bill['history']['first_reading']}}</dd>
<dt>Second Reading:</dt><dd>{{bill['history']['second_reading']}}</dd>
<dt>Passed At:</dt><dd>{{bill['history']['passed_at']}}</dd>
</dl>
</div>
</div>
Expand All @@ -47,7 +53,7 @@
<div class="fb-like" data-href="{{request.url}}" data-layout="standard" data-action="like" data-show-faces="true" data-share="true"></div>
<h3>Comments</h3>
<hr />
<div class="fb-comments" data-href="{{request.url}}" data-numposts="20" data-colorscheme="light"></div>
<div class="fb-comments" data-href="{{request.url}}" data-numposts="20" data-colorscheme="light"></div>
</div>
</div>
</div>
Expand Down
40 changes: 20 additions & 20 deletions billwatcher/templates/bill/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,28 @@ <h4 class="pull-left">Parliament Bills</h4>
{{data.pager(format='$link_first $link_previous ~2~ $link_next $link_last')}}
</div>
<table id="bill-list" class="table table-striped table-responsive">
<thead>
<tr>
<thead>
<tr>
<th>Code</th>
<th>Bill</th>
<th>Status</th>
<th>Year</th>
</tr>
</thead>
<tbody>
{% for bill in data.items %}
<tr>
<th>Bill</th>
<th>Status</th>
<th>Year</th>
</tr>
</thead>
<tbody>
{% for bill in data.items %}
<tr>
<td>{{bill.name}}</td>
<td>
<a href="{{request.route_url('bill.detail', bill_id=bill._id)}}">
{{bill.description}}
</a>
</td>
<td>{{bill.status.capitalize() if bill.status}}</td>
<td>{{bill.year or ''}}</td>
</tr>
{% endfor %}
</tbody>
<td>
<a href="{{request.route_url('bill.detail', bill_id=bill._id)}}">
{{bill.description}}
</a>
</td>
<td>{{bill.status.capitalize() if bill.status}}</td>
<td>{{bill.year or ''}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
Expand Down
7 changes: 3 additions & 4 deletions billwatcher/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ <h1 class="textcenter">Malaysian BillWatcher</h1>
</div>
<div class="row">
<div class="col-lg-8 col-lg-offset-2">

<form id="bigsearch" method="GET" action="{{request.route_url('search')}}">
<form id="bigsearch" method="GET" action="{{request.route_url('search')}}">
<div class="input-group">
<input type="text" name="search" class="form-control" placeholder="Search for Bill here" value="{{request.params.get('search', '')}}">
<input type="text" name="search" class="form-control" placeholder="Search for Bill here" value="{{request.params.get('search', '')}}">
<span class="input-group-btn">
<button type="submit" class="btn btn-default">Go</button>
</span>
</div>
</form>
</form>
</div>
</div>
</div>
Expand Down
42 changes: 21 additions & 21 deletions billwatcher/templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@
<div class="col-lg-12">
<h4 class="pull-left">Search results for <strong>{{request.params.get('search')}}</strong></h4>
<table class="table table-striped table-responsive">
<thead>
<tr>
<thead>
<tr>
<th>Code</th>
<th>Bill</th>
<th style="width: 200px">Status</th>
<th style="width: 100px">Year</th>
</tr>
</thead>
<tbody>
{% for bill in bills %}
<tr>
<th>Bill</th>
<th style="width: 200px">Status</th>
<th style="width: 100px">Year</th>
</tr>
</thead>
<tbody>
{% for bill in bills %}
<tr>
<td>
{{bill['_source'].name}}
</td>
<td>
<a href="{{request.route_url('bill.detail', bill_id=bill._id)}}">
{{bill['_source'].description}}
</a>
</td>
<td>{{bill['_source'].status.capitalize() if bill['_source'].status}}</td>
<td>{{bill['_source'].year or ''}}</td>
</tr>
{% endfor %}
</tbody>
<td>
<a href="{{request.route_url('bill.detail', bill_id=bill._id)}}">
{{bill['_source'].description}}
</a>
</td>
<td>{{bill['_source'].status.capitalize() if bill['_source'].status}}</td>
<td>{{bill['_source'].year or ''}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}
Expand Down
19 changes: 10 additions & 9 deletions billwatcher/templates/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<title>{% block title %}Malaysian Parliament BillWatcher{% endblock %}</title>
<meta name="description" content="Collection of bills debated in Malaysian Parliament">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% block ogp %}{% endblock %}

<link rel="alternate" href="{{request.route_url('feed.list')}}" type="application/rss+xml" title="RSS Feeds" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
Expand Down Expand Up @@ -51,9 +52,9 @@
<span class="input-group-btn">
<button type="submit" class="btn btn-default">Go</button>
</span>
</div>
</form>
{% endif %}
</div>
</form>
{% endif %}
</div>
</div>
</nav>
Expand All @@ -67,22 +68,22 @@
<dl>
<dt>Funded by</dt>
<dd>
<a href="http://isif.asia/">
<img src="{{request.static_url('billwatcher:static/img/isif.png')}}"/>
<a href="http://isif.asia/" title="isif asia">
<img src="{{request.static_url('billwatcher:static/img/isif.png')}}" alt="isif asia" />
</a>
</dd>
</dl>
<dl>
<dt>The Team</dt>
<dd><a href="https://github.com/sweemeng">Swee Meng</a></dd>
<dd><a href="https://github.com/klrkdekira">Chee Leong</a></dd>
</dl>
</div>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Who we are</dt>
<dd>
<img id="sinar-logo" src="{{request.static_url('billwatcher:static/img/sinar.png')}}" />
<img id="sinar-logo" src="{{request.static_url('billwatcher:static/img/sinar.png')}}" alt="Sinar Project" />
<br />
We are a group of concerned Citizen that hope to see more transparency in government.
</dd>
Expand All @@ -99,7 +100,7 @@
</dl>
<dl>
<dt>This is an open source project</dt>
<dd>Our Code is in github you can help us by fork and contribute code, or report bug to us.</dd>
<dd>Our source code is on GitHub, you can help us by forking and contributing codes or reporting bugs to us.</dd>
<dd>
<ul id="github-links" class="pull-left list-inline">
<li>
Expand Down
32 changes: 22 additions & 10 deletions billwatcher/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pyramid.view import view_config
from pyramid.i18n import TranslationStringFactory
from pyramid.response import Response
from pyramid.renderers import render_to_response
from pyramid.exceptions import HTTPNotFound

from webhelpers import feedgenerator, paginate
Expand All @@ -20,7 +21,7 @@ def views_include(config):
config.add_route('bill.doc', '/bill/doc/{bill_id}')

config.add_route('feed.list', '/feed')

config.add_route('search', '/search')

class HomeView(object):
Expand All @@ -34,7 +35,7 @@ def home(self):
.sort([('year', -1), ('name', -1)])
.limit(5))
return {'latest_bills': latest_bills}

class BillView(object):
def __init__(self, request):
self.request = request
Expand All @@ -60,17 +61,17 @@ def _list(self):
'status': 1}).sort([('year', -1),
('name', -1)])
return map(lambda bill: bill, bills)

@view_config(route_name='home', renderer='json', accept='application/json')
@view_config(route_name='bill.list', renderer='json', accept='application/json')
def api_list(self):
return {'bills': self._list()}

@view_config(route_name='bill.list', renderer='bill/list.html', accept='text/html')
def web_list(self):
p = self.params
page = p.get('page', '1')

bills = self._list()
page_url = paginate.PageURL_WebOb(self.request)
data = paginate.Page(bills, page,
Expand All @@ -96,12 +97,23 @@ def _get_bill(self, bill_id):
raise HTTPNotFound()
return bill

@view_config(route_name='bill.detail', renderer='bill/detail.html', accept='text/html')
@view_config(route_name='bill.detail', renderer='json', accept='application/json')
# @view_config(route_name='bill.detail', renderer='json', accept='application/json')
# @view_config(route_name='bill.detail', renderer='bill/detail.html', accept='text/html')
@view_config(route_name='bill.detail', renderer='bill/detail.html')
def view(self):
bill_id = self.request.matchdict['bill_id']
bill = self._get_bill(bill_id)
return {'bill': bill}
if self.request.accept == 'application/json':
resp = render_to_response('json',
{'bill': bill},
request=self.request)
resp.content_type = 'application/json'
else:
resp = render_to_response('bill/detail.html',
{'bill': bill},
request=self.request)
resp.content_type = 'text/html'
return resp

@view_config(route_name='bill.doc')
def doc(self):
Expand All @@ -119,7 +131,7 @@ def doc(self):
resp.content_disposition = 'filename={filename}'.format(filename=document['name'])
resp.content_type = pdf_doc.content_type
resp.body_file.write(pdf_doc.read())
return resp
return resp

class FeedView(object):
def __init__(self, request):
Expand All @@ -145,7 +157,7 @@ def list(self):
resp = Response()
resp.content_type = 'application/rss+xml'
feed.write(resp.body_file, 'utf-8')
return resp
return resp

@view_config(route_name='search', renderer='search.html', accept='text/html')
def search(request):
Expand Down

0 comments on commit f8e3abe

Please sign in to comment.