squeeze

A static site generator that can put the toothpaste back in the tube.
git clone https://git.stjo.hn/squeeze
Log | Files | Refs | README | LICENSE

html.pl (4577B)


      1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      2 % File: html.pl
      3 % Description: DCG definition of an HTML file.
      4 %	This is basically your static website's template.
      5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      6 
      7 page(Entry, Title, Subtitle, Date, CleanTitle) -->
      8 	doctype,
      9 	newline,
     10 	html(Entry, Title, Subtitle, Date, CleanTitle),
     11 	newline.
     12 
     13 html(Entry, Title, Subtitle, Date, CleanTitle) -->
     14 	html_open,
     15 	newline,
     16 	head(CleanTitle),
     17 	newline,
     18 	body(Entry, Title, Subtitle, Date),
     19 	newline,
     20 	html_close.
     21 
     22 head(CleanTitle) -->
     23 	head_open,
     24 	newline, tab,
     25 	title(CleanTitle),
     26 	newline, tab,
     27 	meta,
     28 	newline, tab,
     29 	styles,
     30 	newline, tab,
     31 	rss,
     32 	newline,
     33 	head_close.
     34 
     35 body(Entry, Title, Subtitle, Date) -->
     36 	body_open,
     37 	newline, tab,
     38 	header(Title),
     39 	newline, tab,
     40 	article(Entry, Title, Subtitle, Date),
     41 	newline, tab,
     42 	footer,
     43 	newline,
     44 	body_close.
     45 
     46 header(Title) -->
     47 	header_open,
     48 	newline, tab, tab,
     49 	header_title(Title),
     50 	newline, tab, tab,
     51 	header_subtitle,
     52 	newline, tab,
     53 	header_close.
     54 
     55 article(Entry, Title, Subtitle, Date) -->
     56 	article_open,
     57 	newline, tab, tab,
     58 	article_header(Title, Subtitle, Date),
     59 	newline, tab, tab,
     60 	div_entry_open,
     61 	newline,
     62 	anything(Entry),
     63 	newline, tab, tab,
     64 	div_entry_close,
     65 	newline, tab,
     66 	article_close,
     67 	{ [First|_] = Entry,  char_code('<', First) }.
     68 
     69 % An article without a title, subtitle, or metadata.
     70 article_header(null, null, null) --> [].
     71 
     72 % An article without a subtitle or metadata.
     73 article_header(Title, null, null) -->
     74 	article_title(Title).
     75 
     76 % An article without a subtitle.
     77 article_header(Title, null, Date) -->
     78 	article_title(Title),
     79 	newline, tab, tab,
     80 	article_meta(Date).
     81 
     82 % An article without metadata.
     83 article_header(Title, Subtitle, null) -->
     84 	article_title(Title),
     85 	newline, tab, tab,
     86 	article_subtitle(Subtitle).
     87 
     88 % An article with all header components.
     89 article_header(Title, Subtitle, Date) -->
     90 	article_title(Title),
     91 	newline, tab, tab,
     92 	article_subtitle(Subtitle),
     93 	newline, tab, tab,
     94 	article_meta(Date).
     95 
     96 footer -->
     97 	footer_open,
     98 	newline, tab, tab,
     99 	p_center_open,
    100 	newline, tab, tab, tab,
    101 	license_link,
    102 	newline, tab, tab, tab,
    103 	br,
    104 	newline, tab, tab, tab,
    105 	license_text,
    106 	newline, tab, tab,
    107 	p_close,
    108 	newline, tab,
    109 	footer_close.
    110 
    111 doctype --> "<!DOCTYPE html>".
    112 
    113 html_open --> "<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">".
    114 
    115 head_open --> "<head>".
    116 
    117 meta --> "<meta charset=\"utf-8\" />".
    118 
    119 title(null) -->
    120 	"<title>",
    121 	site_title,
    122 	" | ",
    123 	site_subtitle,
    124 	"</title>".
    125 
    126 title(CleanTitle) -->
    127 	"<title>",
    128 	anything(CleanTitle),
    129 	"</title>".
    130 
    131 styles -->
    132 	"<link rel=\"stylesheet\" href=\"",
    133 	site_url,
    134 	"/theme/css/styles.css\" />".
    135 
    136 rss -->
    137 	"<link rel=\"alternate\" type=\"application/rss+xml\" href=\"",
    138 	site_url,
    139 	"/feeds/rss.xml\" title=\"",
    140 	site_title,
    141 	" Latest Posts\" />".
    142 
    143 head_close --> "</head>".
    144 
    145 body_open --> "<body>".
    146 
    147 header_open --> "<header>".
    148 
    149 header_title(Title) -->
    150 	"<",
    151 	header_node(Title),
    152 	" id=\"blog-title\"><a href=\"",
    153 	site_url,
    154 	"\" title=\"",
    155 	site_title,
    156 	"\" rel=\"home\">",
    157 	site_title,
    158 	"</a></",
    159 	header_node(Title),
    160 	">".
    161 
    162 header_node(null) --> "h1".
    163 
    164 header_node(_) --> "p".
    165 
    166 header_subtitle -->
    167 	"<p id=\"blog-description\">",
    168 	site_subtitle,
    169 	"</p>".
    170 
    171 header_close --> "</header>".
    172 
    173 article_open --> "<article>".
    174 
    175 article_title(ArticleTitle) -->
    176 	"<h1 class=\"entry-title\">",
    177 	anything(ArticleTitle),
    178 	"</h1>".
    179 
    180 article_subtitle(ArticleSubtitle) -->
    181 	"<p class=\"entry-subtitle\">",
    182 	anything(ArticleSubtitle),
    183 	"</p>".
    184 
    185 article_meta(ArticleDate) -->
    186 	"<div class=\"entry-meta\">",
    187 	newline, tab, tab, tab,
    188 	"<time id=\"article-date\" datetime=\"",
    189 	anything(ArticleDate),
    190 	"\">",
    191 	anything(ArticleDate),
    192 	"</time>",
    193 	newline, tab, tab,
    194 	"</div><!-- .entry-meta -->".
    195 
    196 div_entry_open --> "<div class=\"entry-content\">".
    197 
    198 div_entry_close --> "</div><!-- .entry-content -->".
    199 
    200 article_close --> "</article>".
    201 
    202 footer_open --> "<footer>".
    203 
    204 p_center_open --> "<p class=\"center\">".
    205 
    206 license_link -->
    207 	"<a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/3.0/\"><img alt=\"Creative Commons License\" style=\"border-width:0\" src=\"",
    208 	site_url,
    209 	"/theme/images/by-nc-sa_80x15.png\" /></a>".
    210 
    211 br --> "<br />".
    212 
    213 license_text -->
    214 	"Unless otherwise noted content on this website by <a href=\"mailto:",
    215 	user_email,
    216 	"\">",
    217 	user_name,
    218 	"</a> is licensed under a<br /><a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/3.0/\">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.".
    219 
    220 p_close --> "</p>".
    221 
    222 footer_close --> "</footer>".
    223 
    224 body_close --> "</body>".
    225 
    226 html_close --> "</html>".