-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of nodester.com:/node/git/arvidkahl/6751-1067f4…
…4123fb76654fa80e28cf17fdb5
- Loading branch information
Showing
7 changed files
with
102 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Spark. | ||
## What is Spark? | ||
Spark is a community-based imageboard for authors. It references images (called 'Scenes') from popular art community sites (such as CGSociety) and allows users to add text (called 'Stories') of any size to the Scenes. | ||
Images are not hosted on the site, they are referenced via URLs. Additional information must be provided for adding images to Spark. This serves the purpose of paying proper respect to intellectual property rights of the original authors of the images. | ||
## Why is it on GitHub? | ||
I want the project to flourish. If you have comments, issues or ideas, feel free to add them to Spark. | ||
## How can I use Spark? | ||
Just browse over to [spark.nodester.com](http://spark.nodester.com) and start using the site. | ||
## How can I install it for myself? | ||
Clone the repo. Easy as that. Run npm for the dependencies, run `main.coffee`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,30 @@ | ||
config = require './config.coffee' | ||
User = require('./user.coffee').User | ||
users = new User config.mainDBHost, config.mainDBPort, 'spark-user' | ||
|
||
everyauth = module.exports = require 'everyauth' | ||
everyauth.debug = false | ||
everyauth.everymodule.moduleErrback (err) -> | ||
console.log "Auth ERROR - "+err | ||
|
||
everyauth.everymodule.findUserById (userId, callback) -> | ||
callback null, "moo" | ||
# callback has the signature, function (err, user) {...} | ||
everyauth.everymodule.findUserById (userId, callback) -> | ||
users.findByTwitterId userId, (err,res) -> | ||
if res.id | ||
callback null, res.value | ||
else | ||
callback null, null | ||
|
||
everyauth.twitter | ||
.consumerKey(config.twitterConsumerKey) | ||
.consumerSecret(config.twitterConsumerSecret) | ||
.findOrCreateUser((session, token, secret, user) -> | ||
promise = @.Promise().fulfill user | ||
users.findByTwitterId user.id, (err,res) -> | ||
if res.id | ||
user=res.value | ||
else | ||
newUser = {id:user.id,name:user.name,twitter:user} | ||
user = newUser | ||
users.saveById JSON.stringify(user.id), user, (saveErr, saveRes) -> | ||
promise = @.Promise().fulfill user | ||
|
||
).redirectPath '/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# User Class - Handles all user functions | ||
config = require './config.coffee' | ||
cradle = require 'cradle' | ||
|
||
class User | ||
constructor: (host, port, collection) -> | ||
@.connect = new cradle.Connection host, port, { | ||
secure: false | ||
auth: { | ||
username: config.mainDBUser | ||
password: config.mainDBPass | ||
} | ||
cache: true | ||
raw: false | ||
} | ||
@.db = @.connect.database collection | ||
|
||
findByTwitterId: (mykey, callback) -> | ||
@.db.view 'spark-user/byTwitterId', {key: JSON.stringify(mykey)}, (err, res) -> | ||
if (err) | ||
callback err, null | ||
else | ||
if res.length>0 | ||
callback null, res[0] | ||
else | ||
callback null, res | ||
|
||
findById: (mykey, callback) -> | ||
@.db.view 'spark-user/byid', {key: JSON.stringify(mykey)}, (err, res) -> | ||
if (err) | ||
callback err, null | ||
else | ||
if res.length>0 | ||
callback null, res[0] | ||
else | ||
callback null, res | ||
saveById: (id, data, callback) -> | ||
@.db.save id, data, (err, res) -> | ||
callback err, res | ||
|
||
exports.User = User |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters