; Blogue for MOC
; Copyright 2005 Jay McCarthy <>
(module blogue-moc mzscheme
  (require (lib "" "srfi" "19")
           (lib "" "net")
           (lib "")
           (lib "" "xml")
           (lib ""))
  (require ""
  (provide config@)
  (define config@
    (unit/sig blogue-config^
      ; Config
      (define BuildRoot "/Users/jay/Documents/makeoutcity/")
      (define PostRoot "/Users/jay/Documents/makeoutcity/data/makeoutcity")
      (define RsyncPath "")
      (define DaysInRSS 7)
      (define PostsInCategory 100)
      (define Link `("/Users/jay/Documents/makeoutcity/Static/Downloads"
      (define SiteTitle "")
      (define SiteURL "")
      (define AtomURL (format "~a~a" SiteURL "RSS/index.atom"))
      (define Author "Jay McCarthy")
      (define AuthorEmail "")
      (define AuthorAIM "emontapartimejob")
      (define ImagePath "/Images/je_apostrophe.jpg")
      (define Tagline "\"all you need are kisses to start a makeout party\"")
      (define ICBM "42.756395, -71.466684")
      (define CopyrightYears "2003-2005")
      (define Navigation
        `( ("About" "/Categories/About/Author")
           ("Archives" "/Archives")
           ("Categories" "/Categories")))
      ; Templates
      (define (MainTemplate Title Previous Next DisplayAds Body)
        `(html ([xmlns ""] [xml:lang "en"])
               (head (meta ([http-equiv "Content-type"] [content "text/html; charset=utf-8"]))
                     (title ,SiteTitle ": " ,@Title)
                     (meta ([name "MSSmartTagsPreventParsing"] [content "true"]))
                     (meta ([name "author"] [content ,Author]))
                     (meta ([name "robots"] [content "all"]))
                     (meta ([name "ICBM"] [content ,ICBM]))
                     (link ([rel "alternate"] [type "application/rss+xml"] [title "RSS 2.0"] [href "/RSS/index.xml"]))
                     (link ([rel "alternate"] [type "application/rss+xml"] [title "RSS 0.91"] [href "/RSS/index.rss"]))
                     (link ([rel "home"] [title "Home"] [href ,SiteURL]))
                     (link ([rel "stylesheet"] [type "text/css"] [href ,(string-append SiteURL "/style.css")] [media "all"])))
                (div ([id "drop"])
                     (div ([id "tag"])
                          (div ([id "title"])
                               (strong (a ([href "/"]) ,SiteTitle))
                               " - "
                          (div ([id "nav"])
                               ,@(apply append (map (lambda (link)
                                                      `((a ([href ,(list-ref link 1)]) ,(list-ref link 0)) nbsp nbsp nbsp))
                               nbsp nbsp nbsp nbsp nbsp nbsp
                               #| nbsp nbsp nbsp nbsp nbsp nbsp |#
                               ,(if Previous
                                    `(a ([href ,Previous]) "Previous")
                               " / "
                               ,(if Next
                                    `(a ([href ,Next]) "Next")
                (div ([id "MainText"])
                     (div ([class "padder"])
                     ,@(if DisplayAds
                           `((div ([class "padder"] [id "adfooter"])
                                  (script ([type "text/javascript"])
                                          "google_ad_client = \"pub-8940021471694041\";
				     google_ad_width = 336;
				     google_ad_height = 280;
				     google_ad_format = \"336x280_as\";
				     google_ad_channel = \"\";
				     google_color_border = \"C8D4EB\";
				     google_color_bg = \"F4F7FC\";
				     google_color_link = \"000000\";
				     google_color_url = \"339900\";
				     google_color_text = \"000000\";")
                                  (script ([type "text/javascript"] [src ""]))))
                     (div ([class "padder"] [id "footer"])
                          (p "You're visiting "
                             (a ([href "/"]) ,SiteTitle)
                             ". All content by "
                             (a ([href "/Categories/About/Author"]) ,Author)
                             " (" (a ([href ,(string-append "mailto:" AuthorEmail)]) "contact me") ") "
                             "unless otherwise noted, with restrictions on its use specified by a "
                             (a ([href ""]) "Creative Commons License") ". "
                             "When I am syndicating, I prefer "
                             (a ([href ""]) "RSS") ". "
                             "When I am blogging, I use "
                             (a ([href ""]) "blogue") " and "
                             (a ([href ""]) "Tinderbox") ". " 
                             "For design elements, I steal from " (a ([href ""]) "The Web Standards Project") " and "
                             (a ([href ""]) "") ". "
                             "I am a member of " 
                             (a ([href ""]) "Technorati") 
                             ", " (a ([href ""]) "GeoURL") ", and "
                             (a ([href ""]) "orkut") ".")))
                (div ([id "SubNav"])
                     (h3 "What is this place?")
                     (p "This is a part of the " (a ([href "/"]) ,SiteTitle " weblog") ", by me, " (a ([href ""]) ,Author) ". (Click on my name if you're interested in a general site.) If you would like to contact me, I prefer email being sent to " (a ([href ,(string-append "mailto:" AuthorEmail)]) ,AuthorEmail) ", but I also use the AIM account " (strong ,AuthorAIM) ".")
		     (p "The archives on this site may or may not reflect my current opinions and ideas. I don't think it is prudent to be deleting things from it, or manually tagging everything I disagree with as such. So, take everything you see with the appropriate quantity of salt. Also, I don't typically proof-read this site, because most of its content is primarily a reference for my future self.")
                     (p "I read a fair amount, and currently I am reading:")
                      (p "Something... it has been changing so often lately."))
                     (p "If you're interesting in what I've read in the past, I have " (a ([href "/Categories/Books"]) "special section") " of my blog for that purpose.")
                     (p "I am currently a Ph.D. student at " (a ([href ""]) "Brown University") " at the " (a ([href ""]) "Computer Science Department") ". I am working with " (a ([href ""]) "Shriram Krishnamurthi") ".")
                     (p "I recently graduated from the " (a ([href ""]) "University of Massachusetts at Lowell") " where I studied computer science, mathematics, and economics.")
                     (p "I am currently studying human languages at " (a ([href ""]) "The Intercontinental Foreign Language School") ". The languages in question are:")
                      (p "Arabic, French, German, Hebrew, Italian, and Spanish.")
                      (p "(I used to study Hindi, Mandarin Chinese, and Russian, but they are on the backburner for a little while.)"))
                     (p "Sometimes I write " (a ([href "/Categories/FLP/Letters"]) "letters") " and poetry in these languages for practice. If you know an interesting language and would like to trade for English, I'm very interested, just " (a ([href ,(string-append "mailto:" AuthorEmail)]) "email me") ".")
                     (p "If you use aggregator software like " (a ([href ""]) "NetNewsWire") ", you may want my " (a ([class "button"] [href ,AtomURL] [title "Syndication Feed for"]) "Syndication Feed") ".")
                     (p "If you " (strong (em "really")) " like my work, you can buy me stuff from my " (a ([href ""]) "Amazon Wish List") " or look at the Google Ads on some of the pages. But I would prefer that you " (a ([href ""]) "start your own weblog") ", so I can read what " (em "you") " have to say. Or, you can display your tastes with some " (a ([href ""]) "merchandise from CafePress") ".")
                     (p nbsp)))))
      (define (EntryTemplate Permapath PostDate Categories EntryTitle EntryBody)
        `(div ([class "post"])
              (div ([class "postMetaInfo"])
                   (div ([class "postDate"])
                        (a ([href ,Permapath] [title "Permanent Link For This Post"])
                           ,(date->string PostDate "~Y/~m/~d ~H:~M")))
                   (div ([class "postAuthor"]) 
                        "Posted by " (a ([href ""] 
                                         [title "About This Author"]) ,Author))
                   (div ([class "postTopics"]) 
                        "Filed under: " ,@(apply append 
                                                 (map (lambda (category)
                                                        `((a ([href ,(string-append SiteURL "/Categories" category)])
                                                             ,category) " "))
                   (div ([class "postDiscussion"])
                        "Discussion: " (a ([href ,(string-append
                                                   (uri-encode (string-append SiteURL Permapath)))]) "reddit")))
              (h2 ([class "postTitle"]) ,@EntryTitle)
              (div ([class "postContent"])
      (define (Atom/2005 Entries)
        `(feed ([xmlns ""])
               (title ,SiteTitle)
               (link ([href ,SiteURL]))
               (link ([rel "self"] [href ,AtomURL]))
               (updated ,(Post-Date/3339 (first Entries)))
                (name ,Author))
               (id ,SiteURL)
               ,@(map (lambda (Entry)
                          (title ,@(Post-Title Entry))
                          (link ([href ,(Post-Permapath Entry)]))
                          (id ,(format "~a~a" SiteURL (Post-Permapath Entry)))
                          (updated ,(Post-Date/3339 Entry))
                          (content ([type "html"])
                                   ,@(map xexpr->string (Post-Content Entry)))))
      (define (RSS/0.91 Entries)
        `(rss ([version "0.91"] [xmlns:rssHints ""])
               (title ,SiteTitle)
               (link ,SiteURL)
               (description ,SiteTitle ", by " ,Author)
               (language "en")
               (rssHints:containsSameDataAs ,SiteURL "/RSS/index.xml")
               (rssHints:descriptionContains "fullText")
               ,@(map (lambda (Entry)
                        `(item (title ,@(Post-Title Entry))
                               (link ,(Post-Permapath Entry))
                               (description ,@(map xexpr->string (Post-Content Entry)))))
      (define (RSS/2.0 Entries)
        `(rss ([version "2.0"] 
               [xmlns:rssHints ""]
               [xmlns:creativeCommons ""])
               (title ,SiteTitle)
               (link ,SiteURL)
               (description ,SiteTitle ", by " ,Author)
               (language "en-us")
               (copyright ,CopyrightYears " " ,Author)
               (managingEditor ,AuthorEmail)
               (webMaster ,AuthorEmail)
               (creationCommons:license "")
                (url ,SiteURL ,ImagePath)
                (link ,SiteURL)
                (title ,SiteTitle ", by " ,Author))
               (docs "")
               (generator "blogue")
               (ttl "40")
               (rssHints:containsSameDataAs ,SiteURL "/RSS/index.xml")
               (rssHints:descriptionContains "fullText")
               ,@(map (lambda (Entry)
                        `(item (title ,@(Post-Title Entry))
                               (description ,@(map xexpr->string (Post-Content Entry)))
                               (pubDate ,(date->string (Post-Date-tm Entry) "~a, ~d-~b-~Y ~X ~z"))
                               (guid ,(Post-Permapath Entry))
                               (link ,(Post-Permapath Entry))
                               (creativeCommons:license "")
                               ,@(map (lambda (category)
                                        `(category ([domain ,(string-append SiteURL "/Categories")]) ,category))
                                      (map bytes->string/utf-8 (Post-Category Entry)))))