# Path: vise/downloads.py
# def get_downloads_html():
#     if not hasattr(get_downloads_html, 'html'):
#         get_downloads_html.html = QByteArray(get_data('downloads.html').decode('utf-8').replace('_TITLE_', _('Downloads')).encode('utf-8'))
#     return get_downloads_html.html
# 
# @lru_cache(maxsize=150)
# def filename_icon_data(encoded_file_name):
#     return QByteArray(icon_data_for_filename(unhexlify(encoded_file_name).decode('utf-8'), size=64) or get_data('images/blank.png'))
# 
# Path: vise/welcome.py
# def get_welcome_html():
#     if not hasattr(get_welcome_html, 'html'):
#         d = get_data('welcome.html').decode('utf-8')
#         ic = get_data('images/vise.svg')
#         d = d.replace('VISE_ICON', 'data:image/svg+xml;base64,' + base64.standard_b64encode(ic).decode('ascii'))
#         get_welcome_html.html = QByteArray(d.encode('utf-8'))
#     return get_welcome_html.html


from PyQt6.QtCore import QBuffer
from PyQt6.QtWebEngineCore import QWebEngineUrlSchemeHandler
from .downloads import get_downloads_html, filename_icon_data
from .welcome import get_welcome_html
#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>




class UrlSchemeHandler(QWebEngineUrlSchemeHandler):

    def requestStarted(self, rq):
        if bytes(rq.requestMethod()) != b'GET':
            rq.fail(rq.RequestDenied)
            return
        url = rq.requestUrl()
        q = url.path()
        if q == 'downloads':
            rq.reply(b'text/html', QBuffer(get_downloads_html(), self))
        elif q == 'welcome':
            rq.reply(b'text/html', QBuffer(get_welcome_html(), self))

# Path: vise/downloads.py
# def get_downloads_html():
#     if not hasattr(get_downloads_html, 'html'):
#         get_downloads_html.html = QByteArray(get_data('downloads.html').decode('utf-8').replace('_TITLE_', _('Downloads')).encode('utf-8'))
#     return get_downloads_html.html
# 
# @lru_cache(maxsize=150)
# def filename_icon_data(encoded_file_name):
#     return QByteArray(icon_data_for_filename(unhexlify(encoded_file_name).decode('utf-8'), size=64) or get_data('images/blank.png'))
# 
# Path: vise/welcome.py
# def get_welcome_html():
#     if not hasattr(get_welcome_html, 'html'):
#         d = get_data('welcome.html').decode('utf-8')
#         ic = get_data('images/vise.svg')
#         d = d.replace('VISE_ICON', 'data:image/svg+xml;base64,' + base64.standard_b64encode(ic).decode('ascii'))
#         get_welcome_html.html = QByteArray(d.encode('utf-8'))
#     return get_welcome_html.html


# Path: vise/vise_scheme.py
from PyQt6.QtCore import QBuffer
from PyQt6.QtWebEngineCore import QWebEngineUrlSchemeHandler
from .downloads import get_downloads_html, filename_icon_data
from .welcome import get_welcome_html

#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>




class UrlSchemeHandler(QWebEngineUrlSchemeHandler):

    def requestStarted(self, rq):
        if bytes(rq.requestMethod()) != b'GET':
            rq.fail(rq.RequestDenied)
            return
        url = rq.requestUrl()
        q = url.path()
        if q == 'downloads':
            rq.reply(b'text/html', QBuffer(get_downloads_html(), self))
        elif q == 'welcome':
            rq.reply(b'text/html', QBuffer(get_welcome_html(), self))

        elif q.startswith('filename-icon/'):