#!/bin/bash
_mobilesite() {
go run cli.go --html
}
_mobilesite1() {
go run cli.go | ansifilter --html #| tail -n +20 | head -n -3 | sed 's/>=/><span style=/g' | sed 's/<pre>/<pre style="font-size:1px;">/g'
}
_asciititle() {
cat asciititle.txt | ansifilter --html | tail -n +20 | head -n -3 | sed 's/>=/><span style=/g'
# cat asciititle.txt | ansifilter --html | tail -n +20 | head -n -3 | sed 's/>=/><span style=/g' | sed 's/<pre>/<pre style="font-size:1px;">/g'
}
_asciiartmobilehtml() {
[[ "$1" != "" ]] && img2txt -W $1 logo.png | ansifilter --html | tail -n +20 | head -n -3 | sed 's/>=/><span style=/g' | sed 's/<pre>/<pre style="font-size:1px;">/g' || img2txt -W 700 logo.png | ansifilter --html | tail -n +20 | head -n -3 | sed 's/>=/><span style=/g' | sed 's/<pre>/<pre style="font-size:1px;">/g'
}
_asciiartmobile() {
[[ "$1" != "" ]] && img2txt -W $1 logo.png || img2txt -W 700 logo.png
echo -e "\033[0m\033[49m"
}
_asciiart() {
img2txt -W 1599 logo.png | ansifilter --html | tail -n +20 | head -n -3 | sed 's/>=/><span style=/g' | sed 's/<pre>/<pre style="font-size:1px;">/g' | tee logo.html
}
_aboutascii() {
img2txt -W 1184 img/BASH.png | ansifilter --html | tail -n +20 | head -n -3 | sed 's/>=/><span style=/g' | sed 's/<pre>/<pre style="font-size:1px;">/g' | tee aboutascii.html
echo | tee -a aboutascii.html
img2txt -W 1061 img/Go-Logo.png | ansifilter --html | tail -n +20 | head -n -3 | sed 's/>=/><span style=/g' | sed 's/<pre>/<pre style="font-size:1px;">/g' | tee -a aboutascii.html
}
_subcat() {
[[ "$1" == "" ]] && return
[[ "$2" == "" ]] && return
CATEGORY=$1 SUBCATEGORY=$2 awk -F',' '$4 == "TRUE" && $14 == ENVIRON["CATEGORY"] {print}' products.csv | while IFS="," read _image1 _partno _name _enable _price _quantity _shippable _minorder _maxorder _defaultquantity _stepquantity _mfgpartno _mfgname _category _subcategory _location _msrp _cost _type _packagetype _technology _materials _value _valunit _resistance _resunit _tolerance _voltsrating _ampsrating _wattsrating _temprating _tempunit _description1 _description2 _color1 _color2 _sourceinfo _datasheet _docs _reference _attributes _year _condition _note _warning _cablelengthinches _lengthinches _widthinches _heightinches _weightlb _weightoz ; do
_subcategory=${_subcategory//"¼"/"quarter-"}
_subcategory=${_subcategory//"½"/"half-"}
_subcategory=${_subcategory//"1/16"/"sixteenth-"}
_subcategory=${_subcategory//"%"/"-pct"}
_subcategory=${_subcategory//" "/" "}
_subcategory=${_subcategory//" "/"-"}
_subcategory=${_subcategory//" "/"-"}
_subcategory=${_subcategory//"--"/"-"}
_subcategory=${_subcategory//"watt1"/"watt-1"}
_subcategory=${_subcategory//"watt5"/"watt-5"}
[[ "${_subcategory}" != "$2" ]] && continue
[[ "${_category}" != "" ]] && _category="${_category}/"
echo "<pre><a href='/p/${_partno}'><img style='max-width: 300px; max-height: 200px;' src='/img/${_category}${_image1}' alt='${_name}'></a></pre>
<br>
$(echo ${_name} | ansifilter -w 100 --html |tail -n +20 | head -n -3)
<pre><a title='Read more about ${_partno}' href='/p/${_partno}'>Read More</a></pre>
<pre>Price: \$${_price}</pre>
<pre>In stock: ${_quantity}</pre>"
[[ "${_quantity}" != "0" ]] && echo "<pre><button class='snipcart-add-item' data-item-id='${_partno}' data-item-name='${_partno}' data-item-image='/img/${_category}${_image1}' data-item-price='${_price}' data-item-description='${_name}' data-item-min-quantity='1' data-item-quantity='1' data-item-quantity-step='1' data-item-shippable='true' data-itemweight='$(echo "scale=2; ${_weightoz} * 28.3495" | awk '{print int($1+0.5)}')' data-item-length='$(echo "scale=2; ${_length} * 2.54" | awk '{print int($1+0.5)}')' data-item-width='$(echo "scale=2; ${_width} * 2.54" | awk '{print int($1+0.5)}')' data-item-height='$(echo "scale=2; ${_height} * 2.54" | awk '{print int($1+0.5)}')' data-item-has-taxes-included='false'>Add to cart</button></pre>"
echo "<pre>partno: ${_partno}</pre>
<hr>"
done
}
_cat() {
[[ $1 != "" ]] && CATEGORY=$1 awk -F ',' '$4 == "TRUE" && $14 ~ ENVIRON["CATEGORY"] {print}' products.csv | while IFS="," read _image1 _partno _name _enable _price _quantity _shippable _minorder _maxorder _defaultquantity _stepquantity _mfgpartno _mfgname _category _subcategory _location _msrp _cost _type _packagetype _technology _materials _value _valunit _resistance _resunit _tolerance _voltsrating _ampsrating _wattsrating _temprating _tempunit _description1 _description2 _color1 _color2 _sourceinfo _datasheet _docs _reference _attributes _year _condition _note _warning _cablelengthinches _lengthinches _widthinches _heightinches _weightlb _weightoz ; do
[[ "${_category}" != "" ]] && _category="${_category}/"
echo "<pre><a title='Read more about ${_partno}' href='/p/${_partno}'><img style='max-width: 300px; max-height: 200px;' src='/img/${_category}${_image1}' alt='${_name}'></a></pre>
<br>
$(echo ${_name} | ansifilter -w 100 --html |tail -n +20 | head -n -3)
<pre><a title='Read more about ${_partno}' href='/p/${_partno}'>Read More</a></pre>
<pre>Price: \$${_price}</pre>
<pre>In stock: ${_quantity}</pre>"
[[ "${_quantity}" != "0" ]] && echo "<pre><button class='snipcart-add-item' data-item-id='${_partno}' data-item-name='${_partno}' data-item-image='/img/${_category}${_image1}' data-item-price='${_price}' data-item-description='${_name}' data-item-min-quantity='1' data-item-quantity='1' data-item-quantity-step='1' data-item-shippable='true' data-itemweight='$(echo "scale=2; ${_weightoz} * 28.3495" | awk '{print int($1+0.5)}')' data-item-length='$(echo "scale=2; ${_length} * 2.54" | awk '{print int($1+0.5)}')' data-item-width='$(echo "scale=2; ${_width} * 2.54" | awk '{print int($1+0.5)}')' data-item-height='$(echo "scale=2; ${_height} * 2.54" | awk '{print int($1+0.5)}')' data-item-has-taxes-included='false'>Add to cart</button></pre>"
echo "<pre>partno: ${_partno}</pre>
<hr>"
done
}
_prod() {
[[ $1 != "" ]] && PRODUCT=$1 awk -F ',' '$4 == "TRUE" && $2 ~ ENVIRON["PRODUCT"] {print}' products.csv | head -n1 | while IFS="," read _image1 _partno _name _enable _price _quantity _shippable _minorder _maxorder _defaultquantity _stepquantity _mfgpartno _mfgname _category _subcategory _location _msrp _cost _type _packagetype _technology _materials _value _valunit _resistance _resunit _tolerance _voltsrating _ampsrating _wattsrating _temprating _tempunit _description1 _description2 _color1 _color2 _sourceinfo _datasheet _docs _reference _attributes _year _condition _note _warning _cablelengthinches _lengthinches _widthinches _heightinches _weightlb _weightoz ; do
[[ "${_category}" != "" ]] && _category="${_category}/"
echo "<h1 style='font-family:Courier New; font-size:10pt'>${_name}</h1>\n"
echo "<img style='max-width: 800px; max-height: 600px;' src='/img/${_category}${_image1}' alt='${_name}'>
<br>
$(echo ${_name} | ansifilter -w 100 --html |tail -n +20 | head -n -3)
$([[ "${_description1}" != *"${_name}"* ]] && echo ${_description1} | ansifilter -w 100 --html |tail -n +20 | head -n -3)
<pre>Price: \$${_price}</pre>
<pre>In stock: ${_quantity}</pre>"
[[ "${_quantity}" != "0" ]] && echo "<pre><button class='snipcart-add-item' data-item-id='${_partno}' data-item-name='${_partno}' data-item-image='/img/${_category}${_image1}' data-item-price='${_price}' data-item-description='${_name}' data-item-min-quantity='1' data-item-quantity='1' data-item-quantity-step='1' data-item-shippable='true' data-itemweight='$(echo "scale=2; ${_weightoz} * 28.3495" | awk '{print int($1+0.5)}')' data-item-length='$(echo "scale=2; ${_length} * 2.54" | awk '{print int($1+0.5)}')' data-item-width='$(echo "scale=2; ${_width} * 2.54" | awk '{print int($1+0.5)}')' data-item-height='$(echo "scale=2; ${_height} * 2.54" | awk '{print int($1+0.5)}')' data-item-has-taxes-included='false'>Add to cart</button></pre>" || true
echo "<pre>partno: ${_partno}</pre>" || true
[[ "${_mfgname}" != "" ]] && echo "<pre>Brand: ${_mfgname}</pre>" || true
[[ "${_mfgpartno}" != "" ]] && echo "<pre>MPN: ${_mfgpartno}</pre>" || true
[[ "${_category}" != "" ]] && echo "<pre>Category: <a title='Product Category: ${_category/'/'}' href='/cat/${_category/'/'}'>${_category/'/'}</a></pre>" || true
_subcategorylink=${_subcategory//"¼"/"quarter-"}
_subcategorylink=${_subcategorylink//"½"/"half-"}
_subcategorylink=${_subcategorylink//"1/16"/"sixteenth-"}
_subcategorylink=${_subcategorylink//"%"/"-pct"}
_subcategorylink=${_subcategorylink//" "/" "}
_subcategorylink=${_subcategorylink//" "/"-"}
_subcategorylink=${_subcategorylink//" "/"-"}
_subcategorylink=${_subcategorylink//"--"/"-"}
_subcategorylink=${_subcategorylink//"watt1"/"watt-1"}
_subcategorylink=${_subcategorylink//"watt5"/"watt-5"}
[[ "${_subcategory}" != "" ]] && echo "<pre>Subcategory: <a title='Product SubCategory: ${_subcategory}' href='/cat/${_category}${_subcategorylink}'>${_subcategory}</a></pre>" || true
[[ "${_voltsrating}" != '0' ]] && [[ "${_voltsrating}" != '0.0' ]] && [[ "${_voltsrating}" != '' ]] && echo -n "<pre>Voltage: " && echo "${_voltsrating}</pre>" || true
[[ "${_val}" != '0' ]] && [[ "${_val}" != '0.0' ]] && [[ "${_val}" != '' ]] && echo -n "<pre>Value: " && echo #"${_val}${_valunit}</pre>" || true
[[ "${_ampsrating}" != '0' ]] && [[ "${_ampsrating}" != '0.0' ]] && [[ "${_ampsrating}" != '' ]] && echo "<pre>Amperage: ${_ampsrating}</pre>" || true
[[ "${_tolerance}" != '0' ]] && [[ "${_tolerance}" != '0' ]] && [[ "${_tolerance}" != '' ]] && echo "<pre>Tolerance: $(echo "scale=2; ${_tolerance} * 100.0" | bc)%</pre>" || true
[[ "${_type}" != "" ]] && echo "<pre>Type: ${_type}</pre>" || true
[[ "${_packagetype}" != "" ]] && echo "<pre>Package Type: ${_packagetype}</pre>" || true
[[ "${_technology}" != "" ]] && echo "<pre>Technology: ${_technology}</pre>" || true
[[ "${_materials}" != "" ]] && echo "<pre>Materials: ${_materials}</pre>" || true
[[ "${_wattsrating}" != '0' ]] && [[ "${_wattsrating}" != '0.0' ]] && [[ "${_wattsrating}" != '' ]] && echo "<pre>watts rating: ${_wattsrating}</pre>" || true
[[ "${_year}" != "0" ]] && [[ "${_year}" != "" ]] && echo "<pre>Year: ${_year}</pre>" || true
[[ "${_cablelength}" != '0' ]] && [[ "${_cablelength}" != '0.0' ]] && [[ "${_cablelength}" != '' ]] && echo "<pre>Cable Length: ${_cableLength}inches</pre>" || true
[[ "${_weightoz}" != '0' ]] && echo "<pre>Weight: ${_weightoz}oz</pre>" || true
[[ "${_temprating}" != '0' ]] && echo "<pre>Temp rating: ${_temprating}</pre>" || true
[[ "${_condition}" != "" ]] && echo "<pre>Condition: ${_condition}</pre>" || true
[[ "${_datasheet}" != "" ]] && echo "<pre>Datasheet: <a title='Product Datasheet: ${_datasheet}' href='/img/pdf/${_datasheet}'>${_datasheet}</a></pre>" || true
[[ "${_docs}" != "" ]] && echo "<pre>Documentation: ${_docs}</pre>" || true
[[ "${_note}" != "" ]] && echo "<pre>Note: ${_note}</pre>" || true
[[ "${_warning}" != "" ]] && echo "<pre>Warning: ${_warning}</pre>" || true
[[ "${_description2}" != "" ]] && echo "<pre>Additional Description: ${_description2}</pre>" || true
done
}
_prodpkg() {
[[ $1 != "" ]] && PRODUCT=$1 awk -F ',' '$4 == "TRUE" && $2 ~ ENVIRON["PRODUCT"] {print}' products.csv | head -n1 | while IFS="," read _image1 _partno _name _enable _price _quantity _shippable _minorder _maxorder _defaultquantity _stepquantity _mfgpartno _mfgname _category _subcategory _location _msrp _cost _type _packagetype _technology _materials _value _valunit _resistance _resunit _tolerance _voltsrating _ampsrating _wattsrating _temprating _tempunit _description1 _description2 _color1 _color2 _sourceinfo _datasheet _docs _reference _attributes _year _condition _note _warning _cablelengthinches _lengthinches _widthinches _heightinches _weightlb _weightoz ; do
#[[ "${_packagetype}" != "" ]] && echo "${_packagetype}"
[[ "${_packagetype}" != "" ]] && printf "${_packagetype}"
done
}
_prodhead() {
[[ $1 != "" ]] && PRODUCT=$1 awk -F ',' '$4 == "TRUE" && $2 ~ ENVIRON["PRODUCT"] {print}' products.csv | head -n1 | while IFS="," read _image1 _partno _name _enable _price _quantity _shippable _minorder _maxorder _defaultquantity _stepquantity _mfgpartno _mfgname _category _subcategory _location _msrp _cost _type _packagetype _technology _materials _value _valunit _resistance _resunit _tolerance _voltsrating _ampsrating _wattsrating _temprating _tempunit _description1 _description2 _color1 _color2 _sourceinfo _datasheet _docs _reference _attributes _year _condition _note _warning _cablelengthinches _lengthinches _widthinches _heightinches _weightlb _weightoz ; do
echo "<meta charset='UTF-8'>"
echo "<title>magnetosphere electronic surplus | $_name</title>"
echo -n "<meta name='description' content='$_name "
[[ "${_subcategory}" != "" ]] && echo -n "${_subcategory} " || true
[[ "${_category}" != "" ]] && echo -n "${_category}, " || true
[[ "${_voltsrating}" != '0' ]] && [[ "${_voltsrating}" != '0.0' ]] && [[ "${_voltsrating}" != '' ]] && echo -n "${_voltsrating}V " || true
[[ "${_ampsrating}" != '0' ]] && [[ "${_ampsrating}" != '0.0' ]] && [[ "${_ampsrating}" != '' ]] && echo -n "${_ampsrating}A " || true
[[ "${_val}" != '0' ]] && [[ "${_val}" != '0.0' ]] && [[ "${_val}" != '' ]] && echo -n "${_val}${_valunit} " || true
[[ "${_tolerance}" != '0' ]] && [[ "${_tolerance}" != '0' ]] && [[ "${_tolerance}" != '' ]] && echo -n "$(echo "scale=2; ${_tolerance} * 100.0" | bc)% " || true
[[ "${_packagetype}" != "" ]] && echo -n "${_packagetype} " || true
[[ "${_mfgname}" != "" ]] && echo -n "${_technology} " || true
[[ "${_materials}" != "" ]] && echo -n "${_materials} " || true
[[ "${_wattsrating}" != '0' ]] && [[ "${_wattsrating}" != '0.0' ]] && [[ "${_wattsrating}" != '' ]] && echo -n "${_wattsrating}W " || true
[[ "${_cablelength}" != '0' ]] && [[ "${_cablelength}" != '0.0' ]] && [[ "${_cablelength}" != '' ]] && echo -n " ${_cableLength}in" || true
[[ "${_mpn}" != "" ]] && echo -n "${_mpn} " || true
echo "; price: \$${_price}; ${_quantity} In Stock; ${_condition} At Magnetosphere.'>" || true
echo "<script type='application/ld+json'>
{
\"@context\" : \"http://schema.org\"
\"@type\" : \"Product\"
\"name\" : \"${_name}\"
\"image\" : \"https://magnetosphere.net/img/${_category}/${_image1}\"
\"description\" : \"${_description1}\"
\"productID\" : \"${_partno}\""
#\"sku\" : \"${_partno}\"
[[ "${_mpn}" != "" ]] && echo "\"mpn\": \"${_mpn}\""
echo "\"brand\": {
\"@type\": \"Brand\""
[[ ${_mfgname} != "" ]] && echo "\"name\": \"${_mfgname}\"" || echo "\"name\": \"Magnetosphere\"\n"
echo "},
\"offers\" : {
\"@type\" : \"Offer\"
\"priceCurrency\": \"USD\"
\"url\" : \"https://{{$site}}/post/{{$partnumber}}\"
\"price\" : \"{{.Price}}\""
[[ ${_condition} == "used" ]] && echo "\"itemCondition\": \"https://schema.org/UsedCondition\"" || echo "\"itemCondition\": \"https://schema.org/NewCondition\""
echo "\"availability\" : \"https://schema.org/InStock\"
}
}
</script>"
done
}
_prods() {
awk -F ',' '$4 == "TRUE" {print $2}' products.csv
}
_catslinks() {
awk -F',' '$4 == "TRUE" {print $14}' products.csv | sort | uniq -c | sort -nr | while read _i ; do
echo "<pre style='background-color: black;'>${_i%' '*} <a title='Product Category: ${_i#*' '}' href='/cat/${_i#*' '}'>${_i#*' '}</a></pre>"
done
}
_subcatslinks() {
[[ $1 != "" ]] && CATEGORY=$1 awk -F ',' '$4 == "TRUE" && $14 ~ ENVIRON["CATEGORY"] {print $15}' products.csv | grep -v -e '^$'| sort | uniq -c | sort -nr | while read _i ; do
echo -n "<pre style='background-color: black;'>${_i%%' '*} "
_link=${_i#*' '}
_link=${_link//"¼"/"quarter-"}
_link=${_link//"½"/"half-"}
_link=${_link//"1/16"/"sixteenth-"}
_link=${_link//"%"/"-pct"}
_link=${_link//" "/" "}
_link=${_link//" "/"-"}
_link=${_link//" "/"-"}
_link=${_link//"--"/"-"}
_link=${_link//"watt1"/"watt-1"}
_link=${_link//"watt5"/"watt-5"}
echo "<a title='Product SubCategory: ${_i#*' '}' href='/cat/$1/${_link}'>${_i#*' '}</a></pre>"
done
}
_treetest() {
go run m2.go cat | ansifilter --html
}
_cats() {
awk -F',' '$4 == "TRUE" {print $14}' products.csv | sort | uniq -c | sort -nr | awk -F" " '{print$2$3$4$5$6$7$8$9$10}' | grep -v -e '^$'
}
_subcats() {
[[ -z "$1" ]] && awk -F',' '$4 == "TRUE" {print $15}' products.csv | sort | uniq -c | sort -nr | awk -F" " '{print$2$3$4$5$6$7$8$9$10}' | grep -v -e '^$' | while read _i ; do
_i=${_i#*' '}
_i=${_i//"¼"/"quarter-"}
_i=${_i//"½"/"half-"}
_i=${_i//"1/16"/"sixteenth-"}
_i=${_i//"%"/"-pct"}
_i=${_i//" "/" "}
_i=${_i//" "/"-"}
_i=${_i//" "/"-"}
_i=${_i//"--"/"-"}
_i=${_i//"watt1"/"watt-1"}
_i=${_i//"watt5"/"watt-5"}
echo "${_i}"
done || CATEGORY=$1 awk -F',' '$4 == "TRUE" && $14 == ENVIRON["CATEGORY"] {print $15}' products.csv | sort | uniq -c | sort -nr | awk -F" " '{print$2$3$4$5$6$7$8$9$10}' | grep -v -e '^$' | while read _i ; do
_i=${_i#*' '}
_i=${_i//"¼"/"quarter-"}
_i=${_i//"½"/"half-"}
_i=${_i//"1/16"/"sixteenth-"}
_i=${_i//"%"/"-pct"}
_i=${_i//" "/" "}
_i=${_i//" "/"-"}
_i=${_i//" "/"-"}
_i=${_i//"--"/"-"}
_i=${_i//"watt1"/"watt-1"}
_i=${_i//"watt5"/"watt-5"}
echo "${_i}"
done
}
_sitemapxml() {
_update="$(date +%Y-%m-%d)"
echo "<?xml version='1.0' encoding='UTF-8'?>
<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>"
_cats | while read _category ; do
echo "<url>
<loc>https://magnetosphere.net/cat/${_category}</loc>
<lastmod>${_update}</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>"
_subcats ${_category} | while read _subcategory ; do
echo "<url>
<loc>https://magnetosphere.net/cat/${_category}/${_subcategory}</loc>
<lastmod>${_update}</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>"
done
done
awk -F ',' '$4 == "TRUE" {print $2}' products.csv | while read _partno ; do
echo "<url>
<loc>https://magnetosphere.net/p/${_partno}</loc>
<lastmod>${_update}</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>"
done
echo "</urlset>"
}
_yearcalendar() {
seq 01 12 | while read -r _month ; do unbuffer cal --color "$_month" "$(date +%Y)" | ansifilter --html | tail -n +20 | head -n -3 ; done | tee
}
_rainbowcal() {
echo "<p style='font-size:4;'>"
unbuffer cal --color | lolcat -f -F '0.5' | ansifilter --html | tail -n +20 | head -n -3
echo "</p>"
}
#_skywireclihelp() {
# unbuffer skywire-cli --help | ansifilter --html | tail -n +20 | head -n -3 | tee
#}
_dayscalc() {
printf 'There are %s days in the month of %s.\n' "$(cal "$(date +%m)" "$(date +%Y)" | awk 'NF {DAYS = $NF}; END {print DAYS}')" "$(date +%B)"
printf 'Today is %s %s.\n' "$(date +%B)" "$(date +%d)"
printf '%s days remain in the month of %s.\n' "$(echo "$(cal "$(date +%m)" "$(date +%Y)" | awk 'NF {DAYS = $NF}; END {print DAYS}')" - "$(date +%d)" | bc -l)" "$(date +%B)"
printf '%s days in the year %s.\n' "$(seq 01 12 | while read -r _month ; do cal "$_month" "$(date +%Y)" | awk 'NF {DAYS = $NF}; END {print DAYS}' ; done | paste -sd+ | bc -l)" "$(date +%Y)"
printf 'Today is day %s.\n' "$(date +%j)"
printf 'There are %s days remaining in %s\n' "$(echo "$(echo "$(date --date="January 1 next year" +%s)" - "$(date +%s)" | bc -l)" / 60 / 60 / 24 | bc)" "$(date +%Y)"
}
_statusbanner() {
# [[ $(($(date +%s) - $(date -r "status.html" +%s))) -lt 300 ]] && cat status.html && exit
# [[ $(($(date +%s) - $(date -r "status.html" +%s))) -gt 300 ]] && [[ $(systemctl is-active --quiet skycoin-modal >/dev/null) ]] && echo "<div style='position: fixed; bottom: 0; left: 0; width: 100%; background-color: blue; padding: 0px; text-align: center; color: black; font-size: 10px;'><p>payment gateway status: <b>online</b></p></div>" | tee status.html || echo "<div style='position: fixed; bottom: 0; left: 0; width: 100%; background-color: red; padding: 0px; text-align: center; color: black; font-size: 10px;'><p>payment gateway status: <b>offline</b></p></div>" | tee status.html
if systemctl is-active --quiet skycoin-modal >/dev/null ; then printf "payment gateway: <span style='background-color: blue; color: black;'><b>online</b></span>" ; else printf "payment gateway: <span style='background-color: red; color: black;'><b>offline</b></span>" ; fi
}
_logocanvas() {
awk 'NR==321 {print substr($0, 1, 61028) "<canvas id=\"gocanvas\"></canvas>" substr($0, 61029)} NR!=321' logo.html
}
_customlogohtml() {
img2txt -W 1599 logo.png | ansifilter --html | tail -n +20 | head -n -3 | sed 's/>=/><span style=/g' | sed 's/<pre>/<pre style="font-size:1px;">/g'
}
_skywireclihelp(){
go run m2.go --help | ansifilter --html
}
_char_to_entity() {
local char="$1"
case "$char" in
"&") echo "&" ;;
"<") echo "<" ;;
">") echo ">" ;;
'"') echo """ ;;
"'") echo "'" ;;
"┌") echo "┌" ;;
"─") echo "─" ;;
"┐") echo "┐" ;;
"┬") echo "┬" ;;
"├") echo "├" ;;
"┤") echo "┤" ;;
"└") echo "└" ;;
"┘") echo "┘" ;;
"│") echo "│" ;;
"╔") echo "╔" ;;
"╗") echo "╗" ;;
"║") echo "║" ;;
"╚") echo "╚" ;;
"╝") echo "╝" ;;
"═") echo "═" ;;
"┼") echo "┼" ;;
"┴") echo "┴" ;;
"O") echo "O" ;; # ASCII for "O"
"/") echo "/" ;; # ASCII for "/"
"\\") echo "\" ;; # ASCII for "\"
"┌") echo "┌" ;;
"┤") echo "┤" ;;
"o") echo "o" ;; # ASCII for "o"
"│") echo "│" ;;
"└") echo "└" ;;
"┘") echo "┘" ;;
"─") echo "─" ;;
"\n") echo "<br>" ;; # Convert newline to <br>
" ") echo " " ;; # Non-breaking space
*) echo "$char" ;;
esac
}
# Function to convert a string to HTML entities
_sentities() {
local input="$1"
local output=""
local len=${#input}
for (( i=0; i<len; i++ )); do
local char="${input:$i:1}"
local entity="$(_char_to_entity "$char")"
output="${output}${entity}"
done
echo "$output"
}