mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-23 01:06:17 +00:00
parent
4b92d63d2e
commit
4ef11a1953
@ -18,6 +18,7 @@ package de.fabianonline.telegram_backup.exporter;
|
|||||||
|
|
||||||
import de.fabianonline.telegram_backup.UserManager;
|
import de.fabianonline.telegram_backup.UserManager;
|
||||||
import de.fabianonline.telegram_backup.Database;
|
import de.fabianonline.telegram_backup.Database;
|
||||||
|
import de.fabianonline.telegram_backup.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@ -96,8 +97,11 @@ public class HTMLExporter {
|
|||||||
|
|
||||||
mustache = mf.compile("templates/html/chat.mustache");
|
mustache = mf.compile("templates/html/chat.mustache");
|
||||||
|
|
||||||
logger.debug("Generating dialog pages");
|
int i=0;
|
||||||
|
logger.debug("Generating {} dialog pages", dialogs.size());
|
||||||
for (Database.Dialog d : dialogs) {
|
for (Database.Dialog d : dialogs) {
|
||||||
|
i++;
|
||||||
|
logger.trace("Dialog {}/{}: {}", i, dialogs.size(), Utils.anonymize(""+d.id));
|
||||||
LinkedList<HashMap<String, Object>> messages = db.getMessagesForExport(d);
|
LinkedList<HashMap<String, Object>> messages = db.getMessagesForExport(d);
|
||||||
scope.clear();
|
scope.clear();
|
||||||
scope.put("user", user);
|
scope.put("user", user);
|
||||||
@ -114,8 +118,11 @@ public class HTMLExporter {
|
|||||||
w.close();
|
w.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("Generating chat pages");
|
i=0;
|
||||||
|
logger.debug("Generating {} chat pages", chats.size());
|
||||||
for (Database.Chat c : chats) {
|
for (Database.Chat c : chats) {
|
||||||
|
i++;
|
||||||
|
logger.trace("Chat {}/{}: {}", i, chats.size(), Utils.anonymize(""+c.id));
|
||||||
LinkedList<HashMap<String, Object>> messages = db.getMessagesForExport(c);
|
LinkedList<HashMap<String, Object>> messages = db.getMessagesForExport(c);
|
||||||
scope.clear();
|
scope.clear();
|
||||||
scope.put("user", user);
|
scope.put("user", user);
|
||||||
@ -137,6 +144,7 @@ public class HTMLExporter {
|
|||||||
URL cssFile = getClass().getResource("/templates/html/style.css");
|
URL cssFile = getClass().getResource("/templates/html/style.css");
|
||||||
File dest = new File(base + "style.css");
|
File dest = new File(base + "style.css");
|
||||||
FileUtils.copyURLToFile(cssFile, dest);
|
FileUtils.copyURLToFile(cssFile, dest);
|
||||||
|
logger.debug("Done exporting.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new RuntimeException("Exception above!");
|
throw new RuntimeException("Exception above!");
|
||||||
@ -144,7 +152,7 @@ public class HTMLExporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private OutputStreamWriter getWriter(String filename) throws FileNotFoundException {
|
private OutputStreamWriter getWriter(String filename) throws FileNotFoundException {
|
||||||
logger.trace("Creating writer for file {}", filename);
|
logger.trace("Creating writer for file {}", Utils.anonymize(filename));
|
||||||
return new OutputStreamWriter(new FileOutputStream(filename), Charset.forName("UTF-8").newEncoder());
|
return new OutputStreamWriter(new FileOutputStream(filename), Charset.forName("UTF-8").newEncoder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user