mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 16:56:16 +00:00
HTML export now shows some progress information.
This commit is contained in:
parent
6a7560cb98
commit
9bee01698f
@ -61,7 +61,7 @@ class HTMLExporter {
|
|||||||
val chats = db.getListOfChatsForExport()
|
val chats = db.getListOfChatsForExport()
|
||||||
logger.trace("Got {} chats", chats.size)
|
logger.trace("Got {} chats", chats.size)
|
||||||
|
|
||||||
logger.debug("Generating index.html")
|
println("Generating index.html...")
|
||||||
val scope = HashMap<String, Any>()
|
val scope = HashMap<String, Any>()
|
||||||
scope.put("user", user)
|
scope.put("user", user)
|
||||||
scope.put("dialogs", dialogs)
|
scope.put("dialogs", dialogs)
|
||||||
@ -97,7 +97,7 @@ class HTMLExporter {
|
|||||||
mustache = mf.compile("templates/html/chat.mustache")
|
mustache = mf.compile("templates/html/chat.mustache")
|
||||||
|
|
||||||
var i = 0
|
var i = 0
|
||||||
logger.debug("Generating {} dialog pages", dialogs.size)
|
println("Generating ${dialogs.size} dialog pages...")
|
||||||
for (d in dialogs) {
|
for (d in dialogs) {
|
||||||
i++
|
i++
|
||||||
logger.trace("Dialog {}/{}: {}", i, dialogs.size, Utils.anonymize("" + d.id))
|
logger.trace("Dialog {}/{}: {}", i, dialogs.size, Utils.anonymize("" + d.id))
|
||||||
@ -115,10 +115,15 @@ class HTMLExporter {
|
|||||||
w = getWriter(base + "dialogs" + File.separatorChar + "user_" + d.id + ".html")
|
w = getWriter(base + "dialogs" + File.separatorChar + "user_" + d.id + ".html")
|
||||||
mustache.execute(w, scope)
|
mustache.execute(w, scope)
|
||||||
w.close()
|
w.close()
|
||||||
|
print(".")
|
||||||
|
if (i % 100 == 0) {
|
||||||
|
println(" - $i/${dialogs.size}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
println()
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
logger.debug("Generating {} chat pages", chats.size)
|
println("Generating ${chats.size} chat pages...")
|
||||||
for (c in chats) {
|
for (c in chats) {
|
||||||
i++
|
i++
|
||||||
logger.trace("Chat {}/{}: {}", i, chats.size, Utils.anonymize("" + c.id))
|
logger.trace("Chat {}/{}: {}", i, chats.size, Utils.anonymize("" + c.id))
|
||||||
@ -136,14 +141,19 @@ class HTMLExporter {
|
|||||||
w = getWriter(base + "dialogs" + File.separatorChar + "chat_" + c.id + ".html")
|
w = getWriter(base + "dialogs" + File.separatorChar + "chat_" + c.id + ".html")
|
||||||
mustache.execute(w, scope)
|
mustache.execute(w, scope)
|
||||||
w.close()
|
w.close()
|
||||||
|
print(".")
|
||||||
|
if (i % 100 == 0) {
|
||||||
|
println(" - $i/${chats.size}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
println()
|
||||||
|
|
||||||
logger.debug("Generating additional files")
|
println("Generating additional files...")
|
||||||
// Copy CSS
|
// Copy CSS
|
||||||
val cssFile = javaClass.getResource("/templates/html/style.css")
|
val cssFile = javaClass.getResource("/templates/html/style.css")
|
||||||
val dest = File(base + "style.css")
|
val dest = File(base + "style.css")
|
||||||
FileUtils.copyURLToFile(cssFile, dest)
|
FileUtils.copyURLToFile(cssFile, dest)
|
||||||
logger.debug("Done exporting.")
|
println("Finished.")
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
logger.error("Caught an exception!", e)
|
logger.error("Caught an exception!", e)
|
||||||
|
Loading…
Reference in New Issue
Block a user