generated from nhcarrigan/template
This commit is contained in:
Executable
+114
@@ -0,0 +1,114 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
TESTIMONIALS_JSON_URL="https://data.nhcarrigan.com/testimonials.json"
|
||||
TESTIMONIALS_JSON_FILE="testimonials.json"
|
||||
TESTIMONIALS_HTML_FILE="testimonials/index.html"
|
||||
|
||||
# Templating
|
||||
HTML_START='<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Testimonials</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta
|
||||
name="description"
|
||||
content="See what our past clients have to say about our work!"
|
||||
/>
|
||||
<script
|
||||
src="https://cdn.nhcarrigan.com/headers/index.js"
|
||||
async
|
||||
defer
|
||||
></script>
|
||||
<style>
|
||||
hr {
|
||||
border: 1px solid var(--background);
|
||||
}
|
||||
.title {
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
.date {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
@media screen {
|
||||
.card {
|
||||
background: var(--foreground);
|
||||
color: var(--background);
|
||||
width: 80%;
|
||||
margin: auto;
|
||||
border-radius: 10px;
|
||||
box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.7);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
@media print {
|
||||
:root {
|
||||
font-size: 12px;
|
||||
}
|
||||
* {
|
||||
color: black;
|
||||
font-family: "Times New Roman", serif;
|
||||
}
|
||||
video,
|
||||
footer,
|
||||
hr {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Testimonials</h1>
|
||||
<p>See what our past clients have to say about our work!</p>
|
||||
<p>Want to submit your own? <a href="https://forms.nhcarrigan.com/form/M_GrmqASymmO744axMOmu2LaMAaT5F0LmdVcU2c8-gQ">Use our web form</a>.</p>
|
||||
<section>
|
||||
'
|
||||
HTML_END=' </section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
'
|
||||
|
||||
# Fetch the latest testimonials.json
|
||||
curl -sSL "$TESTIMONIALS_JSON_URL" -o "$TESTIMONIALS_JSON_FILE"
|
||||
|
||||
# Convert JSON to HTML, sorted by date descending (newest first)
|
||||
TESTIMONIALS_HTML=$(jq -r '
|
||||
def parse_date:
|
||||
split(" ") |
|
||||
.[2] + "-" +
|
||||
(.[1] |
|
||||
if . == "January" then "01"
|
||||
elif . == "February" then "02"
|
||||
elif . == "March" then "03"
|
||||
elif . == "April" then "04"
|
||||
elif . == "May" then "05"
|
||||
elif . == "June" then "06"
|
||||
elif . == "July" then "07"
|
||||
elif . == "August" then "08"
|
||||
elif . == "September" then "09"
|
||||
elif . == "October" then "10"
|
||||
elif . == "November" then "11"
|
||||
elif . == "December" then "12"
|
||||
else . end
|
||||
) + "-" +
|
||||
(.[0] | if length == 1 then "0" + . else . end);
|
||||
|
||||
sort_by(.date | parse_date) | reverse |
|
||||
.[] |
|
||||
"<div class=\"card\">\n <p class=\"title\">" + .name + "</p>\n <p>" + .content + "</p>\n <p class=\"date\">" + .date + "</p>\n</div>"
|
||||
' "$TESTIMONIALS_JSON_FILE")
|
||||
|
||||
# Create temporary file with the HTML content
|
||||
echo "$HTML_START" > "$TESTIMONIALS_HTML_FILE"
|
||||
echo "$TESTIMONIALS_HTML" >> "$TESTIMONIALS_HTML_FILE"
|
||||
echo "$HTML_END" >> "$TESTIMONIALS_HTML_FILE"
|
||||
|
||||
echo "Testimonials updated in $TESTIMONIALS_HTML_FILE"
|
||||
|
||||
# Clean up
|
||||
rm "$TESTIMONIALS_JSON_FILE"
|
||||
Reference in New Issue
Block a user