zotero / scaffold

Zotero translator creation IDE
http://www.zotero.org/support/dev/scaffold
38 stars 9 forks source link

Tweaks to test display and saving #16

Closed aurimasv closed 10 years ago

aurimasv commented 10 years ago

This accomplishes two things:

When running doWeb or doImport in Scaffold, it will display which item fields will be removed/renamed when the item is actually imported into Zotero. The display is similar to what we see when running tests.

When saving tests, Scaffold will now save the item fields in a deterministic (sorted) way. This means that we should no longer see fields randomly moving around in diffs when updating tests. It will also sort tags, which sometimes tend to jump around. Most of the fields are sorted alphabetically, but I decided that itemType, title, creators, and date (the most important metadata) should always be at the top. I also moved stuff that's rarely used/takes up a lot of space, to the bottom of the list (i.e. tags, seeAlso, attachments, notes).

Thoughts? (I think @adam3smith should like these changes. I'm certainly enjoying them)

Here's an example: Before

{
    "type": "web",
    "url": "http://lhclz.gbv.de/DB=1/XMLPRS=N/PPN?PPN=08727342X",
    "items": [
        {
            "itemType": "book",
            "creators": [
                {
                    "firstName": "Bettina",
                    "lastName": "Reckter",
                    "creatorType": "editor"
                },
                {
                    "firstName": "Rolf H.",
                    "lastName": "Simen",
                    "creatorType": "editor"
                },
                {
                    "firstName": "Karl-Heinz",
                    "lastName": "Preuß",
                    "creatorType": "editor"
                }
            ],
            "notes": [
                {
                    "note": "<div>Institutsbestand, deshalb nähere Informationen im Inst. f. Wirtschaftswissenschaft (IfW13)</div>"
                }
            ],
            "tags": [
                "Umweltschaden",
                "Aufsatzsammlung / Umweltschutz",
                "Aufsatzsammlung",
                "Ökomonie",
                "Umweltschutz",
                "Gleichgewicht",
                "Waldsterben",
                "Tiere",
                "Lebensräume",
                "Vogelarten",
                "Umweltgifte",
                "Bienen",
                "Schmetterlinge",
                "Perlmuscheln",
                "Gewässerverschmutzung",
                "Süßwasserfische",
                "Saurer Regen",
                "Umweltsignale",
                "Trinkwasser",
                "Algenpest",
                "Sonnenenergie",
                "Mülldeponie"
            ],
            "seeAlso": [],
            "attachments": [
                {
                    "title": "Link to Library Catalog Entry",
                    "mimeType": "text/html",
                    "snapshot": false
                },
                {
                    "title": "Library Catalog Entry Snapshot",
                    "mimeType": "text/html",
                    "snapshot": true
                }
            ],
            "title": "Geschichten, die die Forschung schreibt: ein Umweltlesebuch des Deutschen Forschungsdienstes",
            "ISBN": "3-923120-26-5",
            "date": "1990",
            "pages": "319",
            "place": "Bonn - Bad Godesberg",
            "publisher": "Verlag Deutscher Forschungsdienst",
            "libraryCatalog": "Library Catalog - lhclz.gbv.de",
            "numPages": "319",
            "callNumber": "CL 13 : IfW13 40 W 2",
            "shortTitle": "Geschichten, die die Forschung schreibt"
        }
    ]
}

After

{
    "type": "web",
    "url": "http://lhclz.gbv.de/DB=1/XMLPRS=N/PPN?PPN=08727342X",
    "items": [
        {
            "itemType": "book",
            "title": "Geschichten, die die Forschung schreibt: ein Umweltlesebuch des Deutschen Forschungsdienstes",
            "creators": [
                {
                    "firstName": "Bettina",
                    "lastName": "Reckter",
                    "creatorType": "editor"
                },
                {
                    "firstName": "Rolf H.",
                    "lastName": "Simen",
                    "creatorType": "editor"
                },
                {
                    "firstName": "Karl-Heinz",
                    "lastName": "Preuß",
                    "creatorType": "editor"
                }
            ],
            "date": "1990",
            "ISBN": "3-923120-26-5",
            "callNumber": "CL 13 : IfW13 40 W 2",
            "libraryCatalog": "Library Catalog - lhclz.gbv.de",
            "numPages": "319",
            "pages": "319",
            "place": "Bonn - Bad Godesberg",
            "publisher": "Verlag Deutscher Forschungsdienst",
            "shortTitle": "Geschichten, die die Forschung schreibt",
            "attachments": [
                {
                    "title": "Link to Library Catalog Entry",
                    "mimeType": "text/html",
                    "snapshot": false
                },
                {
                    "title": "Library Catalog Entry Snapshot",
                    "mimeType": "text/html",
                    "snapshot": true
                }
            ],
            "tags": [
                "Algenpest",
                "Aufsatzsammlung",
                "Aufsatzsammlung / Umweltschutz",
                "Bienen",
                "Gewässerverschmutzung",
                "Gleichgewicht",
                "Lebensräume",
                "Mülldeponie",
                "Perlmuscheln",
                "Saurer Regen",
                "Schmetterlinge",
                "Sonnenenergie",
                "Süßwasserfische",
                "Tiere",
                "Trinkwasser",
                "Umweltgifte",
                "Umweltschaden",
                "Umweltschutz",
                "Umweltsignale",
                "Vogelarten",
                "Waldsterben",
                "Ökomonie"
            ],
            "notes": [
                {
                    "note": "<div>Institutsbestand, deshalb nähere Informationen im Inst. f. Wirtschaftswissenschaft (IfW13)</div>"
                }
            ],
            "seeAlso": []
        }
    ]
}
aurimasv commented 10 years ago

Oh, one thing. Unfortunately, the first updates using the new Scaffold version will create a large amount of field jumping, but hopefully that should be the end of it!

adam3smith commented 10 years ago

haven't looked at the code, but indeed very happy with the change as such.

On Fri, Jun 27, 2014 at 1:51 AM, Aurimas Vinckevicius < notifications@github.com> wrote:

Oh, one thing. Unfortunately, the first updates using the new Scaffold version will create a large amount of field jumping, but hopefully that should be the end of it!

— Reply to this email directly or view it on GitHub https://github.com/zotero/scaffold/pull/16#issuecomment-47316921.

Sebastian Karcher, PhD Department of Political Science Northwestern University

avram commented 10 years ago

Looks good to me.

aurimasv commented 10 years ago

I tested this a bit and it seems to work ok. We'll see if we get any bugs as we go.