import logging
import os

from django.conf import settings
from faucet import dogecoin_client

DOGE_AMOUNT = float(os.environ['DOGE_AMOUNT'])

def template_constants(request):
  faucet_address = os.environ['FAUCET_ADDR']
  dictionary = {'FAUCET_ADDR': faucet_address}
  if settings.ANALYTICS_ID:
    dictionary['ANALYTICS_ID'] = settings.ANALYTICS_ID
  try:
    server = dogecoin_client.get_rpc_server()
    balance = server.getbalance(os.environ['DOGE_ACCOUNT'])
    total_received = server.getreceivedbyaddress(faucet_address)
    dictionary['balance'] = balance
    dictionary['given_out'] = total_received - balance
    dictionary['give_amount'] = DOGE_AMOUNT
  except Exception as e:
    logging.error('dogecoin client error: ' + str(e))
    dictionary['error'] = 'couldn\'t connect to dogecoin :('
  return dictionary

@@ -344,16 +344,212 @@
 TICS_ID%0A
+%0A  if 'ADSENSE_CLIENT' in os.environ and 'ADSENSE_SLOT' in os.environ:%0A    dictionary%5B'ADSENSE_CLIENT'%5D = os.environ%5B'ADSENSE_CLIENT'%5D%0A    dictionary%5B'ADSENSE_SLOT'%5D = os.environ%5B'ADSENSE_SLOT'%5D%0A%0A
   try:%0A 

add adsense stuff to context processor