langfield / ki

version control for Anki collections
https://langfield.github.io/ki/
GNU Affero General Public License v3.0
80 stars 3 forks source link

How am I supposed to create new cards? #175

Closed m0tholith closed 3 months ago

m0tholith commented 3 months ago

I made my decks in Anki and one single note to go off of. How do I add a new one? Do I keep notes in separate files or group them by deck? What values do I put in the guid field?

m0tholith commented 3 months ago

I made a script that generates a random string with a specified length, it's just this one-liner tr -dc 'A-Za-z0-9' </dev/urandom | head -c 30; echo but when I enter vim I make a macro to run the command on the current line and prepend the contents with guid: " (:silent .!random-str). I also made a snippet (in the luasnip engine) to automatically insert a basic note:

-- ~/.config/lua/ftplugin/markdown.lua

local luasnip = require("luasnip")
local snippet = luasnip.snippet
local t = luasnip.text_node
local i = luasnip.insert_node

luasnip.add_snippets("markdown", {
    snippet("ankinote", {
        t({ "# Note", "```" }),
        t({ "", "guid: " }),
        i(1),
        t({ "", "notetype: " }),
        i(2, "Basic (and reversed card)"),
        t({ "", "```" }),

        t({ "", "", "### Tags", "```" }),
        i(3),
        t({ "", "```" }),

        t({ "", "", "## Front", "" }),
        i(4),

        t({ "", "", "## Back", "" }),
        i(0),
    }),
})

I think that it would be easier, when running ki push, if ki automatically populates GUIDs which have empty fields.

langfield commented 3 months ago

Hi! It's a nice solution! I chose not to implement this functionality because if the file is changed during a push, the working tree would be modified, and so the commit that was made is not what is actually being pushed. Alternatively, the push command could make an additional commit. I think both of these violate the expected behavior of a git-push-like command in an unacceptable way. 🤷‍♀️

Furthermore it makes it difficult to distinguish between a note with a missing GUID because something went wrong during an "import" and a note with an intentionally blank GUID.


