# Path: util/auth.py
# def is_admin():
#     return users.get_current_user() and users.is_current_user_admin()
# 
# Path: util/converter.py
# class RegexConverter(BaseConverter):
# 
#     def __init__(self, url_map, *items):
#         super(RegexConverter, self).__init__(url_map)
#         self.regex = items[0]
# 
# Path: util/company_values.py
# def linkify_company_values(love):
#     # escape the input before we add our own safe links
#     escaped_love = str(markupsafe.escape(love))
#     hashtag_value_mapping = get_hashtag_value_mapping()
# 
#     # find all the hashtags.
#     ht_regex = '#[a-zA-Z0-9]+'
#     present_hashtags = re.findall(ht_regex, escaped_love)
# 
#     # find all the ones we care about
#     valid_hashtags = set()
#     for hashtag in present_hashtags:
#         if hashtag.lower() in hashtag_value_mapping:
#             valid_hashtags.add(hashtag)
# 
#     # replace the hashtags with urls
#     for hashtag in valid_hashtags:
#         value_anchor = '<a href="{value_url}">{word}</a>'.format(
#             value_url='/value/' + hashtag_value_mapping[hashtag.lower()].lower(),
#             word=hashtag
#         )
#         escaped_love = escaped_love.replace(hashtag, value_anchor)
# 
#     return markupsafe.Markup(escaped_love)
# 
# Path: util/csrf.py
# def generate_csrf_token():
#     if '_csrf_token' not in session:
#         session['_csrf_token'] = binascii.hexlify(os.urandom(16))
#     return session['_csrf_token']


from flask import Flask
from flask_themes2 import Themes
from util.auth import is_admin
from util.converter import RegexConverter
from util.company_values import linkify_company_values
from util.csrf import generate_csrf_token
import config
import views  # noqa
# -*- coding: utf-8 -*-
# flake8: noqa



app = Flask(__name__.split('.')[0])
app.secret_key = config.SECRET_KEY
app.url_map.converters['regex'] = RegexConverter
app.jinja_env.globals['config'] = config
app.jinja_env.globals['csrf_token'] = generate_csrf_token
app.jinja_env.globals['is_admin'] = is_admin

# Path: util/auth.py
# def is_admin():
#     return users.get_current_user() and users.is_current_user_admin()
# 
# Path: util/converter.py
# class RegexConverter(BaseConverter):
# 
#     def __init__(self, url_map, *items):
#         super(RegexConverter, self).__init__(url_map)
#         self.regex = items[0]
# 
# Path: util/company_values.py
# def linkify_company_values(love):
#     # escape the input before we add our own safe links
#     escaped_love = str(markupsafe.escape(love))
#     hashtag_value_mapping = get_hashtag_value_mapping()
# 
#     # find all the hashtags.
#     ht_regex = '#[a-zA-Z0-9]+'
#     present_hashtags = re.findall(ht_regex, escaped_love)
# 
#     # find all the ones we care about
#     valid_hashtags = set()
#     for hashtag in present_hashtags:
#         if hashtag.lower() in hashtag_value_mapping:
#             valid_hashtags.add(hashtag)
# 
#     # replace the hashtags with urls
#     for hashtag in valid_hashtags:
#         value_anchor = '<a href="{value_url}">{word}</a>'.format(
#             value_url='/value/' + hashtag_value_mapping[hashtag.lower()].lower(),
#             word=hashtag
#         )
#         escaped_love = escaped_love.replace(hashtag, value_anchor)
# 
#     return markupsafe.Markup(escaped_love)
# 
# Path: util/csrf.py
# def generate_csrf_token():
#     if '_csrf_token' not in session:
#         session['_csrf_token'] = binascii.hexlify(os.urandom(16))
#     return session['_csrf_token']


# Path: main.py
from flask import Flask
from flask_themes2 import Themes
from util.auth import is_admin
from util.converter import RegexConverter
from util.company_values import linkify_company_values
from util.csrf import generate_csrf_token
import config
import views  # noqa

# -*- coding: utf-8 -*-
# flake8: noqa



app = Flask(__name__.split('.')[0])
app.secret_key = config.SECRET_KEY
app.url_map.converters['regex'] = RegexConverter
app.jinja_env.globals['config'] = config
app.jinja_env.globals['csrf_token'] = generate_csrf_token
app.jinja_env.globals['is_admin'] = is_admin

app.jinja_env.filters['linkify_company_values'] = linkify_company_values