blogue-moc.ss
; Blogue for MOC
; Copyright 2005 Jay McCarthy <jay@kenyamountain.com>
(module blogue-moc mzscheme
  (require (lib "time.ss" "srfi" "19")
           (lib "uri-codec.ss" "net")
           (lib "list.ss")
           (lib "xml.ss" "xml")
           (lib "unitsig.ss"))
  (require "blogue-sig.ss"
           "blogue-post.ss")
  (provide config@)
  
  (define config@
    (unit/sig blogue-config^
      (import)
      ; Config
      (define BuildRoot "/Users/jay/Documents/makeoutcity/www.makeoutcity.com")
      (define PostRoot "/Users/jay/Documents/makeoutcity/data/makeoutcity")
      (define RsyncPath "jay@www.makeoutcity.com:public_html/")
      (define DaysInRSS 7)
      (define PostsInCategory 100)
      (define Link `("/Users/jay/Documents/makeoutcity/Static/Downloads"
                     "/Users/jay/Documents/makeoutcity/Static/Images"
                     "/Users/jay/Documents/makeoutcity/Static/Albums"
                     "/Users/jay/Documents/makeoutcity/Static/style.css"))
      (define SiteTitle "makeoutcity.com")
      (define SiteURL "http://www.makeoutcity.com/")
        
      (define AtomURL (format "~a~a" SiteURL "RSS/index.atom"))
      (define Author "Jay McCarthy")
      (define AuthorEmail "jay@kenyamountain.com")
      (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 "http://www.w3.org/1999/xhtml"] [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"])))
               (body
                (div ([id "drop"])
                     (div ([id "tag"])
                          (div ([id "title"])
                               (strong (a ([href "/"]) ,SiteTitle))
                               " - "
                               ,Tagline)
                          (div ([id "nav"])
                               ,@(apply append (map (lambda (link)
                                                      `((a ([href ,(list-ref link 1)]) ,(list-ref link 0)) nbsp nbsp nbsp))
                                                    Navigation))
                               nbsp nbsp nbsp nbsp nbsp nbsp
                               #| nbsp nbsp nbsp nbsp nbsp nbsp |#
                               ,(if Previous
                                    `(a ([href ,Previous]) "Previous")
                                    `"Previous")
                               " / "
                               ,(if Next
                                    `(a ([href ,Next]) "Next")
                                    "Next"))))
                (div ([id "MainText"])
                     (div ([class "padder"])
                          ,@Body)
                     ,@(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 "http://pagead2.googlesyndication.com/pagead/show_ads.js"]))))
                           `())
                     (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 "http://creativecommons.org/licenses/by-sa/1.0"]) "Creative Commons License") ". "
                             "When I am syndicating, I prefer "
                             (a ([href "http://blogs.law.harvard.edu/tech/rss"]) "RSS") ". "
                             "When I am blogging, I use "
                             (a ([href "http://www.makeoutcity.com/Categories/About/blogue"]) "blogue") " and "
                             (a ([href "http://www.eastgate.com/Tinderbox/"]) "Tinderbox") ". " 
                             "For design elements, I steal from " (a ([href "http://webstandards.org/"]) "The Web Standards Project") " and "
                             (a ([href "http://kottke.org"]) "kottke.org") ". "
                             "I am a member of " 
                             (a ([href "http://www.technorati.com/profile/jeapostrophe/40371/bd52902057b1bfe2eb5e89ab9f63dde7"]) "Technorati") 
                             ", " (a ([href "http://geourl.org/near/?p=http%3A%2F%2Fwww.makeoutcity.com"]) "GeoURL") ", and "
                             (a ([href "http://www.orkut.com"]) "orkut") ".")))
                (div ([id "SubNav"])
                     (h3 "What is this place?")
                     (p "This is a part of the " (a ([href "/"]) ,SiteTitle " weblog") ", by me, " (a ([href "http://jay.makeoutcity.com/"]) ,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:")
                     (blockquote
                      (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 "http://www.brown.edu/"]) "Brown University") " at the " (a ([href "http://cs.brown.edu/"]) "Computer Science Department") ". I am working with " (a ([href "http://cs.brown.edu/~sk"]) "Shriram Krishnamurthi") ".")
                     (p "I recently graduated from the " (a ([href "http://www.uml.edu/"]) "University of Massachusetts at Lowell") " where I studied computer science, mathematics, and economics.")
                     (p "I am currently studying human languages at " (a ([href "http://www.tonguesinteractive.com/"]) "The Intercontinental Foreign Language School") ". The languages in question are:")
                     (blockquote
                      (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 "http://ranchero.com/netnewswire"]) "NetNewsWire") ", you may want my " (a ([class "button"] [href ,AtomURL] [title "Syndication Feed for makeoutcity.com"]) "Syndication Feed") ".")
                     (p "If you " (strong (em "really")) " like my work, you can buy me stuff from my " (a ([href "http://www.amazon.com/gp/registry/registry.html/002-2206466-0627267?%5Fencoding=UTF8&type=wishlist&id=STV061I2MKRE"]) "Amazon Wish List") " or look at the Google Ads on some of the pages. But I would prefer that you " (a ([href "http://blogger.com/"]) "start your own weblog") ", so I can read what " (em "you") " have to say. Or, you can display your tastes with some " (a ([href "http://www.cafeshops.com/makeoutcity_com"]) "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 "http://www.makeoutcity.com/Categories/About/Author"] 
                                         [title "About This Author"]) ,Author))
                   (div ([class "postTopics"]) 
                        "Filed under: " ,@(apply append 
                                                 (map (lambda (category)
                                                        `((a ([href ,(string-append SiteURL "/Categories" category)])
                                                             ,category) " "))
                                                      Categories)))
                   (div ([class "postDiscussion"])
                        "Discussion: " (a ([href ,(string-append
                                                   "http://reddit.com/info?url="
                                                   (uri-encode (string-append SiteURL Permapath)))]) "reddit")))
              (h2 ([class "postTitle"]) ,@EntryTitle)
              (div ([class "postContent"])
                   ,@EntryBody)))
      
      (define (Atom/2005 Entries)
        `(feed ([xmlns "http://www.w3.org/2005/Atom"])
               (title ,SiteTitle)
               (link ([href ,SiteURL]))
               (link ([rel "self"] [href ,AtomURL]))
               (updated ,(Post-Date/3339 (first Entries)))
               (author
                (name ,Author))
               (id ,SiteURL)
               
               ,@(map (lambda (Entry)
                        `(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)))))
                      Entries)))
      
      (define (RSS/0.91 Entries)
        `(rss ([version "0.91"] [xmlns:rssHints "http://feeds.scripting.com/rssHintsModule"])
              (channel
               (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)))))
                      Entries))))
      
      (define (RSS/2.0 Entries)
        `(rss ([version "2.0"] 
               [xmlns:rssHints "http://feeds.scripting.com/rssHintsModule"]
               [xmlns:creativeCommons "http://backend.userland.com/creativeCommonsRssModule"])
              (channel
               (title ,SiteTitle)
               (link ,SiteURL)
               (description ,SiteTitle ", by " ,Author)
               (language "en-us")
               (copyright ,CopyrightYears " " ,Author)
               (managingEditor ,AuthorEmail)
               (webMaster ,AuthorEmail)
               (creationCommons:license "http://www.creativecommons.org/licenses/by-sa/1.0")
               (image
                (url ,SiteURL ,ImagePath)
                (link ,SiteURL)
                (title ,SiteTitle ", by " ,Author))
               (docs "http://blogs.law.harvard.edu/tech/rss")
               (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 "http://www.creativecommons.org/licenses/by-sa/1.0")
                               ,@(map (lambda (category)
                                        `(category ([domain ,(string-append SiteURL "/Categories")]) ,category))
                                      (map bytes->string/utf-8 (Post-Category Entry)))))
                      Entries)))))))