Skip to content

Commit

Permalink
Rename HTML_DIR to OUTPUT_DIR. Fixes #22 (.ini options file allowed)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Sontag committed Sep 14, 2016
1 parent 2173d23 commit dda35fa
Show file tree
Hide file tree
Showing 8 changed files with 341 additions and 306 deletions.
Binary file added MibTeX/lib/ini4j-0.5.4.jar
Binary file not shown.
158 changes: 94 additions & 64 deletions MibTeX/src/de/mibtex/BibtexViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,87 +12,117 @@
import de.mibtex.export.ExportHTML;
import de.mibtex.export.ExportJSON;
import de.mibtex.export.ExportNewHTML2;
import org.ini4j.Ini;

import java.io.File;
import java.io.IOException;

/**
* A class to export a given BibTeX file to another format
*
*
* @author Thomas Thuem, Christopher Sontag
*/
public class BibtexViewer {

public static String BIBTEX_DIR;

public static String MAIN_DIR;
public static String HTML_DIR;

public static String OUTPUT_DIR;

public static String PDF_DIR_REL;

public static String PDF_DIR;

public static String TAGS;

private static boolean cleanOutputDir;

private static boolean updateCitations;

public static String CITATION_DIR;


private static String format = "HTML";

public static String CITATION_DIR;

/**
* Example arguments
*
*
* BibtexViewer "C:\\Users\\tthuem\\workspace4.2.1\\tthuem-Bibtex\\"
* "C:\\Users\\tthuem\\Dropbox\\Literatur\\" "HTML\\" "..\\Library\\"
* "Library\\" "tt-tags" "CSV/JSON/HTML" "true" "C:\\Users\\tthuem\\workspace4.2.1\\tthuem-Bibtex\\"
*
*
* @param args array containing:
* - path to Bibtex file path to main directory
* - relative path of the HTML to main directory
* - relative path of PDF files to the HTML folder (for linking files in HTML)
* - relative path of PDF files to main directory
* - name of the tag containing your keywords
* - format for export (CSV/JSON/HTML)
* - boolean for output cleaning (default: false)
* - boolean for update citations file (default:true)
* - path to citations file (default: Bibtex file path)
* - path to Bibtex file path to main directory
* - relative path of the HTML to main directory
* - relative path of PDF files to the HTML folder (for linking files in HTML)
* - relative path of PDF files to main directory
* - name of the tag containing your keywords
* - format for export (CSV/JSON/HTML)
* - boolean for output cleaning (default: false)
* - boolean for update citations file (default:true)
* - path to citations file (default: Bibtex file path)
*/
public static void main(String[] args) {
BIBTEX_DIR = args[0];
MAIN_DIR = args[1];
HTML_DIR = MAIN_DIR + args[2];
PDF_DIR_REL = args[3];
PDF_DIR = MAIN_DIR + args[4];
TAGS = args[5];
try {
cleanOutputDir = Boolean.getBoolean(args[7]);
} catch (Exception e) {
System.out
.println("Output will not be cleaned");
cleanOutputDir = false;
}
try {
updateCitations = Boolean.getBoolean(args[8]);
} catch (Exception e) {
System.out
.println("Citations are going to be updated");
updateCitations = true;
}
try {
CITATION_DIR = args[9];
} catch (Exception e) {
System.out
.println("Citation is saved in Bibtex directory");
CITATION_DIR = BIBTEX_DIR;
}
String format = "HTML";
try {
format = args[6];
} catch (Exception e) {
System.out
.println("Exportformat Parameter not recognized. Setting Exportformat to HTML");
File iniFile = new File("options.ini");
if (iniFile.exists()) {
Ini ini = null;
try {
ini = new Ini(iniFile);
} catch (IOException e) {
e.printStackTrace();
}
BIBTEX_DIR = ini.get("options", "bibtex-dir");
MAIN_DIR = ini.get("options", "main-dir");
OUTPUT_DIR = MAIN_DIR + ini.get("options", "out-dir-rel");
PDF_DIR = MAIN_DIR + ini.get("options", "pdf-dir");
PDF_DIR_REL = ini.get("options", "pdf-dir-rel");
TAGS = ini.get("options", "tags");
cleanOutputDir = ini.get("options", "clean", Boolean.class);
updateCitations = ini.get("options", "citationService", Boolean.class);
String citationDir = ini.get("options", "citation-dir");
if (citationDir.isEmpty()) {
CITATION_DIR = BIBTEX_DIR;
} else {
CITATION_DIR = citationDir;
}
format = ini.get("options", "out-format");
} else {
BIBTEX_DIR = args[0];
MAIN_DIR = args[1];
OUTPUT_DIR = MAIN_DIR + args[2];
PDF_DIR_REL = args[3];
PDF_DIR = MAIN_DIR + args[4];
TAGS = args[5];
try {
cleanOutputDir = Boolean.getBoolean(args[7]);
} catch (Exception e) {
System.out
.println("Output will not be cleaned");
cleanOutputDir = false;
}
try {
updateCitations = Boolean.getBoolean(args[8]);
} catch (Exception e) {
System.out
.println("Citations are going to be updated");
updateCitations = true;
}
try {
CITATION_DIR = args[9];
} catch (Exception e) {
System.out
.println("Citation is saved in Bibtex directory");
CITATION_DIR = BIBTEX_DIR;
}
try {
format = args[6];
} catch (Exception e) {
System.out
.println("Exportformat Parameter not recognized. Setting Exportformat to HTML");
}
}
try {
if (updateCitations && format != "Citations") {
if (updateCitations && !format.equals("Citations")) {
new BibtexViewer("Citations");
}
if (format != null)
Expand All @@ -101,25 +131,25 @@ public static void main(String[] args) {
e.printStackTrace();
}
}

public BibtexViewer(String format) throws Exception {
Export exporter = null;
switch (format) {
case "CSV":
exporter = new ExportCSV(BibtexViewer.BIBTEX_DIR,"literature.bib");
exporter = new ExportCSV(BibtexViewer.BIBTEX_DIR, "literature.bib");
break;
case "JSON":
exporter = new ExportJSON(BibtexViewer.BIBTEX_DIR,"literature.bib");
exporter = new ExportJSON(BibtexViewer.BIBTEX_DIR, "literature.bib");
break;
case "Citations":
exporter = new ExportCitations(BibtexViewer.BIBTEX_DIR,"literature.bib");
exporter = new ExportCitations(BibtexViewer.BIBTEX_DIR, "literature.bib");
break;
case "HTML_NEW":
exporter = new ExportNewHTML2(BibtexViewer.BIBTEX_DIR,"literature.bib");
exporter = new ExportNewHTML2(BibtexViewer.BIBTEX_DIR, "literature.bib");
break;
case "HTML":
default:
exporter = new ExportHTML(BibtexViewer.BIBTEX_DIR,"literature.bib");
exporter = new ExportHTML(BibtexViewer.BIBTEX_DIR, "literature.bib");
}
if (cleanOutputDir) {
exporter.cleanOutputFolder();
Expand Down
Loading

0 comments on commit dda35fa

Please sign in to comment.