Skip to content

Instantly share code, notes, and snippets.

@ecerulm
Created August 1, 2010 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecerulm/503692 to your computer and use it in GitHub Desktop.
Save ecerulm/503692 to your computer and use it in GitHub Desktop.
/*
* Menu: Get Eclipse Icons > Make web page
* Script-Path: /EclipseIcons/monkey/make_web_page.gm
* Kudos: ecerulm
* License: EPL 1.0
*/
def findFilesinFolder(folder) {
def toReturn = new ArrayList();
folder.members().each {
if (it instanceof org.eclipse.core.resources.IFolder) {
toReturn.addAll(findFilesinFolder(it));
} else {
toReturn.add(it);
}
}
return toReturn;
}
def targetProject = workspace.getRoot().getProject( 'EclipseIcons' )
def iconsFolder = targetProject.getFolder("icons");
def buf = new StringBuffer();
buf.append "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
buf.append "<html><head><title>Eclipse Icons</title></head><body>";
def members = iconsFolder.members();
members.each { plugin ->
if (plugin instanceof org.eclipse.core.resources.IFolder) {
def name = plugin.getName();
// buf.append "\nh1. "+name+"
\n";
// buf.append "p. ";
findFilesinFolder(plugin).each {arg ->
def location = arg.getLocation().toString();
def l = iconsFolder.getLocation().toString().length()+1;
location = location.substring(l);
buf.append "<a href=\""+location+"\" title=\""+location+"\"> <img src=\""+location+"\" alt=\"location\"/></a>\n";
}
// buf.append "
\n";
}
}
buf.append "</body></html>";
contents = buf.toString();
def indexHtml = iconsFolder.getFile("index.html");
if (indexHtml.exists()) {
indexHtml.delete(false, true, null);
}
fileStream = new ByteArrayInputStream(contents.getBytes("UTF-8"));
indexHtml.create(fileStream, false, null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment