GithubHelp home page GithubHelp logo

fdesjardins / wikiquote Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 1.0 484 KB

Promise-based interface for Wikiquote (https://en.wikiquote.org/wiki/Main_Page)

JavaScript 100.00%
wikiquote quotes proverbs sayings excerpts fortunes

wikiquote's Introduction

Wikiquote

Build Status NPM Version Coverage

Some handy methods for Wikiquote

Installation

npm install --save wikiquote

Usage

wikiquote
  .searchPeople('steve jobs')
  .then(page => wikiquote.getRandomQuote(page.title))
  .then(quote => console.log(quote))
You always have to keep pushing to innovate. Dylan could have
sung protest songs forever and probably made a lot of money,
but he didn’t. He had to move on, and when he did, by going
electric in 1965, he alienated a lot of people. His 1966 Europe
tour was his greatest…. The Beatles were the same way. They kept
evolving, moving, refining their art. That’s what I’ve always
tried to do — keep moving. Otherwise, as Dylan says, if you are
not busy being born, you’re busy dying.

As quoted in Steve Jobs (2011) by Walter Isaacson, p. 570

API

search(query, options)

query

The search terms used to query wikiquote

Type: string

Examples:

  • Person Name
  • Book Title
  • Movie Title

searchByTitle(query, options)

query

The search terms used to query page titles

Type: string

searchPeople(query, options)

query

The search terms used to query people

Type: string

getPageSections(pageTitle, options)

pageTitle

The title of the wikiquote page

Type: string

getSectionContent(pageTitle, sectionIndex, options)

pageTitle

The title of the wikiquote page

Type: string

getRandomQuote(pageTitle, options)

pageTitle

The title of the wikiquote page

Type: string

list(pageTitle, options)

List all the quotes on a given page

Type: string

options

You can also provide a set of options to each method to customize the query and results.

Type: object

Example:

{
  language: 'en'
}

options.language

The language code to search with

Type: string

For a list of available language codes see https://meta.wikimedia.org/wiki/Wikiquote#List_of_Wikiquotes

License

MIT © Forrest Desjardins

wikiquote's People

Contributors

dependabot[bot] avatar fdesjardins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

dworznik

wikiquote's Issues

Todo

  • /categories
  • /people
  • /qotd
  • /themes
  • /films
  • /proverbs
  • /places
  • date range
  • local cache

Production build with Webpack 3.8.1 throws Uglifyjs Error

When running webpack -p to build my production bundle while wikiquote is being imported/required, I receive the following error from my Webpack output, causing the build to fail.

ERROR in bundle.js from UglifyJs
Unexpected token name «t», expected punc «)» [bundle.js:1,338006]

Below is my webpack.config.js

var path = require("path");
var webpack = require("webpack");
var env = process.env.NODE_ENV || "development";

var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var UglifyJsPlugin = require("uglifyjs-webpack-plugin");

var HtmlWebpackPlugin = new HtmlWebpackPlugin({
  template: "template.html",
  inject: "body"
});
var extractPlugin = new ExtractTextPlugin({
  filename: "main.css"
});
var UglifyJsPlugin = new UglifyJsPlugin({
  uglifyOptions: {
    sourcemaps: true
  }
});

module.exports = {
  entry: "./src/index.js",
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loader: "babel-loader",
        query: {
          presets: ["react", "es2015", "es2017"],
          plugins: ["transform-class-properties"]
        }
      },
      {
        test: /\.scss$/,
        use: extractPlugin.extract({
          use: ["css-loader", "sass-loader"]
        })
      }
    ]
  },
  plugins: [extractPlugin, HtmlWebpackPlugin, UglifyJsPlugin],
  output: {
    filename: "bundle.js",
    path: path.resolve(__dirname, "build"),
    publicPath: "/build"
  },
  devServer: {
    contentBase: path.join(__dirname, "/build"),
    compress: true,
    port: 3000,
    headers: {
      "Access-Control-Allow-Origin": "*"
    }
  }
};

I look forward to hearing back about this issue and getting it resolved swiftly if possible!

Setting Locale

Is there a way to provide a locale if i want to query other languages?

CORS Issue - No Access-Control-Allow-Origin set

When running webpack-dev-server, I face issues with CORS preventing me from making a complete request with wikiquote.

Is there anyway I can set this myself or should this be configured within the module?

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.