mkdir -p "$(PREFIX)/lib" "$(PREFIX)/bin"
cp $(NAME).jar "$(PREFIX)/lib/"
echo "#!/bin/sh" > "$(PREFIX)/bin/$(NAME)"
- echo "$(RJAR) $(RJAR_FLAGS) \"$(PREFIX)/lib/$(NAME).jar\" \"$$@\"" >> "$(PREFIX)/bin/$(NAME)"
+ echo "$(RJAR) $(RJAR_FLAGS) \"$(PREFIX)/lib/$(NAME).jar\" \"\$$@\"" >> "$(PREFIX)/bin/$(NAME)"
chmod a+rx "$(PREFIX)/bin/$(NAME)"
// Most of the rest is dependent upon this:
config = new ConfigBundle();
+ String configDir = System.getenv("CONFIG_DIR");
+ if (configDir == null) {
+ configDir = new File(System.getProperty("user.home"), ".fanfix")
+ .getPath();
+ }
+ if (configDir != null) {
+ if (!new File(configDir).exists()) {
+ new File(configDir).mkdirs();
+ } else {
+ Bundles.setDirectory(configDir);
+ }
+
+ try {
+ config = new ConfigBundle();
+ config.updateFile(configDir);
+ } catch (IOException e) {
+ syserr(e);
+ }
+ try {
+ trans = new StringIdBundle(getLang());
+ trans.updateFile(configDir);
+ } catch (IOException e) {
+ syserr(e);
+ }
+
+ Bundles.setDirectory(configDir);
+ }
+
trans = new StringIdBundle(getLang());
lib = new Library(getFile(Config.LIBRARY_DIR));
debug = Instance.getConfig().getBoolean(Config.DEBUG_ERR, false);
coverDir = null;
}
- String configDir = System.getenv("CONFIG_DIR");
- if (configDir == null) {
- configDir = new File(System.getProperty("user.home"), ".fanfix")
- .getPath();
- }
- if (configDir != null) {
- if (!new File(configDir).exists()) {
- new File(configDir).mkdirs();
- } else {
- Bundles.setDirectory(configDir);
- }
-
- try {
- config = new ConfigBundle();
- config.updateFile(configDir);
- } catch (IOException e) {
- syserr(e);
- }
- try {
- trans = new StringIdBundle(getLang());
- trans.updateFile(configDir);
- } catch (IOException e) {
- syserr(e);
- }
-
- Bundles.setDirectory(configDir);
- }
-
try {
String ua = config.getString(Config.USER_AGENT);
int hours = config.getInteger(Config.CACHE_MAX_TIME_CHANGING, -1);
public class Library {
private File baseDir;
private Map<MetaData, File> stories;
- private BasicSupport itSupport = BasicSupport
- .getSupport(SupportType.INFO_TEXT);
private int lastId;
/**
for (Entry<MetaData, File> entry : getStories().entrySet()) {
if (luid.equals(entry.getKey().getLuid())) {
try {
- return itSupport.process(entry.getValue().toURI()
- .toURL());
+ SupportType type = SupportType.valueOfAllOkUC(entry
+ .getKey().getType());
+ URL url = entry.getValue().toURI().toURL();
+ if (type != null) {
+ return BasicSupport.getSupport(type).process(url);
+ } else {
+ throw new IOException("Unknown type: "
+ + entry.getKey().getType());
+ }
} catch (IOException e) {
// We should not have not-supported files in the
// library
private Map<MetaData, File> getStories() {
if (stories.isEmpty()) {
lastId = 0;
- String format = Instance.getConfig()
- .getString(Config.IMAGE_FORMAT_COVER).toLowerCase();
+ String format = "."
+ + Instance.getConfig().getString(Config.IMAGE_FORMAT_COVER)
+ .toLowerCase();
for (File dir : baseDir.listFiles()) {
if (dir.isDirectory()) {
for (File file : dir.listFiles()) {
String path = file.getPath().toLowerCase();
if (!path.endsWith(".info")
&& !path.endsWith(format)) {
- MetaData meta = itSupport.processMeta(
+ // TODO: export .info reading to a class and use
+ // it here
+ SupportType type = SupportType.INFO_TEXT;
+ if (path.toLowerCase().endsWith(".cbz")) {
+ type = SupportType.CBZ;
+ }
+ BasicSupport support = BasicSupport
+ .getSupport(type);
+ MetaData meta = support.processMeta(
file.toURI().toURL()).getMeta();
if (meta != null) {
stories.put(meta, file);
private String luid;
private String lang;
private String publisher;
+ private String type;
private boolean imageDocument;
/**
this.publisher = publisher;
}
+ /**
+ * The output type this {@link Story} is in.
+ *
+ * @return the type the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * The output type this {@link Story} is in.
+ *
+ * @param type
+ * the new type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
/**
* Document catering mostly to image files.
*
String paragraphNumber = String.format("%04d", 0);
imageName = paragraphNumber + "_" + chapterNameNum + ".png";
+ if (story.getMeta() != null) {
+ story.getMeta().setType(getType().toString());
+ }
+
if (writeCover) {
InfoCover.writeCover(targetDir, targetName, story.getMeta());
}
// will also save the images!
new InfoText().process(story, dir, targetNameOrig);
+ InfoCover.writeInfo(dir, targetNameOrig, story.getMeta());
+ InfoCover.writeCover(dir, targetNameOrig, story.getMeta());
+
IOUtils.writeSmallFile(dir, "version", "3.0");
try {
writeMeta(infoWriter, "LANG", lang);
writeMeta(infoWriter, "IMAGES_DOCUMENT",
meta.isImageDocument() ? "true" : "false");
+ writeMeta(infoWriter, "TYPE", meta.getType());
if (meta.getCover() != null) {
String format = Instance.getConfig()
.getString(Config.IMAGE_FORMAT_COVER).toLowerCase();
if (!entry.isDirectory()
&& entry.getName().startsWith(getDataPrefix())) {
String entryLName = entry.getName().toLowerCase();
+
boolean imageEntry = false;
for (String ext : getImageExt(false)) {
if (entryLName.endsWith(ext)) {