android & benitlux: use NitObject in clients
[nit.git] / lib / html / examples / html_page.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 module html_page is example
16
17 import html
18
19 class NitHomepage
20 super HTMLPage
21
22 redef fun head do
23 add("meta").attr("charset", "utf-8")
24 add("title").text("Nit")
25 add("link").attr("rel", "icon").attr("href", "http://nitlanguage.org/favicon.ico").attr("type", "image/x-icon")
26 add("link").attr("rel", "stylesheet").attr("href", "http://nitlanguage.org/style.css").attr("type", "text/css")
27 add("link").attr("rel", "stylesheet").attr("href", "http://nitlanguage.org/local.css").attr("type", "text/css")
28 end
29
30 redef fun body do
31 open("article").add_class("page")
32 open("section").add_class("pageheader")
33 add_html("<a id='toptitle_first' class='toptitle'>the</a><a id='toptitle_second' class='toptitle' href=''>Nit</a><a id='toptitle_third' class='toptitle' href=''>Programming Language</a>")
34 open("header").add_class("header")
35 open("div").add_class("topsubtitle")
36 add("p").text("A Fun Language for Serious Programming")
37 close("div")
38 close("header")
39 close("section")
40
41 open("div").attr("id", "pagebody")
42 open("section").attr("id", "content")
43 add("h1").text("# What is Nit?")
44 add("p").text("Nit is an object-oriented programming language. The goal of Nit is to propose a robust statically typed programming language where structure is not a pain.")
45 add("p").text("So, what does the famous hello world program look like, in Nit?")
46 add_html("<pre><tt><span class='normal'>print </span><span class='string'>'Hello, World!'</span></tt></pre>")
47
48 add("h1").text("# Feature Highlights")
49 add("h2").text("Usability")
50 add("p").text("Nit's goal is to be usable by real programmers for real projects")
51
52 open("ul")
53 open("li")
54 add("a").attr("href", "http://en.wikipedia.org/wiki/KISS_principle").text("KISS principle")
55 close("li")
56 add("li").text("Script-like language without verbosity nor cryptic statements")
57 add("li").text("Painless static types: static typing should help programmers")
58 add("li").text("Efficient development, efficient execution, efficient evolution.")
59 close("ul")
60
61 add("h2").text("Robustness")
62 add("p").text("Nit will help you to write bug-free programs")
63
64 open("ul")
65 add("li").text("Strong static typing")
66 add("li").text("No more NullPointerException")
67 close("ul")
68
69 add("h2").text("Object-Oriented")
70 add("p").text("Nit's guideline is to follow the most powerful OO principles")
71
72 open("ul")
73 open("li")
74 add("a").attr("href", "./everything_is_an_object/").text("Everything is an object")
75 close("li")
76 open("li")
77 add("a").attr("href", "./multiple_inheritance/").text("Multiple inheritance")
78 close("li")
79 open("li")
80 add("a").attr("href", "./refinement/").text("Open classes")
81 close("li")
82 open("li")
83 add("a").attr("href", "./virtual_types/").text("Virtual types")
84 close("li")
85 close("ul")
86
87
88 add("h1").text("# Getting Started")
89 add("p").text("Get Nit from its Git repository:")
90
91 add_html("<pre><code>$ git clone http://nitlanguage.org/nit.git</code></pre>")
92 add("p").text("Build the compiler (may be long):")
93 add_html("<pre><code>$ cd nit\n")
94 add_html("$ make</code></pre>")
95 add("p").text("Compile a program:")
96 add_html("<pre><code>$ bin/nitc examples/hello_world.nit</code></pre>")
97 add("p").text("Execute the program:")
98 add_html("<pre><code>$ ./hello_world</code></pre>")
99 close("section")
100 close("div")
101 close("article")
102 end
103 end
104
105 var page = new NitHomepage
106 page.write_to stdout
107 page.write_to_file("nit.html")