From 465e8686a40c7187799da13db9ca849e0e9bc51c Mon Sep 17 00:00:00 2001 From: Alex Colucci <17575915+reuseman@users.noreply.github.com> Date: Mon, 19 Apr 2021 12:27:33 +0200 Subject: [PATCH 1/5] Create greetings.yml --- .github/workflows/greetings.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/greetings.yml diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml new file mode 100644 index 0000000..1ca5625 --- /dev/null +++ b/.github/workflows/greetings.yml @@ -0,0 +1,13 @@ +name: Greetings + +on: [pull_request, issues] + +jobs: + greeting: + runs-on: ubuntu-latest + steps: + - uses: actions/first-interaction@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + issue-message: 'Thank you for taking the time to report the issue and help me to make the project better! 🙂' + pr-message: 'Thank you for helping me to make the project better! 🙂' From 8b5c9f0d0521cea94302e29d57618e8ed00fa402 Mon Sep 17 00:00:00 2001 From: Alex Colucci <17575915+reuseman@users.noreply.github.com> Date: Mon, 19 Apr 2021 12:52:38 +0200 Subject: [PATCH 2/5] Create stale.yml --- .github/workflows/stale.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..9c941d6 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,22 @@ +name: Mark stale issues and pull requests + +on: + schedule: + - cron: "30 1 * * *" + +jobs: + stale: + + runs-on: ubuntu-latest + + steps: + - uses: actions/stale@v3 + with: + any-of-labels: 'awaiting feedback' + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-label: 'stale' + stale-pr-label: 'stale' + stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.' + stale-pr-message: 'This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.' + close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.' + close-pr-message: 'This PR was closed because it has been stalled for 7 days with no activity.' From 1d8b8090dca2c99538ff603dc6cd95de0d1e7133 Mon Sep 17 00:00:00 2001 From: Alex Colucci <17575915+reuseman@users.noreply.github.com> Date: Mon, 19 Apr 2021 12:53:40 +0200 Subject: [PATCH 3/5] Update stale.yml --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 9c941d6..a0b93dc 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -2,7 +2,7 @@ name: Mark stale issues and pull requests on: schedule: - - cron: "30 1 * * *" + - cron: "0 13 * * *" jobs: stale: From 6c3b284b4418e11d763ae23587e04bbf0d1d0bf6 Mon Sep 17 00:00:00 2001 From: Ivan Liadniou Date: Tue, 15 Jun 2021 12:57:20 +0200 Subject: [PATCH 4/5] Enable changing the default Anki tag --- main.ts | 2 +- src/entities/card.ts | 2 -- src/gui/settings-tab.ts | 12 ++++++++++++ src/services/cards.ts | 6 ++++++ src/settings.ts | 1 + 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/main.ts b/main.ts index e89e9a2..e6c3fc9 100644 --- a/main.ts +++ b/main.ts @@ -56,7 +56,7 @@ export default class ObsidianFlashcard extends Plugin { } private getDefaultSettings(): ISettings { - return { contextAwareMode: true, sourceSupport: false, codeHighlightSupport: false, contextSeparator: " > ", deck: "Default", flashcardsTag: "card" } + return { contextAwareMode: true, sourceSupport: false, codeHighlightSupport: false, contextSeparator: " > ", deck: "Default", flashcardsTag: "card", defaultAnkiTag: "obsidian" } } private generateCards(activeFile: TFile) { diff --git a/src/entities/card.ts b/src/entities/card.ts index 932f961..fc82d03 100644 --- a/src/entities/card.ts +++ b/src/entities/card.ts @@ -16,7 +16,6 @@ export abstract class Card { containsCode: boolean modelName: string - // TODO set "obsidian as optional in the settings", this means that the tag should be outside constructor(id: number, deckName: string, initialContent: string, fields: Record, reversed: boolean, endOffset: number, tags: string[], inserted: boolean, mediaNames: string[], containsCode: boolean = false) { this.id = id this.deckName = deckName @@ -25,7 +24,6 @@ export abstract class Card { this.reversed = reversed this.endOffset = endOffset this.tags = tags - this.tags.unshift("obsidian") this.inserted = inserted this.mediaNames = mediaNames this.mediaBase64Encoded = [] diff --git a/src/gui/settings-tab.ts b/src/gui/settings-tab.ts index 730cf72..42db700 100644 --- a/src/gui/settings-tab.ts +++ b/src/gui/settings-tab.ts @@ -88,6 +88,18 @@ export class SettingsTab extends PluginSettingTab { }) }) + new Setting(containerEl) + .setName("Default Anki tag") + .setDesc("This tag will be added to each generated card on Anki") + .addText((text) => { + text.setValue(plugin.settings.defaultAnkiTag) + .setPlaceholder("Anki tag") + .onChange((value) => { + if (!value) new Notice("No default tags will be added") + plugin.settings.defaultAnkiTag = value.toLowerCase() + plugin.saveData(plugin.settings) + }) + }) } } \ No newline at end of file diff --git a/src/services/cards.ts b/src/services/cards.ts index adf7a7b..9847eab 100644 --- a/src/services/cards.ts +++ b/src/services/cards.ts @@ -148,6 +148,12 @@ export class CardsService { if (cardsToCreate.length) { let insertedCards = 0 try { + let defaultAnkiTag = this.settings.defaultAnkiTag + if (defaultAnkiTag) { + for (const card of cardsToCreate) { + card.tags.push(defaultAnkiTag) + } + } let ids = await this.anki.addCards(cardsToCreate) // Add IDs from response to Flashcard[] ids.map((id: number, index: number) => { diff --git a/src/settings.ts b/src/settings.ts index 17c11df..c5333b7 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -5,4 +5,5 @@ export interface ISettings { contextSeparator: string deck: string flashcardsTag: string + defaultAnkiTag: string } \ No newline at end of file From 0fc791e342a35e22271f5f8d176bf91fff83a13c Mon Sep 17 00:00:00 2001 From: Alex Colucci Date: Wed, 23 Jun 2021 20:34:21 +0200 Subject: [PATCH 5/5] Remove attribute in inlinecard used for development --- src/entities/inlinecard.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/entities/inlinecard.ts b/src/entities/inlinecard.ts index d818cd5..d2ddafe 100644 --- a/src/entities/inlinecard.ts +++ b/src/entities/inlinecard.ts @@ -3,7 +3,8 @@ import { Card } from "src/entities/card"; export class Inlinecard extends Card { constructor(id: number = -1, deckName: string, initialContent: string, fields: Record, reversed: boolean, endOffset: number, tags: string[] = [], inserted: boolean = false, mediaNames: string[], containsCode: boolean) { - super(id, deckName, initialContent, fields, reversed, endOffset, tags, inserted, mediaNames, [], containsCode) // ! CHANGE [] + super(id, deckName, initialContent, fields, reversed, endOffset, tags, inserted, mediaNames, containsCode) // ! CHANGE [] + this.modelName = this.reversed ? `Obsidian-basic-reversed` : `Obsidian-basic` if (fields["Source"]) { this.modelName += sourceDeckExtension