mirror of
https://github.com/dennisreimann/kindle-display.git
synced 2026-08-13 12:33:45 +02:00
added option to show/hide the second exchange rate
This commit is contained in:
parent
c1ce361fd6
commit
0369b6675e
3 changed files with 11 additions and 6 deletions
|
|
@ -15,3 +15,7 @@ DISPLAY_SERVER_PORT=3030
|
|||
# Shall the fallbacks be used?
|
||||
DISPLAY_FALLBACK_BLOCK=true
|
||||
DISPLAY_FALLBACK_RATES=true
|
||||
|
||||
# Shall a second exchange rate be shown?
|
||||
DISPLAY_SECOND_EXCHANGE_RATE=true
|
||||
|
||||
|
|
|
|||
|
|
@ -25,18 +25,19 @@ fi
|
|||
# Fetch rates using custom BTCPay or Kraken as fallback
|
||||
if [[ "${BTCPAY_API_TOKEN}" && "${BTCPAY_HOST}" ]]; then
|
||||
usdrate=$($tor curl -s -f -H "Authorization: Basic $BTCPAY_API_TOKEN" $BTCPAY_HOST/rates/BTC/USD | jq -r '.data.rate')
|
||||
eurrate=$($tor curl -s -f -H "Authorization: Basic $BTCPAY_API_TOKEN" $BTCPAY_HOST/rates/BTC/EUR | jq -r '.data.rate')
|
||||
|
||||
if [[ ${DISPLAY_SECOND_EXCHANGE_RATE} = true ]]; then
|
||||
eurrate=$($tor curl -s -f -H "Authorization: Basic $BTCPAY_API_TOKEN" $BTCPAY_HOST/rates/BTC/EUR | jq -r '.data.rate')
|
||||
fi
|
||||
fi
|
||||
if [[ "${usdrate}" = "" && ${DISPLAY_FALLBACK_RATES} = true ]]; then
|
||||
usdrate=$($tor curl -s -f https://api.kraken.com/0/public/Ticker\?pair=XBTUSD | jq -r '.result.XXBTZUSD.c[0] // "[]"')
|
||||
fi
|
||||
if [[ "${eurrate}" = "" && ${DISPLAY_FALLBACK_RATES} = true ]]; then
|
||||
if [[ "${eurrate}" = "" && ${DISPLAY_FALLBACK_RATES} = true && ${DISPLAY_SECOND_EXCHANGE_RATE} = true ]]; then
|
||||
eurrate=$($tor curl -s -f https://api.kraken.com/0/public/Ticker\?pair=XBTEUR | jq -r '.result.XXBTZEUR.c[0] // "[]"')
|
||||
fi
|
||||
|
||||
if [[ "${usdrate}" && "${eurrate}" ]]; then
|
||||
rates=$(jo -p -a $(jo rate="$usdrate" code="USD") $(jo rate="$eurrate" code="EUR"))
|
||||
fi
|
||||
rates=$(jo -p -a $(jo rate="$usdrate" code="USD") $(jo rate="$eurrate" code="EUR"))
|
||||
|
||||
# Bitcoin Quotes
|
||||
quote=$( $tor curl -s -f https://www.bitcoin-quotes.com/quotes/random.json 2> /dev/null || echo "null")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
extends _layout
|
||||
block content
|
||||
- const usdRate = rates && rates.find(rate => rate.code === 'USD')
|
||||
- const eurRate = rates && rates.find(rate => rate.code === 'EUR')
|
||||
- const eurRate = rates && rates.find(rate => rate.rate != null && rate.code === 'EUR')
|
||||
- const displayQuote = quote && quote.body.length < 220
|
||||
- const displayEuro = eurRate && (!displayQuote || quote && quote.body.length < 115)
|
||||
.bg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue