Monday, October 16, 2017

TUMBLR PROJECT -- TBD

https://github.com/tumblr/tumblr.js


Build Status
The official JavaScript client library for the Tumblr API. Check out the detailed documentation here.

Installation

Install this package from npm:
npm install --save tumblr.js

Usage

Authentication

Different API methods use different kinds of authentication.
Most of them require at least an API key, which will require you to register an application. The OAuth Consumer Key is your API key.
For methods that require a fully signed request, you'll need OAuth tokens as well, which you get from authenticating as a Tumblr user and allowing access to your API application. Here's the easy way to do it with our own account:
  1. Visit the OAuth applications page
  2. Click "Explore API" on the application you want to authorize
  3. Click the "Allow" button, which will take you to the API console
  4. Click the "Show keys" button, which will show you the credentials you can use to make signed requests.
If you're building an application of your own for users out in the world, you'll need to go through the 3-legged OAuth flow. See the help docs for more info.

In Node.js

var tumblr = require('tumblr.js');
var client = tumblr.createClient({
  consumer_key: '<consumer key>',
  consumer_secret: '<consumer secret>',
  token: '<oauth token>',
  token_secret: '<oauth token secret>'
});
Or, if you prefer:
var tumblr = require('tumblr.js');
var client = new tumblr.Client({
  // ...
});
The request methods return Request objects by default, but you can have it return Promise objects instead, if that's more your thing. Pass returnPromises: true in the options to createClient:
var tumblr = require('tumblr.js');
var client = tumblr.createClient({
  credentials: {
    // ...
  },
  returnPromises: true,
});

In the Browser

Due to CORS restrictions, you're going to have a really hard time using this library in the browser. Although GET endpoints on the Tumblr API support JSONP, this library is not intended for in-browser use. Sorry!

Example

// Show user's blog names
client.userInfo(function(err, data) {
  data.user.blogs.forEach(function(blog) {
    console.log(blog.name);
  });
});

Supported Methods

Below is a list of available methods and their purpose. Available options are documented in the API Docs and are specified as a JavaScript object.
client.blogPosts('staff', {type: 'photo'}, function(err, resp) {
  resp.posts; // use them for something
});
In most cases, since options are optional (heh) they are also an optional argument, so there is no need to pass an empty object when supplying no options, like:
client.blogPosts('staff', function(err, resp) {
  resp.posts; // now we've got all kinds of posts
});
If you're using Promises, use then and/or catch instead of a callback:
client.blogPosts('staff')
  .then(function(resp) {
    resp.posts;
  })
  .catch(function(err) {
    // oops
  });

User Methods

// Get information about the authenticating user & their blogs
client.userInfo(callback);

// Get dashboard for authenticating user
client.userDashboard(options, callback);
client.userDashboard(callback);

// Get likes for authenticating user
client.userLikes(options, callback);
client.userLikes(callback);

// Get followings for authenticating user
client.userFollowing(options, callback);
client.userFollowing(callback);

// Follow or unfollow a given blog
client.followBlog(blogURL, callback);
client.unfollowBlog(blogURL, callback);

// Like or unlike a given post
client.likePost(id, reblogKey, callback);
client.unlikePost(id, reblogKey, callback);

Blog Methods

// Get information about a given blog
client.blogInfo(blogName, callback);

// Get a list of posts for a blog (with optional filtering)
client.blogPosts(blogName, options, callback);
client.blogPosts(blogName, callback);

// Get the avatar URL for a blog
client.blogAvatar(blogName, size, callback);
client.blogAvatar(blogName, callback);

// Get the likes for a blog
client.blogLikes(blogName, options, callback);
client.blogLikes(blogName, callback);

// Get the followers for a blog
client.blogFollowers(blogName, options, callback);
client.blogFollowers(blogName, callback);

// Get the queue for a blog
client.blogQueue(blogName, options, callback);
client.blogQueue(blogName, callback);

// Get the drafts for a blog
client.blogDrafts(blogName, options, callback);
client.blogDrafts(blogName, callback);

// Get the submissions for a blog
client.blogSubmissions(blogName, options, callback);
client.blogSubmissions(blogName, callback);

Post Methods

// Edit a given post
client.editPost(blogName, options, callback);

// Reblog a given post
client.reblogPost(blogName, options, callback);

// Delete a given post
client.deletePost(blogName, id, callback);

// Convenience methods for creating post types
client.createTextPost(blogName, options, callback);
client.createPhotoPost(blogName, options, callback);
client.createQuotePost(blogName, options, callback);
client.createLinkPost(blogName, options, callback);
client.createChatPost(blogName, options, callback);
client.createAudioPost(blogName, options, callback);
client.createVideoPost(blogName, options, callback);

