Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 375229
Collapse All | Expand All

(-)a/org.eclipse.mylyn.docs.epub.ant.core/META-INF/MANIFEST.MF (-2 / +1 lines)
Lines 5-12 Link Here
5
Bundle-Version: 0.8.0.qualifier
5
Bundle-Version: 0.8.0.qualifier
6
Bundle-Vendor: Torkild U. Resheim
6
Bundle-Vendor: Torkild U. Resheim
7
Bundle-RequiredExecutionEnvironment: J2SE-1.5
7
Bundle-RequiredExecutionEnvironment: J2SE-1.5
8
Export-Package: org.eclipse.mylyn.docs.epub.ant;x-internal:=true,
8
Export-Package: org.eclipse.mylyn.docs.epub.ant.core;x-internal:=true;uses:="org.eclipse.mylyn.docs.epub,org.apache.tools.ant.types,org.apache.tools.ant"
9
 org.eclipse.mylyn.docs.epub.ant.core;x-internal:=true;uses:="org.eclipse.mylyn.docs.epub,org.apache.tools.ant.types,org.apache.tools.ant"
10
Require-Bundle: org.apache.ant;bundle-version="1.8.2",
9
Require-Bundle: org.apache.ant;bundle-version="1.8.2",
11
 org.eclipse.ant.core;bundle-version="3.2.300",
10
 org.eclipse.ant.core;bundle-version="3.2.300",
12
 org.eclipse.mylyn.docs.epub.core;bundle-version="0.8.0"
11
 org.eclipse.mylyn.docs.epub.core;bundle-version="0.8.0"
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/ContributorType.java (-66 lines)
Lines 1-66 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.util.Locale;
14
15
/**
16
 * 
17
 * @author Torkild U. Resheim
18
 * @ant.type name="contributor" category="epub"
19
 */
