Implemented babel package list in lib.html.
This commit is contained in:
parent
7cddb39969
commit
58e583e39b
3 changed files with 109 additions and 0 deletions
32
doc/lib.txt
32
doc/lib.txt
|
|
@ -573,3 +573,35 @@ Scientific computing
|
||||||
|
|
||||||
* `libsvm <libsvm.html>`_
|
* `libsvm <libsvm.html>`_
|
||||||
Low level wrapper for `lib svm <http://www.csie.ntu.edu.tw/~cjlin/libsvm/>`_.
|
Low level wrapper for `lib svm <http://www.csie.ntu.edu.tw/~cjlin/libsvm/>`_.
|
||||||
|
|
||||||
|
Babel
|
||||||
|
====================
|
||||||
|
|
||||||
|
Babel is a package manager for the Nimrod programming language.
|
||||||
|
For instructions on how to install Babel packages see
|
||||||
|
`its README <https://github.com/nimrod-code/babel#readme>`_.
|
||||||
|
|
||||||
|
Official packages
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
These packages are officially supported and will therefore be continually
|
||||||
|
maintained to ensure that they work with the latest versions of the Nimrod
|
||||||
|
compiler.
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<div id="officialPkgList"></div>
|
||||||
|
|
||||||
|
Unofficial packages
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
These packages have been developed by independent Nimrod developers and as
|
||||||
|
such may not always be up to date with the latest developments in the
|
||||||
|
Nimrod programming language.
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<div id="unofficialPkgList"></div>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="babelpkglist.js"></script>
|
||||||
|
<script type="text/javascript" src="http://build.nimrod-lang.org/packages?callback=gotPackageList"></script>
|
||||||
|
|
|
||||||
|
|
@ -348,6 +348,10 @@ proc buildNewsRss(c: var TConfigData, destPath: string) =
|
||||||
|
|
||||||
generateRss(destFilename, parseNewsTitles(srcFilename))
|
generateRss(destFilename, parseNewsTitles(srcFilename))
|
||||||
|
|
||||||
|
proc buildJS(destPath: string) =
|
||||||
|
exec("nimrod js -d:release --out:$1 web/babelpkglist.nim" %
|
||||||
|
[destPath / "babelpkglist.js"])
|
||||||
|
|
||||||
proc main(c: var TConfigData) =
|
proc main(c: var TConfigData) =
|
||||||
const
|
const
|
||||||
cmd = "nimrod rst2html --compileonly $1 -o:web/$2.temp web/$2.txt"
|
cmd = "nimrod rst2html --compileonly $1 -o:web/$2.temp web/$2.txt"
|
||||||
|
|
@ -377,6 +381,7 @@ proc main(c: var TConfigData) =
|
||||||
quit("[Error] cannot write file: " & outfile)
|
quit("[Error] cannot write file: " & outfile)
|
||||||
removeFile(temp)
|
removeFile(temp)
|
||||||
copyDir("web/assets", "web/upload/assets")
|
copyDir("web/assets", "web/upload/assets")
|
||||||
|
buildJS("web/upload")
|
||||||
buildNewsRss(c, "web/upload")
|
buildNewsRss(c, "web/upload")
|
||||||
buildAddDoc(c, "web/upload")
|
buildAddDoc(c, "web/upload")
|
||||||
buildDocSamples(c, "web/upload")
|
buildDocSamples(c, "web/upload")
|
||||||
|
|
|
||||||
72
web/babelpkglist.nim
Normal file
72
web/babelpkglist.nim
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
import base64, strutils, json, htmlgen, dom, algorithm
|
||||||
|
|
||||||
|
type
|
||||||
|
TData = object
|
||||||
|
content {.importc.}: cstring
|
||||||
|
|
||||||
|
proc decodeContent(content: string): string =
|
||||||
|
result = ""
|
||||||
|
for line in content.splitLines:
|
||||||
|
if line != "":
|
||||||
|
result.add decode(line)
|
||||||
|
|
||||||
|
proc contains(x: seq[PJSonNode], s: string): bool =
|
||||||
|
for i in x:
|
||||||
|
assert i.kind == JString
|
||||||
|
if i.str == s: return true
|
||||||
|
|
||||||
|
proc processContent(content: string) =
|
||||||
|
var jsonDoc = parseJson(content)
|
||||||
|
assert jsonDoc.kind == JArray
|
||||||
|
var jsonArr = jsonDoc.elems
|
||||||
|
|
||||||
|
jsonArr.sort do (x, y: PJsonNode) -> int:
|
||||||
|
system.cmp(x["name"].str, y["name"].str)
|
||||||
|
|
||||||
|
var
|
||||||
|
officialList = ""
|
||||||
|
officialCount = 0
|
||||||
|
unofficialList = ""
|
||||||
|
unofficialCount = 0
|
||||||
|
|
||||||
|
for pkg in jsonArr:
|
||||||
|
assert pkg.kind == JObject
|
||||||
|
let pkgWeb =
|
||||||
|
if pkg.hasKey("web"): pkg["web"].str
|
||||||
|
else: pkg["url"].str
|
||||||
|
let listItem = li(a(href=pkgWeb, pkg["name"].str), " ", pkg["description"].str)
|
||||||
|
if pkg["url"].str.startsWith("git://github.com/nimrod-code") or
|
||||||
|
"official" in pkg["tags"].elems:
|
||||||
|
officialCount.inc
|
||||||
|
officialList.add listItem & "\n"
|
||||||
|
else:
|
||||||
|
unofficialCount.inc
|
||||||
|
unofficialList.add listItem & "\n"
|
||||||
|
|
||||||
|
var officialPkgListDiv = document.getElementById("officialPkgList")
|
||||||
|
|
||||||
|
officialPkgListDiv.innerHTML.add(
|
||||||
|
p("There are currently " & $officialCount &
|
||||||
|
" official packages in the Babel package repository.") &
|
||||||
|
ul(officialList)
|
||||||
|
)
|
||||||
|
|
||||||
|
var unofficialPkgListDiv = document.getElementById("unofficialPkgList")
|
||||||
|
|
||||||
|
unofficialPkgListDiv.innerHTML.add(
|
||||||
|
p("There are currently " & $unofficialCount &
|
||||||
|
" unofficial packages in the Babel package repository.") &
|
||||||
|
ul(unofficialList)
|
||||||
|
)
|
||||||
|
|
||||||
|
proc gotPackageList(apiReply: TData) {.exportc.} =
|
||||||
|
let decoded = decodeContent($apiReply.content)
|
||||||
|
try:
|
||||||
|
processContent(decoded)
|
||||||
|
except:
|
||||||
|
var officialPkgListDiv = document.getElementById("officialPkgList")
|
||||||
|
var unofficialPkgListDiv = document.getElementById("unofficialPkgList")
|
||||||
|
let msg = p("Unable to retrieve package list: ",
|
||||||
|
code(getCurrentExceptionMsg()))
|
||||||
|
officialPkgListDiv.innerHTML = msg
|
||||||
|
unofficialPkgListDiv.innerHTML = msg
|
||||||
Loading…
Add table
Add a link
Reference in a new issue