Header Module

class epyk.core.html.Header.Header(page: Optional[PageModel] = None)
add_code(code: str, attrs: Optional[dict] = None)

Add a JavaScript tag to the HTML page.

The code will be added in a script tag.

Parameters:
  • code – The JavaScript code to be added to the page

  • attrs – optional. The various attributes to be added to the script tag

add_script(src: str, attrs: Optional[dict] = None)

Add a JavaScript tag to the HTML page.

The script will be added in a script tag.

Parameters:
  • src – The script path added to the page

  • attrs – optional. The various attributes to be added to the script tag

base(url: str)

Specify a dedicated path for the relative paths in the page.

Basically the images will use this path as base if present in the page.

Related Pages:

Parameters:

url – The url path

dev(icon: Optional[str] = None)

Change the tab icon to highlight this page is still in dev mode.

Usage:

page = Report()
page.headers.dev()
Parameters:

icon – Optional. The url path of the icon

favicon(url: str, rel: str = 'icon', sizes: Optional[str] = None, img_type: Optional[str] = None)

The <link> tag defines a link between a document and an external resource.

The <link> tag is used to link to external style sheets.

Usage:

rptObj.headers.favicon('https://github.com/favicon.ico')

Related Pages:

Parameters:
  • url – The url full path

  • rel – Optional

  • sizes – Optional

  • img_type – Optional

property icons

Property to defined / add more icons to the page header. Some browsers (like Safari or Opera) could require specify tags in the page.

The various HTML page header links.

Related Pages:

property meta: Meta

Property to the Meta data dictionary for the HTML page.

Metadata is data (information) about data.

The <meta> tag provides metadata about the HTML document. Metadata will not be displayed on the page, but will be machine parsable.

Usage:

page.headers.meta

Related Pages:

title(value: str)

The <title> tag is required in all HTML documents and it defines the title of the document.

You can NOT have more than one <title> element in an HTML document.

Usage:

page.headers.title("title")

Related Pages:

Parameters:

value – The title value for the page

class epyk.core.html.Header.Icons(header)
apple_touch_icon(url: str, sizes: Optional[str] = None)

Related Pages:

Parameters:
  • url – The path for the svg file

  • sizes – Optional. The size for 25x25

apple_touch_startup_icon(url: str, sizes: Optional[str] = None)

Related Pages:

Parameters:
  • url – The path for the svg file

  • sizes – Optional. The size for 25x25

gif(url: str, sizes: Optional[str] = None)

Related Pages:

Parameters:
  • url – The path for the gif

  • sizes – Optional. The size in a format 25x25

icon(url: str, sizes: Optional[str] = None, img_type: Optional[str] = None)

Set the icon for the page.

Related Pages:

Parameters:
  • url – The url of the icon on the server

  • sizes – Optional. The size of the icon

  • img_type – Optional. The type of picture

svg(url: str, sizes: Optional[str] = None)

Related Pages:

Parameters:
  • url – The path for the svg file

  • sizes – Optional. The size for 25x25

alternative(href: str, file_type: str = 'text/css', media: Optional[str] = None)

Specifying alternative style sheets in a web page provides a way for users to see multiple versions of a page, based on their needs or preferences.

Related Pages:

Parameters:
  • href – The link path for the stylesheet page

  • file_type – Optional. The type of the href tag

  • media – Optional. This resource will then only be loaded if the media condition is true

dns_prefetch(href: str, media: Optional[str] = None, cross_origin: bool = False)

The dns-prefetch keyword for the rel attribute of the <link> element is a hint to browsers that the user is likely to need resources from the target resource’s origin, and therefore the browser can likely improve the user experience by preemptively performing DNS resolution for that origin.

Related Pages:

Parameters:
  • href – The link path for the stylesheet page

  • media – Optional. This resource will then only be loaded if the media condition is true

  • cross_origin – Optional. Specify to the browser to enable the cross origin to get resource from different website.

icon(href: str, cross_origin: bool = False)

Defines a resource for representing the page in the user interface, usually an icon (auditory or visual). In the browser, it is usually referred to as the favicon.

If there are multiple <link rel=”icon”>s, the browser uses their media, type, and sizes attributes to select the most appropriate icon. If several icons are equally appropriate, the last one is used. If the most appropriate icon is later found to be inappropriate, for example because it uses an unsupported format, the browser proceeds to the next-most appropriate, and so on.

Related Pages:

Parameters:
  • href – The link path for the stylesheet page

  • cross_origin – Optional. Specify to the browser to enable the cross origin to get resource from different

website.

imports(href: str, file_type: str = '', media: Optional[str] = None, rel: str = 'import')

HTML Imports is intended to be the packaging mechanism for web components, but you can also use HTML Imports by itself.

Related Pages:

Parameters:
  • href – The link path for the stylesheet page

  • file_type – Optional. The type of the href tag

  • media – Optional. This resource will then only be loaded if the media condition is true

  • rel – Optional. This attribute names a relationship of the linked document to the current document

manifest(href: str, file_type: str = '', media: Optional[str] = None)