20
public class ContributorType {
21
22
	String fileAs;
23
24
	String id;
25
26
	Locale lang;
27
28
	String name;
29
30
	String role;
31
32
	/**
33
	 * @ant.not-required
34
	 */
35
	public void setFileAs(String fileAs) {
36
		this.fileAs = fileAs;
37
	}
38
39
	/**
40
	 * @ant.not-required
41
	 */
42
	public void setId(String id) {
43
		this.id = id;
44
	}
45
46
	/**
47
	 * @ant.not-required the language code
48
	 */
49
	public void setLang(Locale lang) {
50
		this.lang = lang;
51
	}
52
53
	/**
54
	 * @ant.required name of the contributor
55
	 */
56
	public void setName(String name) {
57
		this.name = name;
58
	}
59
60
	/**
61
	 * @ant.not-required
62
	 */
63
	public void setRole(String role) {
64
		this.role = role;
65
	}
66
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/CoverType.java (-38 lines)
Lines 1-38 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
/**
14
 * 
15
 * @author Torkild U. Resheim
16
 * @ant.type name="cover" category="epub"
17
 */
18
public class CoverType {
19
20
	String image;
21
22
	String value;
23
24
	/**
25
	 * @ant.required
26
	 */
27
	public void addText(String value) {
28
		this.value = value;
29
	}
30
31
	/**
32
	 * @ant.required
33
	 */
34
	public void setImage(String image) {
35
		this.image = image;
36
	}
37
38
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/CoverageType.java (-48 lines)
Lines 1-48 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.util.Locale;
14
15
/**
16
 * 
17
 * @author Torkild U. Resheim
18
 * @ant.type name="coverage" category="epub"
19
 */
20
public class CoverageType {
21
22
	String id;
23
24
	String text;
25
26
	Locale lang;
27
28
	/**
29
	 * @ant.required
30
	 */
31
	public void addText(String text) {
32
		this.text = text;
33
	}
34
35
	/**
36
	 * @ant.not-required
37
	 */
38
	public void setId(String id) {
39
		this.id = id;
40
	}
41
42
	/**
43
	 * @ant.not-required
44
	 */
45
	public void setLang(Locale lang) {
46
		this.lang = lang;
47
	}
48
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/CreatorType.java (-66 lines)
Lines 1-66 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.util.Locale;
14
15
/**
16
 * 
17
 * @author Torkild U. Resheim
18
 * @ant.type name="creator" category="epub"
19
 */
20
public class CreatorType {
21
22
	String fileAs;
23
24
	String id;
25
26
	Locale lang;
27
28
	String name;
29
30
	String role;
31
32
	/**
33
	 * @ant.not-required
34
	 */
35
	public void setFileAs(String fileAs) {
36
		this.fileAs = fileAs;
37
	}
38
39
	/**
40
	 * @ant.not-required
41
	 */
42
	public void setId(String id) {
43
		this.id = id;
44
	}
45
46
	/**
47
	 * @ant.not-required
48
	 */
49
	public void setLang(Locale lang) {
50
		this.lang = lang;
51
	}
52
53
	/**
54
	 * @ant.required
55
	 */
56
	public void setName(String name) {
57
		this.name = name;
58
	}
59
60
	/**
61
	 * @ant.not-required
62
	 */
63
	public void setRole(String role) {
64
		this.role = role;
65
	}
66
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/DateType.java (-47 lines)
Lines 1-47 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
/**
14
 * 
15
 * @author Torkild U. Resheim
16
 * @ant.type name="date" category="epub"
17
 */
18
public class DateType {
19
20
	String date;
21
22
	String event;
23
24
	String id;
25
26
	/**
27
	 * @ant.required
28
	 */
29
	public void setDate(String date) {
30
		this.date = date;
31
	}
32
33
	/**
34
	 * @ant.not-required
35
	 */
36
	public void setEvent(String event) {
37
		this.event = event;
38
	}
39
40
	/**
41
	 * @ant.not-required
42
	 */
43
	public void setId(String id) {
44
		this.id = id;
45
	}
46
47
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/EpubTask.java (-243 lines)
Lines 1-243 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.io.File;
14
import java.util.ArrayList;
15
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.DirectoryScanner;
18
import org.apache.tools.ant.Project;
19
import org.apache.tools.ant.Task;
20
import org.eclipse.mylyn.docs.epub.core.EPUB;
21
import org.eclipse.mylyn.docs.epub.core.OPSPublication;
22
import org.eclipse.mylyn.docs.epub.opf.Role;
23
import org.eclipse.mylyn.docs.epub.opf.Type;
24
25
/**
26
 * Assemble a new EPUB.
27
 * 
28
 * 
29
 * @author Torkild U. Resheim
30
 * @ant.task name="epub" category="epub"
31
 */
32
public class EpubTask extends Task {
33
34
	private final OPSPublication ops = OPSPublication.getVersion2Instance();
35
36
	private final ArrayList<FileSetType> filesets;
37
38
	private TocType toc = null;
39
40
	private File workingFolder;
41
42
	private File epubFile;
43
44
	public EpubTask() {
45
		super();
46
		filesets = new ArrayList<FileSetType>();
47
	}
48
49
	public void addConfiguredContributor(ContributorType item) {
50
		if (item.role == null) {
51
			ops.addContributor(item.id, item.lang, item.name, null, item.fileAs);
52
		} else {
53
			ops.addContributor(item.id, item.lang, item.name, Role.get(item.role), item.fileAs);
54
		}
55
	}
56
57
	public void addConfiguredCover(CoverType item) {
58
		ops.setCover(new File(item.image), item.value);
59
	}
60
61
	public void addConfiguredCoverage(CoverageType coverage) {
62
		ops.addCoverage(coverage.id, coverage.lang, coverage.text);
63
	}
64
65
	public void addConfiguredCreator(CreatorType item) {
66
		if (item.role == null) {
67
			ops.addCreator(item.id, item.lang, item.name, null, item.fileAs);
68
		} else {
69
			ops.addCreator(item.id, item.lang, item.name, Role.get(item.role), item.fileAs);
70
		}
71
	}
72
73
	public void addConfiguredDate(DateType item) {
74
		ops.addDate(item.id, item.date, item.event);
75
	}
76
77
	/**
78
	 * The FileSet sub-element is used to add EPUB artifacts that are not a part
79
	 * of the main text. This can be graphical items and styling (CSS).
80
	 * 
81
	 * @param fs
82
	 *            the fileset to add
83
	 */
84
	public void addConfiguredFileSet(FileSetType fs) {
85
		filesets.add(fs);
86
	}
87
88
	public void addConfiguredFormat(FormatType format) {
89
		ops.addFormat(format.id, format.text);
90
	}
91
92
	/**
93
	 * @ant.required
94
	 */
95
	public void addConfiguredIdentifier(IdentifierType identifier) {
96
		ops.addIdentifier(identifier.id, identifier.scheme, identifier.value);
97
	}
98
99
	/**
100
	 * @ant.required
101
	 */
102
	public void addConfiguredItem(ItemType item) {
103
		ops.addItem(item.id, item.lang, item.file, item.dest, item.type, item.spine, item.linear, item.noToc);
104
	}
105
106
	/**
107
	 * @ant.required
108
	 */
109
	public void addConfiguredLanguage(LanguageType language) {
110
		ops.addLanguage(language.id, language.code);
111
	}
112
113
	public void addConfiguredMeta(MetaType item) {
114
		ops.addMeta(item.name, item.content);
115
	}
116
117
	public void addConfiguredPublisher(PublisherType publisher) {
118
		ops.addPublisher(publisher.id, publisher.lang, publisher.text);
119
	}
120
121
	public void addConfiguredReference(ReferenceType reference) {
122
		Type type = Type.get(reference.type);
123
		if (type == null) {
124
			throw new BuildException("Unknown reference type " + reference.type);
125
		}
126
		ops.addReference(reference.href, reference.title, type);
127
	}
128
129
	public void addConfiguredRelation(RelationType relation) {
130
		ops.addRelation(relation.id, relation.lang, relation.text);
131
	}
132
133
	public void addConfiguredRights(RightsType rights) {
134
		ops.addRights(rights.id, rights.lang, rights.text);
135
	}
136
137
	public void addConfiguredSource(SourceType source) {
138
		ops.addSource(source.id, source.lang, source.text);
139
	}
140
141
	public void addConfiguredSubject(SubjectType subject) {
142
		ops.addSubject(subject.id, subject.lang, subject.text);
143
	}
144
145
	/**
146
	 * @ant.required
147
	 */
148
	public void addConfiguredTitle(TitleType title) {
149
		ops.addTitle(title.id, title.lang, title.text);
150
	}
151
152
	public void addConfiguredToc(TocType toc) {
153
		if (this.toc != null) {
154
			throw new BuildException("Only one table of contents (toc) declaration is allowed.");
155
		}
156
		this.toc = toc;
157
	}
158
159
	public void addConfiguredType(org.eclipse.mylyn.docs.epub.ant.TypeType type) {
160
		ops.addType(type.id, type.text);
161
	}
162
163
	private void addFilesets() {
164
		for (FileSetType fs : filesets) {
165
			if (fs.getProject() == null) {
166
				log("Deleting fileset with no project specified;" + " assuming executing project", Project.MSG_VERBOSE);
167
				fs = (FileSetType) fs.clone();
168
				fs.setProject(getProject());
169
			}
170
			final File fsDir = fs.getDir();
171
			if (fsDir == null) {
172
				throw new BuildException("File or Resource without directory or file specified");
173
			} else if (!fsDir.isDirectory()) {
174
				throw new BuildException("Directory does not exist:" + fsDir);
175
			}
176
			DirectoryScanner ds = fs.getDirectoryScanner();
177
			String[] includedFiles = ds.getIncludedFiles();
178
			for (int i = 0; i < includedFiles.length; i++) {
179
				String filename = includedFiles[i].replace('\\', '/');
180
				filename = filename.substring(filename.lastIndexOf("/") + 1);
181
				File base = ds.getBasedir();
182
				File found = new File(base, includedFiles[i]);
183
				ops.addItem(null, fs.lang, found, fs.dest, null, false, true, false);
184
			}
185
186
		}
187
188
	}
189
190
	@Override
191
	public void execute() throws BuildException {
192
		validate();
193
		addFilesets();
194
		if (toc != null) {
195
			if (toc.generate) {
196
				ops.setGenerateToc(true);
197
			} else if (toc.file != null) {
198
				ops.setTableOfContents(toc.file);
199
			}
200
		}
201
		try {
202
			EPUB epub = new EPUB();
203
			epub.add(ops);
204
			if (workingFolder == null) {
205
				epub.pack(epubFile);
206
			} else {
207
				epub.pack(epubFile, workingFolder);
208
			}
209
210
		} catch (Exception e) {
211
			throw new BuildException(e);
212
		}
213
	}
214
215
	/**
216
	 * @ant.not-required Automatically add referenced resources.
217
	 */
218
	public void setIncludeReferenced(boolean automatic) {
219
		ops.setIncludeReferencedResources(automatic);
220
	}
221
222
	/**
223
	 * 
224
	 * 
225
	 * @param file
226
	 *            path to the generated EPUB file.
227
	 */
228
	public void setFile(File file) {
229
		this.epubFile = file;
230
	}
231
232
	public void setIdentifierId(String identifierId) {
233
		ops.setIdentifierId(identifierId);
234
	}
235
236
	public void setWorkingFolder(File workingFolder) {
237
		this.workingFolder = workingFolder;
238
	}
239
240
	private void validate() {
241
	}
242
243
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/FileSetType.java (-36 lines)
Lines 1-36 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.util.Locale;
14
15
/**
16
 * @author Torkild U. Resheim
17
 * @ant.type name="epubfileset" category="epub"
18
 */
19
public class FileSetType extends org.apache.tools.ant.types.FileSet {
20
21
	String dest;
22
23
	Locale lang;
24
25
	public FileSetType() {
26
27
	}
28
29
	public void setLocale(Locale lang) {
30
		this.lang = lang;
31
	}
32
33
	public void setDest(String dest) {
34
		this.dest = dest;
35
	}
36
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/FormatType.java (-37 lines)
Lines 1-37 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
/**
14
 * @author Torkild U. Resheim
15
 * @ant.type name="format" category="epub"
16
 */
17
public class FormatType {
18
19
	String id;
20
21
	String text;
22
23
	/**
24
	 * @ant.required
25
	 */
26
	public void addText(String text) {
27
		this.text = text;
28
	}
29
30
	/**
31
	 * @ant.not-required
32
	 */
33
	public void setId(String id) {
34
		this.id = id;
35
	}
36
37
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/IdentifierType.java (-46 lines)
Lines 1-46 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.docs.epub.ant;
13
14
/**
15
 * @author Torkild U. Resheim
16
 * @ant.type name="identifier" category="epub"
17
 */
18
public class IdentifierType {
19
20
	String id;
21
22
	String scheme;
23
24
	String value;
25
26
	/**
27
	 * @ant.required
28
	 */
29
	public void addText(String value) {
30
		this.value = value;
31
	}
32
33
	/**
34
	 * @ant.required
35
	 */
36
	public void setId(String id) {
37
		this.id = id;
38
	}
39
40
	/**
41
	 * @ant.required
42
	 */
43
	public void setScheme(String scheme) {
44
		this.scheme = scheme;
45
	}
46
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/ItemType.java (-103 lines)
Lines 1-103 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.io.File;
14
import java.util.Locale;
15
16
/**
17
 * @author Torkild U. Resheim
18
 * @ant.type name="item" category="epub"
19
 */
20
public class ItemType {
21
22
	String dest;
23
24
	File file;
25
26
	String id;
27
28
	Locale lang;
29
30
	/** Default is that items are in reading order */
31
	public boolean linear = true;
32
33
	boolean noToc = false;
34
35
	String page;
36
37
	/** Default is to add the item to the spine */
38
	boolean spine = true;
39
40
	String type;
41
42
	/**
43
	 * @ant.not-required
44
	 */
45
	public void setDest(String dest) {
46
		this.dest = dest;
47
	}
48
49
	/**
50
	 * A file on the local file system.
51
	 * 
52
	 * @param file
53
	 * @ant.required
54
	 */
55
	public void setFile(File file) {
56
		this.file = file;
57
	}
58
59
	/**
60
	 * @ant.not-required
61
	 */
62
	public void setId(String id) {
63
		this.id = id;
64
	}
65
66
	public void setLang(Locale lang) {
67
		this.lang = lang;
68
	}
69
70
	public void setLinear(boolean linear) {
71
		this.linear = linear;
72
	}
73
74
	/**
75
	 * @ant.not-required
76
	 */
77
	public void setNoToc(boolean toc) {
78
		this.noToc = toc;
79
	}
80
81
	/**
82
	 * A page on the wiki.
83
	 * 
84
	 * @param page
85
	 */
86
	public void setPage(String page) {
87
		this.page = page;
88
	}
89
90
	/**
91
	 * @ant.not-required
92
	 */
93
	public void setSpine(boolean spine) {
94
		this.spine = spine;
95
	}
96
97
	/**
98
	 * @ant.not-required
99
	 */
100
	public void setType(String type) {
101
		this.type = type;
102
	}
103
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/LanguageType.java (-32 lines)
Lines 1-32 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
/**
14
 * @author Torkild U. Resheim
15
 * @ant.type name="language" category="epub"
16
 */
17
public class LanguageType {
18
	String code;
19
20
	String id;
21
22
	public void setId(String id) {
23
		this.id = id;
24
	}
25
26
	/**
27
	 * @ant.required
28
	 */
29
	public void setCode(String code) {
30
		this.code = code;
31
	}
32
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/MetaType.java (-37 lines)
Lines 1-37 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
/**
14
 * @author Torkild U. Resheim
15
 * @ant.type name="meta" category="epub"
16
 */
17
public class MetaType {
18
19
	String name;
20
21
	String content;
22
23
	/**
24
	 * @ant.required
25
	 */
26
	public void setName(String name) {
27
		this.name = name;
28
	}
29
30
	/**
31
	 * @ant.required
32
	 */
33
	public void setContent(String content) {
34
		this.content = content;
35
	}
36
37
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/PublisherType.java (-48 lines)
Lines 1-48 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.util.Locale;
14
15
/**
16
 * @author Torkild U. Resheim
17
 * @ant.type name="publisher" category="epub"
18
 */
19
public class PublisherType {
20
21
	String id;
22
23
	Locale lang;
24
25
	String text;
26
27
	/**
28
	 * @ant.required
29
	 */
30
	public void addText(String text) {
31
		this.text = text;
32
	}
33
34
	/**
35
	 * @ant.not-required
36
	 */
37
	public void setId(String id) {
38
		this.id = id;
39
	}
40
41
	/**
42
	 * @ant.not-required
43
	 */
44
	public void setLang(Locale lang) {
45
		this.lang = lang;
46
	}
47
48
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/ReferenceType.java (-46 lines)
Lines 1-46 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
/**
14
 * @author Torkild U. Resheim
15
 * @ant.type name="reference" category="epub"
16
 */
17
public class ReferenceType {
18
19
	String href;
20
21
	String title;
22
23
	String type;
24
25
	/**
26
	 * @ant.required
27
	 */
28
	public void setHref(String href) {
29
		this.href = href;
30
	}
31
32
	/**
33
	 * @ant.required
34
	 */
35
	public void setTitle(String title) {
36
		this.title = title;
37
	}
38
39
	/**
40
	 * @ant.required
41
	 */
42
	public void setType(String type) {
43
		this.type = type;
44
	}
45
46
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/RelationType.java (-47 lines)
Lines 1-47 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.util.Locale;
14
15
/**
16
 * @author Torkild U. Resheim
17
 * @ant.type name="relation" category="epub"
18
 */
19
public class RelationType {
20
21
	String id;
22
23
	Locale lang;
24
25
	String text;
26
27
	/**
28
	 * @ant.required
29
	 */
30
	public void addText(String text) {
31
		this.text = text;
32
	}
33
34
	/**
35
	 * @ant.not-required
36
	 */
37
	public void setId(String id) {
38
		this.id = id;
39
	}
40
41
	/**
42
	 * @ant.not-required
43
	 */
44
	public void setLang(Locale lang) {
45
		this.lang = lang;
46
	}
47
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/RightsType.java (-48 lines)
Lines 1-48 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.util.Locale;
14
15
/**
16
 * @author Torkild U. Resheim
17
 * @ant.type name="rights" category="epub"
18
 */
19
public class RightsType {
20
21
	String id;
22
23
	Locale lang;
24
25
	String text;
26
27
	/**
28
	 * @ant.required
29
	 */
30
	public void addText(String text) {
31
		this.text = text;
32
	}
33
34
	/**
35
	 * @ant.not-required
36
	 */
37
	public void setId(String id) {
38
		this.id = id;
39
	}
40
41
	/**
42
	 * @ant.not-required
43
	 */
44
	public void setLang(Locale lang) {
45
		this.lang = lang;
46
	}
47
48
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/SourceType.java (-48 lines)
Lines 1-48 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.util.Locale;
14
15
/**
16
 * @author Torkild U. Resheim
17
 * @ant.type name="source" category="epub"
18
 */
19
public class SourceType {
20
21
	String id;
22
23
	Locale lang;
24
25
	String text;
26
27
	/**
28
	 * @ant.required
29
	 */
30
	public void addText(String text) {
31
		this.text = text;
32
	}
33
34
	/**
35
	 * @ant.not-required
36
	 */
37
	public void setId(String id) {
38
		this.id = id;
39
	}
40
41
	/**
42
	 * @ant.not-required
43
	 */
44
	public void setLang(Locale lang) {
45
		this.lang = lang;
46
	}
47
48
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/SubjectType.java (-48 lines)
Lines 1-48 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.util.Locale;
14
15
/**
16
 * @author Torkild U. Resheim
17
 * @ant.type name="subject" category="epub"
18
 */
19
public class SubjectType {
20
21
	String id;
22
23
	Locale lang;
24
25
	String text;
26
27
	/**
28
	 * @ant.required
29
	 */
30
	public void addText(String text) {
31
		this.text = text;
32
	}
33
34
	/**
35
	 * @ant.not-required
36
	 */
37
	public void setId(String id) {
38
		this.id = id;
39
	}
40
41
	/**
42
	 * @ant.not-required
43
	 */
44
	public void setLang(Locale lang) {
45
		this.lang = lang;
46
	}
47
48
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/TitleType.java (-45 lines)
Lines 1-45 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.util.Locale;
14
15
/**
16
 * @author Torkild U. Resheim
17
 * @ant.type name="title" category="epub"
18
 */
19
public class TitleType {
20
21
	String text;
22
23
	Locale lang;
24
25
	String id;
26
27
	public void setId(String id) {
28
		this.id = id;
29
	}
30
31
	/**
32
	 * @ant.required
33
	 */
34
	public void addText(String text) {
35
		this.text = text;
36
	}
37
38
	/**
39
	 * @ant.not-required
40
	 */
41
	public void setLang(Locale lang) {
42
		this.lang = lang;
43
	}
44
45
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/TocType.java (-41 lines)
Lines 1-41 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
import java.io.File;
14
15
/**
16
 * Represents a table of contents element in the {@link EpubTask}. One should
17
 * specify either a path to a NCX file or whether or not to generate the NCX.
18
 * 
19
 * @author Torkild U. Resheim
20
 * @ant.type name="toc" category="epub"
21
 */
22
public class TocType {
23
24
	File file;
25
26
	boolean generate;
27
28
	/**
29
	 * @ant.not-required
30
	 */
31
	public void setFile(File file) {
32
		this.file = file;
33
	}
34
35
	/**
36
	 * @ant.not-required
37
	 */
38
	public void setGenerate(boolean generate) {
39
		this.generate = generate;
40
	}
41
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/TypeType.java (-37 lines)
Lines 1-37 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Torkild U. Resheim.
3
 * 
4
 * All rights reserved. This program and the accompanying materials are made
5
 * available under the terms of the Eclipse Public License v1.0 which
6
 * accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.mylyn.docs.epub.ant;
12
13
/**
14
 * @author Torkild U. Resheim
15
 * @ant.type name="type" category="epub"
16
 */
17
public class TypeType {
18
19
	String id;
20
21
	String text;
22
23
	/**
24
	 * @ant.required
25
	 */
26
	public void addText(String text) {
27
		this.text = text;
28
	}
29
30
	/**
31
	 * @ant.not-required
32
	 */
33
	public void setId(String id) {
34
		this.id = id;
35
	}
36
37
}
(-)a/org.eclipse.mylyn.docs.epub.ant.core/src/org/eclipse/mylyn/docs/epub/ant/tasks.properties (-2 / +2 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2011 Torkild U. Resheim
2
# Copyright (c) 2011,2012 Torkild U. Resheim
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 8-11 Link Here
8
# Contributors:
8
# Contributors:
9
#     Torkild U. Resheim - initial API and implementation
9
#     Torkild U. Resheim - initial API and implementation
10
###############################################################################
10
###############################################################################
11
epub=org.eclipse.mylyn.docs.epub.ant.EpubTask
11
epub=org.eclipse.mylyn.docs.epub.ant.core.EpubTask
(-)a/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/ant/TestAntTask.java (-18 / +1 lines)
Lines 30-38 Link Here
30
	static ClassLoader classLoader;
30
	static ClassLoader classLoader;
31
31
32
	private static final String SIMPLE_FILE_PATH = "test/ant/simple.epub";
32
	private static final String SIMPLE_FILE_PATH = "test/ant/simple.epub";
33
33
	
34
	private static final String DOC_FILE_PATH = "../org.eclipse.mylyn.docs.epub.help/Building_EPUBs.epub";
35
36
	public TestAntTask(String s) {
34
	public TestAntTask(String s) {
37
		super(s);
35
		super(s);
38
		classLoader = getClass().getClassLoader();
36
		classLoader = getClass().getClassLoader();
Lines 68-86 Link Here
68
		assertEpub(SIMPLE_FILE_PATH);
66
		assertEpub(SIMPLE_FILE_PATH);
69
	}
67
	}
70
68
71
	/**
72
	 * Tests the "Building EPUBs" book (generated using the Ant task) using the
73
	 * epub validator. This book is assembled by building the
74
	 * "org.eclipse.mylyn.docs.epub.ui" bundle. The book contents is converted
75
	 * from Textile markup to HTML using WikiText.
76
	 */
77
	public void testDocumentationBook() {
78
		File file = getFile(DOC_FILE_PATH);
79
		assertTrue("Missing publication " + file, file.exists());
80
		StringWriter sw = new StringWriter();
81
		PrintWriter pw = new PrintWriter(sw);
82
		EpubCheck checker = new EpubCheck(file, pw);
83
		checker.validate();
84
		Assert.assertTrue(sw.getBuffer().toString().trim(), checker.errorCount == 0);
85
	}
86
}
69
}

Return to bug 375229