summaryrefslogtreecommitdiff
path: root/main.ur
blob: 76082f9b4a9fb48c720d2a04d8fdedea545ff944 (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
(* Main -- main entry point
Copyright (C) 2013  Benjamin Barenblat <bbaren@mit.edu>

This file is a part of 6.947.

6.947 is is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

6.947 is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
details.

You should have received a copy of the GNU Affero General Public License along
with 6.947.  If not, see <http://www.gnu.org/licenses/>. *)


(********************************** Styles ***********************************)

style smallCaps

style siteTitle
style navBar
style active			(* TODO: Use for active menu items *)
style content
style footer


(*********************************** Menus ***********************************)

(* Generating nice menus is quite difficult in Ur/Web--there are a lot of links
that the compiler needs to be convinced aren't broken.  The link scheme in this
app is based on a variant 'pageName', which describes the name of the page.
There's one value for each page. *)
con pageName = variant (mapU unit [Main, Forum])

(* 'getName' generates the link text given a 'pageName'. *)
fun getName (n : pageName) : xbody =
    match n { Main = fn ()  => <xml>Main</xml>,
	      Forum = fn () => <xml>Forum</xml> }

(* Now we can do the actual menu generation code. *)
fun menu (current : pageName) : xbody =
    let fun item (target : pageName) (page : unit -> transaction page) =
    	    if Variant.eq current target
    	    then <xml><li class={active}>{getName target}</li></xml>
    	    else <xml><li><a link={page ()}>{getName target}</a></li></xml>
    in
	<xml>
	  <ul class={navBar}>
	    {item (make [#Main] ()) main}
	    {item (make [#Forum] ()) forum}
	  </ul>
	</xml>
    end


(********************************* Template **********************************)

and generic (pageName : option string) (menuAndContent : xbody) : xhtml [] [] =
    let val titleString : string =
	    case pageName of
	      | None => "6.947 – Functional Programming Project Laboratory"
	      | Some s => "6.947 – " ^ s
    in
	<xml>
	  <head>
	    <title>{[titleString]}</title>
	    <link rel="stylesheet" type="text/css" href="//bbaren.scripts.mit.edu/urweb/6.947/site.css"/>
	  </head>
	  <body>
	    <h1 class={siteTitle}><a link={main ()}>6.947 &ndash; Functional Programming Project Laboratory</a></h1>
	    {menuAndContent}
	    <div class={footer}>
	      <p>
		6.947 is free software: you can redistribute it and/or modify it under the terms of the <a href="//gnu.org/licenses/agpl"><span class={smallCaps}>gnu</span> Affero General Public License</a> as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
	      </p>

	      <p>
		6.947 is distributed in the hope that it will be useful, but <span class={smallCaps}>without any warranty</span>; without even the implied warranty of <span class={smallCaps}>merchantability</span> or <span class={smallCaps}>fitness for a particular purpose</span>.
		See the <span class={smallCaps}>gnu</span> Affero General Public License for more details.
	      </p>

	      <p>
		You can get the 6.947 source code <a href="file:///afs/athena.mit.edu/user/b/b/bbaren/web_scripts/urweb/6.947/">via AFS</a>.
	      </p>
	    </div>
	  </body>
	</xml>
    end


(*********************************** Pages ***********************************)

and main () =
    return (generic None <xml>
      {menu (make [#Main] ())}
      <div class={content}>
	<p>
	  Like <a href="//web.mit.edu/6.115/www/">6.115</a>, 6.947 is a chance to remember why you came to <span class={smallCaps}>mit</span>: to learn and to build.
	  Whereas 6.115 focuses on constructing digital systems from compositions of discrete integrated circuits, however, we’ll be focusing on functional programming &ndash; constructing software systems from compositions of discrete mathematical functions.
	  Prepare to leave behind everything you've ever known about programming and enter a world of functors, combinators, and monads; a world without borders or boundaries; <a href="//www.youtube.com/watch?v=OyRW9uFSmh0">a world where anything is possible</a>.
	</p>
      </div>
    </xml>)

and forum () =
    return (generic (Some "Forum") <xml>
      {menu (make [#Forum] ())}
      <div class={content}>
	<p>
	  Coming soon!
	</p>
      </div>
    </xml>)