-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report page showing gender stats for a country #337
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4159011
Prototype of very basic report page
zarino 89796c4
fixup! Prototype of very basic report page
zarino 99a0df8
WIP new "page" layout
zarino 97b2e67
New layout for report page
zarino 077286a
Very hacky prototype of two-tier reports
zarino 5b4c466
Better distinction between summary reports, and detailed reports
zarino 481554a
Pull in and display EP gender stats on report page
struan d6741c7
include per term and per group breakdown for groups and terms
struan 94b4d36
Use gh-pages url for gender stats
chrismytton c32767e
Fix "Play this country" link on report page
chrismytton 0d47659
Move Download data button to legislature level and wire up
chrismytton 5c3e9cb
Fix issue with incorrectly closed div tags
chrismytton fca8be4
Remove "Show details" link on report page
chrismytton 059529f
Link to EveryPolitician download page from country report
chrismytton 227aa1e
Stop linking to the report page from countries list
chrismytton 93753bb
Only allow reports to be accessed when signed in
chrismytton 058d3fa
Add a warning about incompleteness to report page
chrismytton 0434508
Allow hiding the report warning banner with a nobanner param
chrismytton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Gender Balance</title> | ||
|
||
<meta property="og:title" content="What’s the Gender Balance of world politics? Help us find out."> | ||
<meta property="og:url" content="http://www.gender-balance.org"> | ||
<meta property="og:site_name" content="Gender Balance"> | ||
<meta property="og:type" content="website"> | ||
<meta property="og:description" content="By playing this simple game, you can help uncover the true gender balance across individual parliaments, and the world. Swipe left, right, up, or down, and work your way to the top of our leaderboard!"> | ||
<meta property="og:image" content="<%= request.base_url %>/banner.jpg"> | ||
<meta property="og:image:width" content="1200"> | ||
<meta property="og:image:height" content="630"> | ||
|
||
<meta name="twitter:card" content="summary"> | ||
<meta name="twitter:site" content="@mysociety"> | ||
<meta name="twitter:title" content="Play Gender Balance online"> | ||
<meta name="twitter:description" content="By playing this simple game, you can help uncover the true gender balance across individual parliaments, and the world. Swipe left, right, up, or down, and work your way to the top of our leaderboard!"> | ||
<meta name="twitter:image" content="<%= request.base_url %>/banner.jpg"> | ||
<meta name="twitter:image:width" content="1200"> | ||
<meta name="twitter:image:height" content="630"> | ||
|
||
<link href="https://fonts.googleapis.com/css?family=Roboto:400,900,700,500,300,400italic" rel="stylesheet" type="text/css"> | ||
<link href="<%= url '/main.css' %>" rel="stylesheet"> | ||
<!--[if lt IE 9]> | ||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> | ||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | ||
<![endif]--> | ||
<script src="/js/jquery-1.11.3.min.js"></script> | ||
<script src="/js/jquery.transform2d.js"></script> | ||
<script src="/js/jquery.cardswipe.js"></script> | ||
<script src="/js/main.js"></script> | ||
<script> | ||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | ||
ga('create', 'UA-660910-35', 'auto'); | ||
ga('send', 'pageview'); | ||
</script> | ||
</head> | ||
<body class="page <%= yield_content :body_class %>"> | ||
<div class="app-messages"> | ||
<%= erb :flash %> | ||
</div> | ||
<div class="page-header"> | ||
<div class="container"> | ||
<%= yield_content :back_button %> | ||
<h1>Gender Balance</h1> | ||
<%= yield_content :undo_button %> | ||
</div> | ||
</div> | ||
<div class="page-content"> | ||
<%= yield %> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<% content_for :body_class do %>report-page<% end %> | ||
|
||
<% content_for :back_button do %> | ||
<a class="page-header__back" href="/countries"><i class="fa fa-chevron-left"></i> Countries</a> | ||
<% end %> | ||
|
||
<div class="page-section page-section--blue"> | ||
<div class="container"> | ||
|
||
<% unless params[:nobanner] %> | ||
<div class="alert alert--info" role="alert"> | ||
<p><b>Under construction</b>: these stats may be incorrect, please do not share or publish until this notice is removed.</p> | ||
</div> | ||
<% end %> | ||
|
||
<h1 class="page-title"><%= @country[:country] %></h1> | ||
|
||
<p class="report-actions"> | ||
<a href="<%= url("/countries/#{params[:country]}") %>" class="button button--small">Play this country!</a> | ||
<a href="http://everypolitician.org/<%= params[:country].downcase %>/download.html" class="button button--small">Download data</a> | ||
</p> | ||
|
||
<div class="report-legislatures"> | ||
<% @country.legislatures.each_slice(2) do |legislatures| %> | ||
<div class="row"> | ||
<% legislatures.each do |legislature| %> | ||
<% | ||
stats = @legislature_stats[legislature.slug][:totals] | ||
total = stats[:overall][:total].to_f | ||
male = stats[:overall][:male].to_f | ||
female = stats[:overall][:female].to_f | ||
total = male + female | ||
%> | ||
<div class="col-sm-6"> | ||
|
||
<a class="list__item country" href="#<%= legislature.slug %>" data-scroll-to-id> | ||
<h3 class="country__name"><%= legislature.name %></h3> | ||
<div class="country__progress"> | ||
<p class="country__progress__intro">Known gender balance for <%= legislature.name %>:</p> | ||
<div class="progress-bar progress-bar--gendered progress-bar--labelled"> | ||
<div class="progress-bar__males" style="width: <%= male / total * 100 %>%"> | ||
<span class="progress-bar__label"><%= male.to_i %> <%= male.to_i == 1 ? 'man' : 'men' %></span> | ||
</div> | ||
<div class="progress-bar__females" style="width: <%= female / total * 100 %>%"> | ||
<span class="progress-bar__label"><%= female.to_i %> <%= female.to_i == 1 ? 'woman' : 'women' %></span> | ||
</div> | ||
</div> | ||
</div> | ||
</a> | ||
|
||
</div> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<% @country.legislatures.each do |legislature| %> | ||
<div class="page-section page-section--white" id="<%= legislature.slug %>"> | ||
<div class="container"> | ||
|
||
<h2 class="page-title"><%= legislature.name %></h2> | ||
|
||
<div class="row"> | ||
<div class="col-sm-6"> | ||
<h3>Gender balance by term:</h3> | ||
<div class="report-list report-list--by-term"> | ||
<% legislature.legislative_periods.each do |term| %> | ||
<% term_slug = 'term/' + term.slug | ||
term_stats = @legislature_stats[legislature.slug][:terms][term_slug.to_sym] %> | ||
<%= erb :report_partial, locals: { | ||
report: { | ||
id: term.slug, | ||
title: term.name, | ||
total: term_stats[:overall][:total].to_f, | ||
total_male: term_stats[:overall][:male].to_f, | ||
total_female: term_stats[:overall][:female].to_f, | ||
action: 'display-by-group' | ||
} | ||
} %> | ||
<div class="report-list report-list--hidden" id="parties-<%= term.slug %>"> | ||
<% term_stats[:parties].each do |slug, group| %> | ||
<%= erb :report_partial, locals: { | ||
report: { | ||
title: group[:name], | ||
total: group[:total].to_f, | ||
total_male: group[:male].to_f, | ||
total_female: group[:female].to_f, | ||
} | ||
} %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
<div class="col-sm-6"> | ||
<h3>Gender balance by group:</h3> | ||
<% stats = @legislature_stats[legislature.slug][:totals] %> | ||
<div class="report-list report-list--by-group"> | ||
<% stats[:parties].each do |slug, data| | ||
id_slug = slug.to_s.sub('/', '-') %> | ||
<%= erb :report_partial, locals: { | ||
report: { | ||
id: id_slug, | ||
title: data[:name], | ||
total: data[:total].to_f, | ||
total_male: data[:male].to_f, | ||
total_female: data[:female].to_f, | ||
action: 'display-by-term' | ||
} | ||
} %> | ||
<div class="report-list report-list--hidden" id="terms-<%= id_slug %>"> | ||
<% legislature.legislative_periods.each do |term| | ||
term_slug = 'term/' + term.slug | ||
term_stats = @legislature_stats[legislature.slug][:terms][term_slug.to_sym] | ||
group = term_stats[:parties][slug] | ||
if group %> | ||
<%= erb :report_partial, locals: { | ||
report: { | ||
title: term[:name], | ||
total: group[:total].to_f, | ||
total_male: group[:male].to_f, | ||
total_female: group[:female].to_f, | ||
} | ||
} %> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<div class="report <% if report[:headline] %>report--headline<% end %>" id="<%= report[:id] %>"> | ||
|
||
<h3 class="report__title"><%= report[:title] %></h3> | ||
|
||
<% if report[:action] == 'display-by-group' %> | ||
<a class="report__action" data-display-by-group>Display by group</a> | ||
<% elsif report[:action] == 'display-by-term' %> | ||
<a class="report__action" data-display-by-term>Display by term</a> | ||
<% end %> | ||
|
||
<div class="progress-bar progress-bar--gendered progress-bar--labelled"> | ||
<div class="progress-bar__males" style="width: <%= report[:total_male] / report[:total] * 100 %>%"> | ||
<span class="progress-bar__label"><%= report[:total_male].to_i %> <%= report[:total_male].to_i == 1 ? 'man' : 'men' %></span> | ||
</div> | ||
<% if (report[:total_male] + report[:total_female] != report[:total]) %> | ||
<div class="progress-bar__empty" style="width: <%= (report[:total] - report[:total_male] - report[:total_female]) / report[:total] * 100 %>%"> | ||
</div> | ||
<% end %> | ||
<div class="progress-bar__females" style="width: <%= report[:total_female] / report[:total] * 100 %>%"> | ||
<span class="progress-bar__label"><%= report[:total_female].to_i %> <%= report[:total_female].to_i == 1 ? 'woman' : 'women' %></span> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
$grid-max-width: 960px !default; | ||
$grid-gutter: 2em !default; | ||
$grid-breakpoint-sm: 768px !default; | ||
|
||
.container { | ||
margin-right: auto; | ||
margin-left: auto; | ||
padding-left: $grid-gutter / 2; | ||
padding-right: $grid-gutter / 2; | ||
max-width: $grid-max-width; | ||
} | ||
|
||
.row { | ||
@include clearfix(); | ||
margin-left: $grid-gutter / -2; | ||
margin-right: $grid-gutter / -2; | ||
} | ||
|
||
%col { | ||
padding-left: $grid-gutter / 2; | ||
padding-right: $grid-gutter / 2; | ||
min-height: 1px; | ||
} | ||
|
||
@for $i from 1 through 12 { | ||
.col-sm-#{$i} { | ||
@extend %col; | ||
} | ||
} | ||
|
||
@media(min-width: $grid-breakpoint-sm) { | ||
%col-float { | ||
float: left; | ||
} | ||
|
||
@for $i from 1 through 12 { | ||
.col-sm-#{$i} { | ||
@extend %col-float; | ||
width: 100% / 12 * $i; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to do something a little more defensive in case this fails for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Ticketed here #340