Browse Source

modular layouts

pull/1/head
Ivan Polyakov 3 years ago
parent
commit
992c08159d
  1. 52
      layouts/default.sxml
  2. 38
      src/components/footer.scm
  3. 34
      src/components/header.scm
  4. 10
      src/general.scm
  5. 39
      src/templates/clean.scm
  6. 54
      src/templates/default.scm

52
layouts/default.sxml

@ -1,52 +0,0 @@
;; Copyright (C) 2022 Ivan Polyakov
;;
;; This file is part of vilor's website.
;;
;; Vilor's website is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; Vilor's website is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
()
`((xhtml-1.0-strict)
(html (@ (xmlns "http://www.w3.org/1999/xhtml") (xml:lang "en") (lang "en"))
(head
(meta (@ (http-equiv "Content-Type") (content "text/html; charset=ascii")))
(link (@ (rel "stylesheet") (href "/style.css")))
(title ,($ 'title)))
(body
(div (@ (class "wrapper"))
(div (@ (class "header"))
(div (@ (class "container"))
(h4 (@ (class "header__logo")) vilor)
(ul (@ (class "header__nav"))
(li (a (@ (href "/index.html")) "Home"))
(li (a (@ (href "/webapps/index.html")) "Web Apps"))
(li (a (@ (href "http://31.184.254.176:8078/")) "Git"))
(li (a (@ (href "/contacts.html")) "Contacts")))))
(div (@ (class "content container"))
(h1 (@ (class "content__title")) ,($ 'page-name))
(div (@ (class "content__description")) ,($ 'page-desc))
(inject ,contents))
(div (@ (class "footer"))
(div (@ (class "footer__authors"))
(div "Content: " (a (@ (href "/contacts.html")) "Ivan Polyakov"))
(div "Design: " (a (@ (href "https://t.me/olnaolna")) "Olga Revenkova")))
(div (@ (class "links"))
(a (@ (href "http://validator.w3.org/check?uri=referer"))
(img (@ (src "http://www.w3.org/Icons/valid-xhtml10") (alt "Valid XHTML 1.0 Strict") (height 31) (width 88))))
(a (@ (href "http://31.184.254.176:8078/vilor/website/"))
"Source code")
(a (@ (href "http://www.anybrowser.org/campaign/"))
(img (@ (src "/img/anybrowser3.jpg")
(alt "Viewable With Any Browser"))))))))))

38
src/components/footer.scm

@ -0,0 +1,38 @@
;; Copyright (C) 2022 Ivan Polyakov
;;
;; This file is part of vilor's website.
;;
;; Vilor's website is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; Vilor's website is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(define footer-links
'(("http://validator.w3.org/check?uri=referer" "XHTML 1.0")
("https://call-cc.org/" "Made with Chicken Scheme")
("http://31.184.254.176:8078/vilor/website/" "Source code")
("http://www.anybrowser.org/campaign/" "Any Browser")))
(define footer
`(div (@ (class "footer"))
(div (@ (class "footer__authors"))
(div "Content: "
(a (@ (href "/contacts.xhtml")) "Ivan Polyakov"))
(div "Design: "
(a (@ (href "https://t.me/olnaolna")) "Olga Revenkova")))
(div (@ (class "footer__links"))
,(let ((idx -1))
(map (lambda (l)
(set! idx (+ idx 1))
`(,(if (> idx 0) '(" | ") '())
(a (@ (href ,(car l))) ,(cdr l))))
footer-links)))))

34
src/components/header.scm

@ -0,0 +1,34 @@
;; Copyright (C) 2022 Ivan Polyakov
;;
;; This file is part of vilor's website.
;;
;; Vilor's website is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; Vilor's website is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(define header-links
'(("/index.xhtml" "Home")
("/webapps/index.xhtml" "Web Apps")
("http://31.184.254.176:8078/" "Git")
("/contacts.xhtml" "Contacts")))
(define header
`(div (@ (class "header"))
(div (@ (class "container"))
(h4 (@ (class "header__logo")) "vilor")
(span (@ (class "header__nav"))
,(let ((idx -1))
(map (lambda (l)
(set! idx (+ idx 1))
`(,(if (> idx 0) '(" | ") '())
(a (@ (href ,(car l))) ,(cdr l))))
header-links))))))

10
layouts/clean.sxml → src/general.scm

@ -15,11 +15,5 @@
;; You should have received a copy of the GNU General Public License ;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
() (define xhtml-1.0-doctype
`((xhtml-1.0-strict) "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
(html (@ (xmlns "http://www.w3.org/1999/xhtml") (xml:lang "en") (lang "en"))
(head
(meta (@ (http-equiv "Content-Type") (content "text/html; charset=ascii")))
(link (@ (rel "stylesheet") (href "/style.css")))
(title ,($ 'title)))
(body (inject ,contents))))

39
src/templates/clean.scm

@ -0,0 +1,39 @@
;; Copyright (C) 2022 Ivan Polyakov
;;
;; This file is part of vilor's website.
;;
;; Vilor's website is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; Vilor's website is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(define (clean-tpl
page-title
page-content
#!optional (page-styles '()) (page-scripts '()))
`(html (@ (xmlns "http://www.w3.org/1999/xhtml")
(xml:lang "en")
(lang "en"))
(head
(meta (@ (http-equiv "Content-Type")
(content "text/html; charset=ascii")))
(meta (@ (name "viewport")
(content "width=device-width, initial-scale=1")))
,(map (lambda (l)
`(link (@ (rel "stylesheet") (href ,l))))
page-styles)
(title ,page-title))
(body
,page-content
,(map (lambda (l) `(script (@ (src ,l)))) page-scripts))))

54
src/templates/default.scm

@ -0,0 +1,54 @@
;; Copyright (C) 2022 Ivan Polyakov
;;
;; This file is part of vilor's website.
;;
;; Vilor's website is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; Vilor's website is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(load "./src/components/header.scm")
(load "./src/components/footer.scm")
(define (default-tpl
page-title
page-content
page-name
page-desc
#!optional (page-styles '()) (page-scripts '()))
`(html (@ (xmlns "http://www.w3.org/1999/xhtml")
(xml:lang "en")
(lang "en"))
(head
(meta (@ (http-equiv "Content-Type")
(content "text/html; charset=ascii")))
(meta (@ (name "viewport")
(content "width=device-width, initial-scale=1")))
,(map (lambda (l)
`(link (@ (rel "stylesheet") (href ,l))))
page-styles)
(link (@ (rel "stylesheet") (href "/style.css")))
(title ,title))
(body
,header
(hr (@ (style "display: none")))
(div (@ (class "content container"))
(h1 (@ (class "content__title")) ,page-name)
(div (@ (class "content__description")) ,page-desc)
,page-content)
(hr (@ (style "display: none")))
,footer
,(map (lambda (l) `(script (@ (src ,l)))) page-scripts))))
Loading…
Cancel
Save