fdoc

subroutinepage_headprivate

subroutine page_head(site, title, here, prefix, math, b)

Write the start of a page.

Arguments

NameTypeIntentAttributesDescription
sitetype(site_t)in

the site

titlecharacter(len=*)in

the title

hereintegerin

the list page this belongs to, HERE_PAGES, or 0

prefixcharacter(len=*)in

from the page to the root of the site: ../ or ''

mathlogicalin

true to load MathJax

btype(buffer_t)inout

the HTML

Calls

Source

Show the code
subroutine page_head(site, title, here, prefix, math, b)
    type(site_t), intent(in) :: site        !! the site
    character(len=*), intent(in) :: title   !! the title
    integer, intent(in) :: here             !! the list page this belongs to, `HERE_PAGES`, or 0
    character(len=*), intent(in) :: prefix  !! from the page to the root of the site: `../` or `''`
    logical, intent(in) :: math             !! true to load MathJax
    type(buffer_t), intent(inout) :: b      !! the HTML
    integer :: k

    associate (s => site%s)
        call add(b, '<!DOCTYPE html>'//achar(10)//'<html lang="en">'//achar(10)//'<head>'//achar(10))
        call add(b, '<meta charset="utf-8">'//achar(10)//'<meta name="viewport" content="width=device-width, initial-scale=1">')
        call add(b, achar(10)//'<title>')
        call html_escape(title, b, .false.)
        if (title /= s%project) then
            call add(b, ' &ndash; ')
            call html_escape(s%project, b, .false.)
        end if
        call add(b, '</title>'//achar(10))
        if (allocated(s%author)) then
            call add(b, '<meta name="author" content="')
            call html_escape(s%author, b, .true.)
            call add(b, '">'//achar(10))
        end if
        if (allocated(s%favicon)) call add(b, '<link rel="icon" href="'//prefix//'favicon.png">'//achar(10))
        call add(b, '<link rel="stylesheet" href="'//prefix//'css/fdoc.css">'//achar(10))
        if (allocated(s%css)) call add(b, '<link rel="stylesheet" href="'//prefix//'css/user.css">'//achar(10))
        call add(b, '<script src="'//prefix//'js/fdoc.js"></script>'//achar(10))
        call add(b, '<script defer src="'//prefix//'js/sidebar.js"></script>'//achar(10))
        if (math) then
            call add(b, '<script async src="https://cdn.jsdelivr.net/npm/mathjax@2.7.9/MathJax.js?config=TeX-AMS-MML_HTMLorMML">')
            call add(b, '</script>'//achar(10))
        end if
        call add(b, '</head>'//achar(10)//'<body>'//achar(10)//'<header class="top">'//achar(10))
        call add(b, '<a class="brand" href="'//prefix//'index.html">')
        call html_escape(s%project, b, .false.)
        if (allocated(s%version)) then
            call add(b, '<small>')
            call html_escape(s%version, b, .false.)
            call add(b, '</small>')
        end if
        call add(b, '</a>'//achar(10)//'<nav>')
        do k = 1, NUM_LISTS
            if (size(site%members(k)%ids) == 0) cycle
            call add(b, '<a'//trim(merge(' class="here"', '             ', k == here))//' href="'//prefix//'lists/'// &
                     trim(LIST_FILE(k))//'.html">'//trim(LIST_TITLE(k))//'</a>')
        end do
        if (size(site%pages) > 0) then
            call add(b, '<a'//trim(merge(' class="here"', '             ', here == HERE_PAGES))// &
                     ' href="'//prefix//'page/index.html">')
            call html_escape(site%pages(1)%title, b, .false.)
            call add(b, '</a>')
        end if
        call add(b, '</nav>'//achar(10))
        if (s%search) then
            call add(b, '<div class="search"><input type="search" placeholder="Search (/)" aria-label="Search">')
            call add(b, '<div class="results"></div></div>'//achar(10))
        end if
        call add(b, '<button class="theme" title="Change theme" aria-label="Change theme">&#9680;</button>')
        call add(b, achar(10)//'</header>'//achar(10)//'<div class="layout">'//achar(10))
    end associate
end subroutine page_head

Graphs

Calls

Called by