Skip to content

Commit 2eae184

Browse files
refactor: move CSS to a file (#256)
1 parent c0aab29 commit 2eae184

File tree

4 files changed

+63
-50
lines changed

4 files changed

+63
-50
lines changed

.github/workflows/validation.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ jobs:
217217
name: btracker
218218
path: target/debug/btracker
219219
- name: Run binary
220-
run: cargo run
220+
run: cargo run --verbose
221221
- name: Hash output
222222
run: sha256sum output/*
223223
- name: Upload output artifact

resources/web/style.css

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
tr.histogram-footer {
2+
background-color: whitesmoke;
3+
border: 2px solid black;
4+
font-weight: bold;
5+
}
6+
7+
th.wma-column {
8+
background-color: whitesmoke;
9+
border: 3px solid blue;
10+
padding: 7px;
11+
}
12+
13+
td.wma-column {
14+
background-color: whitesmoke;
15+
border-left: 3px solid blue;
16+
border-right: 3px solid blue;
17+
font-weight: bold;
18+
}
19+
20+
img {
21+
border: 2px solid black;
22+
}
23+
24+
table {
25+
border-color: black;
26+
border-style: solid;
27+
border-width: 1px;
28+
}
29+
30+
th {
31+
border: 1px solid black;
32+
padding: 5px;
33+
vertical-align: bottom;
34+
position: sticky;
35+
top: 0;
36+
background-color: whitesmoke;
37+
}
38+
39+
td {
40+
border: 1px solid black;
41+
padding: 5px;
42+
text-align: right;
43+
}
44+
45+
.inline-table {
46+
display: inline-block;
47+
margin-right: 20px;
48+
vertical-align: top;
49+
}
50+
51+
.scrollable-table {
52+
height: 500px;
53+
overflow: auto;
54+
}

src/main.rs

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ const MOVING_AVERAGE_DAYS: usize = 1400;
1313
// Input and output constants
1414
const REPOSITORY_URL: &str = "https://github.com/bitcoin-tools/btracker";
1515
const INPUT_DATA_PATH_STR: &str = "./resources/data/historical_data.tsv";
16-
const INPUT_FAVICON_PATH_STR: &str = "resources/media/favicon.png";
16+
const INPUT_CSS_PATH_STR: &str = "resources/web/style.css";
17+
const INPUT_FAVICON_PATH_STR: &str = "resources/web/favicon.png";
1718
const OUTPUT_DIRECTORY: &str = "output/";
1819
const OUTPUT_PRICE_ANALYTICS_CSV_FILENAME: &str = "processed_data.csv";
1920
const OUTPUT_HISTOGRAM_CSV_FILENAME: &str = "histogram.csv";
2021
const OUTPUT_YEARLY_SUMMARY_CSV_FILENAME: &str = "yearly_summary.csv";
22+
const OUTPUT_CSS_FILENAME: &str = "style.css";
2123
const OUTPUT_FAVICON_FILENAME: &str = "favicon.png";
2224
const OUTPUT_HTML_FILENAME: &str = "index.html";
2325
const OUTPUT_LINEAR_IMAGE_FILENAME: &str = "200_week_moving_average_linear.png";
@@ -911,6 +913,10 @@ fn main() -> Result<(), Box<dyn Error>> {
911913

912914
std::fs::create_dir_all(OUTPUT_DIRECTORY)?;
913915

916+
let input_css_path = Path::new(INPUT_CSS_PATH_STR);
917+
let output_css_path = Path::new(OUTPUT_DIRECTORY).join(OUTPUT_CSS_FILENAME);
918+
std::fs::copy(input_css_path, output_css_path)?;
919+
914920
let input_favicon_path = Path::new(INPUT_FAVICON_PATH_STR);
915921
let output_favicon_path = Path::new(OUTPUT_DIRECTORY).join(OUTPUT_FAVICON_FILENAME);
916922
std::fs::copy(input_favicon_path, output_favicon_path)?;
@@ -995,54 +1001,7 @@ fn main() -> Result<(), Box<dyn Error>> {
9951001
<head>
9961002
<title>{CHART_TITLE}</title>
9971003
<link rel='icon' type='image/png' href='{OUTPUT_FAVICON_FILENAME}'>
998-
<style>
999-
tr.histogram-footer {{
1000-
background-color: whitesmoke;
1001-
border: 2px solid black;
1002-
font-weight: bold;
1003-
}}
1004-
th.wma-column {{
1005-
background-color: whitesmoke;
1006-
border: 3px solid blue;
1007-
padding: 7px;
1008-
}}
1009-
td.wma-column {{
1010-
background-color: whitesmoke;
1011-
border-left: 3px solid blue;
1012-
border-right: 3px solid blue;
1013-
font-weight: bold;
1014-
}}
1015-
img {{
1016-
border: 2px solid black;
1017-
}}
1018-
table {{
1019-
border-color: black;
1020-
border-style: solid;
1021-
border-width: 1px;
1022-
}}
1023-
th {{
1024-
border: 1px solid black;
1025-
padding: 5px;
1026-
vertical-align: bottom;
1027-
position: sticky;
1028-
top: 0;
1029-
background-color: whitesmoke;
1030-
}}
1031-
td {{
1032-
border: 1px solid black;
1033-
padding: 5px;
1034-
text-align: right;
1035-
}}
1036-
.inline-table {{
1037-
display: inline-block;
1038-
margin-right: 20px;
1039-
vertical-align: top;
1040-
}}
1041-
.scrollable-table {{
1042-
height: 500px;
1043-
overflow: auto;
1044-
}}
1045-
</style>
1004+
<link rel='stylesheet' href='style.css'>
10461005
</head>
10471006
<body>
10481007
<h1>{CHART_TITLE}</h1>

0 commit comments

Comments
 (0)