<commit_before>from framework.controller import *
import giveaminute.location as mLocation
import giveaminute.user as mUser
import giveaminute.project as mProject
import giveaminute.idea as mIdea
import giveaminute.messaging as mMessaging
import framework.util as util
import lib.web
#temp
from framework.image_server import *  
import giveaminute.projectResource as mResource  

import cgi
import oauth2 as oauth
import urllib2
import json
import hashlib

tw_settings = Config.get('twitter')
tw_consumer = oauth.Consumer(tw_settings['consumer_key'], tw_settings['consumer_secret'])
tw_client = oauth.Client(tw_consumer)

class Home(Controller):
    def GET(self, action=None, param0=None):
        project_user = dict(is_member = True,
                              is_project_admin = True)
        self.template_data['project_user'] = dict(data = project_user, json = json.dumps(project_user))
                                          
        if (not action or action == 'home'):
            return self.showHome()
        elif (action == 'leaderboard'):
            return self.showLeaderboard()
        elif (action == 'mobile'):
            return self.showMobile()
        elif (action == 'bb'):
            return self.showMobile(isBlackBerry = True)
        elif (action == 'login'):
            return self.showLogin() 
        elif (action == 'nyc'):
            self.redirect('http://nyc.changeby.us/')
        elif (action == 'beta'):
            return self.showBeta()
        else:
            return self.render(action)
            
    def POST(self, action=None, param0=None):
        if (action == 'login'):
            if (param0 == 'forgot'):
                return self.forgotPassword()
            else:
                return self.login()
        elif (action == 'logout'):
            return self.logout()
        elif (action == 'login_twitter'):
            return self.login_twitter()
        elif (action == 'login_facebook'):
            return self.login_facebook() 
        elif (action == 'twitter_callback'):
            return self.tw_authenticated()
        elif (action == 'login_twitter_create'):
            return self.login_twitter_create()
        elif (action == 'login_facebook_create'):
            return self.login_facebook_create()
        elif (action == 'disconnect_facebook'):
            return self.disconnect_facebook()
        elif (action == 'disconnect_twitter'):
            return self.disconnect_twitter()
        elif (action == 'feedback'):
            return self.submitFeedback()
        elif (action == 'beta' and param0 == 'submit'):
            return self.submitInviteRequest()
        elif (action == 'directmsg'):
            return self.directMessageUser()
        else:
            return self.not_found()
            
    def showHome(self):
        locationData = mLocation.getSimpleLocationDictionary(self.db)
        allIdeasData = mIdea.getMostRecentIdeas(self.db, 75);

        locations = dict(data = locationData, json = json.dumps(locationData))
        allIdeas = dict(data = allIdeasData, json = json.dumps(allIdeasData))<commit_msg>Reorganize structure of Twitter and FB services<commit_after>from framework.controller import *
import giveaminute.location as mLocation
import giveaminute.user as mUser
import giveaminute.project as mProject
import giveaminute.idea as mIdea
import giveaminute.messaging as mMessaging
import framework.util as util
import lib.web
#temp
from framework.image_server import *  
import giveaminute.projectResource as mResource  

import cgi
import oauth2 as oauth
import urllib2
import json
import hashlib

tw_settings = Config.get('twitter')
tw_consumer = oauth.Consumer(tw_settings['consumer_key'], tw_settings['consumer_secret'])
tw_client = oauth.Client(tw_consumer)

class Home(Controller):
    def GET(self, action=None, param0=None):
        project_user = dict(is_member = True,
                              is_project_admin = True)
        self.template_data['project_user'] = dict(data = project_user, json = json.dumps(project_user))
                                          
        if (not action or action == 'home'):
            return self.showHome()
        elif (action == 'leaderboard'):
            return self.showLeaderboard()
        elif (action == 'mobile'):
            return self.showMobile()
        elif (action == 'bb'):
            return self.showMobile(isBlackBerry = True)
        elif (action == 'login'):
            return self.showLogin() 
        elif (action == 'nyc'):
            self.redirect('http://nyc.changeby.us/')
        elif (action == 'beta'):
            return self.showBeta()
        else:
            return self.render(action)
            
    def POST(self, action=None, param0=None):
        if (action == 'login'):
            if (param0 == 'forgot'):
                return self.forgotPassword()
            else:
                return self.login()
        elif (action == 'logout'):
            return self.logout()
        elif (action == 'facebook'):
            if (param0 == 'login'):
                return self.login_facebook() 
            elif (param0 == 'create'):
                return self.login_facebook_create()
            elif (param0 == 'disconnect'):
                return self.disconnect_facebook()
            else:
                return self.not_found()                    
        elif (action == 'twitter'):
            if (param0 == 'login'):
                return self.login_twitter()
            elif (param0 == 'callback'):
                return self.tw_authenticated()
            elif (param0 == 'create'):
                return self.login_twitter_create()
            elif (param0 == 'disconnect'):
                return self.disconnect_twitter()
            else:
                return self.not_found()
        elif (action == 'feedback'):
            return self.submitFeedback()
        elif (action == 'beta' and param0 == 'submit'):
            return self.submitInviteRequest()
        elif (action == 'directmsg'):
            return self.directMessageUser()
        else:
            return self.not_found()
            
    def showHome(self):
        locationData = mLocation.getSimpleLocationDictionary(self.db)
        allIdeasData = mIdea.getMostRecentIdeas(self.db, 75);

        locations = dict(data = locationData, json = json.dumps(locationData))
        allIdeas = dict(data = allIdeasData, json = json.dumps(allIdeasData))
{'fraction_non_alphanumeric': 0.10591514400743264, 'fraction_numerical': 0.003561474140600805, 'mean_word_length': 2.18962962962963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3276871', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1682, 'n_words': 429}