from typing import Protocol
from obscura.assets import html_blocks

import importlib.resources as pkg_resources


class GeneratesHTMLBlock(Protocol):
    def generateBlock(self) -> str:
        raise NotImplemented


def readFromHTMLAssetFile(filename: str) -> str:
    with pkg_resources.path(html_blocks, filename) as block_file_path:
        with open(block_file_path) as block_file:
            return block_file.read()


HTML_HEADER = readFromHTMLAssetFile("site_header.html")
GALLERY_ELEMENT_BLOCK = readFromHTMLAssetFile("gallery_element.html")
GALLERY_DETAIL_BLOCK = readFromHTMLAssetFile("gallery_detail.html")
GALLERY_ELEMENT_CAPTION_BLOCK = readFromHTMLAssetFile("gallery_element_caption.html")
EXPOSURE_INFORMATION_BLOCK = readFromHTMLAssetFile("exposure_information.html")
