From 30e61252f75018bbf04fb481eb0a17e835cd1902 Mon Sep 17 00:00:00 2001 From: Kyle Hargraves Date: Mon, 24 Dec 2012 21:02:20 -0600 Subject: [PATCH] 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. --- html/index.erb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/html/index.erb b/html/index.erb index f0533b62..93e0d728 100644 --- a/html/index.erb +++ b/html/index.erb @@ -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 - ["[#{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 + + ["[#{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. \ No newline at end of file +