Skip to content

Commit

Permalink
Merge branch 'master' into python-add-poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
ajparsons authored Sep 25, 2024
2 parents ace1844 + 9005a6c commit 44e91be
Show file tree
Hide file tree
Showing 62 changed files with 674 additions and 377 deletions.
20 changes: 19 additions & 1 deletion classes/Homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,34 @@ public function display() {
$data["commons_dissolved"] = isset($dissolution[1]);

$data['regional'] = $this->getRegionalList();
$data['popular_searches'] = $common->getPopularSearches();
$data['popular_searches'] = []; #$common->getPopularSearches();
$data['urls'] = $this->getURLs();
$data['calendar'] = $this->getCalendarData();
$data['featured'] = $this->getEditorialContent();
$data['topics'] = $this->getFrontPageTopics();
$data['divisions'] = $this->getRecentDivisions();
$data['search_box'] = $this->getSearchBox($data);

return $data;
}

protected function getSearchBox(array $data): Search\SearchBox{
$search_box = new Search\SearchBox();
$search_box->homepage_panel_class = "panel--homepage--overall";
$search_box->homepage_subhead = "";
$search_box->homepage_desc = "Understand who represents you, across the UK’s Parliaments.";
$search_box->search_section = "";
$search_box->quick_links = [];
if (count($data["mp_data"])) {
$search_box->add_quick_link('Find out more about your MP (' . $data["mp_data"]['name'] . ')', $data["mp_data"]['mp_url'], 'torso');
}
$search_box->add_quick_link('Create and manage email alerts', '/alert/', 'megaphone');
$search_box->add_quick_link(gettext('Subscribe to our newsletter'), '/about/#about-mysociety', 'mail');
$search_box->add_quick_link('Donate to support our work', '/support-us/', 'heart');
$search_box->add_quick_link('Learn more about TheyWorkForYou', '/about/', 'magnifying-glass');
return $search_box;
}

protected function getRegionalList() {
return null;
}
Expand Down
3 changes: 3 additions & 0 deletions classes/Renderer/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ private function addContactLink() {
}

