begin take action page
This commit is contained in:
1 parent
e3e291b8cf
commit
1c38a7bdb0
75 files changed
+496
-1
No files matched your search
@@ -7,6 +7,7 @@ from pathlib import Path
|
||||
|
||||
import frontmatter
|
||||
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||
import yaml
|
||||
|
||||
from config import NAV, SITE
|
||||
|
||||
@@ -45,6 +46,52 @@ def build() -> None:
|
||||
)
|
||||
write(TMP, url, html)
|
||||
|
||||
state = (
|
||||
yaml.safe_load((ROOT / "data" / "state.yaml").read_text(encoding="utf-8"))
|
||||
or {}
|
||||
)
|
||||
counties = [
|
||||
yaml.safe_load(p.read_text(encoding="utf-8"))
|
||||
for p in sorted((ROOT / "data" / "counties").glob("*.yaml"))
|
||||
]
|
||||
for c in counties:
|
||||
c["url"] = f"/act/{c['slug']}-county/"
|
||||
|
||||
map_file = STATIC / "assets" / "alabama-counties.svg"
|
||||
map_svg = map_file.read_text(encoding="utf-8") if map_file.exists() else None
|
||||
|
||||
write(
|
||||
TMP,
|
||||
"/act/",
|
||||
env.get_template("act.html").render(
|
||||
**common,
|
||||
url="/act/",
|
||||
state=state,
|
||||
counties=counties,
|
||||
map_svg=map_svg,
|
||||
meta={
|
||||
"title": "Take Action",
|
||||
"description": "Find your representatives and county, and how to contact them.",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
county_tpl = env.get_template("county.html")
|
||||
for c in counties:
|
||||
write(
|
||||
TMP,
|
||||
c["url"],
|
||||
county_tpl.render(
|
||||
**common,
|
||||
url=c["url"],
|
||||
county=c,
|
||||
meta={
|
||||
"title": f"{c['name']} County, Alabama",
|
||||
"description": f"Representatives, local groups, and ways to take action in {c['name']} County, Alabama.",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
(TMP / "404.html").write_text(
|
||||
env.get_template("404.html").render(
|
||||
**common, url="/404.html", meta={"title": "Page not found", "noindex": True}
|
||||
|
||||
@@ -9,5 +9,6 @@ SITE = {
|
||||
NAV = [
|
||||
("Home", "/"),
|
||||
("About", "/about/"),
|
||||
("Take Action", "/act/"),
|
||||
("Join", "/join/"),
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Autauga
|
||||
slug: autauga
|
||||
fips: '01001'
|
||||
region: Central
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Baldwin
|
||||
slug: baldwin
|
||||
fips: '01003'
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Barbour
|
||||
slug: barbour
|
||||
fips: '01005'
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Bibb
|
||||
slug: bibb
|
||||
fips: '01007'
|
||||
region: West
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Blount
|
||||
slug: blount
|
||||
fips: 01009
|
||||
region: Central
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Bullock
|
||||
slug: bullock
|
||||
fips: '01011'
|
||||
region: East
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Butler
|
||||
slug: butler
|
||||
fips: '01013'
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Calhoun
|
||||
slug: calhoun
|
||||
fips: '01015'
|
||||
region: East
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Chambers
|
||||
slug: chambers
|
||||
fips: '01017'
|
||||
region: East
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Cherokee
|
||||
slug: cherokee
|
||||
fips: 01019
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Chilton
|
||||
slug: chilton
|
||||
fips: '01021'
|
||||
region: Central
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Choctaw
|
||||
slug: choctaw
|
||||
fips: '01023'
|
||||
region: West
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Clarke
|
||||
slug: clarke
|
||||
fips: '01025'
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Clay
|
||||
slug: clay
|
||||
fips: '01027'
|
||||
region: East
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Cleburne
|
||||
slug: cleburne
|
||||
fips: 01029
|
||||
region: East
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Coffee
|
||||
slug: coffee
|
||||
fips: '01031'
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Colbert
|
||||
slug: colbert
|
||||
fips: '01033'
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Conecuh
|
||||
slug: conecuh
|
||||
fips: '01035'
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Coosa
|
||||
slug: coosa
|
||||
fips: '01037'
|
||||
region: East
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Covington
|
||||
slug: covington
|
||||
fips: 01039
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Crenshaw
|
||||
slug: crenshaw
|
||||
fips: '01041'
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Cullman
|
||||
slug: cullman
|
||||
fips: '01043'
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Dale
|
||||
slug: dale
|
||||
fips: '01045'
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Dallas
|
||||
slug: dallas
|
||||
fips: '01047'
|
||||
region: Central
|
||||
@@ -0,0 +1,4 @@
|
||||
name: DeKalb
|
||||
slug: dekalb
|
||||
fips: 01049
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Elmore
|
||||
slug: elmore
|
||||
fips: '01051'
|
||||
region: Central
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Escambia
|
||||
slug: escambia
|
||||
fips: '01053'
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Etowah
|
||||
slug: etowah
|
||||
fips: '01055'
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Fayette
|
||||
slug: fayette
|
||||
fips: '01057'
|
||||
region: West
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Franklin
|
||||
slug: franklin
|
||||
fips: 01059
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Geneva
|
||||
slug: geneva
|
||||
fips: '01061'
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Greene
|
||||
slug: greene
|
||||
fips: '01063'
|
||||
region: West
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Hale
|
||||
slug: hale
|
||||
fips: '01065'
|
||||
region: West
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Henry
|
||||
slug: henry
|
||||
fips: '01067'
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Houston
|
||||
slug: houston
|
||||
fips: 01069
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Jackson
|
||||
slug: jackson
|
||||
fips: '01071'
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Jefferson
|
||||
slug: jefferson
|
||||
fips: '01073'
|
||||
region: Central
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Lamar
|
||||
slug: lamar
|
||||
fips: '01075'
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Lauderdale
|
||||
slug: lauderdale
|
||||
fips: '01077'
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Lawrence
|
||||
slug: lawrence
|
||||
fips: 01079
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Lee
|
||||
slug: lee
|
||||
fips: 01081
|
||||
region: East
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Limestone
|
||||
slug: limestone
|
||||
fips: 01083
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Lowndes
|
||||
slug: lowndes
|
||||
fips: 01085
|
||||
region: Central
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Macon
|
||||
slug: macon
|
||||
fips: 01087
|
||||
region: East
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Madison
|
||||
slug: madison
|
||||
fips: 01089
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Marengo
|
||||
slug: marengo
|
||||
fips: 01091
|
||||
region: West
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Marion
|
||||
slug: marion
|
||||
fips: 01093
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Marshall
|
||||
slug: marshall
|
||||
fips: 01095
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Mobile
|
||||
slug: mobile
|
||||
fips: 01097
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Monroe
|
||||
slug: monroe
|
||||
fips: 01099
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Montgomery
|
||||
slug: montgomery
|
||||
fips: '01101'
|
||||
region: Central
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Morgan
|
||||
slug: morgan
|
||||
fips: '01103'
|
||||
region: North
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Perry
|
||||
slug: perry
|
||||
fips: '01105'
|
||||
region: West
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Pickens
|
||||
slug: pickens
|
||||
fips: '01107'
|
||||
region: West
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Pike
|
||||
slug: pike
|
||||
fips: 01109
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Randolph
|
||||
slug: randolph
|
||||
fips: '01111'
|
||||
region: East
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Russell
|
||||
slug: russell
|
||||
fips: '01113'
|
||||
region: East
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Saint Clair
|
||||
slug: saint-clair
|
||||
fips: '01115'
|
||||
region: Central
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Shelby
|
||||
slug: shelby
|
||||
fips: '01117'
|
||||
region: Central
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Sumter
|
||||
slug: sumter
|
||||
fips: 01119
|
||||
region: West
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Talladega
|
||||
slug: talladega
|
||||
fips: '01121'
|
||||
region: East
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Tallapoosa
|
||||
slug: tallapoosa
|
||||
fips: '01123'
|
||||
region: East
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Tuscaloosa
|
||||
slug: tuscaloosa
|
||||
fips: '01125'
|
||||
region: West
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Walker
|
||||
slug: walker
|
||||
fips: '01127'
|
||||
region: Central
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Washington
|
||||
slug: washington
|
||||
fips: 01129
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Wilcox
|
||||
slug: wilcox
|
||||
fips: '01131'
|
||||
region: South
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Winston
|
||||
slug: winston
|
||||
fips: '01133'
|
||||
region: North
|
||||
@@ -0,0 +1,8 @@
|
||||
# Statewide officials for the Take Action page.
|
||||
# Roles only for now. Add name / phone / url per entry when the data is sourced.
|
||||
updated: ""
|
||||
officials:
|
||||
- role: Governor
|
||||
- role: Lieutenant Governor
|
||||
- role: U.S. Senator
|
||||
- role: U.S. Senator
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
"""One-off: create data/counties/<slug>.yaml for all 67 Alabama counties.
|
||||
|
||||
Alabama county FIPS codes are the odd numbers 001..133 in alphabetical order,
|
||||
so they can be computed. Run from the repo root: python scripts/make_county_stubs.py
|
||||
Existing files are never overwritten, so it is safe to re-run.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
# Same regions as the Discord bot's data.py
|
||||
REGIONS = {
|
||||
"North": "Lauderdale, Colbert, Franklin, Marion, Lamar, Madison, Limestone, Morgan, "
|
||||
"Lawrence, Cullman, Winston, Jackson, Marshall, DeKalb, Cherokee, Etowah",
|
||||
"West": "Bibb, Choctaw, Fayette, Greene, Hale, Marengo, Pickens, Sumter, Tuscaloosa, Perry",
|
||||
"South": "Mobile, Baldwin, Houston, Dale, Coffee, Geneva, Henry, Covington, Escambia, "
|
||||
"Conecuh, Monroe, Clarke, Washington, Pike, Barbour, Butler, Crenshaw, Wilcox",
|
||||
"Central": "Jefferson, Shelby, Saint Clair, Blount, Walker, Montgomery, Autauga, Elmore, "
|
||||
"Chilton, Dallas, Lowndes",
|
||||
"East": "Lee, Russell, Chambers, Tallapoosa, Randolph, Macon, Calhoun, Cleburne, Clay, "
|
||||
"Talladega, Coosa, Bullock",
|
||||
}
|
||||
|
||||
region_of = {
|
||||
name.strip(): region
|
||||
for region, names in REGIONS.items()
|
||||
for name in names.split(",")
|
||||
}
|
||||
assert len(region_of) == 67, len(region_of)
|
||||
|
||||
out = Path("data/counties")
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
for i, name in enumerate(sorted(region_of)):
|
||||
slug = name.lower().replace(" ", "-")
|
||||
record = {
|
||||
"name": name,
|
||||
"slug": slug,
|
||||
"fips": f"01{2 * i + 1:03d}",
|
||||
"region": region_of[name],
|
||||
}
|
||||
if name == "DeKalb":
|
||||
assert record["fips"] == "01049" # sanity check on the numbering
|
||||
path = out / f"{slug}.yaml"
|
||||
if not path.exists():
|
||||
path.write_text(yaml.safe_dump(record, sort_keys=False), encoding="utf-8")
|
||||
|
||||
print(f"{len(list(out.glob('*.yaml')))} county files in {out}/")
|
||||
@@ -757,3 +757,59 @@ li .stance-anti {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Take Action / counties ---------- */
|
||||
.breadcrumb {
|
||||
margin-bottom: 1rem;
|
||||
font-size: 0.95rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.official-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
gap: 0.65rem;
|
||||
grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
|
||||
}
|
||||
|
||||
.official-list li {
|
||||
margin: 0;
|
||||
padding: 0.75rem 1rem;
|
||||
background: var(--white);
|
||||
border: 1px solid var(--rule);
|
||||
border-radius: 0.35rem;
|
||||
}
|
||||
|
||||
.county-map {
|
||||
max-width: 28rem;
|
||||
margin: 1rem auto 1.5rem;
|
||||
}
|
||||
|
||||
.county-map svg {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.county-map path {
|
||||
fill: var(--white);
|
||||
stroke: var(--blue);
|
||||
stroke-width: 0.75;
|
||||
}
|
||||
|
||||
.county-map a:hover path,
|
||||
.county-map a:focus path {
|
||||
fill: var(--gold);
|
||||
}
|
||||
|
||||
.county-grid {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
columns: 14rem;
|
||||
column-gap: 1.5rem;
|
||||
}
|
||||
|
||||
.county-grid li {
|
||||
margin: 0 0 0.35rem;
|
||||
break-inside: avoid;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<header class="page-intro wide">
|
||||
<h2>Take Action</h2>
|
||||
<p class="lead">Find out who represents you and how to reach them, from the governor’s office to your county courthouse.</p>
|
||||
</header>
|
||||
|
||||
<section class="wide" aria-labelledby="state-heading">
|
||||
<h3 id="state-heading">Statewide</h3>
|
||||
{% if state.officials %}
|
||||
<ul class="official-list">
|
||||
{% for o in state.officials %}
|
||||
<li>
|
||||
<strong>{{ o.role }}</strong>
|
||||
{% if o.name %}<br>{{ o.name }}{% endif %}
|
||||
{% if o.phone %}<br>{{ o.phone }}{% endif %}
|
||||
{% if o.url %}<br><a href="{{ o.url }}">Official website</a>{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% if state.updated %}<p><em>Last checked: {{ state.updated }}</em></p>{% endif %}
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<section class="wide" aria-labelledby="counties-heading">
|
||||
<h3 id="counties-heading">Find your county</h3>
|
||||
{% if map_svg %}
|
||||
<div class="county-map">{{ map_svg|safe }}</div>
|
||||
{% endif %}
|
||||
<ul class="county-grid">
|
||||
{% for c in counties %}
|
||||
<li><a href="{{ c.url }}">{{ c.name }} County</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,29 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<nav class="breadcrumb" aria-label="Breadcrumb">
|
||||
<a href="/act/">Take Action</a> › {{ county.name }} County
|
||||
</nav>
|
||||
|
||||
<h2>{{ county.name }} County</h2>
|
||||
<p class="lead">{{ county.region }} Alabama</p>
|
||||
|
||||
<section aria-labelledby="about-heading">
|
||||
<h3 id="about-heading">About the county</h3>
|
||||
<p>Coming soon.</p>
|
||||
</section>
|
||||
|
||||
<section aria-labelledby="reps-heading">
|
||||
<h3 id="reps-heading">Who represents you</h3>
|
||||
<p>Coming soon.</p>
|
||||
</section>
|
||||
|
||||
<section aria-labelledby="groups-heading">
|
||||
<h3 id="groups-heading">Local chapters and groups</h3>
|
||||
<p>Coming soon.</p>
|
||||
</section>
|
||||
|
||||
<section aria-labelledby="news-heading">
|
||||
<h3 id="news-heading">News and events</h3>
|
||||
<p>Coming soon.</p>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -5,7 +5,7 @@
|
||||
</div>
|
||||
<nav aria-label="Main">
|
||||
{% for label, href in nav %}
|
||||
<a href="{{ href }}" {% if href==url %} aria-current="page" {% endif %}>{{ label }}</a>
|
||||
<a href="{{ href }}" {% if href==url or (href !="/" and url.startswith(href)) %} aria-current="page" {% endif %}>{{ label }}</a>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
</header>
|
||||
Reference in new issue
Block a user