Skip to content

Commit

Permalink
#2 0.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonLukas committed Mar 18, 2022
1 parent 2b7ae09 commit 6f3f8a3
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ I was using Calibre and Pandoc-Export plugin, but I was wondering about a short
- [x] Become a Communityplugin 🎉
- [x] Create workaround for other embedded files
- [x] Add ==highlighting==
- [x] .md export _(mergedown)_
- [ ] Foldercover or filecover
- [ ] .html export (Archive)
- [ ] .epub export (Pocketbook)
- [ ] .pdf export (would be nice for IOS & Android)

### Extra features (no kindle data needed)
- [x] .md export _(mergedown)_
- [x] Audio export
- [x] Video export
- [x] define own exportpath
### Just try it!
For embedding local images, please use the following format:
``` ![[image.jpg]] ```
Expand Down
23 changes: 21 additions & 2 deletions main.js

Large diffs are not rendered by default.

22 changes: 19 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const DEFAULT_SETTINGS: Partial < KindlePluginSettings > = {
port: "",
smtphost: "",
pass: "",
expath: "",
backend: "https://staneks.de/apps/md2mobi/",


Expand Down Expand Up @@ -66,9 +67,11 @@ export default class Kindle extends Plugin {
let lines = data.split("\n")
let result = await this.Mergedown(lines, Inhalt, imagelist, imagename, links);
Inhalt = result.Inhalt;
// get time in milliseconds
Inhalt = Inhalt.replace(/%%[\s\S]*?%%/g, "");
let time = new Date().getTime();
this.app.vault.create(dokument.basename + '_mergedown_'+time+'.md', Inhalt);
let expath = this.settings.expath;
this.app.vault.createFolder(expath);
this.app.vault.create(expath +'/'+ dokument.basename + '_mergedown_'+time+'.md', Inhalt);
if (lang == "de") {
new Notice("✔️ Mergedown erfolgreich!");
} else {
Expand Down Expand Up @@ -348,9 +351,22 @@ export default class Kindle extends Plugin {
let base64 = Buffer.from(data).toString('base64');
imagename.push(file.name);
imagelist.push(base64);
Inhalt += '\n!['+ file.name +'](data:image/'+ file.extension+';base64,' + base64 + ')' + '\n';
Inhalt += '\n!['+ file.name +'](data:image/'+ file.extension+';base64,' + base64 + ')\n';
}

if (file.extension == "mp4" || file.extension == "webm" || file.extension == "ogv" || file.extension == "avi" || file.extension == "mov" || file.extension == "wmv" || file.extension == "mpg" || file.extension == "mpeg" || file.extension == "mkv" || file.extension == "flv" || file.extension == "swf" || file.extension == "vob" || file.extension == "m4v" || file.extension == "m4a" || file.extension == "m4b" || file.extension == "m4r" || file.extension == "3gp" || file.extension == "3g2" || file.extension == "f4v" || file.extension == "f4a" || file.extension == "f4b") {
let data = await this.app.vault.readBinary(file);
let base64 = Buffer.from(data).toString('base64');
Inhalt += '\n<video controls><source src="data:video/'+ file.extension+';base64,' + base64 + '" type="video/'+ file.extension+'"></video>\n';
}

if (file.extension == "mp3" || file.extension == "ogg" || file.extension == "wav" || file.extension == "flac") {
let data = await this.app.vault.readBinary(file);
let base64 = Buffer.from(data).toString('base64');
Inhalt += '\n<audio controls><source src="data:audio/'+ file.extension+';base64,' + base64 + '" type="audio/'+ file.extension+'"></audio>\n';
}


if (file.extension == 'md') {
let links2: Array < string > = [];
let data = await this.app.vault.cachedRead(file);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-kindle-export",
"name": "Kindle",
"version": "0.0.9",
"version": "0.0.10",
"minAppVersion": "0.13.24",
"description": "Send .md as .mobi to Kindle",
"author": "Simeon Stanek",
Expand Down
14 changes: 14 additions & 0 deletions settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@ export class KindleSettingTab extends PluginSettingTab {
})
);

new Setting(containerEl)
.setName("Exportpath")
.setDesc("Set the path where you want to export your files to. (e.g. /folder)")
.addText((text) =>
text
.setPlaceholder("/folder")
.setValue(this.plugin.settings.expath)
.onChange(async (value) => {
this.plugin.settings.expath = value;
await this.plugin.saveSettings();
console.log(this.plugin.settings);
})
);

containerEl.createEl("hr");
containerEl.createEl("p", { text: "Host your own Obsidian2Kindle-Converter."});
containerEl.createEl("a", { text: "Fork from Github 🔗", href: "https://github.com/SimeonLukas/Obsidian2Kindle"});
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
"0.0.7": "0.13.24",
"0.0.8": "0.13.24",
"0.0.9": "0.13.24",
"0.0.10": "0.13.24",
}

0 comments on commit 6f3f8a3

Please sign in to comment.