diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2010-11-02 20:46:16 -0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2010-11-02 20:46:16 -0200 |
| commit | 04d2aa2f9d81cb48875267437858bdf22eec759b (patch) | |
| tree | eb945355712163d3694431399e8cd9fd70304c21 | |
| parent | 4f9f675e59b98edfe9f41c7bad51591acb919634 (diff) | |
| download | luarocks-04d2aa2f9d81cb48875267437858bdf22eec759b.tar.gz luarocks-04d2aa2f9d81cb48875267437858bdf22eec759b.tar.bz2 luarocks-04d2aa2f9d81cb48875267437858bdf22eec759b.zip | |
display external dependencies in index.html page
| -rw-r--r-- | src/luarocks/index.lua | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/src/luarocks/index.lua b/src/luarocks/index.lua index 18afd797..570db431 100644 --- a/src/luarocks/index.lua +++ b/src/luarocks/index.lua | |||
| @@ -64,6 +64,7 @@ local index_package_start = [[ | |||
| 64 | <td class="package"> | 64 | <td class="package"> |
| 65 | <p><a name="$anchor"></a><b>$package</b> - $summary<br/> | 65 | <p><a name="$anchor"></a><b>$package</b> - $summary<br/> |
| 66 | </p><blockquote><p>$detailed<br/> | 66 | </p><blockquote><p>$detailed<br/> |
| 67 | $externaldependencies | ||
| 67 | <font size="-1"><a href="$original">latest sources</a> $homepage | License: $license</font></p> | 68 | <font size="-1"><a href="$original">latest sources</a> $homepage | License: $license</font></p> |
| 68 | </blockquote></a></td> | 69 | </blockquote></a></td> |
| 69 | <td class="version"> | 70 | <td class="version"> |
| @@ -83,6 +84,34 @@ local index_footer = [[ | |||
| 83 | </html> | 84 | </html> |
| 84 | ]] | 85 | ]] |
| 85 | 86 | ||
| 87 | function format_external_dependencies(rockspec) | ||
| 88 | if rockspec.external_dependencies then | ||
| 89 | local deplist = {} | ||
| 90 | local listed_set = {} | ||
| 91 | local plats = nil | ||
| 92 | for name, desc in util.sortedpairs(rockspec.external_dependencies) do | ||
| 93 | if name ~= "platforms" then | ||
| 94 | table.insert(deplist, name:lower()) | ||
| 95 | listed_set[name] = true | ||
| 96 | else | ||
| 97 | plats = desc | ||
| 98 | end | ||
| 99 | end | ||
| 100 | if plats then | ||
| 101 | for plat, entries in util.sortedpairs(plats) do | ||
| 102 | for name, desc in util.sortedpairs(entries) do | ||
| 103 | if not listed_set[name] then | ||
| 104 | table.insert(deplist, name:lower() .. " (on "..plat..")") | ||
| 105 | end | ||
| 106 | end | ||
| 107 | end | ||
| 108 | end | ||
| 109 | return '<p><b>External dependencies:</b> ' .. table.concat(deplist, ', ').. '</p>' | ||
| 110 | else | ||
| 111 | return "" | ||
| 112 | end | ||
| 113 | end | ||
| 114 | |||
| 86 | function make_index(repo) | 115 | function make_index(repo) |
| 87 | if not fs.is_dir(repo) then | 116 | if not fs.is_dir(repo) then |
| 88 | return nil, "Cannot access repository at "..repo | 117 | return nil, "Cannot access repository at "..repo |
| @@ -96,9 +125,8 @@ function make_index(repo) | |||
| 96 | local output = index_package_start | 125 | local output = index_package_start |
| 97 | for version, data in util.sortedpairs(version_list, deps.compare_versions) do | 126 | for version, data in util.sortedpairs(version_list, deps.compare_versions) do |
| 98 | local versions = {} | 127 | local versions = {} |
| 99 | local versions_order = {} | ||
| 100 | output = output..version..': ' | 128 | output = output..version..': ' |
| 101 | 129 | table.sort(data, function(a,b) return a.arch < b.arch end) | |
| 102 | for _, item in ipairs(data) do | 130 | for _, item in ipairs(data) do |
| 103 | local link = '<a href="$url">'..item.arch..'</a>' | 131 | local link = '<a href="$url">'..item.arch..'</a>' |
| 104 | if item.arch == 'rockspec' then | 132 | if item.arch == 'rockspec' then |
| @@ -108,14 +136,9 @@ function make_index(repo) | |||
| 108 | else | 136 | else |
| 109 | link = link:gsub("$url", ("%s-%s.%s.rock"):format(package, version, item.arch)) | 137 | link = link:gsub("$url", ("%s-%s.%s.rock"):format(package, version, item.arch)) |
| 110 | end | 138 | end |
| 111 | versions[item.arch] = link | 139 | table.insert(versions, link) |
| 112 | table.insert(versions_order, item.arch) | ||
| 113 | end | ||
| 114 | table.sort(versions_order) | ||
| 115 | for i, arch in ipairs(versions_order) do | ||
| 116 | versions_order[i] = versions[versions_order[i]] | ||
| 117 | end | 140 | end |
| 118 | output = output .. table.concat(versions_order, ', ') .. '<br/>' | 141 | output = output .. table.concat(versions, ', ') .. '<br/>' |
| 119 | end | 142 | end |
| 120 | output = output .. index_package_end | 143 | output = output .. index_package_end |
| 121 | if latest_rockspec then | 144 | if latest_rockspec then |
| @@ -127,7 +150,8 @@ function make_index(repo) | |||
| 127 | summary = rockspec.description.summary or "", | 150 | summary = rockspec.description.summary or "", |
| 128 | detailed = rockspec.description.detailed or "", | 151 | detailed = rockspec.description.detailed or "", |
| 129 | license = rockspec.description.license or "N/A", | 152 | license = rockspec.description.license or "N/A", |
| 130 | homepage = rockspec.description.homepage and ("| <a href="..rockspec.description.homepage..">project homepage</a>") or "" | 153 | homepage = rockspec.description.homepage and ("| <a href="..rockspec.description.homepage..">project homepage</a>") or "", |
| 154 | externaldependencies = format_external_dependencies(rockspec) | ||
| 131 | } | 155 | } |
| 132 | vars.detailed = vars.detailed:gsub("\n\n", "</p><p>"):gsub("%s+", " ") | 156 | vars.detailed = vars.detailed:gsub("\n\n", "</p><p>"):gsub("%s+", " ") |
| 133 | output = output:gsub("$(%w+)", vars) | 157 | output = output:gsub("$(%w+)", vars) |
