From 42a57c60624fdac5989723ccc70d2238fb517a7a Mon Sep 17 00:00:00 2001 From: dgreen Date: Fri, 4 Dec 2009 16:53:48 +0000 Subject: NEW - bug 294991: Update MediaWikiImageFetcher task to use MediaWiki API to determine image URLs https://bugs.eclipse.org/bugs/show_bug.cgi?id=294991 --- org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF | 1 - org.eclipse.mylyn.help.ui/build-helper.xml | 12 +- .../help/ui/anttask/MediaWikiImageFetcher.java | 147 --------------------- .../internal/help/ui/anttask/tasks.properties | 11 -- 4 files changed, 5 insertions(+), 166 deletions(-) delete mode 100644 org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/internal/help/ui/anttask/MediaWikiImageFetcher.java delete mode 100644 org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/internal/help/ui/anttask/tasks.properties (limited to 'org.eclipse.mylyn.help.ui') diff --git a/org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF index 2c190d0c7..dde7fcf3a 100644 --- a/org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF @@ -13,5 +13,4 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.mylyn.commons.ui;bundle-version="[3.0.0,4.0.0)";resolution:=optional, org.apache.ant;bundle-version="1.7.0";resolution:=optional Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Export-Package: org.eclipse.mylyn.internal.help.ui.anttask;x-internal:=true Bundle-Localization: plugin diff --git a/org.eclipse.mylyn.help.ui/build-helper.xml b/org.eclipse.mylyn.help.ui/build-helper.xml index 20b760fee..4d554b823 100644 --- a/org.eclipse.mylyn.help.ui/build-helper.xml +++ b/org.eclipse.mylyn.help.ui/build-helper.xml @@ -28,7 +28,7 @@ - + @@ -45,7 +45,7 @@ - + - - - + @@ -78,7 +76,7 @@ = Updating This Document = This document is maintained in a collaborative wiki. If you wish to update or modify this document please visit -@{help.doc.url.html} +@{help.doc.url.base}/@{help.doc.pageName} ]+)", Pattern.MULTILINE); //$NON-NLS-1$ - String htmlSrc; - try { - htmlSrc = readSrc(); - } catch (IOException e) { - throw new BuildException("Cannot read src: " + src + ": " + e.getMessage(), e); //$NON-NLS-1$ //$NON-NLS-2$ - } - log("Parsing " + src, Project.MSG_INFO); //$NON-NLS-1$ - int fileCount = 0; - Matcher imagePatternMatcher = imagePattern.matcher(htmlSrc); - while (imagePatternMatcher.find()) { - String alt = imagePatternMatcher.group(1); - String imageFragment = imagePatternMatcher.group(2); - if (imageFragment != null) { - Matcher fragmentUrlMatcher = fragmentUrlPattern.matcher(imageFragment); - if (fragmentUrlMatcher.find()) { - String url = fragmentUrlMatcher.group(1); - String qualifiedUrl = base + url; - log("Fetching " + qualifiedUrl, Project.MSG_INFO); //$NON-NLS-1$ - Get get = new Get(); - get.setProject(getProject()); - get.setLocation(getLocation()); - try { - get.setSrc(new URL(qualifiedUrl)); - } catch (MalformedURLException e) { - log("Skipping " + url + ": " + e.getMessage(), Project.MSG_WARN); //$NON-NLS-1$ //$NON-NLS-2$ - continue; - } - // note: we use the alt text for the name since for some files there is a case-difference between - // the server URL and the text used in the image src of the markup - String name = alt == null ? url.substring(url.lastIndexOf('/')) : alt; - get.setDest(new File(dest, name)); - get.execute(); - ++fileCount; - } - } - } - log("Fetched " + fileCount + " image files for " + src, Project.MSG_INFO); //$NON-NLS-1$ //$NON-NLS-2$ - } - - public String getBase() { - return base; - } - - public File getDest() { - return dest; - } - - public File getSrc() { - return src; - } - - private String readSrc() throws IOException { - StringBuilder buf = new StringBuilder((int) src.length()); - Reader reader = new BufferedReader(new FileReader(src)); - try { - int i; - while ((i = reader.read()) != -1) { - buf.append((char) i); - } - } finally { - reader.close(); - } - return buf.toString(); - } - - public void setBase(String base) { - this.base = base; - } - - public void setDest(File dest) { - this.dest = dest; - } - - public void setSrc(File src) { - this.src = src; - } - -} diff --git a/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/internal/help/ui/anttask/tasks.properties b/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/internal/help/ui/anttask/tasks.properties deleted file mode 100644 index 33848771c..000000000 --- a/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/internal/help/ui/anttask/tasks.properties +++ /dev/null @@ -1,11 +0,0 @@ -############################################################################### -# Copyright (c) 2009 Tasktop Technologies and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Tasktop Technologies - initial API and implementation -############################################################################### -mediawiki-fetch-images=org.eclipse.mylyn.internal.help.ui.anttask.MediaWikiImageFetcher -- cgit v1.2.3