code
stringlengths
1
1.73M
language
stringclasses
1 value
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
Ruby
SETTINGS = {} SETTINGS["feed"] = {} SETTINGS["feed"]["username"] = "edwyn2" SETTINGS["feed"]["password"] = "234567" # filter settings SETTINGS["sport.filter.most_popular.limit"] = 6 SETTINGS["sport.filter.most_bets.limit"] = 6 SETTINGS["sport.filter.most_comment.limit"] = 6 # rss settings SETTINGS["rss.cache.time"]...
Ruby
require 'mongrel_cluster/recipes' set :application, "13wins" set :repository, "http://13wins.googlecode.com/svn/trunk/" # If you aren't deploying to /u/apps/#{application} on the target # servers (which is the default), you can specify the actual location # via the :deploy_to variable: # set :deploy_to, "/var/www/#{a...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between...
Ruby
# Be sure to restart your server when you modify this file # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.2...
Ruby
# Don't change this file! # Configure your app in config/environment.rb and config/environments/*.rb RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) module Rails class << self def boot! unless booted? preinitialize pick_boot.run end end def booted? ...
Ruby
ActionController::Routing::Routes.draw do |map| map.resources :results # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :...
Ruby
#!/usr/bin/env ruby fetcher_command = `ps -A -f | grep "ruby ./script/fetcher" | grep -v grep` if fetcher_command != '' pid = fetcher_command.strip.split(/\s+/)[1] `kill #{pid}` else puts "pid not found, is it running?" end
Ruby
load 'deploy' if respond_to?(:namespace) # cap2 differentiator Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } load 'config/deploy'
Ruby
atom_feed :language=>"en_US"do |feed| feed.title(SETTINGS['rss.title']) feed.updated(Time.now) cache "rss_feed_for_most_comment_matches",SETTINGS['rss.cache.time'].from_now do for match in @most_comment_matches feed.entry(match,:url=>"http://apps.facebook.com/thirteenwins") do |entry| entry.ti...
Ruby
# Methods added to this helper will be available to all templates in the application. # Methods used by 'views' module ApplicationHelper # Format Time and Date def format_time(time,format=:date,timezone=0) return '' if time.blank? case format when :date timezone.hours.since(time).strftime "%...
Ruby
module UsersHelper end
Ruby
module MatchesHelper def point_spread(match,team) case match.bet_type when "total" if team == match.home_team "total over #{match.total_point}" else "total under #{match.total_point}" end else home_point_spread = away_point_spread = match.point_sprea...
Ruby
module BuyWinsHelper end
Ruby
module TeamsHelper def team_pic(team) image_tag(team.pic || "team.gif",:alt=>h(team.name)) end def team_detail(team) str = content_tag(:p,team_pic(team),:style=>"text-align:center") str << content_tag(:p,h(team.displayed_name),:style=>"text-align:center") end end
Ruby
module ResultsHelper end
Ruby
module WinstreaksHelper def winstreak_count(winstreak) if winstreak.goal? content_tag(:div,winstreak.streak_count,:class=>"winstreak-goal") else winstreak.streak_count end end end
Ruby
module WelcomeHelper end
Ruby
module SportsHelper end
Ruby
module BetsHelper def bet_status(bet) if bet.played? str = case bet.win when nil image_tag("draw.png") when true if bet.winstreak_value == 0.5 image_tag("half_win.png") else image_tag("win.png") e...
Ruby
module Admin::UsersHelper end
Ruby
module Admin::MatchesHelper end
Ruby
module Admin::TeamsHelper end
Ruby
module Admin::SportsHelper end
Ruby
module Admin::BetsHelper end
Ruby
module Admin::LeaguesHelper end
Ruby
module Admin::CountriesHelper end
Ruby
module Admin::PrizesHelper end
Ruby
module NewsfeedsHelper end
Ruby
module PointConfigsHelper end
Ruby
module LeaguesHelper end
Ruby
module PointHistoryHelper end
Ruby
module PrizesHelper def prize_pic(prize) image_tag(prize.pic) end def prize_desc(prize) content_tag(:p,prize.name,:style=>"font-weight:bold") + content_tag(:p,prize.description) end end
Ruby
class RemoteLinkRenderer < WillPaginate::LinkRenderer def prepare(collection, options, template) @remote = options.delete(:remote) || {} super end protected def page_link(page, text, attributes = {}) @template.link_to(text, {:url => url_for(page), :method => :get, :section=>'test'}) end end
Ruby
class Football < Sport end
Ruby
# Logging all user requests class IlogAction < ActiveRecord::Base belongs_to :ilog end
Ruby
class Prize < ActiveRecord::Base end
Ruby
class Result < ActiveRecord::Base end
Ruby
class WinstreakPublisher < Facebooker::Rails::Publisher helper TeamsHelper,BetsHelper,MatchesHelper,ApplicationHelper def self.default_url_options {:host=>"apps.railser.com"} end def update_profile(user) send_as :profile recipients user.facebook_user profile_main render(:partial=>"profile_mai...
Ruby
class Country < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name has_many :sports has_many :leagues end
Ruby
class League < ActiveRecord::Base belongs_to :country belongs_to :sport validates_presence_of :sport_id def find_or_create_team(team_name,league) team = Team.find_or_initialize_by_name(team_name) team.sport = league.sport team.save! team end def fetch_results urls = [ "http:/...
Ruby
class Ilog < ActiveRecord::Base belongs_to :user has_many :ilog_actions end
Ruby
class TeamNotFoundInMatch < Exception def initialize(team) super "#{team && team.name} not found in match" end end class Match < ActiveRecord::Base validates_presence_of :away_team_id,:home_team_id,:sport_id,:point_spread after_save :calc_challenge # If match played, calculate all challenges on this mat...
Ruby
class BuyWin < ActiveRecord::Base # Buy free win model end
Ruby
# Used to check if two team names are effectively the same team # Method is used when detemining match results class TeamMapping < ActiveRecord::Base validates_presence_of :team_name1,:team_name2 validates_uniqueness_of :team_name1 end
Ruby
# Recording all WinPoint transactions class PointHistory < ActiveRecord::Base after_create :add_user_invited_num belongs_to :user # Add invited friends count def add_user_invited_num if self.action == "invite friend" and self.user self.user.invitation_sent_number = self.user.invitation_sent_number.to_i + 1 ...
Ruby
class Team < ActiveRecord::Base validates_presence_of :name,:sport_id validates_uniqueness_of :name belongs_to :sport def pic pic = read_attribute :pic if pic.blank? "team_no_pic.png" else pic end end def displayed_name if self.display_name.to_s.size>0 self.display_nam...
Ruby
class NotificationPublisher < Facebooker::Rails::Publisher # Send challenge via email def challenge_email(ch) send_as :email recipients(ch.to_user_id.to_s) from(Facebooker::User.new(ch.from_user_id)) title "You have received a 13wins challenge!" fbml render :partial=>'friends_bet/email',:locals=>{:ch=>ch} e...
Ruby
class UserPrize < ActiveRecord::Base belongs_to :prize belongs_to :user end
Ruby
class User < ActiveRecord::Base has_many :bets do #Friends placing bets will include a friends_count #friend_bets = User.first.bets.friends_scope.all :order=>"friends_count DESC" (order based on time at which friends placed bet) #friend_bets.first.friends_count def friends_scope Bet.scoped( ...
Ruby
class FetchLog < ActiveRecord::Base def self.last_fetched_at fetch_log = FetchLog.first fetch_log && fetch_log.last_fetched_at end def self.update_last_fetched_at fetch_log = FetchLog.first unless fetch_log fetch_log = FetchLog.new end fetch_log.last_fetched_at = Time.now fetch_...
Ruby
class Challenge < ActiveRecord::Base belongs_to :sender, :class_name=>"User",:foreign_key=>:from_user_id belongs_to :goter,:class_name=>"User",:foreign_key=>:to_user_id belongs_to :match named_scope :placed_bet,:conditions=>["mode=?","bet_1"] named_scope :not_accept_bet,:conditions=>["mode=?","bet_0"] end
Ruby
class Bet < ActiveRecord::Base #belongs_to :user #belongs_to :match belongs_to :user,:counter_cache=>true belongs_to :match,:counter_cache=>true belongs_to :team belongs_to :winstreak validates_presence_of :user_id,:match_id,:team_id validates_uniqueness_of :match_id,:scope=>:user_id,:on=>:create name...
Ruby
class Basketball < Sport end
Ruby
class PointConfig < ActiveRecord::Base # PointConfig['your_config'] => nil or point def self.[](config_name) find_by_name(config_name).try :point end end
Ruby
require "open-uri" require "timeout" class Sport < ActiveRecord::Base belongs_to :country has_many :leagues has_many :matches has_many :teams # Get match data from handicap feed and create matches def fetch_matches #cid = leagues.collect(&:cid) * "," leagues.collect(&:cid).compact.uniq.each d...
Ruby
class Newsfeed < ActiveRecord::Base end
Ruby
class EarnWin < ActiveRecord::Base end
Ruby
# Acts like a history to record data such as winstreak, number of bets, and prize data class Winstreak < ActiveRecord::Base belongs_to :user belongs_to :prize has_many :bets,:order=>"#{Bet.table_name}.updated_at ASC" do def win scoped( :conditions=>"win = true" ) end end has_many :m...
Ruby
# This is the feed queue # Feeds are queued and stored here until sent out class UserAction < ActiveRecord::Base serialize :feed end
Ruby
class Tutorial < ActiveRecord::Base def findBigGame logger.error "Big Game!" end end
Ruby
# Bets Controller controls bet and challenge actions # In 13wins, the user may place bets on sport matches using their WinPoints and also wager WinPoints to challenge their friends class BetsController < ApplicationController # List bets in current streak def hide_howto current_user.hide_howto = true c...
Ruby
class HelpController < ApplicationController def index logger.error "--------------------" logger.error facebook_session.user.timezone logger.error "--------------------" end end
Ruby
class TeamsController < ApplicationController # List Teams def index end # Show Team info def show end end
Ruby
class LeaguesController < ApplicationController def show end def index end end
Ruby
# Point History controller controls WinPoint History # In 13wins, each user may view their WinPoint history and all +/- transactions to their WinPoints class PointHistoryController < ApplicationController # List users WinPoint increase/decrease history def index @phs = PointHistory.paginate :per_page=>15,:cond...
Ruby
#Gets all newfeeds from google rss feed and puts them into newsfeeds table #also selects newsfeds from database to show in bets [age in "news" section require 'rss' class NewsfeedsController < ApplicationController # List feeds by team_id # Save and render a couple of news def index @sid = params[:sid].to_i ...
Ruby
class CountriesController < ApplicationController def show end def index end end
Ruby
class PointConfigsController < ApplicationController def show end def index end end
Ruby
class WelcomeController < ApplicationController # show index , user first install this app will show this page def index end end
Ruby
# Sports controller controls display of sport matches # In 13wins, each tab displayed a certain sport. Each sport allows for a variety of different filters based on user interaction and match attributes class SportsController < ApplicationController # Display Sport def show flash[:notice]= params[:noice] if p...
Ruby
# Friends_Bet controller controls friend betting actions # In 13wins, the user may view bets placed by friends and also wager challenges against them using WinPoints class FriendsBetController < ApplicationController # List challenges using match id and user id def index @sid = params[:sid] metch = Match....
Ruby
class MatchesController < ApplicationController skip_before_filter :ensure_authenticated_to_facebook,:update_friends,:only=>:index def index @most_comment_matches = Match.all(:limit=>SETTINGS['rss.size'],:order=>"comment_count desc",:include=>[:home_team,:away_team]) @most_bet_matches = Match.all(:limit=>S...
Ruby
# Comments controller controls user comments/trash talk for each match # In 13wins, the user may submit comments/trash talk per each scheduled match class CommentsController < ApplicationController # List comments by match_id # Create a comment and render a new list (ajax) def index logger.error " inside comm...
Ruby
class TutorialController < ApplicationController layout 'cleanFacebook' def index logger.error " Hello Sport" #Basketball @sportBasketball = Sport.find(3) # exclude matches that have been bet on limit = 1 @basketballMatchOfTheDay = current_user.matches.friends_scope.scoped( :orde...
Ruby
# Winstreaks controller controls Player Betting History # In 13wins, the user may view their previous betting history class WinstreaksController < ApplicationController # List user bet history def history @winstreaks = current_user.winstreaks.paginate :order=>"#{Winstreak.table_name}.id desc", :include=...
Ruby
class BaseController < ApplicationController def show end def index end end
Ruby
# ADMIN: Used to view bets placed class Admin::BetsController < Admin::BaseController def index Bet.paginate :page=>params[:page] end def destroy @bet = Bet.find params[:id] @bet.destroy flash[:notice] = 'Successful deleted.' redirect_to @bet end end
Ruby
# ADMIN: Used to add/remove/edit teams class Admin::TeamsController < Admin::BaseController def index @teams = Team @teams = @teams.scoped(:conditions=>{:alias_done=>false}) if params[:no_alias] @teams = @teams.paginate :page=>params[:page] end def edit @team = Team.find params[:id] end def...
Ruby
# ADMIN: Used to add/remove/edit leagues class Admin::LeaguesController < Admin::BaseController def index @leagues = League.paginate :page=>params[:page] end def edit @league = League.find params[:id] end def update @league = League.find params[:id] if @league.update_attributes params[:leag...
Ruby
# ADMIN: Used to add/remove/edit countries class Admin::CountriesController < Admin::BaseController def index @countries = Country.paginate :page=>params[:page] end def edit @country = Country.find params[:id] end def destroy @country = Country.find params[:id] @country.destroy flash[:n...
Ruby
# ADMIN: Used to add/remove/edit sports class Admin::SportsController < Admin::BaseController def index @sports = Sport.paginate :page=>params[:page],:order=>"position asc" end def update @sport = Sport.find params[:id] if @sport.update_attributes params[:sport] flash[:notice] = 'updated succe...
Ruby
# ADMIN: Used to add/remove/edit matches class Admin::MatchesController < Admin::BaseController def index @search = Match.new_search params[:search] do |search| search.conditions.home_team.name_contains = params[:name] search.conditions.played = !!params[:played] #search.conditions.away_team.or...
Ruby
# ADMIN: Check admin rights # This is the main controller that controls all the data mining activities. # # Methods: # - getAll() # - getOne() # # Comments: # - This class is the only class in the entire app that stores the user data when the user is using the app. # - _id is the internal ID used by the app, do not...
Ruby
# ADMIN: Used to edit +/- WinPoint assignments for certain actions (such as invitations, comments, placing bets, etc...) class Admin::PointConfigsController < ApplicationController # GET /point_configs # GET /point_configs.xml def index @point_configs = PointConfig.find(:all) end # GET /point_configs/1 ...
Ruby
# ADMIN: Used to add/remove/edit prizes class Admin::PrizesController < Admin::BaseController def new @prize = Prize.new end def index @prizes = Prize.paginate :page=>params[:page] end def edit @prize = Prize.find params[:id] end def create @prize = Prize.new params[:prize] if @pri...
Ruby
# ADMIN: Used to add/remove/edit users class Admin::UsersController < Admin::BaseController def index if params[:order] == "point" @users = User.paginate :page=>params[:page],:order=>'point' else @users = User.paginate :page=>params[:page],:order=>'created_at desc' end end def destroy ...
Ruby
class Admin::ResultsController < Admin::BaseController # GET /results # GET /results.xml def index @results = Result.find(:all) end def play result = Result.find(params[:rid]) match = Match.find(params[:mid]) match.play_from_point(result.home_point,result.away_point) @notic = "match playe...
Ruby
class EarnWinsController < ApplicationController # List free wins bought and current streak level def index if count = params[:sent_count] flash[:notice] = "#{} invitation(s) sent. You earn #{count * 50} WinPoints!" end @buy_wins = BuyWin.find(:all) @level = current_user.current_winst...
Ruby
# SRpoint controller controls external rewards offered by Ad agencies # In 13wins, users may complete advertising offers or use microtransactions to earn WinPoints require 'md5' class SrpointController < ApplicationController skip_before_filter #Buy WinPoints action through Super Rewards (srpoint) def buy_point ...
Ruby
class ForumController < ApplicationController def index end end
Ruby
# Used to call all other controllers # Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base helper :all # include all helpers, all the time # See ActionController:...
Ruby
# Prize controller controls application prizes # In 13wins, the user may win a prize if they reach a 13-15 winstreak class PrizesController < ApplicationController # User selects a prize # (prize change only allowed when the streak required for the prize is less than the current streak of the user) def select ...
Ruby
# Invite controller controls friend invitations # In 13wins, the user may invite friends online (via FB chat) or offline (via FB messages) to earn WinPoints # Additional WinPoints are rewarded for successful invite installs class InvitedController < ApplicationController # Display offline invite info (# of WinPoint...
Ruby
# Users controller controls leaderboards and hide actions # In 13wins, the leaderboard displays global/friend rankings based on a variety of player stats # In 13wins, the user may hide notifications and messages class UsersController < ApplicationController # List users based on leaderboard filter requirements de...
Ruby