123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- #? stdtmpl | standard
- #proc generateHTMLPage(c: var TConfigData, currentTab, title, content, rss,
- # rootDir = ""): string =
- # result = ""
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>${title} - $c.projectTitle</title>
- <link rel="stylesheet" type="text/css" href="${rootDir}assets/style.css?t=2320" />
- <link rel="shortcut icon" href="${rootDir}assets/images/favicon.ico">
- #if len(rss) > 0:
- <link href="$rss" title="Recent changes" type="application/atom+xml" rel="alternate">
- #end if
- </head>
- <body>
- <div id="bountysource">
- <a href="https://salt.bountysource.com/teams/nim">
- <div class="page-layout" style="padding: 2pt 2pt 2pt 30pt">
- <img src="${rootDir}assets/bountysource/bountysource.png" style="width: 20px; float: left;">
- <span style="margin-left: 10pt; float: left; margin-top: 2pt;">Fund Nim and help us develop it further!</span>
- <img src="https://api.bountysource.com/badge/team?team_id=19072&style=raised" style="margin-top: 2pt; margin-left: 10pt"/>
- </div>
- </a>
- </div>
- <header id="head">
- <div class="page-layout tall">
- <div id="head-logo"></div>
- <a id="head-logo-link" href="${rootDir}index.html"></a>
- <nav id="head-links">
- #for i in 0.. c.tabs.len-1:
- # let t = c.tabs[i].val
- # if t != "index" and t != "community" and t != "news":
- # let name = c.tabs[i].key
- # if currentTab == t:
- <a class="active"
- # else:
- <a
- # end if
- # if t.contains('.'):
- href="${t}" title = "$c.projectName - $name">$name</a>
- # else:
- href="${rootDir}${t}.html" title = "$c.projectName - $name">$name</a>
- # end if
- # end if
- #end for
- </nav>
- </div>
- </header>
- # if currentTab == "index":
- <section id="neck" class="home">
- # else:
- <section id="neck">
- # end
- <div class="page-layout tall">
- <div id="glow-arrow"></div>
- # if currentTab == "index":
- <div id="slideshow">
- <!-- slides -->
- <div id="slide0" class="active codeslide2">
- <div>
- <h2>Nim is simple..</h2>
- <pre>
- <span class="cmt"># compute average line length</span>
- <span class="kwd">var</span>
- <span class="tab"> </span>sum = <span class="val">0</span>
- <span class="tab end"> </span>count = <span class="val">0</span>
- <span class="kwd">for</span> line <span class="kwd">in</span> stdin.lines:
- <span class="tab"> </span>sum += line.len
- <span class="tab end"> </span>count += <span class="val">1</span>
- echo(<span class="val">"Average line length: "</span>,
- <span class="kwd">if</span> count > <span class="val">0</span>: sum / count <span class="kwd">else</span>: <span class="val">0</span>)
- </pre>
- </div>
- <div>
- <h2>..and type safe...</h2>
- <pre>
- <span class="cmt"># create and greet someone</span>
- <span class="kwd">type</span> <span class="def">Person</span> = <span class="kwd">object</span>
- <span class="tab"> </span>name: <span class="typ">string</span>
- <span class="tab end"> </span>age: <span class="typ">int</span>
- <span class="kwd">proc</span> <span class="def">greet</span>(p: <span class="typ">Person</span>) =
- <span class="tab"> </span>echo <span class="val">"Hi, I'm "</span>, p.name, <span class="val">"."</span>
- <span class="tab end"> </span>echo <span class="val">"I am "</span>, p.age, <span class="val">" years old."</span>
- <span class="kwd">let</span> p = <span class="typ">Person</span>(name:<span class="val">"Jon"</span>, age:<span class="val">18</span>)
- p.greet() <span class="cmt"># or greet(p)</span>
- </pre>
- </div>
- </div>
- <div id="slide1" class="codeslide3">
- <div>
- <h2>C FFI is easy in Nim..</h2>
- <pre>
- <span class="cmt"># declare a C procedure..</span>
- <span class="kwd">proc</span> <span class="def">unsafeScanf</span>(f: <span class="typ">File</span>, s: <span class="typ">cstring</span>)
- <span class="tab"> </span>{.varargs,
- <span class="tab"> </span>importc: <span class="val">"fscanf"</span>,
- <span class="tab end"> </span>header: <span class="val">"<stdio.h>"</span>.}
- <span class="cmt"># ..and use it...</span>
- <span class="kwd">var</span> x: <span class="typ">cint</span>
- stdin.unsafeScanf(<span class="val">"%d"</span>, <span class="kwd">addr</span> x)
- </pre>
- <p><span class="desc"><b>Compile and run with:</b><br> $ nim c -r example.nim</span></p>
- </div>
- <div>
- <h2>..and DSLs are too...</h2>
- <pre>
- <span class="cmt"># a simple html server</span>
- <span class="kwd">import</span>
- jester, asyncdispatch, htmlgen
- <span class="kwd">routes</span>:
- <span class="tab"> </span><span class="kwd">get</span> <span class="val">"/"</span>:
- <span class="tab end"> <span class="tab end"> </span></span><span class="kwd">resp</span> h1(<span class="val">"Hello world"</span>)
- runForever()
- </pre>
- <p><span class="desc"><b>View in browser at:</b><br> localhost:5000</span></p>
- </div>
- </div>
- <div id="slide2" class="niaslide">
- <a href="news/e030_nim_in_action_in_production.html">
- <img src="${rootDir}assets/niminaction/banner2.png" alt="A printed copy of Nim in Action should be available in March 2017!"/>
- </a>
- </div>
- <div id="slide3" class="niaslide">
- <a href="sponsors.html">
- <img src="${rootDir}assets/bountysource/meet_sponsors.png" alt="Meet our BountySource sponsors!"/>
- </a>
- </div>
- </div>
- <div id="slideshow-nav">
- <div id="slideControl0" onclick="slideshow_click(0)" class="active"></div>
- <div id="slideControl1" onclick="slideshow_click(1)"></div>
- <div id="slideControl2" onclick="slideshow_click(2)"></div>
- <div id="slideControl3" onclick="slideshow_click(3)"></div>
- </div>
- # end
- <aside id="sidebar">
- # if len(c.links) > 0:
- <h3>More Links</h3>
- <div id="sidebar-links">
- # for i in 0..c.links.len-1:
- <a href="${c.links[i].val}" id="${c.links[i].id}">${c.links[i].key}</a>
- # end for
- </div>
- # end if
- # if len(c.ticker) > 0:
- <h3 class="blue">Latest News</h3>
- <div id="sidebar-news">
- ${c.ticker % rootDir}
- </div>
- # end if
- </aside>
- </div>
- </section>
- <section id="body">
- <div id="body-border"></div>
- <div id="glow-line"></div>
- <div class="page-layout">
- <article id="content" class="page">
- $content
- </article>
- </div>
- </section>
- <!--- #foot --->
- <footer id="foot" class="home">
- <div class="page-layout tall">
- <div id="foot-links">
- <div>
- <h4>Documentation</h4>
- <a href="${rootDir}documentation.html">Stable Documentation</a>
- <a href="${rootDir}learn.html">Learning Resources</a>
- <!-- <a href="">Development Documentation</a> -->
- <a href="https://github.com/nim-lang/nim">Issues & Requests</a>
- </div>
- <div>
- <h4>Community</h4>
- <a href="https://forum.nim-lang.org">User Forum</a>
- <a href="http://webchat.freenode.net/?channels=nim">Online IRC</a>
- <a href="https://irclogs.nim-lang.org/">IRC Logs</a>
- </div>
- </div>
- <div id="foot-legal">
- <h4>Written in Nim - Powered by <a href="https://github.com/dom96/jester">Jester</a></h4>
- Web Design by <a href="http://reign-studios.net/philipwitte/">Philip Witte</a> & <a href="http://picheta.me/">Dominik Picheta</a><br>
- Copyright © 2017 - <a href="https://nim-lang.org/blog/">Andreas Rumpf</a> & <a href="https://github.com/nim-lang/nim/graphs/contributors">Contributors</a>
- </div>
- </div>
- </footer>
- # if currentTab == "index":
- <script src="${rootDir}assets/index.js"></script>
- # end if
- # if c.gaId.len != 0:
- <script>
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
- ga('create', '${c.gaId}', 'nim-lang.org');
- ga('send', 'pageview');
- </script>
- # end if
- </body>
- </html>
- #end proc
- #
- #
- #proc generateSponsors(sponsors: seq[Sponsor]): string =
- #result = ""
- #for sponsor in sponsors:
- <dt class="level-${sponsor.level}">
- #if sponsor.url.len > 0:
- <a href="${sponsor.url}" target="_blank">${sponsor.name}</a>
- #else:
- ${sponsor.name}
- #end if
- </dt>
- <dd class="logo">
- #if sponsor.logo.len > 0:
- <a href="${sponsor.url}" target="_blank">
- <img alt="${sponsor.name}'s logo" src="${sponsor.logo}"/>
- </a>
- #end if
- </dd>
- <dd class="this_month">
- Donated <b>$$${sponsor.thisMonth}</b> this month
- </dd>
- <dd class="legend">
- Donated $$${sponsor.allTime} in total since ${sponsor.since}
- </dd>
- #end for
- #end proc
- #proc generateSponsorsPage(activeSponsors, inactiveSponsors: seq[Sponsor]): string =
- #result = ""
- <h1 id="our-current-sponsors">Our Current Sponsors</h1>
- <p>This section lists the companies and individuals that are, very kindly, contributing a
- monthly amount to help sustain Nim's development. For more details take a
- look at the <a href="https://salt.bountysource.com/teams/nim">Bountysource campaign</a>.</p>
- <p class="lastUpdate">Last updated: ${getTime().utc().format("dd/MM/yyyy")}</p>
- <dl>
- ${generateSponsors(activeSponsors)}
- </dl>
- #
- <h1 id="our-past-sponsors">Our Past Sponsors</h1>
- <p>This section lists the companies and individuals that have contributed
- money in the past to help sustain Nim's development. For more details take a
- look at the <a href="https://salt.bountysource.com/teams/nim">Bountysource campaign</a>.</p>
- <dl>
- ${generateSponsors(inactiveSponsors)}
- </dl>
- #
- #end proc
|