--- Module which builds the index.html page to be used in rocks servers. module("luarocks.index", package.seeall) local util = require("luarocks.util") local fs = require("luarocks.fs") local deps = require("luarocks.deps") local persist = require("luarocks.persist") local dir = require("luarocks.dir") local manif = require("luarocks.manif") local ext_url_target = ' target="_blank"' local index_header = [[
Lua modules available from this location for use with LuaRocks:
|
]] local index_package_end = [[ |
External dependencies: ' .. table.concat(deplist, ', ').. '
' else return "" end end function make_index(repo) if not fs.is_dir(repo) then return nil, "Cannot access repository at "..repo end local manifest = manif.load_manifest(repo) local out = io.open(dir.path(repo, "index.html"), "w") out:write(index_header) for package, version_list in util.sortedpairs(manifest.repository) do local latest_rockspec = nil local output = index_package_start for version, data in util.sortedpairs(version_list, deps.compare_versions) do local versions = {} output = output..version..': ' table.sort(data, function(a,b) return a.arch < b.arch end) for _, item in ipairs(data) do local link = ''..item.arch..'' if item.arch == 'rockspec' then local rs = ("%s-%s.rockspec"):format(package, version) if not latest_rockspec then latest_rockspec = rs end link = link:gsub("$url", rs) else link = link:gsub("$url", ("%s-%s.%s.rock"):format(package, version, item.arch)) end table.insert(versions, link) end output = output .. table.concat(versions, ', ') .. '"):gsub("%s+", " ") vars.detailed = vars.detailed:gsub("(https?://[a-zA-Z0-9%.%%-_%+%[%]=%?&/$@;:]+)", '%1') output = output:gsub("$(%w+)", vars) else output = output:gsub("$anchor", package) output = output:gsub("$package", package) output = output:gsub("$(%w+)", "") end out:write(output) end out:write(index_footer) out:close() end