Commit graph

36 commits

Author SHA1 Message Date
Damien Elmes
37a239cf38 add basic type checking for anki/ 2019-12-16 08:17:28 +10:00
Arthur Milchior
556ef5d34b newField checks its input is a str
Indeed, it takes as input a name (str). For some reason in some test
it was given a model. This actually led to some strange failed test.
2019-11-25 00:15:20 +01:00
Damien Elmes
0577157970 Revert "Merge pull request #345 from Arthur-Milchior/noFullSyncWhenEditingNewModel"
This reverts commit 0ffb308004, reversing
changes made to fed2f2fa3d.

This approach is flawed. Any minor change to the note type will set usn
to -1, causing the schema not to be modified when it should be.
2019-10-27 21:37:21 +10:00
Arthur Milchior
9863b6f9ff Use _modSchemaIfRequired in all cases.
Same logic than in last commit. Actually, there is no change of model
which need a full sync until the model is uploaded. After all, even if
a change in model imply that some card will change, those cards and
notes have not been uploaded either
2019-10-24 04:45:12 +02:00
Arthur Milchior
b78480fe52 New model can be edited without full sync
This commit solves a problem that I had many time in the past. When I
create a new model, I usually want to edit it. Clone of existing
models present no interest by themselves. And as soon as I edit it, I
need to do a full sync.

As far as I understand ankiweb (which is sadly closed source), the
full sync is required because ankiweb needs to know that the model
associated to note type on the server did change. But since the model
is new, it has no note type associated to on the server, so there is
no need to do a full sync immediatly. Since the model is new, it also
means there is no risk of the inconsistency with a change made in
another computer/smartphone.

Thus, when a field/template is added, I check that the model is not
new by checking both whether it's id is not null, and also that it's
usn is not -1. (I set usn early in the model's life)

If it does not make into anki, then it'll be an add-on. But it's worth
a try first.
2019-10-24 04:44:52 +02:00
Damien Elmes
8497da27cf ensure the list of note types is not empty
fixes an issue opening the add screen if a user manages to delete
all their note types with an add-on or a sync
2019-04-21 18:02:12 +10:00
Damien Elmes
3cf770c73c Revert "moveTemplate slightly quicker"
This reverts commit b29fd508c7.

This caused a regression:
https://github.com/dae/anki/pull/294
2019-03-11 13:49:58 +10:00
Damien Elmes
ebdd8dae4b tidy up unused imports 2019-03-04 17:25:19 +10:00
Damien Elmes
6e077ab414 use raw strings for regexs 2019-03-04 17:03:43 +10:00
Damien Elmes
4037a034aa fix inconsistent indentation 2019-03-04 16:54:22 +10:00
Damien Elmes
372d5ed6e8 update copyright and clarify licenses 2019-02-05 14:01:33 +10:00
Damien Elmes
867e4b9f94 support {{CardFlag}}
https://anki.tenderapp.com/discussions/ankidesktop/32158-flags
2019-02-05 13:00:47 +10:00
Arthur-Milchior
b29fd508c7 moveTemplate slightly quicker
When a template is moved, only move the ord of cards whose position
did change.
2019-01-20 15:46:58 +01:00
Damien Elmes
b17946b282 fix detection of multiline cloze deletions 2018-06-15 11:24:59 +10:00
Rémy Léone
4446b85ef2 Simplify comparisons 2017-09-10 15:32:51 +02:00
Illia Volochii
13b7e01044 Stop inheriting from object
It is not needed in Python 3.
2017-02-07 00:21:33 +02:00
Damien Elmes
15b349e3a8 start port to python 3
unit tests pass and main screens of GUI load
2016-05-12 14:45:35 +10:00
Dave Shifflett
643ec35449 Use alternate pattern match during field changes
When a user renames or deletes a field, Anki tries to go through the
user's templates to substitute occurrences of that field name with its
new name or remove the field.

However, if the user has multiple Mustache placeholders on a single
line, this does not work as intended because the leading (.*) capture
group grabs the text in-between the two (or more) Mustache placeholders.

Examples:

    {{#Flag}}
        ...
    {{/Flag}}{{^Flag}}
        ...
    {{/Flag}}

or

    {{Front}} {{#Flag}}...{{/Flag}}

or

    {{Front}} Hello. {{Victim}}
2014-12-29 20:09:09 -06:00
Damien Elmes
6e7e08ebd0 be explicit about modSchema()'s check flag
- remove gui code that adds exceptions for syncing
- use check=False for all syncing and upgrade code
2014-11-03 16:28:12 +09:00
Soren I. Bjornstad
625d7d5a82 rename fields in template properly when more than one modifier used
Previously something like {{type:cloze:Text}} in the template would not
be renamed when the field was renamed.
2014-08-11 11:33:39 -05:00
Damien Elmes
694682d964 fix multiple cloze tags contained on one line
inner regex was capturing multiple clozes. fixes
https://anki.tenderapp.com/discussions/ankidesktop/6599-empty-cards-3533-cards-to-delete
2014-04-16 01:15:59 +09:00
Julien Baley
7e3597fb8e Adding support for chained modifiers. One can now write e.g. {{cloze:text:Field}} or {{text:cloze:Field}}, it's order independent. 2014-02-18 17:24:28 +00:00
Damien Elmes
7aee582a58 loop should exit early, and allNames() doesn't need modification 2013-10-06 09:26:43 +09:00
Damien Elmes
f1837e7e0a when ensuring model unique, check id not obj
this should fix an issue where we were attaching a suffix to non-duplicate
names on sync
2013-10-05 23:53:09 +09:00
Damien Elmes
9524dbed96 give note types unique name when adding/importing (#325) 2013-10-04 09:00:08 +09:00
Damien Elmes
e73bfa9d02 ignore qfmt/afmt when checking if note types are the same 2013-09-04 02:18:53 +09:00
Damien Elmes
cfac1eb99b add utf8 input back to latex
This was what we originally had in templates in Anki 1. It was changed to
utf8x at one point, then we discovered that some LaTeX installs didn't have
that package so it was removed, when we should have reverted to utf8 instead.
This fixes things like umlauts but does not allow display of things like
Japanese text.
2013-05-27 10:52:55 +09:00
Damien Elmes
7957dff33f make sure sort field updated when field deleted (#737) 2013-04-11 14:23:06 +09:00
Damien Elmes
c437a38446 move card type deletion back to X on card tabs 2013-04-11 14:02:01 +09:00
Damien Elmes
19012e6110 don't set browser font on card creation (#543) 2013-01-29 09:40:47 +09:00
Damien Elmes
c335ea2cee note type manager needs to ignore the default note type for current deck 2013-01-08 21:39:37 +09:00
Damien Elmes
0447cb4f41 fix issues with clozes and <% %> 2013-01-04 14:39:06 +09:00
Damien Elmes
d11a1e0d54 allow browser font customization on a per-template basis 2012-12-22 10:10:52 +09:00
Damien Elmes
b2457811a2 optimize imports 2012-12-22 09:17:10 +09:00
Damien Elmes
2095e5c4b3 strip HTML when calculating field checksum (users will need to checkDB) 2012-12-21 20:51:45 +09:00
Damien Elmes
d477df8c28 merged libanki and ankiqt into single distro 2012-12-21 16:51:59 +09:00