summaryrefslogtreecommitdiffstats
path: root/apps/base/templates/theme.scm
blob: a9440778142ebb58ee634fbf69cd47b040248d62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
;;; Harmonic Flow web site

(define-module (apps base templates theme)
  #:use-module (apps base templates components)
  #:use-module (apps base utils)
  #:use-module (apps i18n)
  #:export (theme))


(define* (theme #:key
                (lang-tag %current-ietf-tag)
		(title '())
		(description "")
		(keywords '())
                (index? #true)
                (active-menu-item (C_ "website menu" "About"))
		(css '())
		(scripts '())
		(crumbs '())
		(content '(div "")))
  "Return an SHTML document using the website's theme.

   LANG-TAG (string)
     IETF language tag. This is used to specify the language of the
     document. For example: en, en-CA. If not provided, the value
     defaults to the currently built language, i.e. the
     %current-ietf-tag from (apps i18n).

   TITLE (list)
     A list of strings to form the value of the title element of the
     document. The elements of the list are joined together with em
     dashes as separators between them. For example, a list with two
     strings like 'Hello', and 'Blog' will result in a title like
     'Hello — Blog — Guix'.

   DESCRIPTION (string)
     The description of the document. This is the value used for the
     description meta element.

   KEYWORDS (list)
     A list of keyword strings that will be used as the value for
     the keywords meta element of the document.

   INDEX? (boolean)
     Indicate whether the page should be indexed by Internet robots,
     such as search engine robots. If not provided, it defaults to
     true.

   ACTIVE-MENU-ITEM (string)
     The label of the menu item in the navigation bar that should be
     highlighted to indicate the current section of the website that
     is being browsed. If not provided, the value defaults to 'About'.

   CSS (list)
     A list of strings that represent absolute URL paths to additional
     style sheets. For example: '/static/app/css/style.css'. If not
     provided, the value defaults to an empty list.

   SCRIPTS (list)
     A list of strings that represent absolute URL paths to additional
     script files. For example: '/static/app/js/builds.js'. If not
     provided, the value defaults to an empty list.

   CRUMBS (list)
     A list of <crumb> objects as defined in (apps base types). This
     objects are used to form the breadcrumbs of the website.

   CONTENT (SHTML)
     A main element with the content of the page. For example:
     '(main (h2 'Hello World!') (p 'Once upon a time...'))."
  `((doctype "html")

    (html
     (@ (lang ,lang-tag))

     (head
      ,(if (null? title)
           `(title ,(C_ "webpage title" "Harmonic Flow"))
           `(title ,(string-join (append title
                                         (C_ "webpage title" '("Harmonic Flow"))))))
      (meta (@ (charset "UTF-8")))
      (meta (@ (name "keywords") (content ,(string-join keywords ", "))))
      (meta (@ (name "description") (content ,description)))
      (meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0")))
      ;; Info for Internet robots.
      ,(if index?
           ""
           '(meta (@ (name "robots") (content "noindex"))))
      ;; Menu prefetch.
      (link (@ (rel "prefetch") (href ,(hfweb-url "menu/index.html"))))
      ;; Base CSS.
      (link (@ (rel "stylesheet") (href ,(hfweb-url "static/base/css/elements.css"))))
      (link (@ (rel "stylesheet") (href ,(hfweb-url "static/base/css/common.css"))))
      (link (@ (rel "stylesheet") (href ,(hfweb-url "static/base/css/messages.css"))))
      (link (@ (rel "stylesheet") (href ,(hfweb-url "static/base/css/navbar.css"))))
      (link (@ (rel "stylesheet") (href ,(hfweb-url "static/base/css/breadcrumbs.css"))))
      (link (@ (rel "stylesheet") (href ,(hfweb-url "static/base/css/buttons.css"))))
      (link (@ (rel "stylesheet") (href ,(hfweb-url "static/base/css/footer.css"))))
      (link (@ (rel "stylesheet") (href ,(hfweb-url "static/base/highlight/styles/stackoverflow-light.min.css"))))
      ;; Additional CSS.
      ,@(map (lambda (style-sheet)
	       `(link (@ (rel "stylesheet") (href ,style-sheet))))
	     css)
      ;; Feeds.
      (link (@ (type "application/atom+xml") (rel "alternate")
               (title ,(C_ "webpage title" "Harmonic Flow — Activity Feed"))
	       (href ,(hfweb-url "feeds/blog.atom"))))
      (link (@ (rel "icon") (type "image/png")
	       (href ,(hfweb-url "static/base/img/icon.png"))))
      (link (@ (rel "icon") (type "image/svg+xml") (sizes "any")
	       (href ,(hfweb-url "static/base/img/icon.svg"))))
      ;; Scripts:
      (script (@ (src ,(hfweb-url"static/base/highlight/highlight.min.js"))))
      (script (("hljs.highlightAll();")))
      ;; Additional scripts.
      ,@(map (lambda (script)
	       `(script (@ (src ,script)) ""))
	     scripts))

     (body
      ,(navbar #:active-item active-menu-item)

      ,(if (null? crumbs) "" (breadcrumbs crumbs))

      ,content
      ,(G_
        `(footer
          "Powered by "
          ,(G_ `(a
                 (@ (class "link-yellow")
                    (href ,(gnu-url "software/guile/")))
                 "GNU Guile"))
          ".  Website "
          ,(G_ `(a
                 (@ (class "link-yellow")
                    (href "https://git.harmonicflow.org/cgi-bin/cgit.cgi/hf-web.git/"))
                 "  Source code"))
          " is licensed the "
          ,(G_ `(a
                 (@ (class "link-yellow")
                    (href ,(gnu-url "licenses/agpl-3.0.html")))
                 "GNU AGPL"))
          "."))))))