* complete removal of web folder, fixes #9304 * remove `buildJS`
This commit is contained in:
parent
7f18d7cbc1
commit
c492a7fd83
4 changed files with 1 additions and 7 deletions
|
|
@ -323,7 +323,7 @@ proc buildPdfDoc*(nimArgs, destPath: string) =
|
|||
removeFile(changeFileExt(d, "tex"))
|
||||
|
||||
proc buildJS() =
|
||||
exec(findNim() & " js -d:release --out:$1 web/nimblepkglist.nim" %
|
||||
exec(findNim() & " js -d:release --out:$1 tools/nimblepkglist.nim" %
|
||||
[webUploadOutput / "nimblepkglist.js"])
|
||||
exec(findNim() & " js " & (docHackDir / "dochack.nim"))
|
||||
|
||||
|
|
|
|||
77
tools/nimblepkglist.nim
Normal file
77
tools/nimblepkglist.nim
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
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[JSonNode], 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: JsonNode) -> int:
|
||||
strutils.cmpIgnoreCase(x["name"].str, y["name"].str)
|
||||
|
||||
var
|
||||
officialList = ""
|
||||
officialCount = 0
|
||||
unofficialList = ""
|
||||
unofficialCount = 0
|
||||
let
|
||||
endings = {'.', '!'}
|
||||
|
||||
for pkg in jsonArr:
|
||||
assert pkg.kind == JObject
|
||||
if not pkg.hasKey"url": continue
|
||||
let pkgWeb =
|
||||
if pkg.hasKey("web"): pkg["web"].str
|
||||
else: pkg["url"].str
|
||||
let
|
||||
desc = pkg["description"].str
|
||||
dot = if desc.high > 0 and desc[desc.high] in endings: "" else: "."
|
||||
listItem = li(a(href=pkgWeb, pkg["name"].str), " ", desc & dot)
|
||||
if pkg["url"].str.startsWith("https://github.com/nim-lang") or
|
||||
pkg["url"].str.startsWith("git://github.com/nim-lang") 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 =
|
||||
p("There are currently " & $officialCount &
|
||||
" official packages in the Nimble package repository.") &
|
||||
ul(officialList)
|
||||
|
||||
var unofficialPkgListDiv = document.getElementById("unofficialPkgList")
|
||||
|
||||
unofficialPkgListDiv.innerHTML =
|
||||
p("There are currently " & $unofficialCount &
|
||||
" unofficial packages in the Nimble 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
|
||||
|
|
@ -445,10 +445,6 @@ proc buildNewsRss(c: var TConfigData, destPath: string) =
|
|||
|
||||
generateRss(destFilename, parseNewsTitles(srcFilename))
|
||||
|
||||
proc buildJS(c: TConfigData) =
|
||||
exec(findNim(c) & " js -d:release --out:$1 web/nimblepkglist.nim" %
|
||||
[c.webUploadOutput / "nimblepkglist.js"])
|
||||
|
||||
proc readSponsors(sponsorsFile: string): seq[Sponsor] =
|
||||
result = @[]
|
||||
var fileStream = newFileStream(sponsorsFile, fmRead)
|
||||
|
|
@ -528,7 +524,6 @@ proc onlyDocs(c: var TConfigData) =
|
|||
|
||||
proc main(c: var TConfigData) =
|
||||
buildWebsite(c)
|
||||
buildJS(c)
|
||||
let docup = c.webUploadOutput / NimVersion
|
||||
createDir(docup)
|
||||
buildAddDoc(c, docup)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue