<commit_before>import aiohttp_jinja2

from .consts import TEMPLATE_APP_KEY, APP_KEY


__all__ = ['Admin', 'get_admin']


def get_admin(app, *, app_key=APP_KEY):
    return app.get(app_key)


class Admin:

    def __init__(self, app, *, name=None, url=None, loop):
        self._app = app
        self._loop = loop
        self._resources = []
        self._url = url or '/admin'
        self._name = name or 'aiohttp_admin'

    @property
    def app(self):
        return self._app

    @property
    def name(self):
        return self._name

    def add_resource(self, resource):
        resource.setup(self.app, self._url)
        self._resources.append(resource)

    @aiohttp_jinja2.template('admin.html', app_key=TEMPLATE_APP_KEY)
    async def index_handler(self, request):
        return {'name': self._name}<commit_msg>pass template name to admin object<commit_after>from aiohttp_jinja2 import render_template

from .consts import TEMPLATE_APP_KEY, APP_KEY


__all__ = ['Admin', 'get_admin']


def get_admin(app, *, app_key=APP_KEY):
    return app.get(app_key)


class Admin:

    def __init__(self, app, *, name=None, url=None, template=None, loop):
        self._app = app
        self._loop = loop
        self._resources = []
        self._url = url or '/admin'
        self._name = name or 'aiohttp_admin'
        self._temalate = template or 'admin.html'

    @property
    def app(self):
        return self._app

    @property
    def template(self):
        return self._temalate

    @property
    def name(self):
        return self._name

    def add_resource(self, resource):
        resource.setup(self.app, self._url)
        self._resources.append(resource)

    async def index_handler(self, request):
        t = self._temalate
        context = {'name': self._name}
        return render_template(t, request, context, app_key=TEMPLATE_APP_KEY)
{'fraction_non_alphanumeric': 0.10784837159636947, 'fraction_numerical': 0.001601708489054992, 'mean_word_length': 2.785858585858586, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2934233', 'n_tokens_mistral': 618, 'n_tokens_neox': 592, 'n_words': 143}