# jugo

> JavaScript port of OpenFuego

Latest version **0.0.5** (published 2015-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install jugo
pnpm add jugo
yarn add jugo
bun add jugo
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2015-03-22 |
| First published | 2015-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+7 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Ben Southgate |
| Maintainers | bsouthga |
| Keywords | twitter, fuego, openfuego, journalism |

## Links

- npm: https://www.npmjs.com/package/jugo
- Repository: https://github.com/bsouthga/jugo
- Issues: https://github.com/bsouthga/jugo/issues
- npm.io page: https://npm.io/package/jugo

## Dependencies (6)

- [twit](https://npm.io/package/twit.md) ^1.1.20
- [lodash](https://npm.io/package/lodash.md) ^3.3.0
- [cheerio](https://npm.io/package/cheerio.md) ^0.18.0
- [mongodb](https://npm.io/package/mongodb.md) ^1.4.31
- [request](https://npm.io/package/request.md) ^2.53.0
- [queue-async](https://npm.io/package/queue-async.md) ^1.0.7

## Recent versions

- 0.0.5 (latest) — 2015-03-22
- 0.0.4 — 2015-03-22
- 0.0.3 — 2015-03-22
- 0.0.2 — 2015-03-22
- 0.0.1 — 2015-02-19

## README

# jugo

### [fuego](https://github.com/niemanlab/openfuego) for JavaScript

## Installation

To run jugo, the following must be installed

- [NodeJS](http://nodejs.org/)
- [MongoDB](http://www.mongodb.org/)

Once both are installed, run the following to install jugo locally

```shell
npm install jugo
```

## Usage

### Collection script

To start collecting tweets from your "universe" via the [twitter gardenhose](https://dev.twitter.com/streaming/public), create a script containing the following...


```javascript

var jugo = require('jugo');

var J = jugo({
  "twitter" : {
    "consumer_key": "<INSERT KEY>",
    "consumer_secret": "<INSERT KEY>",
    "access_token": "<INSERT KEY>",
    "access_token_secret": "<INSERT KEY>"
  },
  "accounts" : [
    ... // list of accounts you want to track
  ],
  "database" : "mongodb://localhost/test" // database location
})

// start collecting
J.collect();

```

And then run it as a background process. This will collect tweets as they come in, as well as metadata scraped from the urls. The collection script creates two mongo collections `posts` and `meta` which contain documents of the following schema...


```javascript
// example post document
{
  url : post_url,
  date : new Date(tweet.created_at),
  account : tweet.user.screen_name,
  followers : tweet.user.followers_count,
  retweets : tweet.retweet_count,
  favorites : tweet.favorite_count
}

// example meta document
{
  url : url,
  title : ..., // open graph protocol title
  image : ...,// open graph protocol image
  author : ..., // open graph protocol author
  description : .., // open graph protocol description
  date : ..., // open graph protocol date
}
```

### Usage in a web app

Jugo also provides a little wrapper for aggregating and accessing the tweets in the database. For example, in node express application, one might use Jugo as follows...

```javascript

var jugo = require('jugo');

var J = jugo(jugo_config);

// open jugo database connection when app starts
J.open(function() {
  console.log('database open!')
});

// database query api
app.get('/get/:query', function(req, res) {
  var params = getJsonFromUrl(req.params.query);

  var max, min;

  if (params.max) {
    var date_num = parseInt(params.max);
    if (!isNaN(date_num)) {
      max = new Date(date_num);
    }
  }

  if (params.min) {
    var date_num = parseInt(params.min);
    if (!isNaN(date_num)) {
      min = new Date(date_num);
    }
  }

  //
  // Use jugo "get" method to find top 40 stories
  // (currently ranked by number of tweets)
  // returns ...
  // {
  //   url : (shared url)
  //   count : (number of shares in specified timeframe)
  //   meta : (object containing scraped OG protocol metadata)
  // }
  //
  J.get(
    {
      max_date : max,
      min_date : min,
      num : 40
    },
    function(results) {
      res.send(results);
    }
  );
})

```

---
_Source: https://npm.io/package/jugo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
