diff --git a/src/GitHub/delete.ts b/src/GitHub/delete.ts index ff6dc322..126ebd83 100644 --- a/src/GitHub/delete.ts +++ b/src/GitHub/delete.ts @@ -39,6 +39,7 @@ export async function deleteFromGithub( const monoProperties: MonoRepoProperties = { frontmatter: repo, repo: repoProperties.repo, + convert: repoProperties.convert, }; deleted.push(await deleteFromGithubOneRepo( silent, @@ -85,7 +86,7 @@ async function deleteFromGithubOneRepo( logs({settings}, `No file to delete in ${repo.owner}/${repo.repo}`); return {success: false, deleted: [], undeleted: []}; } - const allSharedFiles = filesManagement.getAllFileWithPath(repoProperties.repo); + const allSharedFiles = filesManagement.getAllFileWithPath(repoProperties.repo, repoProperties.convert); const allSharedConverted = allSharedFiles.map((file) => { return { converted: file.converted, repo: file.repoFrontmatter }; }); @@ -307,7 +308,7 @@ function cleanDryRun( Vault.recurseChildren(dryRunFolder as TFolder, (file: TAbstractFile) => { if (!excludedFileFromDelete(normalizePath(file.path.replace(dryRunFolderPath, "")), settings) && (isAttachment(file.path, settings.embed.unHandledObsidianExt) || file.path.match("md$")) && file instanceof TFile) dryRunFiles.push(file); }); - const allSharedFiles = filesManagement.getAllFileWithPath(repoProperties.repo).map((file) => { + const allSharedFiles = filesManagement.getAllFileWithPath(repoProperties.repo, repoProperties.convert).map((file) => { return { converted: file.converted, repo: file.repoFrontmatter }; }); let deletedSuccess = 0; diff --git a/src/GitHub/files.ts b/src/GitHub/files.ts index 3865ce3a..54b3fbdb 100644 --- a/src/GitHub/files.ts +++ b/src/GitHub/files.ts @@ -86,12 +86,12 @@ export class FilesManagement extends Publisher { * @return {ConvertedLink[]} The shared files */ - getAllFileWithPath(repo: Repository | null): ConvertedLink[] { + getAllFileWithPath(repo: Repository | null, convert: FrontmatterConvert): ConvertedLink[] { const files = this.vault.getFiles().filter((x) => !x.path.startsWith(this.settings.github.dryRun.folderName)); const allFileWithPath: ConvertedLink[] = []; for (const file of files) { if (isAttachment(file.name, this.settings.embed.unHandledObsidianExt)) { - const filepath = getImagePath(file, this.settings, null); + const filepath = getImagePath(file, this.settings, convert); allFileWithPath.push({ converted: filepath, real: file.path, diff --git a/src/GitHub/upload.ts b/src/GitHub/upload.ts index 0e111094..cc08b82a 100644 --- a/src/GitHub/upload.ts +++ b/src/GitHub/upload.ts @@ -102,6 +102,7 @@ export default class Publisher { const repoProperties: MonoRepoProperties = { frontmatter: properties.frontmatter.repo, repo: properties.repository, + convert: properties.frontmatter.general, }; try { for (const file of linkedFiles) { @@ -335,7 +336,8 @@ export default class Publisher { { frontmatter: repo, repo: properties.repository, - } as MonoRepoProperties + convert: properties.frontmatter.general, + } ); } return { diff --git a/src/commands/callback.ts b/src/commands/callback.ts index 5c83cbd7..391146b3 100644 --- a/src/commands/callback.ts +++ b/src/commands/callback.ts @@ -11,7 +11,7 @@ import GithubPublisher from "../main"; import {MonoRepoProperties, MultiRepoProperties, Repository} from "../settings/interface"; import {createLink} from "../utils"; import {checkRepositoryValidity, isShared} from "../utils/data_validation_test"; -import { frontmatterFromFile, getRepoFrontmatter } from "../utils/parse_frontmatter"; +import { frontmatterFromFile, getFrontmatterSettings, getRepoFrontmatter } from "../utils/parse_frontmatter"; import {purgeNotesRemote, shareOneNote} from "."; import {shareEditedOnly, uploadAllEditedNotes, uploadAllNotes, uploadNewNotes} from "./plugin_commands"; @@ -80,6 +80,11 @@ export async function purgeNotesRemoteCallback(plugin: GithubPublisher, repo: Re const monoRepo: MonoRepoProperties = { frontmatter: Array.isArray(frontmatter) ? frontmatter[0] : frontmatter, repo, + convert: getFrontmatterSettings( + null, + plugin.settings, + repo + ) }; //@ts-ignore const publisher = await plugin.reloadOctokit(repo?.smartKey); diff --git a/src/commands/file_menu.ts b/src/commands/file_menu.ts index ebd017a3..63b4c0d6 100644 --- a/src/commands/file_menu.ts +++ b/src/commands/file_menu.ts @@ -4,7 +4,7 @@ import { Menu, MenuItem, Platform, TFile, TFolder} from "obsidian"; import GithubPublisher from "../main"; import {MonoRepoProperties, Repository} from "../settings/interface"; import {defaultRepo, getRepoSharedKey, isExcludedPath, isInDryRunFolder, isShared, multipleSharedKey} from "../utils/data_validation_test"; -import { frontmatterFromFile, getRepoFrontmatter } from "../utils/parse_frontmatter"; +import { frontmatterFromFile, getFrontmatterSettings, getRepoFrontmatter } from "../utils/parse_frontmatter"; import {shareAllMarkedNotes, shareOneNote} from "."; import {ChooseRepoToRun} from "./suggest_other_repo_commands_modal"; @@ -22,6 +22,11 @@ export async function shareFolderRepo(plugin: GithubPublisher, folder: TFolder, const monoProperties: MonoRepoProperties = { frontmatter: Array.isArray(repoFrontmatter) ? repoFrontmatter[0] : repoFrontmatter, repo, + convert: getFrontmatterSettings( + null, + plugin.settings, + repo + ) }; await shareAllMarkedNotes( publisher, diff --git a/src/commands/index.ts b/src/commands/index.ts index acd58e87..93ae3acb 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -255,7 +255,7 @@ export async function shareNewNote( ): Promise { const plugin = PublisherManager.plugin; new Notice(i18next.t("informations.scanningRepo") ); - const sharedFilesWithPaths = PublisherManager.getAllFileWithPath(monoRepo.repo); + const sharedFilesWithPaths = PublisherManager.getAllFileWithPath(monoRepo.repo, monoRepo.convert); // Get all file in the repo before the creation of the branch const githubSharedNotes = await PublisherManager.getAllFileFromRepo( monoRepo.frontmatter.branch, // we need to take the master branch because the branch to create doesn't exist yet @@ -301,7 +301,7 @@ export async function shareAllEditedNotes( ) { const plugin = PublisherManager.plugin; new Notice(i18next.t("informations.scanningRepo") ); - const sharedFilesWithPaths = PublisherManager.getAllFileWithPath(monoRepo.repo); + const sharedFilesWithPaths = PublisherManager.getAllFileWithPath(monoRepo.repo, monoRepo.convert); const githubSharedNotes = await PublisherManager.getAllFileFromRepo( monoRepo.frontmatter.branch, monoRepo.frontmatter @@ -352,7 +352,7 @@ export async function shareOnlyEdited( const shortRepo = monoRepo.repo; const repoFrontmatter = monoRepo.frontmatter; new Notice(i18next.t("informations.scanningRepo") ); - const sharedFilesWithPaths = PublisherManager.getAllFileWithPath(shortRepo); + const sharedFilesWithPaths = PublisherManager.getAllFileWithPath(shortRepo, monoRepo.convert); const githubSharedNotes = await PublisherManager.getAllFileFromRepo( repoFrontmatter.branch, repoFrontmatter diff --git a/src/commands/plugin_commands.ts b/src/commands/plugin_commands.ts index 6ea3c0cd..87ee7958 100644 --- a/src/commands/plugin_commands.ts +++ b/src/commands/plugin_commands.ts @@ -10,7 +10,7 @@ import GithubPublisher from "../main"; import {MonoRepoProperties, MultiRepoProperties, Repository} from "../settings/interface"; import {createLink} from "../utils"; import {checkRepositoryValidity, isShared} from "../utils/data_validation_test"; -import { frontmatterFromFile, getRepoFrontmatter } from "../utils/parse_frontmatter"; +import { frontmatterFromFile, getFrontmatterSettings, getRepoFrontmatter } from "../utils/parse_frontmatter"; import { purgeNotesRemote, shareAllEditedNotes, @@ -83,7 +83,12 @@ export async function deleteCommands(plugin : GithubPublisher, repo: Repository const publisher = await plugin.reloadOctokit(repo?.smartKey); const mono: MonoRepoProperties = { frontmatter: Array.isArray(repoFrontmatter) ? repoFrontmatter[0] : repoFrontmatter, - repo + repo, + convert: getFrontmatterSettings( + null, + plugin.settings, + repo + ) }; await purgeNotesRemote( publisher, @@ -108,7 +113,12 @@ export async function uploadAllNotes(plugin: GithubPublisher, repo: Repository | const repoFrontmatter = getRepoFrontmatter(plugin.settings, repo); const mono: MonoRepoProperties = { frontmatter: Array.isArray(repoFrontmatter) ? repoFrontmatter[0] : repoFrontmatter, - repo + repo, + convert: getFrontmatterSettings( + null, + plugin.settings, + repo + ) }; await shareAllMarkedNotes( publisher, @@ -137,8 +147,9 @@ export async function uploadNewNotes(plugin: GithubPublisher, branchName: string branchName, { frontmatter: Array.isArray(repoFrontmatter) ? repoFrontmatter[0] : repoFrontmatter, - repo - } as MonoRepoProperties, + repo, + convert: getFrontmatterSettings(null, plugin.settings, repo) + }, ); } @@ -179,8 +190,9 @@ export async function uploadAllEditedNotes(plugin: GithubPublisher ,branchName: branchName, { frontmatter: Array.isArray(repoFrontmatter) ? repoFrontmatter[0] : repoFrontmatter, - repo - } as MonoRepoProperties, + repo, + convert: getFrontmatterSettings(null, plugin.settings, repo) + }, ); } @@ -200,7 +212,8 @@ export async function shareEditedOnly(branchName: string, repo: Repository|null, branchName, { frontmatter: Array.isArray(repoFrontmatter) ? repoFrontmatter[0] : repoFrontmatter, - repo - } as MonoRepoProperties, + repo, + convert: getFrontmatterSettings(null, plugin.settings, repo) + }, ); } diff --git a/src/settings/interface.ts b/src/settings/interface.ts index 1b835158..8cc4e731 100644 --- a/src/settings/interface.ts +++ b/src/settings/interface.ts @@ -223,6 +223,7 @@ export interface MonoProperties { export interface MonoRepoProperties { frontmatter: RepoFrontmatter; repo: Repository | null; + convert: FrontmatterConvert; } export interface MultiRepoProperties {