-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-web-site.sch
1539 lines (1360 loc) · 54 KB
/
build-web-site.sch
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; TBD: File download sizes
; To generate HTML from this file, start Scheme 48 (from s48.org) and
; issue the commands ",config ... (doit ...)" below, replacing
; <target-directory> with a directory of your choice that is not a
; subdirectory of this one.
;
; Or use the Makefile.
; This is REALLY UGLY CODE, please don't hold me to it
(define articles-root "http://psyche.entclub.org/pdf/")
;(define text-files-root "/Users/jar/Scratch/Psyche/text/")
(define text-files-root "text/") ;; or ../text/
(define cec-base-url "http://psyche.entclub.org/")
"
,bench
,config ,load web/web-config.scm
,open define-record-types sorting c-system-function tables
,open extended-ports signals posix-files
,open html xml web-utils
,load pdf-file-sizes.sch bhl/first-pages.sch build-web-site.sch
,load articles.sch journal-meta.sch dois.sch
(doit <toc> <outdir>) ;toc/processed-toc.txt build
"
(define (testit) (doit "toc.txt" "~/Scratch/Psyche/build"))
; There is a module system conflict: both POSIX and HTML export
; bindings of LINK.
;
; We would need the POSIX structure only for mkdir -p (formerly we
; also used it for the file existence check).
; Use C-SYSTEM-FUNCTION instead of POSIX for now.
(define (doit toc-file build-dir)
(do-quick-part toc-file build-dir)
(do-slow-part-1 build-dir))
(define (do-quick-part toc-file build-dir)
(read-prepared-toc-file toc-file)
(message "index.html")
(write-page build-dir
"index.html"
(make-main-page "index.html"))
(message "master-toc.html")
(write-page build-dir
"master-toc.html"
(make-master-toc-page "master-toc.html"))
(message "about.html")
(write-page build-dir
"about.html"
(make-about-page "about.html"))
(message "contact.html")
(write-page build-dir
"contact.html"
(make-contact-page "contact.html")))
(define (message x) (display x) (newline))
(define (do-slow-part toc-file build-dir)
(read-prepared-toc-file toc-file)
(do-slow-part-1 build-dir))
(define (do-slow-part-1 build-dir)
(system (string-append "mkdir -p "
(path->filename build-dir "metadata")))
;; (write-articles-metadata (all-volumes-with-tocs) build-dir) -- too big, now split among vols
(for-each (lambda (volnum)
(process-one-volume volnum build-dir))
(cdr (iota 104))
)
(newline))
(define-record-type article :article
(make-article stem title authors volume year pages issue id doi bhl comments)
(stem article-stem) ;E.g. "30-013" for PDF file, if any
(title article-title)
(authors article-authors) ;list of authors
(volume article-volume)
(year article-year)
(pages article-pages set-article-pages!)
(id article-id) ;sequential within volume
(issue article-issue)
(doi article-doi)
(bhl article-bhl)
(comments article-comments))
; Write TOC page, and one 'stub' page per article.
(define (process-one-volume volnum build-dir)
(let ((articles (create-article-list volnum)))
(if articles
(begin
(display volnum) (display #\space)
;; Directory will need to be created if only to hold the toc file.
(system (string-append "mkdir -p "
(path->filename build-dir (number->string volnum))))
(let ((volpath (path-to-toc volnum)))
(write-page build-dir
volpath
(make-volume-toc-page volnum articles build-dir volpath)))
(for-each (lambda (article)
(if (and article (article-stem article) (prepared? article))
;; Write the article's own page.
(write-article-page article build-dir)))
articles)
(write-volume-metadata volnum
(path->filename build-dir (path-to-metadata volnum)))))))
(define (create-article-list volnum)
(let ((toc (get-volume-toc volnum))
(prepared (get-volume-scans volnum))) ;List of 'stems' vv-ppp
(if toc
;; Augment TOC with any additional files listed in
;; the prepared articles list.
(if prepared
(list-sort article<
(append toc
(map (lambda (id)
(dummy-article-info volnum id))
(filter (lambda (id)
(and (string? id)
(not (maybe-article-info volnum id))))
prepared))))
toc)
;; No TOC yet; just use the prepared article list (e.g. volume 1).
(if prepared
(map (lambda (id)
(dummy-article-info volnum id))
prepared)
#f))))
(define (article< a1 a2)
(if (= (article-volume a1) (article-volume a2))
(if (and (string? (article-stem a1))
(string? (article-stem a2)))
(string<? (article-stem a1)
(article-stem a2))
(< (car (article-pages a1))
(car (article-pages a2))))
(< (article-volume a1) (article-volume a2))))
(define (make-volume-toc-page volnum articles build-dir here)
(let* ((prepared (get-volume-scans volnum)) ;List of stems "30-013"
(aux (if prepared
(filter (lambda (x) (not (integer? x)))
prepared)
'())))
(make-articles-page (span "Volume " volnum
" (" (volume->years volnum) ")")
articles
(compose-aux-links aux volnum here)
(string-append "Psyche "
(number->string volnum))
here)))
(define (compose-aux-links aux volnum here)
(let ((issue-numbers ; (reverse ...) ;foo
(filter (lambda (x) x)
(map cover-info aux))))
;; TBD: also deal with Index and stray-plates.
(span (map (lambda (issue-number)
(p (span (class= "contentlink")
(a (href= ;; (symbol->string aux-thing)
(string-append articles-root
(number->string volnum)
"/"
(number->string volnum)
"-covers-n" issue-number ".pdf"))
;; Text is
"Front and back matter for issue "
issue-number))))
issue-numbers)
(if (memq 'index aux)
(p (span (class= "contentlink")
(a (href=
(string-append articles-root
(number->string volnum)
"/"
(number->string volnum)
"-index" ".pdf"))
"Index to volume "
volnum)))
(span))
(p (a (rlink (path-to-metadata volnum) here)
"Table of contents metadata (XML)")))))
; Not sure where to put the .xml file: in the volume directory
; (e.g. 10/metadata.xml), or in a metadata directory (metadata/10.xml)?
(define (path-to-metadata volnum)
(cons "metadata" (string-append (number->string volnum) ".xml")))
; If article name starts with "covers-n" then return the issue number
; as a string.
(define (cover-info sc)
(if (symbol? sc)
(let ((z (symbol->string sc)))
(if (and (> (string-length z) 8)
(equal? (substring z 0 8) "covers-n"))
(substring z 8 (string-length z)) ;e.g. "1+2"
#f))
#f))
(define (path-to-toc volnum)
(path-in-volume volnum "toc.html"))
; Returns a URI reference
(define (path-to-landing-page article)
(let ((stem (article-stem article)))
(if (and stem
(table-ref pdf-file-sizes stem))
(path-in-volume (article-volume article)
(string-append stem
".html"))
#f)))
(define (path-in-volume volnum path)
(cons (number->string volnum) path))
(define (create-stem volnum id)
(let ((id (stringify id)))
(string-append (number->string volnum)
"-"
(case (string-length id)
((1) "00")
((2) "0")
(else ""))
id)))
(define (parse-stem stem)
(let* ((chars (string->list stem))
(tail (member #\- chars))
(page-part (list->string (cdr tail)))
(page-num (string->number page-part))
(volnum (string->number (list->string (sublist chars 0 (- (length chars) (length tail)))))))
(list volnum (or page-num page-part))))
(define (write-article-page article build-dir)
(let ((path (path-to-landing-page article)))
(if path
(write-page build-dir
path
(make-article-landing-page path article)))))
; Quoth Google Scholar on May 10, 2007:
;
; We recommend embedding the following tags* within your articles' abstract
; pages:
;
; <meta name="citation_journal_title" content="Journal Name">
; <meta name="citation_authors"
; content="Last Name1, First Name1; Last Name2, First Name2">
; <meta name="citation_title" content="Article Title">
; <meta name="citation_date" content="01/01/2007">
; <meta name="citation_volume" content="10">
; <meta name="citation_issue" content="1">
; <meta name="citation_firstpage" content="1">
; <meta name="citation_lastpage" content="15">
; <meta name="citation_doi" content="10.1074/jbc.M309524200">
; <meta name="citation_pdf_url"
; content="http://www.publishername.org/10/1/1.pdf">
; <meta name="citation_abstract_html_url"
; content="http://www.publishername.org/cgi/content/abstract/10/1/1">
; <meta name="citation_fulltext_html_url"
; content="http://www.publishername.org/cgi/content/full/10/1/1">
; <meta name="dc.Contributor" content="Last Name1, First Name1">
; <meta name="dc.Contributor" content="Last Name2, First Name2">
; <meta name="dc.Title" content="Article Title">
; <meta name="dc.Date" content="01/01/2007">
; <meta name="citation_publisher" content="Publisher Name">
; Table of contents for one volume or for a set of articles (query result?)
(define (make-article-landing-page here article)
(apply-meta-boilerplate
here
(string-append "Psyche "
(number->string (article-volume article))
":"
(article-page-range article))
(make-google-scholar-stuff here article)
(div
(p (if (not (null? (article-authors article)))
(list (span (class= "authors")
(maybe-with-period
(andify (article-authors article))))
(br))
'())
(span (class= "title")
(maybe-with-period
(article-title article)))
(br)
(maybe-with-period
(article-reference article)))
(p (let ((doi-url (article-doi-url article)))
(if doi-url
(list (span (class= "stableurl")
"This article at Hindawi Publishing: "
(a (href= doi-url) doi-url))
(br))
'()))
(let ((bhl-url (article-bhl-url article)))
(if bhl-url
(list (span (class= "stableurl")
"This article at Biodiversity Heritage Library: "
(a (href= bhl-url) bhl-url))
(br))
'()))
(span (class= "contentlink")
(let ((url (article-cec-pdf-url article here)))
(if url
(list "CEC's scan of this article: "
(a (href= url) url)
(let ((size (table-ref pdf-file-sizes (article-stem article))))
(if size
(list ", " size "K")
'()))
(br))
'())))
(let ((cec-url (string-append cec-base-url
(path->string here))))
(list (span (class= "stableurl")
"This landing page: "
(a (href= cec-url) cec-url))
(br)))
(make-article-abstract article)
(hr)
(let ((volnum (article-volume article)))
(span (a (rlink (path-to-toc volnum) here)
"Volume " volnum " table of contents")))
))))
(define (make-google-scholar-stuff here article)
(let ((title-string (article-title-string article))
(inverted-authors (map (lambda (name)
(invert-name (remove-markup name)))
(article-authors article))))
(list (meta (name= "citation_journal_title")
(content= "Psyche"))
;; authors
(if (not (null? inverted-authors))
(meta (name= "citation_authors")
(content=
(apply string-append
(car inverted-authors)
(apply append (map (lambda (inv)
(list "; " inv))
(cdr inverted-authors))))))
'())
(meta (name= "citation_title")
(content= title-string))
(meta (name= "citation_date")
(content= (article-year article)))
(meta (name= "citation_volume")
(content= (article-volume article)))
(let ((issue (article-issue article)))
(if issue
(meta (name= "citation_issue")
(content= issue))
(begin
(if (not (null? (article-authors article)))
(begin (write `(missing issue: ,(article-volume article) ,@(article-pages article)))
(newline)))
'()))) ;?
(let ((pages (article-pages article)))
(if pages
(list (meta (name= "citation_firstpage")
(content= (car pages)))
(if (integer? (cadr pages))
(meta (name= "citation_lastpage")
(content= (cadr pages)))
'()))
'()))
(let ((cec-url (article-cec-pdf-url article here)))
(if cec-url
(meta (name= "citation_pdf_url")
(content= cec-url))))
(meta (name= "citation_publisher")
(content= "Cambridge Entomological Club"))
;; citation_abstract_html_url
;; citation_fulltext_html_url
(meta (name= "dc.Title")
(content= title-string))
(meta (name= "dc.Date")
(content= (article-year article)))
(map (lambda (author)
(meta (name= "dc.Contributor")
(content= (remove-markup author))))
inverted-authors))))
(define doi-prefix "https://doi.org/")
(define (article-doi-url article)
(if (article-doi article)
(string-append doi-prefix (article-doi article))
(if (article-pages article)
(let* ((key (vpq->key (article-volume article)
(car (article-pages article))
(cadr (article-pages article))))
(doi-list (table-ref dois key)))
(if (pair? doi-list)
(if (null? (cdr doi-list))
(string-append doi-prefix (car doi-list))
#f) ;Ambiguous... normal
;; TBD: filter out "Exchange Column"
#f))
#f)))
(define first-pages-table (make-string-table))
(for-each (lambda (first-page)
(table-set! first-pages-table (car first-page) (cadr first-page)))
first-pages)
(define (article-bhl-url article)
(let ((pageid (or (article-bhl article)
(table-ref first-pages-table (bhl-key article)))))
(if pageid
(string-append "https://www.biodiversitylibrary.org/page/"
pageid)
#f)))
(define (bhl-key article)
(let ((pages (article-pages article)))
(if pages
(string-append (number->string (article-volume article))
"-"
(number->string (car pages))
"-"
(if (integer? (cadr pages))
(number->string (cadr pages))
(number->string (car pages))))
"no pages")))
(define (make-article-abstract article)
(if (article-stem article)
(let ((fname (string-append text-files-root
(number->string (article-volume article))
"/"
(article-stem article)
".txt")))
(if (accessible? fname (access-mode read))
(call-with-input-file fname
(lambda (iport)
;; Skip over header. Usually about 6 lines.
(let loop ()
(let ((line (read-line-foo iport)))
(if (eof-object? line)
(warn "ill-formed .txt file")
(if (= (string-length line) 0)
'ok
(loop)))))
(list
(hr)
(p (i "The following unprocessed text is extracted automatically "
"from the PDF file, and "
"is likely to be both incomplete and full of errors. "
"Please consult the PDF file for the complete article."))
(p (reverse
(let loop ((items '()) (count 0))
(let ((line (read-line-foo iport)))
(if (eof-object? line)
items
(let ((items (cons line items)))
(if (> count 5000) ;increased, was 500
items
(loop (if (> (string-length line) 40)
items
(cons (br) items))
(+ count 1))))))))))))
(begin (write `(no text file ,fname)) (newline)
'())))))
;; path may be #f
(define (write-page build-dir path item)
(if path
(call-with-output-file (path->filename build-dir path)
(lambda (port)
(write-item item port)))))
(define (make-master-toc-page here)
(apply-boilerplate here "Psyche master table of contents"
(div
(h3 "Tables of Contents")
(p "For some volumes, articles and/or table of contents are not yet available on this web site.")
(let* ((vs (map (lambda (volnum)
(let ((foo
(td (volume-stuff volnum here))))
foo))
(cdr (iota 104))))
(k 3) ;Number of columns
(n (length vs)) ;103
;; Add dummy entries to end of volumes list
(vs (append vs (map (lambda (i) '()) (cdr (iota k)))))
(n/k (/ (+ n (- k 1)) k))) ;35
(table (width= "100%")
(apply map
(lambda vv (apply tr vv))
(map (lambda (i)
(sublist vs (* i n/k) (* (+ i 1) n/k)))
(iota k))))))))
(define (round-up-to-nearest-multiple n k)
(- (+ n (- k 1)) (remainder (+ n (- k 1)) k)))
(define (volume-stuff volnum here)
(let* ((stuff (span "Volume "
volnum
" ("
(volume->years volnum)
")"))
(stuff (if (get-volume-toc volnum)
stuff
(span "[" stuff "]"))))
(if (or (get-volume-scans volnum)
(get-volume-toc volnum))
(a (rlink (path-to-toc volnum)
here)
stuff)
stuff)))
(define (make-about-page here)
(apply-boilerplate here "About Psyche"
(div
(h3 "About " (i "Psyche"))
(p (i "Psyche") " is a journal for the publication of "
"'biological contributions upon Arthropoda from any competent person.' "
"It was founded in 1874 by the "
(a (href= "http://entclub.org/") "Cambridge Entomological Club")
". "
"The title derives from the Greek word for butterfly. ")
(p "The Club transferred management of the journal to "
(a (href= "http://www.hindawi.com/journals/psyche/")
"Hindawi Publishing Corporation")
" in July 2007. "
"Hindawi "
(a (href= "http://www.hindawi.com/journals/psyche/guidelines.html")
"accepts manuscripts")
" for review "
"and publishes new articles online as the are ready. "
"Access to new articles is open; there are no "
"subscription or access charges.")
(p "The Cambridge Entomological Club will honor written requests for refunds "
"of advance payment to CEC for issues not received (through volume 103). "
"Indicate the amount paid and "
"which issues were expected but not received, "
"and include an email address for correspondence. "
"Address requests to "
"Cambridge Entomological Club,"
" 26 Oxford St., Cambridge, MA 02138.")
(p "The Club has scanned "
"a 95% complete set of back issues "
"and has prepared all 5000+ articles "
"for download from this web site. "
"Articles were scanned at 400 dpi, processed by custom software for "
"contrast enhancement, "
"then processed by Adobe Acrobat for character recognition. ")
(p "The Club's back issues scanning project was made possible "
"by a generous grant from benefactor "
(a (href= "http://people.csail.mit.edu/tk/")
"Tom Knight")
".")
(p "Hindawi has prepared its own archive of back issues, "
"which may be accessed "
(a (href= "http://www.hindawi.com/journals/psyche/contents.html")
"here") ".")
(p "All articles published in "
(i "Psyche")
" prior to 1989 are in the public domain.")
(hr)
(p (a (rlink (path-to-landing-page (get-article-info 81 3)) here)
"History of the Cambridge Entomological Club [and "
(i "Psyche")
"]"))
(p (a (href= "http://www.google.com/search?q=psyche+entomology+-consciousness&ie=UTF-8&oe=UTF-8")
"References to " (i "Psyche")
" on the Internet")
" (Google search)")
(p (a (href= "http://psyche1.entclub.org/options/")
"Memo on the future of " (i "Psyche")))
(p (a (href= "https://github.com/jar398/psyche")
"Source code")
" for this web site")
)))
(define (make-contact-page here)
(apply-boilerplate here "Contact Psyche"
(div
(h3 "Contact " (i "Psyche"))
(p (dl
(dt "As of 2007, " (i "Psyche") " is published by "
(a (href= "http://www.hindawi.com/")
"Hindawi Publishing Corporation")
". All correspondence regarding current publication should be addressed to Hindawi.")))
(p (dl (dt "This archive of " (i "Psyche") " pre 2007 is provided by "
" the Cambridge Entomological Club"
" and is managed by Jonathan A. Rees. "
"Email: "
(a (href= "mailto:[email protected]") "[email protected]"))))
(p (dl
(dt "Address for written correspondence:")
(dd "Cambridge Entomological Club" (br)
"26 Oxford St." (br)
"Cambridge, MA 02138"))))))
; Article has:
; title, authors, citation (volume, issue(?), page number start/end, year),
; abstract-is-on-line flag,
; article-is-on-line flag
(define (make-main-page here)
(make-articles-page "Featured articles"
(featured-articles)
(span)
"Psyche: A Journal of Entomology"
here))
; Make page for a list of articles (usually a table of contents, but
; not always)
(define (make-articles-page heading articles more title here)
(apply-boilerplate here title
(span (h3 heading)
(map (lambda (art)
(if art
(p (div (class= "title")
(article-title-element art here))
(if (not (null? (article-authors art)))
(div (class= "authors")
(maybe-with-period
(andify
(article-authors art))))
(div))
(let ((doi-url (article-doi-url art))
(bhl-url (article-bhl-url art))
(cec-land (path-to-landing-page art))
(cec-pdf (article-cec-pdf-url art here)))
;; One line with several things
(if (not (or doi-url bhl-url cec-land cec-pdf))
(begin
(write `(missing article ,(article-title art)))
(newline)))
(div (class= "accesslinks") ;make smaller
(article-reference art) ;Psyche n:n-n,yyyy
(if doi-url
(list " | "
(a (href= doi-url) doi-url))
'())
(if bhl-url
(list " | "
(a (href= bhl-url) "At BHL"))
'())
(let ()
(if (or cec-land cec-pdf)
(list " | "
(if cec-pdf
(a (href= cec-pdf) "At CEC")
'())
(if (and cec-land cec-pdf)
" "
'())
(if cec-land
(a (rlink cec-land here) "(OCR)")
'()))
'())))))
(div)))
articles)
more)))
(define (prepared? article)
(let ((prepared (get-volume-scans (article-volume article))))
(if prepared
(member (article-id article) prepared)
#f)))
(define (article-title-element art here)
;; title
(strong (maybe-with-period (article-title art))))
(define (article-title-string art)
(remove-markup (article-title art)))
(define (remove-markup item)
(cond ((string? item)
item)
((list? item)
(apply string-append (map remove-markup item)))
((element? item)
(remove-markup (element-content item)))
((entity? item)
(string-append "&"
(entity-name item)
";"))
(else (error "confusing markup" item))))
(define (maybe-with-period x) ; => item
(cond ((pair? x)
(if (null? (cdr x))
(cons (maybe-with-period (car x)) '())
(cons (car x) (maybe-with-period (cdr x)))))
((and (string? x)
(memq (string-ref x (- (string-length x) 1))
'(#\. #\? #\!)))
x)
((not x) "")
(else (list x "."))))
; Relative URL for CEC PDF. #f if none.
(define (article-cec-pdf-url art here)
(if (article-stem art)
(let* ((volnum (number->string (article-volume art)))
(path (cons volnum
(string-append (article-stem art)
".pdf"))))
(string-append articles-root
(path->string path)))
#f))
; The thing that comes after the ':' in a citation
(define (article-page-range art)
(let ((pages (article-pages art)))
(if pages
(let ((p (car pages))
(q (cadr pages)))
(if (equal? p q)
(number->string p)
(string-append (number->string p)
"-"
(stringify q))))
"supplemental")))
; We get this from utils.scm
;(define (stringify x)
; (cond ((number? x) (number->string x))
; ((symbol? x) (symbol->string x))
; (else x)))
(define (article-reference art)
(span (class= "citation")
(i "Psyche ") (strong (article-volume art))
(if (and (article-issue art)
(> (string-length (article-issue art)) 0))
(list "(" (article-issue art) ")"))
":"
(article-page-range art)
", " (article-year art)))
(define-record-discloser :article
(lambda (art)
`(article ,(article-stem art))))
; URI reference to target page relative to here.
; Path ("a" "b" . "c") == "a/b/c"
; Path ("a" "b") == "a/b/"
(define (rlink where here)
(let ((ref (reference where here)))
(if ref
(href= ref)
(class= "selflink"))))
; Creates a relative reference to page 'where' that can be used on
; page 'here'
(define (reference where here) ;Returns a string
(if (and (pair? where)
(pair? here)
(equal? (car where) (car here)))
(reference (cdr where) (cdr here))
(if (equal? where here)
#f
(if (pair? here)
(reference (cons ".." where) (cdr here))
(path->string where)))))
(define (path->string x)
(if (string? x)
x
(if (null? x)
""
(string-append (car x) "/" (path->string (cdr x))))))
(define mood-color "#DCE6FF")
(define (apply-boilerplate here the-title main-stuff)
(apply-meta-boilerplate here the-title '() main-stuff))
(define (apply-meta-boilerplate here the-title meta-elements main-stuff)
(html
(apply head
(title the-title)
(hlink (type= "text/css")
(rel= "stylesheet")
(rlink "style.css" here))
(meta (charset= "utf-8"))
meta-elements)
(body
(table
(width= "100%")
(tr
(td (align= "left") (valign= "top") (width= 170) (height= 170)
(img (src= (reference "seal150.png" here))
(width= 150)
(height= 150)
(alt= "Cambridge Entomological Club, 1874")))
(td (align= "center")
(div (class= "journaltitle")
"PSYCHE")
(br)
(div (class= "journalsubtitle")
"A Journal of Entomology")
(br)
(div (class= "old")
"founded in 1874 by the "
(a (href= "http://entclub.org/")
"Cambridge Entomological Club")))
(if #f
(td (align= "right") (valign= "top") (width= 170)
(div (class= "issn")
"Print ISSN 0033-2615"))
'()))
(tr (td (valign= "top") ;Left gutter
(width= 170)
(bgcolor= mood-color) ;pale blue; ->css
(div (class= "controlbar")
(div (class= "control")
(form (action= "http://google.com/search")
(method= "GET")
"Quick search"
(input (type= "hidden")
(name= "as_sitesearch")
(value= "entclub.org"))
(input (type= "text")
(name= "as_q")
(size= 13))
(input (type= "submit")
(name= "btnG")
(value= "Go!"))))
(div (class= "control")
(a (rlink "master-toc.html" here)
"Contents"))
(div (class= "control")
(a (rlink "index.html" here)
"Home"))
(div (class= "control")
(a (rlink "about.html" here)
"About"))
(div (class= "control")
(a (href= "http://www.hindawi.com/journals/psyche/guidelines.html")
"Author information"))
(div (class= "control")
(a (rlink "contact.html" here)
"Contact"))
; (div (class= "control")
; "Editors"
; (div (class="editors")
; (editor "Naomi E. Pierce"
; "http://www.oeb.harvard.edu/faculty/pierce/people/Naomi/Naomi.html")
; (editor "Edward O. Wilson"
; "http://www-museum.unl.edu/research/entomology/workers/EWilson.htm")))
;
; (div (class= "control")
; "Associate Editors"
; (div (class="editors")
; (editor "Stefan P. Cover"
; "http://www.mcz.harvard.edu/Departments/Entomology/personnel.cfm")
; (editor "J. W. Stubblefield" #f)
; (editor "James F. Traniello"
; "http://www.bu.edu/biology/Faculty_Staff/jft.html")
; ))
;
; (div (class= "control")
; (div (i "Psyche") " Online")
; (div (class="editors")
; (editor "Jonathan A. Rees" "http://mumble.net/~jar")))
(br)
(div (class= "issn")
"Print ISSN 0033-2615")
))
(td (valign= "top")
(table (frame= "border")
(tr
(td
(strong
"This is the CEC archive of "
(i "Psyche") " through 2000. "
(i "Psyche") " is now published by "
(a (href= "http://www.hindawi.com/journals/psyche/contents.html")
"Hindawi Publishing")
"."))))
main-stuff)
(if #f
(td (right-gutter here))
'())
))
)))
; Obsolete
(define (right-gutter here)
(div (valign= "top") ;Right gutter
(width= 180)
(bgcolor= mood-color) ;pale blue; ; ->css
(div (class= "archivebar")
(map (lambda (vol+year)
(list (volume-stuff (car vol+year) here)
(br)))
(reverse (volume-year-alist))))
(br)
))
(define (editor name link)
(p (class= "editor")
(if link
(a (class="editor")
(href= link)
name)
name)))
(define (volume-year-alist)
(map (lambda (volnum)
(list volnum
(let ((toc (get-volume-toc volnum)))
(if toc
(article-year (car toc))
(volume->year volnum)))))
(all-volumes-with-scans)))
; 52-001 VN
; 77-385 H&W recruuitment trails
; 99-015 H&W termite mimic
; 99-003 Eisner
; 102-173 BH & SC
; 78-229 Levi
; 86-091 rhythmic
(define (featured-articles)
(map (lambda (x) (apply get-article-info x))
'((52 001) ;VN
(68 075) ;WB insect control
(77 385) ;H&W recruitment trails
(78 229) ;Levi
(81 3) ;history, again
(86 091) ;rhythmic
(99 003) ;Eisner
(99 015) ;H&W termite mimic
(102 173) ;BH & SC
)))
; Previous set
(define (featured-articles-1)
(list (get-article-info 101 119) ;Prodryas
(get-article-info 101 203) ;Barry Bolton
(get-article-info 100 025) ;H E Evans
(get-article-info 100 163) ;Say
(get-article-info 100 185) ;Richness
(get-article-info 81 3) ;History
))
; Synthesizes article info if not found in TOC
(define (get-article-info volnum id)
(or (maybe-article-info volnum id)
(dummy-article-info volnum id)))