Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

first try. this is shit

  • Loading branch information...
commit 5a06344236762af24a8a36b2fb893942a977ff1a 1 parent a7f00d5
Joe Longstreet joelongstreet authored
4 .gitignore
@@ -12,4 +12,6 @@ logs
12 12 results
13 13
14 14 node_modules
15   -npm-debug.log
  15 +npm-debug.log
  16 +.DS_Store
  17 +fb_images
1  Procfile
... ... @@ -0,0 +1 @@
  1 +web: node runner.js
49 app.coffee
... ... @@ -0,0 +1,49 @@
  1 +express = require 'express'
  2 +path = require 'path'
  3 +fs = require 'fs'
  4 +util = require 'util'
  5 +stylus = require 'stylus'
  6 +http = require 'http'
  7 +request = require 'request'
  8 +app = express.createServer()
  9 +port = process.env.PORT || 3001
  10 +
  11 +#app.use require('connect-assets')(src : 'public')
  12 +
  13 +app.configure ->
  14 + #app.use express.logger format: ':method :url :status'
  15 + app.use express.static path.join __dirname, 'public'
  16 + app.use stylus.middleware
  17 + debug: true
  18 + force: true
  19 + src: "#{__dirname}/public"
  20 + dest: "#{__dirname}/public"
  21 + app.set 'views', path.join __dirname, 'public/views'
  22 + app.set 'view engine', 'jade'
  23 +
  24 +find_fb_photo = (req, res, next) ->
  25 + rando = Math.floor(Math.random() * 10000000) + 1
  26 + fb_req = "https://graph.facebook.com/#{rando}?fields=picture"
  27 + res.uid = rando
  28 + request fb_req, (error, response, body) ->
  29 + res.pic = JSON.parse(response.body).picture
  30 + next()
  31 +
  32 +app.get '/', find_fb_photo, (req, res, next) ->
  33 +
  34 + ###
  35 + request.get res.pic, (err, data) ->
  36 + fs.writeFile "#{__dirname}/public/fb_images/#{res.uid}.gif", data, 'binary', (err) ->
  37 + res.contentType 'image/gif'
  38 + res.end "#{__dirname}/public/fb_images/#{res.uid}.gif", 'binary'
  39 + ###
  40 +
  41 + piped = request(res.pic).pipe(fs.createWriteStream("#{__dirname}/public/fb_images/#{res.uid}.gif"))
  42 + setTimeout (->
  43 + img = fs.readFileSync piped.path
  44 + res.contentType 'image/gif'
  45 + res.end img, 'binary'
  46 + ), 1500
  47 +
  48 +app.listen port
  49 +console.log 'server running on port ' + port
17 package.json
... ... @@ -0,0 +1,17 @@
  1 +{
  2 + "name" : "facehold.it",
  3 + "version" : "1.0.0",
  4 + "engines" : {
  5 + "node" : "0.6.15",
  6 + "npm" : "1.1.9"
  7 + },
  8 + "dependencies" : {
  9 + "express" : "v2.5.8",
  10 + "coffee-script" : "v1.2.0",
  11 + "jade" : "v0.20.0",
  12 + "stylus" : "v0.22.5",
  13 + "connect-assets" : "v2.1.9",
  14 + "socket.io" : "v0.9.0",
  15 + "ntwitter" : "v0.3.0"
  16 + }
  17 +}
1  public/views/_analytics.html
... ... @@ -0,0 +1 @@
  1 +Analytics Go Here
0  public/views/index.jade
No changes.
8 public/views/layout.jade
... ... @@ -0,0 +1,8 @@
  1 +!!! 5
  2 +html
  3 + head
  4 + title facehold.it
  5 +
  6 + body
  7 + != body
  8 + //include _analytics.html
2  runner.js
... ... @@ -0,0 +1,2 @@
  1 +require('coffee-script')
  2 +require('./app.coffee')

0 comments on commit 5a06344

Please sign in to comment.
Something went wrong with that request. Please try again.