Giter Club home page Giter Club logo

anki2's Introduction

Anki2

Create Anki Flashcards with Ruby! Supports images, audio, HTML and CSS.

Installation

Add this line to your application's Gemfile:

gem 'anki2'

And then execute:

$ bundle

Usage

Let's make your first deck.

@anki = Anki2.new
@anki.add_card('Are Walruses magical?', 'Yes')
@anki.add_card('What animals are magical?', 'Unicorns and Walruses')
@anki.save

This will save the deck in the default location anki/deck.apkg. Change the output path like this:

@anki = Anki2.new({
  name: 'Magical Animals', 
  output_path: 'public/MagicalAnimals.apkg'
})

Congratulations!

Images

Let's make a flashcard with an image. Put a picture of a blobfish (here's one) into a subfolder called images.

@anki = Anki2.new
@anki.add_card(
  'What is this animal called? <img src="blobfish.jpg">',
  'A Blobfish'
)
@anki.add_media('images/blobfish.jpg')
@anki.save

Yay! If you have a lot of cards with a lot of images, just call add_media once and give it a path to the directory that contains your media. All the files from that directory will be included and are available in the deck, like so:

@anki.add_card('<img src="front.jpg">','<img src="back.jpg">')
@anki.add_media('images')
@anki.save

Audio

@anki = Anki2.new
@anki.add_card('よ[audio:yo.mp3]','yo')
@anki.add_media('yo.mp3')
@anki.save

CSS + HTML

@anki = Anki2.new(css: '.kanji { font-size: 88px; }')
@anki.add_card('<span class="kanji">大</span>', 'Big')
@anki.save

Feel free to get crazy.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release to create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Bugs

Here's a list of things that don't work yet:

  • Tags
  • Subdecks
  • Modifying the model: fields and card templates
  • Reading/Modifying existing decks
  • The structure of the code could use some love
  • And maybe add some tests?

Much Love to you if you contribute and fix one of them. Or just open an issue here if you really want to do something that the gem doesn't do yet - I'll be glad to help.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/anki2/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
  6. Thank you 💕

anki2's People

Contributors

albertzak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.