Skip to content

Commit

Permalink
server test with tags
Browse files Browse the repository at this point in the history
  • Loading branch information
hhzl committed Jan 16, 2017
1 parent 0d7b214 commit 8397a6d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/server/deck-name.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
pear die Birne food fruit
lemon die Zitrone food fruit
banana die Banane food fruit
tomato die Tomate food vegetable
carrot die Karotte food vegetable
onion die Zwiebel food vegetable
rice der Reis food
salt das Salz food
oil das Öl food
flour das Mehl food
water das Wasser food
a tree ein Baum nature
a river ein Fluss nature
the sun die Sonne nature sky
the moon der Mond nature sky
one star ein Stern nature sky
two stars zwei Sterne nature sky
three stars drei Sterne nature sky
lion der Löwe animal
hyena die Hyäne animal
goat die Ziege animal
cow die Kuh animal
cock der Hahn animal
hen das Henne animal
dog der Hund animal
42 changes: 42 additions & 0 deletions examples/server/server2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

const fs = require('fs');
const AnkiExport = require('../../dist/index').default;

const apkg = new AnkiExport('deck-name-node');

apkg.addMedia('anki.png', fs.readFileSync('../assets/anki.png'));

apkg.addCard('pear','die Birne', {"tags":["food","fruit"]});
apkg.addCard('lemon','die Zitrone', {"tags":["food","fruit"]});
apkg.addCard('banana','die Banane', {"tags":["food","fruit"]});
apkg.addCard('tomato','die Tomate', {"tags":["food","vegetable"]});
apkg.addCard('carrot','die Karotte', {"tags":["food","vegetable"]});
apkg.addCard('onion','die Zwiebel', {"tags":["food","vegetable"]});
apkg.addCard('rice','der Reis', {"tags":["food"]});
apkg.addCard('salt','das Salz', {"tags":["food"]});
apkg.addCard('oil','das Öl', {"tags":["food"]});
apkg.addCard('flour','das Mehl', {"tags":["food"]});
apkg.addCard('water','das Wasser', {"tags":["food"]});
apkg.addCard('a tree','ein Baum', {"tags":["nature"]});
apkg.addCard('a river','ein Fluss', {"tags":["nature"]});
apkg.addCard('the sun','die Sonne', {"tags":["nature","sky"]});
apkg.addCard('the moon','der Mond', {"tags":["nature","sky"]});
apkg.addCard('one star','ein Stern', {"tags":["nature","sky"]});
apkg.addCard('two stars','zwei Sterne', {"tags":["nature","sky"]});
apkg.addCard('three stars','drei Sterne', {"tags":["nature","sky"]});
apkg.addCard('lion','der Löwe', {"tags":["animal"]});
apkg.addCard('hyena','die Hyäne', {"tags":["animal"]});
apkg.addCard('goat','die Ziege', {"tags":["animal"]});
apkg.addCard('cow','die Kuh', {"tags":["animal"]});
apkg.addCard('cock','der Hahn', {"tags":["animal"]});
apkg.addCard('hen','das Henne', {"tags":["animal"]});
apkg.addCard('dog','der Hund', {"tags":["animal"]});

apkg
.save()
.then(zip => {
fs.writeFileSync('./output.apkg', zip, 'binary');
console.log(`Package has been generated: output.pkg`);
})
.catch(err => console.log(err.stack || err));

0 comments on commit 8397a6d

Please sign in to comment.