Compare commits

17 Commits

Author SHA1 Message Date
35812791f5 Add text to top of Federal Divisions page 2025-04-24 17:45:26 +10:00
72c7413195 Use convert command if magick command isn't installed 2025-04-21 21:40:40 +10:00
Kim Taylor
2cf3d0bd26 Ignore candidates from divisions outside Victoria. 2025-04-19 15:47:49 +10:00
Kim Taylor
babf8f81b6 Pledge page specifically mentions question 4. 2025-04-18 11:00:42 +10:00
Kim Taylor
1e3e4a99e6 Update form link on division pages. 2025-04-14 21:22:23 +10:00
Kim Taylor
60a33194e1 Update pledge-page generation for federal election. 2025-04-13 15:57:04 +10:00
Kim Taylor
d8684760e5 Update homepage pledge image rotation for federal. 2025-04-13 13:36:50 +10:00
Kim Taylor
1735d52781 Update division page generation. 2025-04-11 21:21:42 +10:00
Kim Taylor
675058201a Update date generic form parser for federal 2025 form. 2025-03-30 23:02:48 +11:00
Kim Taylor
05b0898979 Only one election. 2025-03-04 23:53:49 +11:00
Kim Taylor
c172222e15 Update wording on division pages. 2025-03-04 23:51:10 +11:00
Kim Taylor
5e3d22de3e Update front page auto-update to look at federal data. 2025-03-04 22:42:50 +11:00
Kim Taylor
9b9c1a6869 Update pledge page to generate pledges for federal divisions. 2025-03-04 22:28:19 +11:00
Kim Taylor
f5f04d01eb Update LGA page to generate Federal Divisions page. 2025-03-04 21:58:26 +11:00
Kim Taylor
0bddcb7520 Generate division pages. Need to update text. 2025-03-04 21:44:12 +11:00
Kim Taylor
608ed0f92c Update map generator for federal election. 2025-03-03 21:05:24 +11:00
Kim Taylor
2a0ba8eed2 Update pledge message for federal election. 2025-03-02 15:54:33 +11:00
18 changed files with 224 additions and 64 deletions

View File

