Exemplo n.º 1
0
def microsoft_splash(environ, start_response):
    en_txt={ 'message':"Click on the button to go to the IIAB home page",\
            'btn1':"GO TO IIAB HOME PAGE",'doc_root':get_iiab_env("WWWROOT")}
    es_txt={ 'message':"Haga clic en el botón para ir a la página de inicio de IIAB",\
            'btn1':"IIAB",'doc_root':get_iiab_env("WWWROOT")}
    if lang == "en":
        txt = en_txt
    elif lang == "es":
        txt = es_txt
    response_body = str(j2_env.get_template("simple.template").render(**txt))
    status = '200 OK'
    response_headers = [('Content-type', 'text/html'),
                        ('Content-Length', str(len(response_body)))]
    start_response(status, response_headers)
    return [response_body]
Exemplo n.º 2
0
def android_https(environ, start_response):
    en_txt={ 'message':"""Please ignore the SECURITY warning which appears after clicking the first button""",\
             'btn2':'Click this first Go to the browser we need',\
             'btn1':'Then click this to go to IIAB home page',\
            'doc_root':get_iiab_env("WWWROOT") }
    es_txt={ 'message':"Haga clic en el botón para ir a la página de inicio de IIAB",\
            'btn1':"IIAB",'doc_root':get_iiab_env("WWWROOT")}
    if lang == "en":
        txt = en_txt
    elif lang == "es":
        txt = es_txt
    response_body = str(j2_env.get_template("simple.template").render(**txt))
    status = '200 OK'
    response_headers = [('Content-type', 'text/html'),
                        ('Content-Length', str(len(response_body)))]
    start_response(status, response_headers)
    return [response_body]
Exemplo n.º 3
0
def mac_splash(environ, start_response):
    logger.debug("in function mac_splash")
    en_txt={ 'message':"Click on the button to go to the IIAB home page",\
            'btn1':"GO TO IIAB HOME PAGE",'success_token': 'Success',
            'doc_root':get_iiab_env("WWWROOT")}
    es_txt={ 'message':"Haga clic en el botón para ir a la página de inicio de IIAB",\
            'btn1':"IIAB",'doc_root':get_iiab_env("WWWROOT")}
    if lang == "en":
        txt = en_txt
    elif lang == "es":
        txt = es_txt
    set_lasttimestamp(ip)
    response_body = str(j2_env.get_template("mac.template").render(**txt))
    status = '200 Success'
    response_headers = [('Content-type', 'text/html'),
                        ('Content-Length', str(len(response_body)))]
    start_response(status, response_headers)
    return [response_body]
Exemplo n.º 4
0
IIAB_PATH = '/etc/iiab'
if not IIAB_PATH in sys.path:
    sys.path.append(IIAB_PATH)
from iiab_env import get_iiab_env

# Config Files
iiab_config_file = "{{ iiab_config_file }}"

# Variables that should be read from config file
# All of these variables will be read from config files and recomputed in init()
iiab_zim_path = "{{ iiab_zim_path }}"
kiwix_library_xml = "{{ kiwix_library_xml }}"

iiab_base_path = "{{ iiab_base }}"
kiwix_manage = iiab_base_path + "/kiwix/bin/kiwix-manage"
doc_root = get_iiab_env('WWWROOT')
zim_version_idx = doc_root + "/common/assets/zim_version_idx.json"
zim_versions = {}
old_zim_map = {"bad.zim": "unparseable name"}


def main():
    """Server routine"""

    init()

    # remove existing file
    try:
        os.remove(kiwix_library_xml)
    except OSError:
        pass
Exemplo n.º 5
0
# Create the jinja2 environment.
CAPTIVE_PORTAL_BASE = "/opt/iiab/captive-portal"
j2_env = Environment(loader=FileSystemLoader(CAPTIVE_PORTAL_BASE),
                     trim_blocks=True)

# Define time outs
INACTIVITY_TO = 30
PORTAL_TO = 20  # delay after triggered by ajax upon click of link to home page
# I had hoped that returning 204 status after some delay
#  would dispense with android's "sign-in to network" (no work)

# Get the IIAB variables
sys.path.append('/etc/iiab/')
from iiab_env import get_iiab_env
doc_root = get_iiab_env("WWWROOT")
fully_qualified_domain_name = get_iiab_env("FQDN")


# set up some logging -- selectable for diagnostics
# Create dummy iostream to capture stderr and stdout
class StreamToLogger(object):
    """
    Fake file-like stream object that redirects writes to a logger instance.
    """
    def __init__(self, logger, log_level=logging.INFO):
        self.logger = logger
        self.log_level = log_level
        self.linebuf = ''

    def write(self, buf):
Exemplo n.º 6
0
if not SCRIPT_DIR in sys.path:
    sys.path.append(SCRIPT_DIR)
import iiab_make_kiwix_lib as kiwix

IIAB_PATH='/etc/iiab'
if not IIAB_PATH in sys.path:
    sys.path.append(IIAB_PATH)
from iiab_env import get_iiab_env
KIWIX_CAT = IIAB_PATH + '/kiwix_catalog.json'

# Config Files
# iiab_ini_file should be in {{ iiab_env_file }} (/etc/iiab/iiab.env) ?
#iiab_ini_file = "{{ iiab_ini_file }}" # nominally /etc/iiab/iiab.ini
iiab_ini_file = "/etc/iiab/iiab.ini" # comment out after testing

IIAB_INI = get_iiab_env('IIAB_INI') # future
if IIAB_INI:
    iiab_ini_file = IIAB_INI

iiab_base_path = "/opt/iiab"
doc_root = get_iiab_env('WWWROOT')
zim_version_idx_dir = doc_root + "/common/assets/"
zim_version_idx_file = "zim_version_idx.json"
zim_path = "/library/zims"
menuDefs = doc_root + "/js-menu/menu-files/menu-defs/"
menuImages = doc_root + "/js-menu/menu-files/images/"
menuJsonPath = doc_root + "/home/menu.json"
rachelPath = doc_root + 'modules'
default_logos = {
   "wiktionary":"wiktionary.png",
}
Exemplo n.º 7
0
# Create the jinja2 environment.
CAPTIVE_PORTAL_BASE = "/opt/iiab/captive-portal"
j2_env = Environment(loader=FileSystemLoader(CAPTIVE_PORTAL_BASE),
                     trim_blocks=True)

# Define time outs
INACTIVITY_TO = 30
PORTAL_TO = 0  # delay after triggered by ajax upon click of link to home page
# I had hoped that returning 204 status after some delay
#  would dispense with android's "sign-in to network" (no work)

# Get the IIAB variables
sys.path.append('/etc/iiab/')
from iiab_env import get_iiab_env

doc_root = get_iiab_env("WWWROOT")

# make a way to find new URLs queried by new clients
# CATCH substitues this server for apache at port 80
CATCH = False
if len(sys.argv) > 1 and sys.argv[1] == '-d':
    CATCH = True
    PORT = 80
else:
    PORT = 9090


# set up some logging -- selectable for diagnostics
# Create dummy iostream to capture stderr and stdout
class StreamToLogger(object):
    """