Web: link to github and emacswiki

Adds an additional column to the table on http://melpa.milkbox.net
which provides a link directly to the github or emacswiki page for
a recipe.

My main gripe with using both `package-list-packages` and the web
UI is the extra effort required just to go check out a project's
README or similar. This should now be easier for the vast majority
of recipes in MELPA.

For emacswiki pages, only those recipes whose file matches the name
of the recipe are linked (ie, if the recipe uses :files, then no
link will be generated). This is Not Perfect(tm), but not bad either.
This commit is contained in:
Kyle Hargraves 2012-12-24 21:02:20 -06:00
parent 2086675f58
commit 30e61252f7

View file

@ -13,11 +13,13 @@
<%
require 'json'
archive_json = JSON.parse(File.open("../archive.json").read)
recipe_json = JSON.parse(File.open("../recipes.json").read)
headers = ["Package", "Version", "Description", "Source"]
headers = ["Package", "Version", "Description", "Recipe", "Source"]
data = archive_json.keys.sort.map do |pkgname|
versions, deps, descr, pkgtype = archive_json[pkgname]
recipe = recipe_json[pkgname]
version = versions.join('.')
pkgurl = "packages/#{pkgname}-#{version}." + (pkgtype == "single" ? "el" : "tar")
recipe_url = "https://github.com/milkypostman/melpa/blob/master/recipes/#{pkgname}"
@ -25,10 +27,17 @@
if descr =~ /(.*?)(\s*-\*-.*?)?\s*\[source:\s*(\w+)\]\s*/
descr, source = $1, $3
end
["<a name=\"#{pkgname}\"></a>[#{pkgname}](#{pkgurl})", version, descr, "[#{source}](#{recipe_url})"]
case source
when 'github' then source_url = "https://github.com/#{recipe['repo']}"
when 'wiki' then source_url = recipe.key?('files') ? nil : "http://www.emacswiki.org/emacs/#{pkgname}.el"
else source_url = nil
end
["<a name=\"#{pkgname}\"></a>[#{pkgname}](#{pkgurl})", version, descr, "[recipe](#{recipe_url})", source_url ? "[#{source}](#{source_url})" : ""]
end
colwidth = [0,0,0, 9]
colwidth = [0,0,0,0, 9]
data.map do |row|
row.to_enum(:each_with_index).map do |e,i|
@ -138,4 +147,4 @@ most of the packages that I am interested in.
<script language="javascript">
$("table").dataTable({bPaginate: false, bLengthChange: false});
$('div.dataTables_filter input').focus().attr("placeholder", "Enter filter terms");
</script>
</script>