private function addDonateLink() {
if (LANGUAGE == 'cy') {
return;
}
$menudata = $this->pagedata->page_metadata('donate', 'menu');
$text = $menudata['text'];
$title = $menudata['title'];
Expand Down
18 changes: 18 additions & 0 deletions classes/SPHomepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ class SPHomepage extends Homepage {
'SPWRANSLIST' => array('recent_wrans', 'spwransfront', 'Written answers'),
);

protected function getSearchBox(array $data): Search\SearchBox{
$search_box = new Search\SearchBox();
$search_box->homepage_panel_class = "panel--homepage--scotland";
$search_box->homepage_subhead = "Scottish Parliament";
$search_box->homepage_desc = "";
$search_box->search_section = "scotland";
$search_box->quick_links = [];
if (count($data["mp_data"])) {
$regional_con = $data["regional"][0]["constituency"];
$search_box->add_quick_link('Find out more about your MSPs for ' . $data["mp_data"]["constituency"] . ' (' . $regional_con . ')', '/postcode/?pc=' . $data["mp_data"]['postcode'], 'torso' );
}
$search_box->add_quick_link('Create and manage email alerts', '/alert/', 'megaphone');
$search_box->add_quick_link(gettext('Subscribe to our newsletter'), '/about/#about-mysociety', 'mail');
$search_box->add_quick_link('Donate to support our work', '/support-us/', 'heart');
$search_box->add_quick_link('Learn more about TheyWorkForYou', '/about/', 'magnifying-glass');
return $search_box;
}

protected function getEditorialContent() {
$debatelist = new \SPLIST;
$item = $debatelist->display('recent_debates', array('days' => 7, 'num' => 1), 'none');
Expand Down
34 changes: 34 additions & 0 deletions classes/Search/SearchBox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace MySociety\TheyWorkForYou\Search;


class SearchBox
{
public string $homepage_panel_class;
public string $homepage_subhead;
public string $homepage_desc;
public string $search_section;
public array $quick_links;

public function __construct(string $homepage_panel_class = '',
string $homepage_subhead = '',
string $homepage_desc = '',
string $search_section = '',
array $quick_links = [])
{
$this->homepage_panel_class = $homepage_panel_class;
$this->homepage_subhead = $homepage_subhead;
$this->homepage_desc = $homepage_desc;
$this->search_section = $search_section;
$this->quick_links = $quick_links;
}

public function add_quick_link(string $title, string $url, string $icon): void
{
$this->quick_links[] = ['title' => $title, 'url' => $url, 'icon' => $icon];
}

}

?>
28 changes: 28 additions & 0 deletions classes/SectionView/NiView.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,38 @@ protected function display_front_ni() {
$data['debates'] = array( 'recent' => $recent);

$data['regional'] = $this->getMLAList();
$data['search_box'] = $this->getSearchBox($data);
$data['template'] = 'ni/index';

return $data;
}

protected function getSearchBox(array $data): \MySociety\TheyWorkForYou\Search\SearchBox{

global $THEUSER;

if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) {
$postcode = $THEUSER->postcode();
} else {
$postcode = null;
}

$search_box = new \MySociety\TheyWorkForYou\Search\SearchBox();
$search_box->homepage_panel_class = "panel--homepage--niassembly";
$search_box->homepage_subhead = "Northern Ireland Assembly";
$search_box->homepage_desc = "";
$search_box->search_section = "ni";
$search_box->quick_links = [];
if (count($data["regional"])) {
$constituency = $data["regional"][0]["constituency"];
$search_box->add_quick_link('Find out more about your MLAs for ' . $constituency, '/postcode/?pc=' . $postcode, 'torso');
}
$search_box->add_quick_link('Create and manage email alerts', '/alert/','megaphone');
$search_box->add_quick_link(gettext('Subscribe to our newsletter'), '/about/#about-mysociety', 'mail');
$search_box->add_quick_link('Donate to support our work', '/support-us/','heart');
$search_box->add_quick_link('Learn more about TheyWorkForYou', '/about/', 'magnifying-glass');
return $search_box;
}

protected function getMLAList() {
global $THEUSER;
Expand Down
2 changes: 1 addition & 1 deletion classes/SectionView/SectionView.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function addCommonData($data) {

$common = new \MySociety\TheyWorkForYou\Common;
$data['urls'] = $this->getURLs($data);
$data['popular_searches'] = $common->getPopularSearches();
$data['popular_searches'] = []; #$common->getPopularSearches();
$data['recess_major'] = $this->getRecessMajor();

$nextprev = $DATA->page_metadata($this_page, 'nextprev');
Expand Down
24 changes: 24 additions & 0 deletions classes/SectionView/SeneddView.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,35 @@ protected function display_front_senedd() {
$data['debates'] = array( 'recent' => $recent);

$data['regional'] = $this->getMSList();
$data['search_box'] = $this->getSearchBox($data);
$data['template'] = 'senedd/index';

return $data;
}

protected function getSearchBox(array $data): \MySociety\TheyWorkForYou\Search\SearchBox{
$search_box = new \MySociety\TheyWorkForYou\Search\SearchBox();
$search_box->homepage_panel_class = "panel--homepage--senedd";
$search_box->homepage_subhead = gettext("Senedd / Welsh Parliament");
$search_box->homepage_desc = "";
$search_box->search_section = "senedd";
$search_box->quick_links = [];
if (count($data["regional"])) {
// get all unique constituencies
$constituencies = array();
foreach ($data["regional"] as $member) {
$constituencies[$member["constituency"]] = 1;
}
$constituencies = array_keys($constituencies);
$search_box->add_quick_link(sprintf(gettext('Find out more about your MSs for %s and %s'), $constituencies[0], $constituencies[1]), '/postcode/?pc=' . $data["mp_data"]['postcode'],'torso');
}
$search_box->add_quick_link(gettext('Create and manage email alerts'), '/alert/','megaphone');
$search_box->add_quick_link(gettext('Subscribe to our newsletter'), '/about/#about-mysociety', 'mail');
$search_box->add_quick_link(gettext('Donate to support our work'), '/support-us/', 'heart');
$search_box->add_quick_link(gettext('Learn more about TheyWorkForYou'), '/about/', 'magnifying-glass');
return $search_box;
}

protected function getMSList() {
global $THEUSER;

Expand Down
28 changes: 26 additions & 2 deletions locale/cy_GB.UTF-8/LC_MESSAGES/TheyWorkForYou.po
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,30 @@ msgstr "Ni allwch chwilio am fwy nag un ystod o ddyddiadau."
msgid "Maximum term length is 255 characters."
msgstr "Yr hyd term mwyaf yw 255 nod."

#: classes/SectionView/SeneddView.php:121
#, php-format
msgid "Find out more about your MSs for %s and %s"
msgstr "Darganfod mwy am eich Aelodau Cynulliad dros %s a %s"

#: classes/SectionView/SeneddView.php:125
msgid " and "
msgstr " a "

msgid "Create and manage email alerts"
msgstr "Creu hysbysiad"

#: classes/SectionView/SeneddView.php:132
msgid "Subscribe to our newsletter"
msgstr "Cofrestrwch am y newyddion diweddaraf gan mySociety"

#: classes/SectionView/SeneddView.php:133
msgid "Donate to support our work"
msgstr "Cyfrannu"

#: classes/SectionView/SeneddView.php:134
msgid "Learn more about TheyWorkForYou"
msgstr "Ynglŷn â TheyWorkForYou"

#: classes/User.php:196
msgid "Please enter a password"
msgstr "Rhowch eich cyfrinair"
Expand Down Expand Up @@ -2595,7 +2619,7 @@ msgid "About mySociety"
msgstr "Ynglŷn â mySociety"

#: www/includes/easyparliament/templates/html/static/about.php:34
msgid "TheyWorkForYou is run by <a href=\"https://www.mysociety.org/\">mySociety</a>, a UK charity that puts <a href=\"https://www.mysociety.org/2021/11/24/the-need-to-repower-democracy/\">power in more people's hands</a> through the use of digital tools and data."
msgid "TheyWorkForYou is run by <a href=\"https://www.mysociety.org/\">mySociety</a>, a UK charity that helps people access information and participate in democracy. We enable people across the UK to become changemakers by providing technology, research and data, openly and for free."
msgstr "Mae TheyWorkForYou yn cael ei reoli gan <a href=\"https://www.mysociety.org/\">mySociety</a>, elusen yn y Deyrnas Unedig sy'n rhoi grym yn nwylo mwy o bobl drwy ddefnyddio data ac offer digidol."

#: www/includes/easyparliament/templates/html/static/about.php:35
Expand All @@ -2607,7 +2631,7 @@ msgid "Find out more about how mySociety is funded."
msgstr "Rhagor o wybodaeth am y modd y mae mySociety yn cael ei ariannu."

#: www/includes/easyparliament/templates/html/static/about.php:39
msgid "Sign up for updates from mySociety"
msgid "Sign up for updates on our democracy and Parliaments work"
msgstr "Cofrestrwch am y newyddion diweddaraf gan mySociety"

#: www/includes/easyparliament/templates/html/static/about.php:61
Expand Down
2 changes: 1 addition & 1 deletion scripts/future-fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def fetch_url(date):
def get_calendar_events():
date = datetime.date.today()
data = fetch_url(date)
data = sorted(data, key=lambda x: x["StartDate"] + x["StartTime"])
data = sorted(data, key=lambda x: x["StartDate"] + str(x["SortOrder"]))
for event in data:
yield Entry(event)

Expand Down
2 changes: 1 addition & 1 deletion tests/AcceptBasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private function fetch_page($path, $file = 'index.php', $vars = array())
public function testHome()
{
$page = $this->fetch_page('');
$this->assertStringContainsString('Find out more', $page);
$this->assertStringContainsString('Learn more about', $page);
$this->assertStringContainsString('Create an alert', $page);
$this->assertStringContainsString('Upcoming', $page);
}
Expand Down
12 changes: 4 additions & 8 deletions www/docs/mp/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@
$data['image'] = $MEMBER->image();
$data['member_summary'] = person_summary_description($MEMBER);
$data['enter_leave'] = $MEMBER->getEnterLeaveStrings();
$data['entry_date'] = $MEMBER->getEntryDate();
$data['leave_date'] = $MEMBER->getLeftDate();
$data['entry_date'] = $MEMBER->getEntryDate(HOUSE_TYPE_COMMONS);
$data['leave_date'] = $MEMBER->getLeftDate(HOUSE_TYPE_COMMONS);
$data['is_new_mp'] = $MEMBER->isNew();
$data['other_parties'] = $MEMBER->getOtherPartiesString();
$data['other_constituencies'] = $MEMBER->getOtherConstituenciesString();
Expand All @@ -358,16 +358,12 @@
$data['has_expenses'] = $data['leave_date'] > '2004-01-01';

$data['pre_2010_expenses'] = False;
$data['post_2010_expenses'] = $data['leave_date'] > '2010-05-05';
$data['post_2010_expenses'] = $data['leave_date'] > '2010-05-05' ? $MEMBER->extra_info['datadotparl_id'] : '';

if ($data['entry_date'] < '2010-05-05') {
$data['pre_2010_expenses'] = True;
// Set the expenses URL if we know it
if (isset($MEMBER->extra_info['expenses_url'])) {
$data['expenses_url_2004'] = $MEMBER->extra_info['expenses_url'];
} else {
$data['expenses_url_2004'] = 'https://mpsallowances.parliament.uk/mpslordsandoffices/hocallowances/allowances%2Dby%2Dmp/';
}
$data['expenses_url_2004'] = $MEMBER->extra_info['expenses_url'] ?? 'https://mpsallowances.parliament.uk/mpslordsandoffices/hocallowances/allowances%2Dby%2Dmp/';
}

$data['constituency_previous_mps'] = constituency_previous_mps($MEMBER);
Expand Down
6 changes: 5 additions & 1 deletion www/docs/regmem/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ function parse_file($file, $date, $type, &$out) {

function _load_file($f) {
$file = file_get_contents($f);
$file = utf8_encode($file);
preg_match('#encoding="([^"]*)"#', $file, $m);
$encoding = $m[1];
if ($encoding == 'ISO-8859-1') {
$file = @iconv('iso-8859-1', 'utf-8', $out);
}
return $file;
}

Expand Down
1 change: 1 addition & 0 deletions www/docs/style/img/mysoc-footer/logo-mysociety-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added www/docs/style/img/ni-assembly-desktop.webp
Binary file not shown.
Binary file added www/docs/style/img/ni-assembly-huge.webp
Binary file not shown.
Binary file added www/docs/style/img/ni-assembly-mobile.webp
Binary file not shown.
Binary file added www/docs/style/img/ni-assembly-tablet.webp
Binary file not shown.
Binary file removed www/docs/style/img/ni-parliament-desktop.jpg
Binary file not shown.
Binary file removed www/docs/style/img/ni-parliament-mobile.jpg
Binary file not shown.
Binary file removed www/docs/style/img/ni-parliament-tablet.jpg
Binary file not shown.
Binary file removed www/docs/style/img/scottish-parliament-desktop.jpg
Binary file not shown.
Binary file not shown.
Binary file added www/docs/style/img/scottish-parliament-huge.webp
Binary file not shown.
Binary file removed www/docs/style/img/scottish-parliament-mobile.jpg
Binary file not shown.
Binary file not shown.
Binary file removed www/docs/style/img/scottish-parliament-tablet.jpg
Binary file not shown.
Binary file not shown.
Binary file removed www/docs/style/img/senedd-desktop.jpg
Binary file not shown.
Binary file removed www/docs/style/img/senedd-mobile.jpg
Binary file not shown.
Binary file added www/docs/style/img/senedd-parliament-desktop.webp
Binary file not shown.
Binary file added www/docs/style/img/senedd-parliament-huge.webp
Binary file not shown.
Binary file added www/docs/style/img/senedd-parliament-mobile.webp
Binary file not shown.
Binary file added www/docs/style/img/senedd-parliament-tablet.webp
Binary file not shown.
Binary file removed www/docs/style/img/senedd-tablet.jpg
Binary file not shown.
Binary file added www/docs/style/img/uk-parliament-desktop.webp
Binary file not shown.
Binary file added www/docs/style/img/uk-parliament-huge.webp
Binary file not shown.
Binary file added www/docs/style/img/uk-parliament-mobile.webp
Binary file not shown.
Binary file added www/docs/style/img/uk-parliament-tablet.webp
Binary file not shown.
4 changes: 2 additions & 2 deletions www/docs/style/sass/_mysoc_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $mysoc-footer-background-color: #fff !default;
$mysoc-footer-text-color: #333 !default;
$mysoc-footer-site-name-text-color: $mysoc-footer-text-color !default;

$mysoc-footer-link-text-color: #4FADED !default;
$mysoc-footer-link-text-color: $links !default;
$mysoc-footer-link-hover-text-color: darken($mysoc-footer-link-text-color, 10%) !default;

$mysoc-footer-site-name-font-size: 1.5em !default;
Expand Down Expand Up @@ -33,7 +33,7 @@ $mysoc-footer-breakpoint-sm: 768px !default;
box-sizing: border-box;
background-color: $mysoc-footer-background-color;
color: $mysoc-footer-text-color;
padding: 2em 0;
padding: 2em 1.5em;
font-size: 1em;
line-height: 1.5em;
border-top: $mysoc-footer-border-top;
Expand Down
15 changes: 11 additions & 4 deletions www/docs/style/sass/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,19 @@ $column-gutter: 3%;
$row-width: em-calc(1140);
$block-grid-default-spacing: 3%;

$primary-color: #62b356;
$primary-color: #4b7e45;
$primary-color-100: lighten($primary-color, 45%);
$primary-color-200: lighten($primary-color, 40%);
$primary-color-300: lighten($primary-color, 35%);
$primary-color-600: darken($primary-color, 5%);
$primary-color-700: darken($primary-color, 10%);
$secondary-color: #A94CA6;
$color-red: #dc3545;
$color-yellow: #ffe500;

$body-bg: #f3f1eb;
$body-font-color: #333333;
$links: #4faded;
$links: #1567ae;
$brand: $primary-color;
$footer: #444;
$topbar-bg-color: $brand;
Expand Down Expand Up @@ -260,7 +267,7 @@ $margin: 1em;
// $paragraph-font-family: inherit;
// $paragraph-font-weight: normal;
// $paragraph-font-size: 1em;
// $paragraph-line-height: 1.6;
$paragraph-line-height: 1.4;
// $paragraph-margin-bottom: em-calc(20);
// $paragraph-aside-font-size: em-calc(14);
// $paragraph-aside-line-height: 1.35;
Expand Down Expand Up @@ -408,7 +415,7 @@ $margin: 1em;

// We use these to build padding for buttons.

// $button-med: em-calc(12);
$button-med: em-calc(8);
// $button-tny: em-calc(7);
// $button-sml: em-calc(9);
// $button-lrg: em-calc(16);
Expand Down
Loading

0 comments on commit 44e91be

Please sign in to comment.