A node.js library for interacting with the Neocities api that actually has more capabilities than the original api itself.
WARNING - This module is not yet on NPM; the following command will not work
$ npm install neocities-extended
Instead, clone this repository where you want it to be installed, and reference the folder directly in the require statement.
First, require the library and initialize:
var Neocities = require('neocities-extended') // or reference to the folder
var api = new Neocities('YOURUSERNAME', 'YOURPASSWORD')
// local file path is ./index.js, saved on site as derp.js
api.upload([
{name: 'derp.js', path: './index.js'}
], function(resp) {
console.log(resp)
})
// site path is derp.js, saved on client as index.js
api.download([
{name: 'derp.js', path: 'index.js'}
], function(resp) {
console.log(resp)
})
api.delete(['derp.js'], function(resp) {
console.log(resp)
})
api.list('dirname', function(resp) {
console.log(resp)
})
api.info(function(resp) {
console.log(resp)
})
api.info('youpi', function(resp) {
console.log(resp)
})
The API key is a more secure way to upload data, since it doesn't store or send your username or password. First, Log in normally with a callback for the key option. (This then uses the key once it is aquired instead of your username and password.)
var api = new Neocities('YOURUSERNAME', 'YOURPASSWORD', {key: function(key) {/* store your key here */}})
Then, use the key instead of the username or password the next time you log in.
var api = new Neocities('YOURAPIKEY')
// foo is the local folder, images is what it will be named on your site
// hidden.json is not uploaded, nor any file ending with .conf.json
api.push('foo/', 'images/', ['hidden.json', /\.conf\.json$/])
Similar to download, but for folders
// same argument syntax as push
api.pull('foo/', 'images', ['site.png'])