-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
165 lines (138 loc) · 5.76 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#
# Colors
#
# Define ANSI color codes
RESET_COLOR = \033[m
BLUE = \033[1;34m
YELLOW = \033[1;33m
GREEN = \033[1;32m
RED = \033[1;31m
BLACK = \033[1;30m
MAGENTA = \033[1;35m
CYAN = \033[1;36m
WHITE = \033[1;37m
DBLUE = \033[0;34m
DYELLOW = \033[0;33m
DGREEN = \033[0;32m
DRED = \033[0;31m
DBLACK = \033[0;30m
DMAGENTA = \033[0;35m
DCYAN = \033[0;36m
DWHITE = \033[0;37m
BG_WHITE = \033[47m
BG_RED = \033[41m
BG_GREEN = \033[42m
BG_YELLOW = \033[43m
BG_BLUE = \033[44m
BG_MAGENTA = \033[45m
BG_CYAN = \033[46m
# Name some of the colors
COM_COLOR = $(DBLUE)
OBJ_COLOR = $(DCYAN)
OK_COLOR = $(DGREEN)
ERROR_COLOR = $(DRED)
WARN_COLOR = $(DYELLOW)
NO_COLOR = $(RESET_COLOR)
OK_STRING = "[OK]"
ERROR_STRING = "[ERROR]"
WARN_STRING = "[WARNING]"
define banner
@echo " $(WHITE)__________$(RESET_COLOR)"
@echo "$(WHITE) |$(DWHITE) PALEWIRE $(RESET_COLOR)$(WHITE)|$(RESET_COLOR)"
@echo "$(WHITE) |&&& ======|$(RESET_COLOR)"
@echo "$(WHITE) |=== ======|$(RESET_COLOR) $(DWHITE)This is a $(RESET_COLOR)$(DBLACK)$(BG_WHITE)palewire$(RESET_COLOR)$(DWHITE) automation$(RESET_COLOR)"
@echo "$(WHITE) |=== == %%%|$(RESET_COLOR)"
@echo "$(WHITE) |[_] ======|$(RESET_COLOR) $(1)"
@echo "$(WHITE) |=== ===!##|$(RESET_COLOR)"
@echo "$(WHITE) |__________|$(RESET_COLOR)"
@echo ""
endef
#
# Python helpers
#
PIPENV := pipenv run
PYTHON := python -W ignore -m
#
# Commands
#
all: cedar-rapids-buildings-unsafe-after-derecho-2020.db \
chicago-regions.db \
la-county-election-precinct-maps-2016-primary.db \
la-county-election-precinct-maps-2018-primary.db \
la-county-election-precinct-maps-2018-general.db \
la-county-election-precinct-maps-2020-general.db \
la-county-tsunami-hazard-zones.db \
lausd-school-campus-maps.db
cedar-rapids-buildings-unsafe-after-derecho-2020.db:
@curl -L https://raw.githubusercontent.com/palewire/cedar-rapids-buildings-unsafe-after-derecho-2020/master/output/placards.csv | $(PIPENV) sqlite-utils insert cedar-rapids-buildings-unsafe-after-derecho-2020.db placards - --csv
chicago-regions.db:
curl -L https://raw.githubusercontent.com/palewire/chicago-regions-map/main/output/regions.geojson | $(PIPENV) geojson-to-sqlite chicago-regions.db regions - --spatial-index
la-county-election-precinct-maps-2016-primary.db:
curl -L https://raw.githubusercontent.com/datadesk/la-county-2016-primary-precinct-maps/master/Consolidations.geojson | $(PIPENV) geojson-to-sqlite la-county-election-precinct-maps-2016-primary.db precincts - --spatial-index
la-county-election-precinct-maps-2018-primary.db:
curl -L https://raw.githubusercontent.com/datadesk/la-county-election-precincts-2018/master/geojson/primary.geojson | $(PIPENV) geojson-to-sqlite la-county-election-precinct-maps-2018-primary.db precincts - --spatial-index
la-county-election-precinct-maps-2018-general.db:
curl -L https://raw.githubusercontent.com/datadesk/la-county-election-precincts-2018/master/geojson/general.geojson | $(PIPENV) geojson-to-sqlite la-county-election-precinct-maps-2018-general.db precincts - --spatial-index
la-county-election-precinct-maps-2020-general.db:
curl -L https://github.com/datadesk/la-county-election-precincts-2020/raw/main/json/la-precincts.json | $(PIPENV) geojson-to-sqlite la-county-election-precinct-maps-2020-general.db precincts - --spatial-index
la-county-tsunami-hazard-zones.db:
curl -L https://github.com/datadesk/los-angeles-county-tsunami-hazard-areas/raw/main/areas.json | $(PIPENV) geojson-to-sqlite la-county-tsunami-hazard-zones.db zones - --spatial-index
lausd-school-campus-maps.db:
curl -L https://github.com/datadesk/lausd-school-campus-polygons/raw/master/lausd-school-campus-polygons.geojson | $(PIPENV) geojson-to-sqlite lausd-school-campus-maps.db campuses - --spatial-index
clean:
@rm -f ./*.db
@rm -f ./*.geojson
@rm -f ./*.csv
install_plugins: ## Install datasette plugins
@$(PIPENV) datasette install \
datasette-cluster-map \
datasette-vega \
datasette-search-all \
datasette-configure-fts \
datasette-geojson \
datasette-geojson-map
serve: ## Serve a local test site
@$(PIPENV) datasette \
./cedar-rapids-buildings-unsafe-after-derecho-2020.db \
./chicago-regions.db \
./la-county-election-precinct-maps-2016-primary.db \
./la-county-election-precinct-maps-2018-primary.db \
./la-county-election-precinct-maps-2018-general.db \
./la-county-election-precinct-maps-2020-general.db \
./la-county-tsunami-hazard-zones.db \
./lausd-school-campus-maps.db \
-m metadata.yml \
--load-extension spatialite \
--template-dir=./templates/ \
--static assets:./static-files/ \
--setting allow_download on
deploy: ## Deploy to fly.io
$(call banner, 🚢 Deploying the site 🚢)
@$(PIPENV) datasette publish fly \
./cedar-rapids-buildings-unsafe-after-derecho-2020.db \
./chicago-regions.db \
./la-county-election-precinct-maps-2016-primary.db \
./la-county-election-precinct-maps-2018-primary.db \
./la-county-election-precinct-maps-2018-general.db \
./la-county-election-precinct-maps-2020-general.db \
./la-county-tsunami-hazard-zones.db \
./lausd-school-campus-maps.db \
-m metadata.yml \
--app="datasette-palewi-re" \
--install datasette-cluster-map \
--install datasette-vega \
--install datasette-search-all \
--install datasette-configure-fts \
--install datasette-geojson \
--install datasette-geojson-map \
--spatialite \
--template-dir=./templates/ \
--static assets:./static-files/ \
--setting base_url https://palewi.re/data/
#
# Extras
#
help: ## Show this help. Example: make help
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# Mark all the commands that don't have a target
.PHONY: help deploy install_plugins serve