Skip to content

Commit

Permalink
Spring cleaning.
Browse files Browse the repository at this point in the history
- Updated readme.
- Updated dependencies.
– Added nodejitsu support.
  • Loading branch information
alexindigo committed May 1, 2013
1 parent ec7ff28 commit bd5a6d0
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 38 deletions.
6 changes: 6 additions & 0 deletions .npmignore
@@ -0,0 +1,6 @@
/node_modules/
.gitignore
.gitmodules
.npmignore
*.sublime-*
sftp-config.json
70 changes: 54 additions & 16 deletions README.md
Expand Up @@ -14,65 +14,102 @@ Try it for yourself: [http://libere.co/](http://libere.co/)
npm install libereco
```

## Codebux
## Usage

Could be deployed to [https://www.nodejitsu.com/](nodejitsu.com) out of the box:
```
+ 100.00 # initial stipend
- 14.46 # index.js
- 16.53 # lib/api_500px.js
- 6.44 # lib/api.js
- 22.98 # lib/api_flickr.js
—————————————————————————————————————————————————
+ 39.57
cd node_modules/libereco/
jitsu env set api_500px_key <500px consumer key>
jitsu env set api_500px_secret <500px consumer secret>
jitsu env set api_flickr_key <flickr api key>
jitsu env set api_flickr_secret <flickr api secret>
jitsu deploy
```

## Usage
Read below for more details.

### Add API services
### Add API services (required)

*You need at least two services enabled for application to work.*

* 500px *([request API key](http://500px.com/settings/applications?from=developers))*:

Environment variables:
```
export api_500px_key <500px consumer key>
export api_500px_secret <500px consumer secret>
```

Or npm config:
```
npm config set libereco:api_500px_key <500px consumer key>
npm config set libereco:api_500px_secret <500px consumer secret>
```

* Flickr *([request API key](http://www.flickr.com/services/apps/create/apply/))*:

Environment variables:
```
export api_flickr_key <flickr api key>
export api_flickr_secret <flickr api secret>
```

Or npm config:
```
npm config set libereco:api_flickr_key <flickr api key>
npm config set libereco:api_flickr_secret <flickr api secret>
```


### Customize HTTP server
### Customize HTTP server (optional)

* Hostname *(Defaults to OS assigned hostname)*:

Environment variables:
```
export host libereco.yourapp.com
```

Or npm config:
```
npm config set libereco:host libereco.yourapp.com
```

* Port *(Defaults to port 8000)*:
* Port *(Defaults to port ```8000```)*:

Environment variables:
```
export port 1337
```

Or npm config:
```
npm config set libereco:port 1337
```

* Path for static files (*Defaults to static*):
* Path for static files (*Defaults to ```static```*):

*Useful for customizing UI of the app and keeping `npm update` functionality*

Environment variables:
```
export path /var/www/custom_root
```

Or npm config:
```
npm config set libereco:path /var/www/custom_root
```

* Index file (*Defaults to index.html*):
* Index file (*Defaults to ```index.html```*):

*For example temporally switching to the maintenance page*

Environment variables:
```
export index maintenance.html
```

Or npm config:
```
npm config set libereco:index maintenance.html
```
Expand All @@ -85,11 +122,12 @@ npm start libereco

You can specify all the config parameters on start time:


```
index=maintenance.html path=/var/www/theme2 port=1337 npm start libereco
```

Open your favorite latest webkit browser and liberate your photos. :)
Open your favorite modern browser and liberate your photos. :)

## Browser support

Expand Down
22 changes: 15 additions & 7 deletions index.js
Expand Up @@ -30,28 +30,30 @@ var path = require('path')
// {{{ prepare environment

// process config settings
Config.host = process.env.host || process.env.npm_package_config_host;
Config.host = getConfigVar('host');

Config.port = process.env.port || process.env.npm_package_config_port || Config.port;
Config.port = getConfigVar('port') || Config.port;

Config.path = process.env.path || process.env.npm_package_config_path || Config.path;
Config.path = getConfigVar('path') || Config.path;
if (Config.path[0] != '/') Config.path = path.join(__dirname, Config.path);

Config.index = process.env.index || process.env.npm_package_config_index || Config.index;
Config.index = getConfigVar('index') || Config.index;
if (Config.index[0] != '/') Config.index = path.join(Config.path, Config.index);

Config.oauthCallback = getConfigVar('oauth_callback') || Config.oauthCallback;

// check APIs
for (var service in APIs)
{
if (!APIs.hasOwnProperty(service)) continue;

// check that we have both api key and secret for each service
if (process.env['npm_package_config_api_'+service+'_key'] && process.env['npm_package_config_api_'+service+'_secret'])
if (getConfigVar('api_'+service+'_key') && getConfigVar('api_'+service+'_secret'))
{
APIs[service].oauth(
{
key : process.env['npm_package_config_api_'+service+'_key'],
secret : process.env['npm_package_config_api_'+service+'_secret'],
key : getConfigVar('api_'+service+'_key'),
secret : getConfigVar('api_'+service+'_secret'),
callback : Config.oauthCallback
});
}
Expand Down Expand Up @@ -256,3 +258,9 @@ function createOAuthVerifier(socket, service, token, secret)
};
}

// fetches variable from environment or npm config
// TODO: Should we account for 0?
function getConfigVar(key)
{
return process.env[key] || process.env['npm_package_config_'+key] || null;
}
5 changes: 4 additions & 1 deletion lib/api_500px.js
Expand Up @@ -231,7 +231,10 @@ api500px.prototype.upload = function api500pxUpload(info, srcUrl, callback)
});
res.on('end', function()
{
console.log('end-500', body);
if (process.env['NODE_ENV'] != 'production')
{
console.log('end-500', body);
}

try
{
Expand Down
5 changes: 4 additions & 1 deletion lib/api_flickr.js
Expand Up @@ -350,7 +350,10 @@ apiFlickr.prototype.upload = function apiFlickrUpload(info, srcUrl, callback)
{
var match;

console.log('end-Flickr', body);
if (process.env['NODE_ENV'] != 'production')
{
console.log('end-Flickr', body);
}

if (match = body.match(/<photoid>([0-9]+)<\/photoid>/))
{
Expand Down
19 changes: 6 additions & 13 deletions package.json
@@ -1,19 +1,11 @@
{
"name": "libereco",
"version": "0.0.5",
"version": "0.0.6",
"description": "Liberate your photos from the hosting platforms lockin.",
"main": "index.js",
"codebux": {
"score": "+39.57"
},
"config": {
"port": "8000",
"path": "static"
},
"scripts": {
"start": "node index.js"
},
"node":"0.6.17",
"engines": {
"node": ">= 0.6"
},
Expand All @@ -27,17 +19,18 @@
"500px",
"flickr",
"freedom",
"liberation",
"migrate"
],
"author": "Alex Indigo <iam@alexindigo.com>",
"license": "MIT",
"dependencies": {
"oauth": "~0.9.8",
"form-data": "0.0.3",
"form-data": "~0.0.9",
"socket.io": "~0.9.10",
"request": "~2.10.0",
"request": "~2.21.0",
"tako": "~0.3.0",
"async": "~0.1.22",
"valentine": "~1.5.5"
"async": "~0.2.7",
"valentine": "~1.6.0"
}
}

0 comments on commit bd5a6d0

Please sign in to comment.