The manifest keyword for the rel attribute of the <link> element indicates that the target resource is a Web app manifest.

Web app manifests are deployed in your HTML pages using a <link> element in the <head> of a document:

Related Pages:

Parameters:
  • href – The link path for the stylesheet page

  • file_type – Optional. The type of the href tag

  • media – Optional. This resource will then only be loaded if the media condition is true

pingback(href: str, cross_origin: bool = False)

Pingbacks (also known as trackbacks) are a form of automated comment for a page or post, created when another WordPress blog links to that page or post.

Related Pages:

Parameters:
  • href – The link path for the stylesheet page

  • cross_origin – Optional. Specify to the browser to enable the cross origin to get resource from

different website.

preconnect(href: str, media: Optional[str] = None, cross_origin: bool = False)

The preconnect directive allows the browser to setup early connections before an HTTP request is actually sent to the server. This includes DNS lookups, TLS negotiations, TCP handshakes. This in turn eliminates roundtrip latency and saves time for users.

Related Pages:

Parameters:
  • href – The link path for the stylesheet page

  • media – Optional. This resource will then only be loaded if the media condition is true

  • cross_origin – Optional. Specify to the browser to enable the cross origin to get resource from different website.

prefetch(href: str, media: Optional[str] = None, cross_origin: bool = False)

The prefetch keyword for the rel attribute of the <link> element is a hint to browsers that the user is likely to need the target resource for future navigations, and therefore the browser can likely improve the user experience by preemptively fetching and caching the resource.

Related Pages:

Parameters:
  • href – The link path for the stylesheet page

  • media – Optional. This resource will then only be loaded if the media condition is true

  • cross_origin – Optional. Specify to the browser to enable the cross origin to get resource from different website.

preload(href: str, file_type: str = '', media: Optional[str] = None, cross_origin: bool = False)

The preload keyword for the rel attribute of the <link> element indicates the user is highly likely to require the target resource for the current navigation, and therefore the browser must preemptively fetch and cache the resource.

Related Pages:

Parameters:
  • href – The link path for the stylesheet page

  • file_type – Optional. The type of the href tag

  • media – Optional. This resource will then only be loaded if the media condition is true

  • cross_origin – Optional. Specify to the browser to enable the cross origin to get resource from different website.

prerender(href: str, media: Optional[str] = None, cross_origin: bool = False)

The prerender keyword for the rel attribute of the <link> element is a hint to browsers that the user might need the target resource for the next navigation, and therefore the browser can likely improve the user experience by preemptively fetching and processing the resource — for example, by fetching its subresources or performing some rendering in the background offscreen.

Related Pages:

Parameters:
  • href – The link path for the stylesheet page

  • media – Optional. This resource will then only be loaded if the media condition is true

  • cross_origin – Optional. Specify to the browser to enable the cross origin to get resource from different website.

Some websites create short links to make sharing links via instant messaging easier.

Related Pages:

Parameters:

href – The url path

stylesheet(href: str, file_type: str = 'text/css', media: Optional[str] = None, rel: str = 'stylesheet', cross_origin: bool = False)

Link the page to a style sheet.

Related Pages:

Parameters:
  • href – The link path for the stylesheet page

  • file_type – Optional. The type of the href tag

  • media – Optional. This resource will then only be loaded if the media condition is true

  • rel – Optional. This attribute names a relationship of the linked document to the current document

  • cross_origin – Optional. Specify to the browser to enable the cross origin to get resource from different website.

class epyk.core.html.Header.Meta(page: PageModel)
author(name: str)

Define the author of the page.

Usage:

page.headers.meta.author('epykure')

Related Pages:

Parameters:

name – The author name

charset(value: str = 'utf-8')

Define the character set used.

Usage:

page.headers.meta.charset("test")

Related Pages:

Parameters:

value – Optional. The charset encoding

custom(name: str, content: str)

Bespoke function to add other meta tags.

Usage:

page.headers.meta.custom('language', 'python')

Related Pages:

Parameters:
  • name – The name for the meta tag

  • content – The value of the meta tag

description(value: str)

Define a description of your web page.

Usage:

page.headers.meta.description('This is a description')

Related Pages:

Parameters:

value – The report description

http_equiv(name: str, content: str)

Bespoke function to add other http-equiv tags to the meta section.

Usage:

rptObj.headers.meta.http_equiv('language', 'python')

Related Pages:

Parameters:
  • name – The name for the meta tag

  • content – The value of the meta tag

keywords(content: Union[list, str])

Define keywords for search engine.

Usage:

page.headers.meta.keywords(['python', 'javascript'])

Related Pages:

Parameters:

content – The keyword data

refresh(time: int)

Refresh document every X seconds.

Usage:

page.headers.meta.refresh(10)

Related Pages:

Parameters:

time – A time in second

viewport(attrs: Optional[dict] = None)

Setting the viewport to make your website look good on all devices.

Usage:

page.headers.meta.viewport({"width": "device-width"})

Related Pages:

Parameters:

attrs – Optional. The view port attributes