website.nimf 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. #? stdtmpl | standard
  2. #proc generateHTMLPage(c: var TConfigData, currentTab, title, content, rss,
  3. # rootDir = ""): string =
  4. # result = ""
  5. <!DOCTYPE html>
  6. <html>
  7. <head>
  8. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  9. <title>${title} - $c.projectTitle</title>
  10. <link rel="stylesheet" type="text/css" href="${rootDir}assets/style.css?t=2320" />
  11. <link rel="shortcut icon" href="${rootDir}assets/images/favicon.ico">
  12. #if len(rss) > 0:
  13. <link href="$rss" title="Recent changes" type="application/atom+xml" rel="alternate">
  14. #end if
  15. </head>
  16. <body>
  17. <div id="bountysource">
  18. <a href="https://salt.bountysource.com/teams/nim">
  19. <div class="page-layout" style="padding: 2pt 2pt 2pt 30pt">
  20. <img src="${rootDir}assets/bountysource/bountysource.png" style="width: 20px; float: left;">
  21. <span style="margin-left: 10pt; float: left; margin-top: 2pt;">Fund Nim and help us develop it further!</span>
  22. <img src="https://api.bountysource.com/badge/team?team_id=19072&style=raised" style="margin-top: 2pt; margin-left: 10pt"/>
  23. </div>
  24. </a>
  25. </div>
  26. <header id="head">
  27. <div class="page-layout tall">
  28. <div id="head-logo"></div>
  29. <a id="head-logo-link" href="${rootDir}index.html"></a>
  30. <nav id="head-links">
  31. #for i in 0.. c.tabs.len-1:
  32. # let t = c.tabs[i].val
  33. # if t != "index" and t != "community" and t != "news":
  34. # let name = c.tabs[i].key
  35. # if currentTab == t:
  36. <a class="active"
  37. # else:
  38. <a
  39. # end if
  40. # if t.contains('.'):
  41. href="${t}" title = "$c.projectName - $name">$name</a>
  42. # else:
  43. href="${rootDir}${t}.html" title = "$c.projectName - $name">$name</a>
  44. # end if
  45. # end if
  46. #end for
  47. </nav>
  48. </div>
  49. </header>
  50. # if currentTab == "index":
  51. <section id="neck" class="home">
  52. # else:
  53. <section id="neck">
  54. # end
  55. <div class="page-layout tall">
  56. <div id="glow-arrow"></div>
  57. # if currentTab == "index":
  58. <div id="slideshow">
  59. <!-- slides -->
  60. <div id="slide0" class="active codeslide2">
  61. <div>
  62. <h2>Nim is simple..</h2>
  63. <pre>
  64. <span class="cmt"># compute average line length</span>
  65. <span class="kwd">var</span>
  66. <span class="tab"> </span>sum = <span class="val">0</span>
  67. <span class="tab end"> </span>count = <span class="val">0</span>
  68. <span class="kwd">for</span> line <span class="kwd">in</span> stdin.lines:
  69. <span class="tab"> </span>sum += line.len
  70. <span class="tab end"> </span>count += <span class="val">1</span>
  71. echo(<span class="val">"Average line length: "</span>,
  72. <span class="kwd">if</span> count &gt; <span class="val">0</span>: sum / count <span class="kwd">else</span>: <span class="val">0</span>)
  73. </pre>
  74. </div>
  75. <div>
  76. <h2>..and type safe...</h2>
  77. <pre>
  78. <span class="cmt"># create and greet someone</span>
  79. <span class="kwd">type</span> <span class="def">Person</span> = <span class="kwd">object</span>
  80. <span class="tab"> </span>name: <span class="typ">string</span>
  81. <span class="tab end"> </span>age: <span class="typ">int</span>
  82. <span class="kwd">proc</span> <span class="def">greet</span>(p: <span class="typ">Person</span>) =
  83. <span class="tab"> </span>echo <span class="val">"Hi, I'm "</span>, p.name, <span class="val">"."</span>
  84. <span class="tab end"> </span>echo <span class="val">"I am "</span>, p.age, <span class="val">" years old."</span>
  85. <span class="kwd">let</span> p = <span class="typ">Person</span>(name:<span class="val">"Jon"</span>, age:<span class="val">18</span>)
  86. p.greet() <span class="cmt"># or greet(p)</span>
  87. </pre>
  88. </div>
  89. </div>
  90. <div id="slide1" class="codeslide3">
  91. <div>
  92. <h2>C FFI is easy in Nim..</h2>
  93. <pre>
  94. <span class="cmt"># declare a C procedure..</span>
  95. <span class="kwd">proc</span> <span class="def">unsafeScanf</span>(f: <span class="typ">File</span>, s: <span class="typ">cstring</span>)
  96. <span class="tab"> </span>{.varargs,
  97. <span class="tab"> </span>importc: <span class="val">"fscanf"</span>,
  98. <span class="tab end"> </span>header: <span class="val">"&lt;stdio.h&gt;"</span>.}
  99. <span class="cmt"># ..and use it...</span>
  100. <span class="kwd">var</span> x: <span class="typ">cint</span>
  101. stdin.unsafeScanf(<span class="val">"%d"</span>, <span class="kwd">addr</span> x)
  102. </pre>
  103. <p><span class="desc"><b>Compile and run with:</b><br>&nbsp;&nbsp;&nbsp;&nbsp;&#36; nim c -r example.nim</span></p>
  104. </div>
  105. <div>
  106. <h2>..and DSLs are too...</h2>
  107. <pre>
  108. <span class="cmt"># a simple html server</span>
  109. <span class="kwd">import</span>
  110. jester, asyncdispatch, htmlgen
  111. <span class="kwd">routes</span>:
  112. <span class="tab"> </span><span class="kwd">get</span> <span class="val">"/"</span>:
  113. <span class="tab end"> <span class="tab end"> </span></span><span class="kwd">resp</span> h1(<span class="val">"Hello world"</span>)
  114. runForever()
  115. </pre>
  116. <p><span class="desc"><b>View in browser at:</b><br>&nbsp;&nbsp;&nbsp;&nbsp;localhost:5000</span></p>
  117. </div>
  118. </div>
  119. <div id="slide2" class="niaslide">
  120. <a href="news/e030_nim_in_action_in_production.html">
  121. <img src="${rootDir}assets/niminaction/banner2.png" alt="A printed copy of Nim in Action should be available in March 2017!"/>
  122. </a>
  123. </div>
  124. <div id="slide3" class="niaslide">
  125. <a href="sponsors.html">
  126. <img src="${rootDir}assets/bountysource/meet_sponsors.png" alt="Meet our BountySource sponsors!"/>
  127. </a>
  128. </div>
  129. </div>
  130. <div id="slideshow-nav">
  131. <div id="slideControl0" onclick="slideshow_click(0)" class="active"></div>
  132. <div id="slideControl1" onclick="slideshow_click(1)"></div>
  133. <div id="slideControl2" onclick="slideshow_click(2)"></div>
  134. <div id="slideControl3" onclick="slideshow_click(3)"></div>
  135. </div>
  136. # end
  137. <aside id="sidebar">
  138. # if len(c.links) > 0:
  139. <h3>More Links</h3>
  140. <div id="sidebar-links">
  141. # for i in 0..c.links.len-1:
  142. <a href="${c.links[i].val}" id="${c.links[i].id}">${c.links[i].key}</a>
  143. # end for
  144. </div>
  145. # end if
  146. # if len(c.ticker) > 0:
  147. <h3 class="blue">Latest News</h3>
  148. <div id="sidebar-news">
  149. ${c.ticker % rootDir}
  150. </div>
  151. # end if
  152. </aside>
  153. </div>
  154. </section>
  155. <section id="body">
  156. <div id="body-border"></div>
  157. <div id="glow-line"></div>
  158. <div class="page-layout">
  159. <article id="content" class="page">
  160. $content
  161. </article>
  162. </div>
  163. </section>
  164. <!--- #foot --->
  165. <footer id="foot" class="home">
  166. <div class="page-layout tall">
  167. <div id="foot-links">
  168. <div>
  169. <h4>Documentation</h4>
  170. <a href="${rootDir}documentation.html">Stable Documentation</a>
  171. <a href="${rootDir}learn.html">Learning Resources</a>
  172. <!-- <a href="">Development Documentation</a> -->
  173. <a href="https://github.com/nim-lang/nim">Issues &amp; Requests</a>
  174. </div>
  175. <div>
  176. <h4>Community</h4>
  177. <a href="https://forum.nim-lang.org">User Forum</a>
  178. <a href="http://webchat.freenode.net/?channels=nim">Online IRC</a>
  179. <a href="https://irclogs.nim-lang.org/">IRC Logs</a>
  180. </div>
  181. </div>
  182. <div id="foot-legal">
  183. <h4>Written in Nim - Powered by <a href="https://github.com/dom96/jester">Jester</a></h4>
  184. Web Design by <a href="http://reign-studios.net/philipwitte/">Philip Witte</a> &amp; <a href="http://picheta.me/">Dominik Picheta</a><br>
  185. Copyright © 2017 - <a href="https://nim-lang.org/blog/">Andreas Rumpf</a> &amp; <a href="https://github.com/nim-lang/nim/graphs/contributors">Contributors</a>
  186. </div>
  187. </div>
  188. </footer>
  189. # if currentTab == "index":
  190. <script src="${rootDir}assets/index.js"></script>
  191. # end if
  192. # if c.gaId.len != 0:
  193. <script>
  194. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  195. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  196. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  197. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  198. ga('create', '${c.gaId}', 'nim-lang.org');
  199. ga('send', 'pageview');
  200. </script>
  201. # end if
  202. </body>
  203. </html>
  204. #end proc
  205. #
  206. #
  207. #proc generateSponsors(sponsors: seq[Sponsor]): string =
  208. #result = ""
  209. #for sponsor in sponsors:
  210. <dt class="level-${sponsor.level}">
  211. #if sponsor.url.len > 0:
  212. <a href="${sponsor.url}" target="_blank">${sponsor.name}</a>
  213. #else:
  214. ${sponsor.name}
  215. #end if
  216. </dt>
  217. <dd class="logo">
  218. #if sponsor.logo.len > 0:
  219. <a href="${sponsor.url}" target="_blank">
  220. <img alt="${sponsor.name}'s logo" src="${sponsor.logo}"/>
  221. </a>
  222. #end if
  223. </dd>
  224. <dd class="this_month">
  225. Donated <b>$$${sponsor.thisMonth}</b> this month
  226. </dd>
  227. <dd class="legend">
  228. Donated $$${sponsor.allTime} in total since ${sponsor.since}
  229. </dd>
  230. #end for
  231. #end proc
  232. #proc generateSponsorsPage(activeSponsors, inactiveSponsors: seq[Sponsor]): string =
  233. #result = ""
  234. <h1 id="our-current-sponsors">Our Current Sponsors</h1>
  235. <p>This section lists the companies and individuals that are, very kindly, contributing a
  236. monthly amount to help sustain Nim's development. For more details take a
  237. look at the <a href="https://salt.bountysource.com/teams/nim">Bountysource campaign</a>.</p>
  238. <p class="lastUpdate">Last updated: ${getTime().getGMTime().format("dd/MM/yyyy")}</p>
  239. <dl>
  240. ${generateSponsors(activeSponsors)}
  241. </dl>
  242. #
  243. <h1 id="our-past-sponsors">Our Past Sponsors</h1>
  244. <p>This section lists the companies and individuals that have contributed
  245. money in the past to help sustain Nim's development. For more details take a
  246. look at the <a href="https://salt.bountysource.com/teams/nim">Bountysource campaign</a>.</p>
  247. <dl>
  248. ${generateSponsors(inactiveSponsors)}
  249. </dl>
  250. #
  251. #end proc