Tagged Methods

// View posts tagged with a certain tag
client.taggedPosts(tag, options, callback);
client.taggedPosts(tag, callback);

Unsupported Methods

You can make GET and POST requests to any endpoint directly. These methods are used internally by the methods listed above:
// GET requests
client.getRequest(apiPath, params, callback);

// POST requests
client.postRequest(apiPath, params, callback);
In the unlikely event that we add a bunch of methods to the API docs and don't update this client, you can map new client methods to API endpoints. URL and query parameters are automatically turned into arguments to these methods. It's a little weird to explain, so just look at these examples:
// GET methods
client.addGetMethods({
  // creates client.userInfo(params, callback)
  userInfo: '/user/info',
  // client.blogInfo(blogIdentifier, params, callback)
  blogInfo: '/blog/:blogIdentifier/info',
  // Creates client.taggedPosts(tag, params, callback)
  taggedPosts: ['/tagged', ['tag']],
});

// POST methods
client.addPostMethods({
  // client.deletePost(blogIdentifier, id, params, callback)
  deletePost: ['/blog/:blogIdentifier/post/delete', ['id']],
  // Creates client.likePost(tag, id, reblog_key, params, callback)
  likePost: ['/user/like', ['id', 'reblog_key']],
});

Running Tests

npm test # linter and tests
gulp lint # linter
gulp test # just the tests

PROJECT IDEA #2 Mix AUDIO


USE THIS API to Get Sounds
http://freesound.org/docs/api/

Download Sound (OAuth2 required)

GET /apiv2/sounds/<sound_id>/download/
This resource allows you to download a sound in its original format/quality (the format/quality with which the sound was uploaded). It requires OAuth2 authentication.

Examples

Download a sound:
curl -H "Authorization: Bearer {{access_token}}" 'https://www.freesound.org/apiv2/sounds/14854/download/'



https://github.com/kevincennis/Mix.js

Mix.js

travis
Multitrack mixing with the Web Audio API.
Documentation (and lots of cleanup) forthcoming.

Demo

Getting started (for Developers)

Install Grunt
npm install -g grunt-cli (may require sudo)
Install Node dependencies
npm install
Build & Test
npm test or grunt
Start a local webserver at http://localhost:8888
npm start

Usage (for... Users)

  • Download mix.js.zip from the Releases page and unzip it
  • Put your own audio (mono mp3 or wav) in the /sounds directory
  • Edit mix.json to reflect your track names and audio URLs
  • Copy the directory to your webserver
To save a mix, open the dev tools in your browser and enter JSON.stringify(App.mix.toJSON(), null, ' ') and copy the output into mix.json.

Contributing

Pull requests are completely welcome and appreciated. Before submitting, please make sure that your code conforms to the Idiomatic.js style guide.

Tests

Unfotunately, PhantomJS doesn't currently support the Web Audio API, which makes meaningful testing for most of Mix.js pretty much impossible. That said, if you write code which can be tested, please submit tests with your pull request.

Bugs

Bugs should be filed on this repo's Issues page. Please include any relevant details (browser, OS, etc.) as well as steps to reproduce.

IDEAS PROJECT IDEA #1

NYPL PROJECT #1
USE THIS API TO "Get Images"
http://api.repo.nypl.org/
Authentication Token
1st9uk7cyntxg451
Application name
SFTWMIX
<img src="Butterfly.jpg" id="img1">
<img src="Flower.jpg" id="img2">
<p>Blended image<br><canvas id="canvas"></canvas></p>
<script>
window.onload = function () {
    var img1 = document.getElementById('img1');
    var img2 = document.getElementById('img2');
    var canvas = document.getElementById("canvas");
    var context = canvas.getContext("2d");
    var width = img1.width;
    var height = img1.height;
    canvas.width = width;
    canvas.height = height;

    var pixels = 4 * width * height;
    context.drawImage(img1, 0, 0);
    var image1 = context.getImageData(0, 0, width, height);
    var imageData1 = image1.data;
    context.drawImage(img2, 0, 0);
    var image2 = context.getImageData(0, 0, width, height);
    var imageData2 = image2.data;
    while (pixels--) {
        imageData1[pixels] = imageData1[pixels] * 0.5 + imageData2[pixels] * 0.5;
    }
    image1.data = imageData1;
    context.putImageData(image1, 0, 0);
};
</script>

Scripting for the Web Final

I spent a lot of time working on my updated portfolio website this semester. Here's an excerpt of the reflection post I wrote (because t...