From: m0tholith @.> Sent: Saturday, August 17, 2024 3:26:02 PM To: langfield/ki @.> Cc: Subscribed @.***> Subject: Re: [langfield/ki] How am I supposed to create new cards? (Issue #175)

I made a script that generates a random string with a specified length, it's just this one-liner tr -dc 'A-Za-z0-9' </dev/urandom | head -c 30; echo but when I enter vim I make a macro to run the command on the current line and prepend the

I made a script that generates a random string with a specified length, it's just this one-liner tr -dc 'A-Za-z0-9' </dev/urandom | head -c 30; echo but when I enter vim I make a macro to run the command on the current line and prepend the contents with guid: " (:silent .!random-str). I also made a snippet (in the luasnip engine) to automatically insert a basic note:

-- ~/.config/lua/ftplugin/markdown.lua

local luasnip = require("luasnip") local snippet = luasnip.snippet local t = luasnip.text_node local i = luasnip.insert_node

luasnip.add_snippets("markdown", { snippet("ankinote", { t({ "# Note", "" }), t({ "", "guid: " }), i(1), t({ "", "notetype: " }), i(2, "Basic (and reversed card)"), t({ "", "" }),

    t({ "", "", "### Tags", "```" }),
    i(3),
    t({ "", "```" }),

    t({ "", "", "## Front", "" }),
    i(4),

    t({ "", "", "## Back", "" }),
    i(0),
}),

})

I think that it would be easier, when running ki push, if ki automatically populates GUIDs which have empty fields.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/langfield/ki/issues/175*issuecomment-2294951735__;Iw!!KGKeukY!1qccQ6BsOWX4CaJ6kVoYNr0ciIK2QHQJ6aeK8hbzSAhKkbw63Fp3o4bOGeq02xy2rNfdmY8BiA4xKuBMNry_Ji1n-q2Czg$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AISQNI33TG3STGEFXR7GUYDZR6PUVAVCNFSM6AAAAABMVE4HGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJUHE2TCNZTGU__;!!KGKeukY!1qccQ6BsOWX4CaJ6kVoYNr0ciIK2QHQJ6aeK8hbzSAhKkbw63Fp3o4bOGeq02xy2rNfdmY8BiA4xKuBMNry_Ji32ygM0-w$. You are receiving this because you are subscribed to this thread.Message ID: @.***>

langfield commented 3 months ago

Thanks very much for trying out the tool, by the way! I really appreciate detailed feedback like this, and I'd love to know if anything else isn't quite working for you, and how you're using it.


From: Whitaker, Brendan T. @.> Sent: Saturday, August 17, 2024 10:14:11 PM To: langfield/ki @.> Subject: Re: [langfield/ki] How am I supposed to create new cards? (Issue #175)

Hi! It's a nice solution! I chose not to implement this functionality because if the file is changed during a push, the working tree would be modified, and so the commit that was made is not what is actually being pushed. Alternatively, the push command could make an additional commit. I think both of these violate the expected behavior of a git-push-like command in an unacceptable way. 🤷‍♀️

Furthermore it makes it difficult to distinguish between a note with a missing GUID because something went wrong during an "import" and a note with an intentionally blank GUID.


From: m0tholith @.> Sent: Saturday, August 17, 2024 3:26:02 PM To: langfield/ki @.> Cc: Subscribed @.***> Subject: Re: [langfield/ki] How am I supposed to create new cards? (Issue #175)

I made a script that generates a random string with a specified length, it's just this one-liner tr -dc 'A-Za-z0-9' </dev/urandom | head -c 30; echo but when I enter vim I make a macro to run the command on the current line and prepend the

I made a script that generates a random string with a specified length, it's just this one-liner tr -dc 'A-Za-z0-9' </dev/urandom | head -c 30; echo but when I enter vim I make a macro to run the command on the current line and prepend the contents with guid: " (:silent .!random-str). I also made a snippet (in the luasnip engine) to automatically insert a basic note:

-- ~/.config/lua/ftplugin/markdown.lua

local luasnip = require("luasnip") local snippet = luasnip.snippet local t = luasnip.text_node local i = luasnip.insert_node

luasnip.add_snippets("markdown", { snippet("ankinote", { t({ "# Note", "" }), t({ "", "guid: " }), i(1), t({ "", "notetype: " }), i(2, "Basic (and reversed card)"), t({ "", "" }),

    t({ "", "", "### Tags", "```" }),
    i(3),
    t({ "", "```" }),

    t({ "", "", "## Front", "" }),
    i(4),

    t({ "", "", "## Back", "" }),
    i(0),
}),

})

I think that it would be easier, when running ki push, if ki automatically populates GUIDs which have empty fields.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/langfield/ki/issues/175*issuecomment-2294951735__;Iw!!KGKeukY!1qccQ6BsOWX4CaJ6kVoYNr0ciIK2QHQJ6aeK8hbzSAhKkbw63Fp3o4bOGeq02xy2rNfdmY8BiA4xKuBMNry_Ji1n-q2Czg$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AISQNI33TG3STGEFXR7GUYDZR6PUVAVCNFSM6AAAAABMVE4HGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJUHE2TCNZTGU__;!!KGKeukY!1qccQ6BsOWX4CaJ6kVoYNr0ciIK2QHQJ6aeK8hbzSAhKkbw63Fp3o4bOGeq02xy2rNfdmY8BiA4xKuBMNry_Ji32ygM0-w$. You are receiving this because you are subscribed to this thread.Message ID: @.***>

m0tholith commented 3 months ago

Hi! It's a nice solution! I chose not to implement this functionality because if the file is changed during a push, the working tree would be modified, and so the commit that was made is not what is actually being pushed. Alternatively, the push command could make an additional commit. I think both of these violate the expected behavior of a git-push-like command in an unacceptable way. 🤷‍♀️ Furthermore it makes it difficult to distinguish between a note with a missing GUID because something went wrong during an "import" and a note with an intentionally blank GUID.

Ah, I see. I guess it's not that bad since it's so fast to create notes anyway!

Thanks very much for trying out the tool, by the way! I really appreciate detailed feedback like this, and I'd love to know if anything else isn't quite working for you, and how you're using it.

ki is an awesome tool, thank you for putting the time and effort into making this! It's actually been really stable for me, at least when I use it right :sweat_smile: I specifically use it for making german flashcards since it's just a little setup and I'm all set to revise all the words I've learned so far. It's awesome!

langfield commented 3 months ago

Lovely! I am very glad to hear it's working for you :)