Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding support for hubot

  • Loading branch information...
commit dd342ca959e1116df748df04f392ded84a049ad6 1 parent c88f928
Joe Longstreet joelongstreet authored
Showing with 344 additions and 0 deletions.
  1. +34 −0 app.coffee
  2. +310 −0 fb_locales.js
34 app.coffee
View
@@ -93,12 +93,14 @@ get_photo_count = (next) ->
else next(res)
+
app.get '/', (req, res, next) ->
if req.headers.referrer
res.redirect '/pic'
else
res.redirect '/25'
+
app.get '/pic', (req, res, next) ->
get_photo_count (photo_count) ->
@@ -106,6 +108,38 @@ app.get '/pic', (req, res, next) ->
res.redirect "https://s3.amazonaws.com/faceholder/#{url}.jpg"
+
+fb_locales = JSON.parse(fs.readFileSync('./fb_locales.js','utf-8'))
+
+app.get '/hubot', (req, res, next) ->
+ get_photo_count (photo_count) ->
+ get_photo_url photo_count, 0, (id, index) ->
+
+ fb_req = "https://graph.facebook.com/#{id}"
+
+ request
+ method : 'GET'
+ url : fb_req
+ timeout : 1500
+ , (err, resp, body) ->
+
+ fb_body = JSON.parse(body)
+
+ locale == 'American'
+ for location in fb_locales
+ if location.fb_code == fb_body.locale
+ locale = location.nationality
+
+ res.send
+ id : fb_body.id
+ name : fb_body.name
+ gender : fb_body.gender
+ nationality : locale
+ url : fb_req
+ image : "https://s3.amazonaws.com/faceholder/#{id}.jpg"
+
+
+
app.get '/:number', (req, res, next) ->
if req.params.number > 100 then res.render 'max'
310 fb_locales.js
View
@@ -0,0 +1,310 @@
+[
+ {
+ "nationality" : "Afrikaans",
+ "fb_code" : "af_ZA"
+ },
+ {
+ "nationality" : "Arabic",
+ "fb_code" : "ar_AR"
+ },
+ {
+ "nationality" : "Azerbaijani",
+ "fb_code" : "az_AZ"
+ },
+ {
+ "nationality" : "Belarusian",
+ "fb_code" : "be_BY"
+ },
+ {
+ "nationality" : "Bulgarian",
+ "fb_code" : "bg_BG"
+ },
+ {
+ "nationality" : "Bengali",
+ "fb_code" : "bn_IN"
+ },
+ {
+ "nationality" : "Bosnian",
+ "fb_code" : "bs_BA"
+ },
+ {
+ "nationality" : "Catalan",
+ "fb_code" : "ca_ES"
+ },
+ {
+ "nationality" : "Czech",
+ "fb_code" : "cs_CZ"
+ },
+ {
+ "nationality" : "Welsh",
+ "fb_code" : "cy_GB"
+ },
+ {
+ "nationality" : "Danish",
+ "fb_code" : "da_DK"
+ },
+ {
+ "nationality" : "German",
+ "fb_code" : "de_DE"
+ },
+ {
+ "nationality" : "Greek",
+ "fb_code" : "el_GR"
+ },
+ {
+ "nationality" : "English",
+ "fb_code" : "en_GB"
+ },
+ {
+ "nationality" : "Pirate",
+ "fb_code" : "en_PI"
+ },
+ {
+ "nationality" : "American",
+ "fb_code" : "en_UD"
+ },
+ {
+ "nationality" : "American",
+ "fb_code" : "en_US"
+ },
+ {
+ "nationality" : "Esperanto",
+ "fb_code" : "eo_EO"
+ },
+ {
+ "nationality" : "Spanish",
+ "fb_code" : "es_ES"
+ },
+ {
+ "nationality" : "Spanish",
+ "fb_code" : "es_LA"
+ },
+ {
+ "nationality" : "Estonian",
+ "fb_code" : "et_EE"
+ },
+ {
+ "nationality" : "Basque",
+ "fb_code" : "eu_ES"
+ },
+ {
+ "nationality" : "Persian",
+ "fb_code" : "fa_IR"
+ },
+ {
+ "nationality" : "Leet Speak",
+ "fb_code" : "fb_LT"
+ },
+ {
+ "nationality" : "Finnish",
+ "fb_code" : "fi_FI"
+ },
+ {
+ "nationality" : "Faroese",
+ "fb_code" : "fo_FO"
+ },
+ {
+ "nationality" : "French Canadian",
+ "fb_code" : "fr_CA"
+ },
+ {
+ "nationality" : "French (France)",
+ "fb_code" : "fr_FR"
+ },
+ {
+ "nationality" : "Frisian",
+ "fb_code" : "fy_NL"
+ },
+ {
+ "nationality" : "Irish",
+ "fb_code" : "ga_IE"
+ },
+ {
+ "nationality" : "Galician",
+ "fb_code" : "gl_ES"
+ },
+ {
+ "nationality" : "Hebrew",
+ "fb_code" : "he_IL"
+ },
+ {
+ "nationality" : "Hindi",
+ "fb_code" : "hi_IN"
+ },
+ {
+ "nationality" : "Croatian",
+ "fb_code" : "hr_HR"
+ },
+ {
+ "nationality" : "Hungarian",
+ "fb_code" : "hu_HU"
+ },
+ {
+ "nationality" : "Armenian",
+ "fb_code" : "hy_AM"
+ },
+ {
+ "nationality" : "Indonesian",
+ "fb_code" : "id_ID"
+ },
+ {
+ "nationality" : "Icelandic",
+ "fb_code" : "is_IS"
+ },
+ {
+ "nationality" : "Italian",
+ "fb_code" : "it_IT"
+ },
+ {
+ "nationality" : "Japanese",
+ "fb_code" : "ja_JP"
+ },
+ {
+ "nationality" : "Georgian",
+ "fb_code" : "ka_GE"
+ },
+ {
+ "nationality" : "Khmer",
+ "fb_code" : "km_KH"
+ },
+ {
+ "nationality" : "Korean",
+ "fb_code" : "ko_KR"
+ },
+ {
+ "nationality" : "Kurdish",
+ "fb_code" : "ku_TR"
+ },
+ {
+ "nationality" : "Latin",
+ "fb_code" : "la_VA"
+ },
+ {
+ "nationality" : "Lithuanian",
+ "fb_code" : "lt_LT"
+ },
+ {
+ "nationality" : "Latvian",
+ "fb_code" : "lv_LV"
+ },
+ {
+ "nationality" : "Macedonian",
+ "fb_code" : "mk_MK"
+ },
+ {
+ "nationality" : "Malayalam",
+ "fb_code" : "ml_IN"
+ },
+ {
+ "nationality" : "Malay",
+ "fb_code" : "ms_MY"
+ },
+ {
+ "nationality" : "Norwegian (bokmal)",
+ "fb_code" : "nb_NO"
+ },
+ {
+ "nationality" : "Nepali",
+ "fb_code" : "ne_NP"
+ },
+ {
+ "nationality" : "Dutch",
+ "fb_code" : "nl_NL"
+ },
+ {
+ "nationality" : "Norwegian (nynorsk)",
+ "fb_code" : "nn_NO"
+ },
+ {
+ "nationality" : "Punjabi",
+ "fb_code" : "pa_IN"
+ },
+ {
+ "nationality" : "Polish",
+ "fb_code" : "pl_PL"
+ },
+ {
+ "nationality" : "Pashto",
+ "fb_code" : "ps_AF"
+ },
+ {
+ "nationality" : "Portuguese (Brazil)",
+ "fb_code" : "pt_BR"
+ },
+ {
+ "nationality" : "Portuguese (Portugal)",
+ "fb_code" : "pt_PT"
+ },
+ {
+ "nationality" : "Romanian",
+ "fb_code" : "ro_RO"
+ },
+ {
+ "nationality" : "Russian",
+ "fb_code" : "ru_RU"
+ },
+ {
+ "nationality" : "Slovak",
+ "fb_code" : "sk_SK"
+ },
+ {
+ "nationality" : "Slovenian",
+ "fb_code" : "sl_SI"
+ },
+ {
+ "nationality" : "Albanian",
+ "fb_code" : "sq_AL"
+ },
+ {
+ "nationality" : "Serbian",
+ "fb_code" : "sr_RS"
+ },
+ {
+ "nationality" : "Swedish",
+ "fb_code" : "sv_SE"
+ },
+ {
+ "nationality" : "Swahili",
+ "fb_code" : "sw_KE"
+ },
+ {
+ "nationality" : "Tamil",
+ "fb_code" : "ta_IN"
+ },
+ {
+ "nationality" : "Telugu",
+ "fb_code" : "te_IN"
+ },
+ {
+ "nationality" : "Thai",
+ "fb_code" : "th_TH"
+ },
+ {
+ "nationality" : "Filipino",
+ "fb_code" : "tl_PH"
+ },
+ {
+ "nationality" : "Turkish",
+ "fb_code" : "tr_TR"
+ },
+ {
+ "nationality" : "Ukrainian",
+ "fb_code" : "uk_UA"
+ },
+ {
+ "nationality" : "Vietnamese",
+ "fb_code" : "vi_VN"
+ },
+ {
+ "nationality" : "Simplified Chinese (China)",
+ "fb_code" : "zh_CN"
+ },
+ {
+ "nationality" : "Traditional Chinese (Hong Kong)",
+ "fb_code" : "zh_HK"
+ },
+ {
+ "nationality" : "Traditional Chinese (Taiwan)",
+ "fb_code" : "zh_TW"
+ }
+]
Please sign in to comment.
Something went wrong with that request. Please try again.