summaryrefslogtreecommitdiff
path: root/website/www.scm
blob: 05575200f5f0d2c67da4a217b67537344c9e84fb (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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
(define-module (www)
  #:use-module (www utils)
  #:use-module (www shared)
  #:use-module (www packages)
  #:use-module (www download)
  #:use-module (www donate)
  #:use-module (www about)
  #:use-module (www contribute)
  #:use-module (www help)
  #:use-module (sxml simple)
  #:use-module (sxml match)
  #:use-module (web client)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-9)
  #:use-module (srfi srfi-19)
  #:use-module (srfi srfi-26)
  #:use-module (ice-9 match)
  #:export (main-page

            %web-pages
            export-web-page
            export-web-site))

(define %atom-url
  ;; The web site's news feed.
  "http://savannah.gnu.org/news/atom.php?group=guix")

(define (fetch-news)
  "Return the SXML tree of the Atom news feed."
  (call-with-values
      (lambda ()
        (http-get %atom-url))
    (lambda (response contents)
      (call-with-input-string contents
        (lambda (port)
          (xml->sxml port
                     #:namespaces '((atom . "http://www.w3.org/2005/Atom")
                                    (x . "http://www.w3.org/1999/xhtml"))
                     #:trim-whitespace? #t))))))

(define-record-type <news-entry>
  (news-entry url title date author content)
  news-entry?
  (url      news-entry-url)                       ;string
  (title    news-entry-title)                     ;string
  (date     news-entry-date)                      ;SRFI-19 date
  (author   news-entry-author)                    ;sxml
  (content  news-entry-content))                  ;sxml

(define (news-items)
  "Return the list of <news-entry> taken from the web site's RSS feed."
  (sxml-match (fetch-news)
    ((*TOP* (*PI* ,pi ...)
            (atom:feed
             (atom:id ,feed-id)
             (atom:link)
             (atom:title ,feed-title)
             (atom:updated ,feed-updated)
             (atom:entry
              (atom:id ,id)
              (atom:link (@ (href ,link)))
              (atom:title ,title)
              (atom:updated ,updated)
              (atom:author ,author)
              (atom:content ,content)
              ,rest ...)
             ...
             ))
     (map news-entry
          link title
          (map (cut string->date <> "~Y-~m-~d") updated)
          author content))))

(define (sxml->string* tree)
  "Flatten tree by dismissing tags and attributes, and return the resulting
string."
  (define (sxml->strings tree)
    (match tree
      (((? symbol?) ('@ _ ...) body ...)
       (append-map sxml->strings body))
      (((? symbol?) body ...)
       (append-map sxml->strings body))
      ((? string?)
       (list tree))))

  (string-concatenate (sxml->strings tree)))

(define (summarize-string str n)
  "Truncate STR at the first space encountered starting from the Nth
character."
  (if (<= (string-length str) n)
      str
      (let ((space (string-index str #\space n)))
        (string-take str (or space n)))))

(define (news-entry->sxml entry)
  "Return the an SXML tree representing ENTRY, a <news-entry>."
  `(a (@ (href ,(news-entry-url entry))
         (class "news-entry"))
      (h4 ,(news-entry-title entry))
      (p (@ (class "news-date"))
         ,(date->string (news-entry-date entry) "~B ~e, ~Y"))
      (p (@ (class "news-summary"))
         ,(summarize-string (sxml->string* (news-entry-content entry))
                            230)
         "…")))

(define (main-page)
  `(html (@ (lang "en"))
	 ,(html-page-header "Home" #:css "index.css")
	 (body
	  ,(html-page-description)
	  ,(html-page-links)
	  (div (@ (id "content-box"))
	       (div (@ (id "featured-box"))
		    (div (@ (class "featured-content"))
			 (h1 (@ (class "featured-heading"))
			     "The Guix System Distribution")
			 (ul (li (b "Liberating.")
				 " GuixSD is an advanced distribution of the "
				 (a (@ (href ,(gnu-url ""))
				       (class "hlink-yellow"))
				    "GNU Operating System")
				 " developed by the "
				 (a (@ (href ,(gnu-url ""))
				       (class "hlink-yellow"))
				    "GNU Project ")
				 "—which respects the "
				 (a (@ (href ,(gnu-url "philosophy/free-sw.html"))
				       (class "hlink-yellow"))
				    "freedom of computer users")
				 ". ")
			     (li (b "Dependable.")
				 " The "
				 (a (@ (href ,(guix-url "manual"))
				       (class "hlink-yellow"))
				    "GNU Guix")
				 " package manager, in addition to standard
package management features, supports transactional upgrades and roll-backs,
unprivileged package management, per-user profiles, and garbage collection.")
			     (li (b "Hackable.")
				 " It provides "
				 (a (@ (href ,(gnu-url "software/guile/"))
				       (class "hlink-yellow"))
				    "Guile Scheme")
				 " APIs, including high-level embedded
domain-specific languages (EDSLs), to describe how packages are built and
composed."))
			 (div (@ (class "featured-actions"))
			      (a (@ (href ,(base-url "download"))
				    (class "action download"))
				 "TEST v" ,(latest-guix-version) " (alpha)")
			      (a (@ (href ,(base-url "contribute"))
				    (class "action contribute"))
				 "CONTRIBUTE"))))
	       (div (@ (id "discovery-box"))
		    (h2 "Discover GuixSD")
		    (div (@ (class "info-box text-center"))
			 (video (@ (src "http://audio-video.gnu.org/video/misc/2015-01__GNU_Guix__The_Emacs_of_Distros.webm")
				   (poster
				    ,(image-url "the-emacs-of-distros.png"))
				   (controls "controls")
				   (class "video-preview")))
			 (p "January 2015, The Emacs of Distros (48 minutes)")
			 (p (a (@ (href ,(base-url "help/#talks"))
				  (class "hlink-more-light"))
			       "Check all talks")))
		    (div (@ (class "info-box text-left"))
			 (p (a (@ (href ,(guix-url "manual"))
				  (class "hlink-yellow"))
			       "GNU Guix Documentation")
			    (br)
			    "You may also find more information about GNU Guix
by running info guix.")
			 (p (a (@ (href "http://arxiv.org/abs/1305.4584")
				  (class "hlink-yellow"))
			       "Functional Package Management with Guix")
			    (br)
			    "A paper presented at the 2013 European Lisp
Symposium (ELS), describes the rationale, design, and implementation of Guix's
packaging API. ")
			 (p (a (@ (href "http://www.gnu.org/manual/")
				  (class "hlink-yellow"))
			       "GNU Manuals Online")
			    (br)
			    "Primary documentation for official GNU packages.")
			 (p (a (@ (href ,(base-url "help"))
				  (class "hlink-more-light"))
			       "Find more documentation")))
		    (img (@ (src ,(image-url "h-separator-darker.png"))
			    (class "h-separator")
			    (alt "")))
		    (div (@ (id "screens-box"))
			 (a (@ (href ,(screenshot-url "0.8.2" "grub-menu.png")))
			    (img (@ (src ,(thumb-url "grub-menu-thumb.png"))
				    (class "screenshot-thumb")
				    (alt "GRUB menu"))))
			 (a (@ (href ,(screenshot-url "0.8.2" "slim.png")))
			    (img (@ (src ,(thumb-url "slim-thumb.png"))
				    (class "screenshot-thumb")
				    (alt "Slim login manager"))))
			 (a (@ (href ,(screenshot-url "0.8.2" "windowmaker+icecat+inkscape.png")))
			    (img (@ (src ,(thumb-url "windowmaker+icecat+inkscape-thumb.png"))
				    (class "screenshot-thumb")
				    (alt "Windowmaker, Icecat, and Inkscape"))))
			 (a (@ (href ,(screenshot-url "0.8.2" "user-interfaces.png")))
			    (img (@ (src ,(thumb-url "user-interfaces-thumb.png"))
				    (class "screenshot-thumb")
				    (alt "mplayer and xterm"))))
			 (a (@ (href ,(screenshot-url "0.8.2" "emacs-ui-packages.png")))
			    (img (@ (src ,(thumb-url "emacs-ui-packages-thumb.png"))
				    (class "screenshot-thumb")
				    (alt "Emacs user interface to the package manager."))))
			 (a (@ (href ,(screenshot-url "0.8.2" "emacs-ui-generations.png")))
			    (img (@ (src ,(thumb-url "emacs-ui-generations-thumb.png"))
				    (class "screenshot-thumb")
				    (alt "Emacs user interface generations.")))))
		    (p (a (@ (href ,(base-url "contribute") )
			     (class "hlink-yellow-boxed"))
			  "Help us package more software →")))

	       (div (@ (id "news-box"))
		    (h2 "News")
		    ,@(map news-entry->sxml (take (news-items) 3))
		    (p (a (@ (href "https://savannah.gnu.org/news/?group=guix")
			     (class "hlink-more-dark"))
			  "More news")))

	       (div (@ (id "contact-box"))
		    (h2 "Contact")
		    (div (@ (class "info-box text-justify"))
			 (h3 "IRC Channel")
			 (p "Some Guix users and developers hang out on the
#guix channel of the Freenode IRC network. "
			    (small "(See "
				   (a (@ (href "https://gnunet.org/bot/log/guix/"))
				      "channel logs")
				   ")")
			    ".")

                         ;; XXX: Doesn't feel right to (1) suggest a JS
                         ;; client, and (2) make it too easy to join the
                         ;; channel.
			 ;; (p (@ (class "text-right"))
			 ;;    (a (@ (href "http://webchat.freenode.net/?channels=%23guix")
			 ;;          (class "button btn-blue"))
			 ;;       "Connect"))

			 (h3 "Report Bugs")
			 (p "Use the bugs mailing list to report bugs. Please
check whether the bug is already in the "
			    (a (@ (href "http://debbugs.gnu.org/cgi/pkgreport.cgi?pkg=guix"))
			       "bug database")
			    ".")
			 (p (@ (class "text-right"))
			    (a (@ (href "mailto:bug-guix@gnu.org")
				  (class "button btn-red"))
			       "Report")))

		    (div (@ (class "info-box text-left"))
			 (h3 "Mailing Lists")
			 (p (a (@ (href "https://lists.gnu.org/mailman/listinfo/guix-devel"))
			       (b "guix-devel"))
			    (small " ("
				   (a (@ (href "https://lists.gnu.org/archive/html/guix-devel"))
				      "archive")
				   ")")
			    (br)
			    "Discussion about the development of GNU Guix and
the Guix System Distribution (GuixSD).")
			 (p (a (@ (href "https://lists.gnu.org/mailman/listinfo/bug-guix"))
			       (b "bug-guix"))
			    (small " ("
				   (a (@ (href "https://lists.gnu.org/archive/html/bug-guix"))
				      "archive")
				   ")")
			    (br)
			    "Bug reports for GNU Guix and the Guix System
Distribution.")
			 (p (a (@ (href "https://lists.gnu.org/mailman/listinfo/gnu-system-discuss"))
			       (b "gnu-system-discuss"))
			    (small " ("
				   (a (@ (href "http://lists.gnu.org/archive/html/gnu-system-discuss/"))
				      "archive")
				   ")")
			    (br)
			    "Discussion about the development of
the broader GNU system.")

			 (p (a (@ (href ,(base-url "about#contact"))
				  (class "hlink-more-dark"))
			       "Find all the available lists")))))
	  ,(html-page-footer))))


;;;
;;; HTML export.
;;;

(define %web-pages
  ;; Mapping of web pages to HTML file names.
  `(("index.html" ,main-page)
    ("about/index.html" ,about-page)
    ("contribute/index.html" ,contribute-page)
    ("donate/index.html" ,donate-page)
    ("download/index.html" ,download-page)
    ("help/index.html" ,help-page)
    ("packages/index.html" ,packages-page)))

(define (mkdir* directory)
  "Make DIRECTORY unless it already exists."
  (catch 'system-error
    (lambda ()
      (mkdir directory))
    (lambda args
      (unless (= EEXIST (system-error-errno args))
        (apply throw args)))))

(define (export-web-page page file)
  "Export PAGE, an SXML tree, to FILE."
  (mkdir* (dirname file))
  (call-with-output-file file
    (lambda (port)
      (sxml->xml page port))))

(define* (export-web-site #:optional (directory "."))
  "Export the whole web site as HTML files created in DIRECTORY."
  (for-each (match-lambda
              ((filename page)
               (export-web-page (page)
                                (string-append directory
                                               file-name-separator-string
                                               filename))))
            %web-pages))

;; Local Variables:
;; eval: (put 'sxml-match 'scheme-indent-function 1)
;; End: