Skip to content

Commit b0a3c7b

Browse files
authored
Ian/add citation to page (#29)
* add citation file * move CITATION.cff location, add citation rendering script
1 parent 42e0f15 commit b0a3c7b

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

layouts/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ <h2>Result</h2>
131131
</div>
132132

133133

134+
134135
<hr>
135136
<h2>Methodology</h2>
136137
<p>Users interested in reading more about the methodology of this tool can <a href="https://github.com/acep-uaf/energy-cost-burden-site/wiki/Methodology">visit our documentation</a></p>
138+
<h2>Citation</h2>
139+
<div id="citation"></div>
137140
<hr>
138141
<h2>Contact</h2>
139142
<p>If you have questions regarding this tool, please reach out via email to <a href="mailto:ACEP.info@alaska.edu">ACEP.info@alaska.edu</a>.</p>
@@ -146,10 +149,10 @@ <h2>Funding</h2>
146149
</div>
147150
<div id="map"></div>
148151

149-
<!-- <script src="https://unpkg.com/leaflet/dist/leaflet.js"></script> -->
150152
<script src="https://cdn.jsdelivr.net/npm/leaflet@1.9/dist/leaflet.min.js"></script>
151153
<script src="https://cdn.jsdelivr.net/npm/papaparse@5.5/papaparse.min.js"></script>
152154
<script src="https://cdn.jsdelivr.net/npm/jszip@3.10/dist/jszip.min.js"></script>
155+
<script src="https://cdn.jsdelivr.net/npm/js-yaml@4.1/dist/js-yaml.min.js"></script>
153156
<script src="{{ "js/script.js" | absURL }}"></script>
154157
</body>
155158
</html>

static/data/CITATION.cff

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
cff-version: 1.2.0
2+
title: FNSB Energy Burden Estimator
3+
message: >-
4+
If you use this software, please cite it using the
5+
metadata from this file.
6+
type: software
7+
authors:
8+
- given-names: J.
9+
family-names: Kaczmarski
10+
affiliation: University of Alaska Fairbanks
11+
orcid: 'https://orcid.org/0000-0003-4612-1150'
12+
- given-names: I.
13+
family-names: MacDougall
14+
affiliation: Alaska Center for Energy and Power
15+
repository-code: 'https://github.com/acep-uaf/energy-cost-burden-site'
16+
url: 'https://fnsb-energy-burden.acep.uaf.edu'
17+
abstract: >-
18+
A tool for estimating the average annual household energy
19+
costs as a share of total household income in the
20+
Fairbanks North Star Borough (FNSB) census boundary based
21+
on energy prices and census data. This tool is an
22+
extension of the 2024 Borough commissioned report: Energy
23+
Burden Analysis of the Fairbanks North Star Borough
24+
https://doi.org/10.5281/zenodo.12575185.
25+
keywords:
26+
- Energy Burden
27+
- Economics
28+
- Geospatial
29+
- Alaska
30+
license: MIT
31+
version: V1.0.0
32+
date-released: '2025-10-16'

static/js/script.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,5 +578,35 @@ document.addEventListener("DOMContentLoaded", async () => {
578578
d > 2 ? '#FED976' :
579579
'#FFEDA0';
580580
}
581+
582+
583+
const citationDiv = document.getElementById('citation');
584+
const citationUrl = "data/CITATION.cff";
585+
586+
try {
587+
const response = await fetch(citationUrl);
588+
if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`);
589+
const cffText = await response.text();
590+
const data = jsyaml.load(cffText);
591+
592+
const authors = data.authors
593+
.map(a => `${a['family-names']}, ${a['given-names'].charAt(0)}.`)
594+
.join(' & ');
595+
const title = data.title || 'Untitled';
596+
const version = data.version ? ` (v${data.version})` : '';
597+
const year = data['date-released']
598+
? new Date(data['date-released']).getFullYear()
599+
: 'n.d.';
600+
const publisher = data.publisher || 'Alaska Center for Energy and Power';
601+
const url = data.url || '#';
602+
603+
citationDiv.innerHTML = `${authors} (${year}). <i>${title}</i>${version}. ${publisher}. <a href="${url}">${url}</a>`;
604+
} catch (error) {
605+
console.error('Citation load error:', error);
606+
citationDiv.textContent = 'Citation unavailable.';
607+
}
608+
609+
610+
581611
});
582-
612+

0 commit comments

Comments
 (0)