@@ -42,21 +42,23 @@ match_lga($candidate_data, $lga_list);
foreach ($candidate_data as $key => $candidate) { foreach ($candidate_data as $key => $candidate) {
$score = 0; $score = 0;
if ($candidate['Pledge'] === "y") $score++; if ($candidate['q0'] === "Yes") $score++;
if ($candidate['q1'] === "Yes") $score++; if ($candidate['q1'] === "Yes") $score++;
if ($candidate['q2'] === "Yes") $score++;
if ($candidate['q3'] === "Yes") $score++; if ($candidate['q3'] === "Yes") $score++;
if ($candidate['q4'] === "Yes") $score++; if ($candidate['q4'] === "Yes") $score++;
if ($candidate['q7'] === "Yes") $score++;
$candidate_data[$key]['Score'] = $score; $candidate_data[$key]['Score'] = $score;
$candidate_data[$key]['Pledge'] = $candidate['q4'];
} }
$header = ["Ward", "Candidate Name", "Rating", "Pledge", "Picture"]; $header = ["Candidate Name", "Rating", "Pledge", "Picture"];
/* Generate candidates-generic.csv */ /* Generate candidates-generic.csv */
foreach ($lga_list as $lga) { foreach ($lga_list as $lga) {
$lga_candidates = array_filter($candidate_data, function ($candidate) use ($lga) { $lga_candidates = array_filter($candidate_data, function ($candidate) use ($lga) {
return $candidate['match_lga'] === $lga['slug']; return $candidate['match_division'] === $lga['slug'];
}); });
if (count($lga_candidates) === 0) continue; if (count($lga_candidates) === 0) continue;
@@ -91,7 +93,6 @@ foreach ($lga_list as $lga) {
} }
$lines[] = [ $lines[] = [
$candidate['match_ward'],
$candidate['Name'], $candidate['Name'],
$candidate['Score'], $candidate['Score'],
$candidate['Pledge'], $candidate['Pledge'],

View File

@@ -42,7 +42,7 @@ $image_map = [];
foreach ($candidate_data as $candidate) { foreach ($candidate_data as $candidate) {
if (strlen($candidate['photo_url'])) { if (strlen($candidate['photo_url'])) {
$map['url'] = $candidate['photo_url']; $map['url'] = $candidate['photo_url'];
$map['match_lga'] = $candidate['match_lga']; $map['match_division'] = $candidate['match_division'];
$image_map[$candidate['Photo']] = $map; $image_map[$candidate['Photo']] = $map;
} }
} }

View File

@@ -10,19 +10,11 @@ function parse_generic_csv($generic_csv) {
$is_question = false; $is_question = false;
foreach ($headers as $key => $value) { foreach ($headers as $key => $value) {
/* Override key name for questions */ /* Override key name for questions */
if ($value === "Verified") {
$is_question = false;
}
if (strstr($value, "candidate photo")) $value = "Photo"; if (strstr($value, "candidate photo")) $value = "Photo";
if (strstr($value, "In which Local Government Area")) $value = "LGA"; if (strstr($value, "In which federal Division are")) continue;
if (strstr($value, "In which Ward")) $value = "Ward"; if (strstr($value, "In which Federal Division are")) $value = "Division";
if (strstr($value, "Political Party")) $value = "Party"; if (strstr($value, "Political Party")) $value = "Party";
if (strstr($value, "Protected bike lanes provide")) continue;
if ($value === "Pledge") {
if (strstr($data[$key], "I pledge")) $data[$key] = "y";
else $data[$key] = "n";
}
if ($value === "Photo") { if ($value === "Photo") {
$candidate['photo_url'] = $data[$key]; $candidate['photo_url'] = $data[$key];
@@ -35,7 +27,7 @@ function parse_generic_csv($generic_csv) {
$candidate[$value] = $data[$key]; $candidate[$value] = $data[$key];
} }
if ($value === "Pledge") { if ($value === "Party") {
$is_question = true; $is_question = true;
} }
} }
@@ -54,8 +46,9 @@ function match_lga(&$candidate_data, $lga_list) {
foreach ($candidate_data as &$candidate) { foreach ($candidate_data as &$candidate) {
/* Match user typed LGA/Ward to our database */ /* Match user typed LGA/Ward to our database */
$max_score = 0; $max_score = 0;
$match_lga = null;
foreach ($lga_list as $lga) { foreach ($lga_list as $lga) {
$aa = preg_split("/[^a-z]/", strtolower($candidate['LGA'])); $aa = preg_split("/[^a-z]/", strtolower($candidate['Division']));
$bb = preg_split("/[^a-z]/", $lga['slug']); $bb = preg_split("/[^a-z]/", $lga['slug']);
$score_sum = 0; $score_sum = 0;
@@ -73,6 +66,7 @@ function match_lga(&$candidate_data, $lga_list) {
} }
} }
/*
$max_score = 0; $max_score = 0;
foreach ($match_lga['wardNames'] as $ward) { foreach ($match_lga['wardNames'] as $ward) {
similar_text(strtolower($ward), strtolower($candidate['Ward']), $score); similar_text(strtolower($ward), strtolower($candidate['Ward']), $score);
@@ -81,9 +75,14 @@ function match_lga(&$candidate_data, $lga_list) {
$match_ward = $ward; $match_ward = $ward;
} }
} }
*/
$candidate['match_lga'] = $match_lga['slug']; if ($match_lga === null) {
$candidate['match_ward'] = $match_ward; $candidate['match_division'] = "no_match";
} else {
$candidate['match_division'] = $match_lga['slug'];
}
//$candidate['match_ward'] = $match_ward;
} }
} }

View File

@@ -5,11 +5,11 @@
GENERIC_SURVEY=../generic-survey/responses.csv GENERIC_SURVEY=../generic-survey/responses.csv
IMAGES=../generic-survey/images IMAGES=../generic-survey/images
DATA_PATH="../spl-data" DATA_PATH="../spl-data/federal_2025"
echo "Fetching latest responses to generic survey." echo "Fetching latest responses to generic survey."
rm -f $GENERIC_SURVEY # Force re-fetch rm -f $GENERIC_SURVEY # Force re-fetch
rclone -v copyto --drive-export-formats csv 'bikewest:spl_generic_survey_2024/Streets People Love council election candidate pledge and survey (Responses).csv' $GENERIC_SURVEY rclone -v copyto --drive-export-formats csv 'bikewest:spl_generic_survey_federal_2025/Streets People Love Federal Election candidate pledge (Responses).csv' $GENERIC_SURVEY
config_files=() config_files=()
for folder in "$DATA_PATH"/*; do for folder in "$DATA_PATH"/*; do
@@ -47,7 +47,12 @@ for key in $(jq -r 'keys[]' <<< $image_map) ; do
;; ;;
esac esac
lga=$(jq -r ".[\"$key\"][\"match_lga\"]" <<< $image_map) lga=$(jq -r ".[\"$key\"][\"match_division\"]" <<< $image_map)
if [ ! -d $"$DATA_PATH/$lga" ] ; then
continue
fi
dst="$DATA_PATH/$lga/$key$suffix" dst="$DATA_PATH/$lga/$key$suffix"
if [ -f $dst ] ; then if [ -f $dst ] ; then
@@ -55,7 +60,11 @@ for key in $(jq -r 'keys[]' <<< $image_map) ; do
fi fi
echo "Resizing $dst" echo "Resizing $dst"
convert $IMAGES/$key -resize 400x400 $dst if command -v magick >/dev/null 2>&1; then
magick $IMAGES/$key -resize 400x400 $dst
else
convert $IMAGES/$key -resize 400x400 $dst
fi
done done
echo "Generating candidates-generic.csv files." echo "Generating candidates-generic.csv files."

View File

@@ -21,6 +21,13 @@ foreach ($candidates_files as $file) {
$lgas_with_data[] = basename(dirname($file)); $lgas_with_data[] = basename(dirname($file));
} }
print('<!-- wp:paragraph -->' . "\n");
print('<p>The Streets People Love campaign has created scorecards for candidates in the 2025 federal election. Scorecards have been generated based on a candidate\'s engagement with the Streets People Love campaign, their commitment to our pledge, their responses to a survey and input from campaign members located in the division in which they are running.</p>' . "\n");
print('<!-- /wp:paragraph -->' . "\n");
print('<!-- wp:paragraph -->' . "\n");
print('<p>Can\'t see a candidate you know is running? Candidates who don\'t take our survey won\'t appear on this page. Feel free to send your local candidates the <a href="https://forms.gle/CeGbJF11SUkATjfN8">Streets People Love Pledge and Survey</a> and let them know it\'s important to local residents that they do take part, so that we can vote for those who want to build the streets people love.</p>' . "\n");
print('<!-- /wp:paragraph -->' . "\n");
print('<!-- wp:list --> <ul class="wp-block-list">' . "\n"); print('<!-- wp:list --> <ul class="wp-block-list">' . "\n");
foreach ($lga_files as $config_file) { foreach ($lga_files as $config_file) {
@@ -41,7 +48,7 @@ foreach ($lga_files as $config_file) {
print('<!-- wp:list-item {"style":{"typography":{"fontStyle":"normal","fontWeight":"'); print('<!-- wp:list-item {"style":{"typography":{"fontStyle":"normal","fontWeight":"');
print($font_weight . '"}}} -->' . "\n"); print($font_weight . '"}}} -->' . "\n");
print('<li style="font-style:normal;font-weight:' . $font_weight . '">'); print('<li style="font-style:normal;font-weight:' . $font_weight . '">');
print('<a href="' . $config['slug'] . '">' . $config['councilName'] . "</a></li>\n"); print('<a href="' . $config['slug'] . '">' . $config['divisionName'] . "</a></li>\n");
print('<!-- /wp:list-item -->' . "\n"); print('<!-- /wp:list-item -->' . "\n");
} }

View File

@@ -4,7 +4,7 @@
# The folder containing data for each council. # The folder containing data for each council.
# Includes the list of candidates and any media. # Includes the list of candidates and any media.
DATA_PATH="../spl-data" DATA_PATH="../spl-data/federal_2025"
# Controls the flags that are passed to every usage of the wp command. # Controls the flags that are passed to every usage of the wp command.
#WP_FLAGS="--allow-root --path=/var/www/html" #WP_FLAGS="--allow-root --path=/var/www/html"
@@ -23,7 +23,7 @@ function create_or_update_page() {
media_inputs+=("$file") media_inputs+=("$file")
fi fi
done done
for file in "$DATA_PATH"/*.{jpeg,jpg,png,gif}.json; do for file in "$DATA_PATH"/../*.{jpeg,jpg,png,gif}.json; do
if test -f "$file"; then if test -f "$file"; then
media_inputs+=("$file") media_inputs+=("$file")
fi fi

View File

@@ -4,7 +4,7 @@
# The folder containing data for each council. # The folder containing data for each council.
# Includes the list of candidates and any media. # Includes the list of candidates and any media.
DATA_PATH="../spl-data" DATA_PATH="../spl-data/federal_2025"
# Iterate over folders in data path # Iterate over folders in data path
candidates_files=() candidates_files=()
@@ -22,4 +22,4 @@ done
content=$(php lga-page.php --candidates-files "${candidates_files[*]}" \ content=$(php lga-page.php --candidates-files "${candidates_files[*]}" \
--lga-files "${lga_files[*]}") --lga-files "${lga_files[*]}")
echo "$content" | wp post update 465 - echo "$content" | wp post update 245813 -

View File

@@ -4,7 +4,7 @@
# The folder containing data for each council. # The folder containing data for each council.
# Includes the list of candidates and any media. # Includes the list of candidates and any media.
DATA_PATH="../spl-data" DATA_PATH="../spl-data/federal_2025"
DEFAULT_IMAGE="../spl-data/default.png.json" DEFAULT_IMAGE="../spl-data/default.png.json"
# Iterate over folders in data path # Iterate over folders in data path
@@ -22,4 +22,4 @@ done
content=$(php pledge-update/pledge-page.php --candidates-files "${candidates_files[*]}" \ content=$(php pledge-update/pledge-page.php --candidates-files "${candidates_files[*]}" \
--default-image $DEFAULT_IMAGE) --default-image $DEFAULT_IMAGE)
echo "$content" | wp post update 12106 - echo "$content" | wp post update 245816 -

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
SHPFILE := ../../../spl-data/federal_2025/aec_data/E_VIC24_region.shp
SHAPELIB := ../../../lib/shapelib-1.6.0
../federal_2025_boundaries.json: $(SHPFILE) shptojson
LD_LIBRARY_PATH=$(SHAPELIB)/.libs ./shptojson $(SHPFILE) > $@
CFLAGS := -I $(SHAPELIB)
LDFLAGS := -L $(SHAPELIB)/.libs
shptojson: shptojson.c
gcc -Wall $(CFLAGS) $(LDFLAGS) -lshp $< -o $@

View File

@@ -0,0 +1,142 @@
/******************************************************************************
*
* Project: Shapelib
* Purpose: Sample application for dumping contents of a shapefile to
* the terminal in human readable form.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
*
* SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
******************************************************************************
*
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "shapefil.h"
int main(int argc, char **argv)
{
int nPrecision = 15;
int first;
const char *divison_name;
/* -------------------------------------------------------------------- */
/* Display a usage message. */
/* -------------------------------------------------------------------- */
if (argc != 2)
{
printf("Usage: shptojson shp_file\n");
exit(1);
}
/* -------------------------------------------------------------------- */
/* Open the passed shapefile. */
/* -------------------------------------------------------------------- */
SHPHandle hSHP = SHPOpen(argv[1], "rb");
DBFHandle hDBF = DBFOpen(argv[1], "rb");
if (hSHP == NULL || hDBF == NULL)
{
printf("Unable to open:%s\n", argv[1]);
exit(1);
}
/* -------------------------------------------------------------------- */
/* Print out the file bounds. */
/* -------------------------------------------------------------------- */
int nEntities;
int nShapeType;
double adfMinBound[4];
double adfMaxBound[4];
SHPGetInfo(hSHP, &nEntities, &nShapeType, adfMinBound, adfMaxBound);
fprintf(stderr, "Shapefile Type: %s # of Shapes: %d\n\n",
SHPTypeName(nShapeType), nEntities);
/* -------------------------------------------------------------------- */
/* Skim over the list of shapes, printing all the vertices. */
/* -------------------------------------------------------------------- */
printf("[\n");
for (int i = 0; i < nEntities; i++)
{
SHPObject *psShape = SHPReadObject(hSHP, i);
if (psShape == NULL)
{
fprintf(stderr,
"Unable to read shape %d, terminating object reading.\n",
i);
break;
}
divison_name = DBFReadStringAttribute(hDBF, i, 1);
fprintf(stderr, "shape %s has %i parts\n", divison_name, psShape->nParts);
printf(" {\n");
printf(" \"electorateId\": \"%08i\",\n", i);
printf(" \"electorateName\": \"%s\",\n", divison_name);
printf(" \"electorateType\": \"Division\",\n");
printf(" \"parentElectorateName\": \"%s\",\n", divison_name);
printf(" \"boundaryJson\": \"{\\\"type\\\": ");
if (psShape->nParts != 1)
{
printf("\\\"MultiPolygon\\\",\\\"coordinates\\\":[[[");
}
else
{
printf("\\\"Polygon\\\",\\\"coordinates\\\":[[");
}
first = 1;
for (int j = 0, iPart = 1; j < psShape->nVertices; j++)
{
if (iPart < psShape->nParts && psShape->panPartStart[iPart] == j)
{
iPart++;
printf("]],[[");
}
else if (!first)
{
printf(",");
}
first = 0;
printf("[%.*g,%.*g]", nPrecision, psShape->padfX[j],
nPrecision, psShape->padfY[j]);
}
if (i == (nEntities-1))
{
if (psShape->nParts != 1)
{
printf("]]]}\"\n }\n");
}
else
{
printf("]]}\"\n }\n");
}
}
else
{
if (psShape->nParts != 1)
{
printf("]]]}\"\n },\n");
}
else
{
printf("]]}\"\n },\n");
}
}
SHPDestroyObject(psShape);
}
printf("]\n");
SHPClose(hSHP);
DBFClose(hDBF);
exit(0);
}

View File

@@ -32,7 +32,7 @@ map.on('load', () => {
map.addImage('blue-circle', image); map.addImage('blue-circle', image);
fetch("wards_withboundaries.json") fetch("federal_2025_boundaries.json")
.then(response => { .then(response => {
response.json() response.json()
.then((wardData) => { .then((wardData) => {
@@ -117,7 +117,7 @@ map.on('load', () => {
// //
// The 2024 set of boundaries only uses 2 MultiPolygon objects (Cathedral in Murrindindi Shire Council and Island in Bass Coast Shire Council) // The 2024 set of boundaries only uses 2 MultiPolygon objects (Cathedral in Murrindindi Shire Council and Island in Bass Coast Shire Council)
// Luckily, the second polygon for both objects results in a good label placement. // Luckily, the second polygon for both objects results in a good label placement.
centrePoint = polylabel(featureCollection.features[0].geometry.coordinates[1], 0.000001); centrePoint = polylabel(featureCollection.features[0].geometry.coordinates[0], 0.000001);
} }

View File

@@ -4,7 +4,7 @@ function sluggify($input) {
return strtolower(str_replace(' ', '-', $input)); return strtolower(str_replace(' ', '-', $input));
} }
$surveyLink = "<a href=\"https://forms.gle/gnDNyBiVC64tDo2Y7\">Streets People Love Pledge and Survey</a>"; $surveyLink = "<a href=\"https://forms.gle/CeGbJF11SUkATjfN8\">Streets People Love Pledge and Survey</a>";
if (isset($config["survey"])) { if (isset($config["survey"])) {
$surveyLink = $config["survey"]; $surveyLink = $config["survey"];
} }
@@ -18,7 +18,7 @@ if (isset($config["survey"])) {
<?php else: ?> <?php else: ?>
<p>The Streets People Love campaign has created scorecards for candidates in the 2024 council elections. Scorecards have been generated based on a candidate's engagement with the Streets People Love campaign, their commitment to our pledge, their responses to a survey and input from campaign members located in the local government area in which they are running.</p> <p>The Streets People Love campaign has created scorecards for candidates in the 2025 federal election. Scorecards have been generated based on a candidate's engagement with the Streets People Love campaign, their commitment to our pledge, their responses to a survey and input from campaign members located in the division in which they are running.</p>
<!-- /wp:paragraph --> <!-- /wp:paragraph -->
<!-- wp:paragraph --> <!-- wp:paragraph -->
@@ -35,20 +35,16 @@ if (isset($config["survey"])) {
<?php <?php
$wardCount = count($config['wardNames']); $wardCount = 1; //count($config['wardNames']);
if ($wardCount > 1) { if ($wardCount > 1) {
$wardsDescription = $config['councilName'] . " is divided into " . $wardCount . " wards:"; $wardsDescription = $config['divisionName'] . " is divided into " . $wardCount . " wards:";
} else { } else {
$wardsDescription = $config['councilName'] . " is unsubdivided and does not contain any wards."; $wardsDescription = $config['divisionName'] . " is unsubdivided and does not contain any wards.";
} }
?> ?>
<!-- wp:paragraph -->
<p><?php echo $wardsDescription; ?></p>
<!-- /wp:paragraph -->
<?php if (isset($media["map.jpg"])): ?> <?php if (isset($media["map.jpg"])): ?>
<!-- wp:image {"id":<?php echo $media["map.jpg"]['id']; ?>,"width":"550px","sizeSlug":"full","linkDestination":"media","className":"is-style-default"} --> <!-- wp:image {"id":<?php echo $media["map.jpg"]['id']; ?>,"width":"550px","sizeSlug":"full","linkDestination":"media","className":"is-style-default"} -->
<figure class="wp-block-image size-full is-resized is-style-default"><a href="<?php echo $media["map.jpg"]['url']; ?>" target="_blank" rel="noreferrer noopener"><img src="<?php echo $media["map.jpg"]['url']; ?>" alt="" class="wp-image-<?php echo $media["map.jpg"]['id']; ?>" style="width:550px"/></a></figure> <figure class="wp-block-image size-full is-resized is-style-default"><a href="<?php echo $media["map.jpg"]['url']; ?>" target="_blank" rel="noreferrer noopener"><img src="<?php echo $media["map.jpg"]['url']; ?>" alt="" class="wp-image-<?php echo $media["map.jpg"]['id']; ?>" style="width:550px"/></a></figure>
@@ -106,37 +102,32 @@ if (isset($config["survey"])) {
$groupNames = $config['groupNames']; $groupNames = $config['groupNames'];
$propertyOnCandidate = 'Group'; $propertyOnCandidate = 'Group';
} else { } else {
$groupNames = $config['wardNames']; $groupNames = ['N/A']; // $config['wardNames'];
$propertyOnCandidate = 'Ward'; $propertyOnCandidate = 'Ward';
} }
?> ?>
<?php foreach ($groupNames as $index => $groupName): ?> <?php foreach ($groupNames as $index => $groupName): ?>
<!-- wp:heading {"level":3,"className":"is-style-default"} -->
<?php $groupSlug = sluggify($groupName); ?>
<h3 class="wp-block-heading is-style-default" id="<?php echo $groupSlug; ?>"><a style="text-decoration: none;" href="#<?php echo $groupSlug; ?>"><?php echo htmlspecialchars($groupName); ?></a></h3>
<!-- /wp:heading -->
<?php <?php
$groupCandidates = array_filter($candidates, function ($candidate) use ($groupName, $propertyOnCandidate) { $groupCandidates = array_filter($candidates, function ($candidate) use ($groupName, $propertyOnCandidate) {
return isset($candidate[$propertyOnCandidate]) && return isset($candidate[$propertyOnCandidate]) &&
strtolower($candidate[$propertyOnCandidate]) === strtolower($groupName); strtolower($candidate[$propertyOnCandidate]) === strtolower($groupName);
}); });
usort($groupCandidates, function($a, $b) { usort($candidates, function($a, $b) {
if ($a == $b) { if ($a == $b) {
return 0; return 0;
} }
return (((int) $a['Rating']) < ((int) $b['Rating'])) ? 1 : -1; return (((int) $a['Rating']) < ((int) $b['Rating'])) ? 1 : -1;
}); });
if (count($groupCandidates) > 0): if (count($candidates) > 0):
?> ?>
<?php <?php
$columnCount = 4; $columnCount = 4;
$chunkedWardCandidates = array_chunk($groupCandidates, $columnCount); $chunkedWardCandidates = array_chunk($candidates, $columnCount);
?> ?>
<?php foreach($chunkedWardCandidates as $chunk): ?> <?php foreach($chunkedWardCandidates as $chunk): ?>
@@ -203,7 +194,7 @@ if (isset($config["survey"])) {
<?php else: ?> <?php else: ?>
<!-- wp:paragraph --> <!-- wp:paragraph -->
<p>No candidates in this ward have completed the survey. Send your local candidates the <?php echo $surveyLink; ?> and ask them to take part so that local residents can vote for the candidates who want to build the streets people love.</p> <p>No candidates in this division have completed the survey. Send your local candidates the <?php echo $surveyLink; ?> and ask them to take part so that local residents can vote for the candidates who want to build the streets people love.</p>
<!-- /wp:paragraph --> <!-- /wp:paragraph -->
<?php endif; ?> <?php endif; ?>

View File

@@ -15,11 +15,11 @@ $candidate_data = parse_pledge_data(explode(" ", $candidates_files), null);
/* Select people who have taken the pledge (and have an image) */ /* Select people who have taken the pledge (and have an image) */
$pledgeCandidates = array_filter($candidate_data, function ($candidate) { $pledgeCandidates = array_filter($candidate_data, function ($candidate) {
return $candidate['Pledge'] === 'y' && $candidate['Picture'] !== ""; return $candidate['Pledge'] === 'Yes' && $candidate['Picture'] !== "";
}); });
/* Select 9 random candidates */ /* Select 9 random candidates */
$pledgeKeys = array_rand($pledgeCandidates, 9); $pledgeKeys = array_rand($pledgeCandidates, min(count($pledgeCandidates), 9));
shuffle($pledgeKeys); shuffle($pledgeKeys);
$i = 0; $i = 0;

View File

@@ -61,7 +61,7 @@ function parse_pledge_data($candidates_files, $default_image) {
if (!empty($elected_data) && array_key_exists($name_slug, $elected_data)) { if (!empty($elected_data) && array_key_exists($name_slug, $elected_data)) {
$candidate['Elected'] = $elected_data[$name_slug]['Elected']; $candidate['Elected'] = $elected_data[$name_slug]['Elected'];
} }
$candidate['Council'] = $config['councilName']; $candidate['Council'] = $config['divisionName'];
$candidate['Path'] = dirname($file); $candidate['Path'] = dirname($file);
$media_desc = $candidate['Path']."/". $media_desc = $candidate['Path']."/".
$candidate['Picture'].".json"; $candidate['Picture'].".json";

View File

@@ -32,7 +32,7 @@ $candidate_data = parse_pledge_data(explode(" ", $candidates_files), $default_im
/* Select people who have taken the pledge */ /* Select people who have taken the pledge */
$pledgeCandidates = array_filter($candidate_data, function ($candidate) { $pledgeCandidates = array_filter($candidate_data, function ($candidate) {
return $candidate['Pledge'] === 'y'; return $candidate['Pledge'] === 'Yes';
}); });
$renderer = new SPLPageRenderer(); $renderer = new SPLPageRenderer();

View File

@@ -5,15 +5,15 @@ function sluggify($input) {
?> ?>
<!-- wp:paragraph --> <!-- wp:paragraph -->
<p>The Streets People Love campaign offers council candidates the opportunity to take the following pledge:</p> <p>The Streets People Love campaign offers federal candidates the opportunity to take the following pledge:</p>
<!-- /wp:paragraph --> <!-- /wp:paragraph -->
<!-- wp:paragraph {"style":{"color":{"background":"#10B5B0"}}} --> <!-- wp:paragraph {"style":{"color":{"background":"#10B5B0"}}} -->
<p class="has-background" style="background-color:#10B5B0">If elected Councillor, I pledge to allocate budget and street space to build streets people love, and ensure that residents of all ages and abilities can safely move around our council area, irrespective of whether they choose to walk, cycle, wheel, use public transport or drive.</p> <p class="has-background" style="background-color:#10B5B0">If elected, I pledge to vote for a national Active Transport Infrastructure Program that invests $400 million annually, equivalent to $15 per person, for the duration of the <a href="https://www.betterstreets.org.au/2025-federal-election">United Nations Decade of Sustainable Transport</a>, from 2026 to 2035.</p>
<!-- /wp:paragraph --> <!-- /wp:paragraph -->
<!-- wp:paragraph --> <!-- wp:paragraph -->
<p>Candidates from these councils have taken the pledge:</p> <p>Candidates from these divisions have taken the pledge:</p>
<!-- /wp:paragraph --> <!-- /wp:paragraph -->
<?php <?php
@@ -44,9 +44,9 @@ $councilCount = count($councils);
<!-- wp:list {"style":{"spacing":{"margin":{"top":"0","right":"0","bottom":"0","left":"0"}}}} --> <!-- wp:list {"style":{"spacing":{"margin":{"top":"0","right":"0","bottom":"0","left":"0"}}}} -->
<ul style="margin-top:0;margin-right:0;margin-bottom:0;margin-left:0" class="wp-block-list"> <ul style="margin-top:0;margin-right:0;margin-bottom:0;margin-left:0" class="wp-block-list">
<?php foreach($councilChunks[$columnIdx] as $councilName): ?> <?php foreach($councilChunks[$columnIdx] as $divisionName): ?>
<!-- wp:list-item --> <!-- wp:list-item -->
<li><a href="#<?php echo sluggify($councilName); ?>"><?php echo $councilName; ?></a></li> <li><a href="#<?php echo sluggify($divisionName); ?>"><?php echo $divisionName; ?></a></li>
<!-- /wp:list-item --> <!-- /wp:list-item -->
<?php endforeach; ?> <?php endforeach; ?>

View File

@@ -11,7 +11,7 @@
#wp post create --post_type=page --post_title="test_pledge" movie-homepage #wp post create --post_type=page --post_title="test_pledge" movie-homepage
#wp post update 1803 ../spl-data/movie-homepage #wp post update 1803 ../spl-data/movie-homepage
DATA_PATH="../spl-data" DATA_PATH="../spl-data/federal_2025"
candidates_files=() candidates_files=()
for folder in "$DATA_PATH"/*; do for folder in "$DATA_PATH"/*; do