GithubHelp home page GithubHelp logo

xadillax / daily-sentence Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 1.0 19 KB

A `daily-sentence` module for node.js. (data from http://xue.youdao.com/w?page=1&type=all&position=tinyEnglish)

License: MIT License

JavaScript 100.00%

daily-sentence's Introduction

Daily Sentence (Node.js)

A daily-sentence module for node.js. (data from http://xue.youdao.com/w?page=1&type=all&position=tinyEnglish)

It will offer you different an English sentence (translation included) and an image each day. Something like:

不入虎穴,焉得虎子

He who would search for pearl must dive deep.

不入虎穴,焉得虎子。

—— [4/2/2014]

Installation

You just input that code under terminal:

$ npm install daily-sentence --save

And you just need require this module in your code file:

var daily = require("daily-sentence");

Usage

Today

You can get today's sentence via

daily.today(function(err, sentence) {
    // DO SOMETHING...
});

One Day

You can get oneday's sentence via:

daily.get(ONE_DAY, function(err, sentence) {
    // DO SOMETHING...
});

The ONE_DAY above is a variable. It can be:

  • Timestamp. (Eg. 1396793790)
  • Timestamp with millionsecond. (Eg. 1396793790762)
  • A time string. (Eg. "2012/1/2", "Apr 2, 2012", etc. Refer to SugarJS)
  • A date object. (Eg. new Date())

Sentence Format

The callback function will offer you an object that like:

{
    "date"  : "yyyy-mm-dd",
    "image" : "THE_IMAGE_URL",
    "sen"   : "THE_ENGLISH_SENTENCE",
    "trans" : "THE_TRANSLATION"
}

Disable Cache

The module will default enable local cache (to save the network traffic). It will create a .daily-sen-db directory at your current work directory (process.cwd()). And all the cache file will be put into it.

If you don't want to use the cache files, you can disable it before you get.

daily.setUseCache(false);

And if you want to reopen it, just switch the false to true.

To Do

Maybe I will create some sync functions. Just maybe.

Contribute

Anyone can do contribution to this project. And I will glad to merge your commit.

Just contact me @:

  • Email: admin#xcoder.in
  • Weibo
  • StackOverflow

License

MIT

daily-sentence's People

Contributors

xadillax avatar

Stargazers

 avatar martin avatar  avatar loufq avatar

Watchers

James Cloos avatar  avatar martin avatar  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.