Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

Commit

Permalink
disabling updates/friending unless in production mode. making templat…
Browse files Browse the repository at this point in the history
…able, adding in a few special options for templating. moving default into /default folder. updating README.
  • Loading branch information
gleuch committed Oct 25, 2009
1 parent 7c354a7 commit b645c12
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 18 deletions.
20 changes: 16 additions & 4 deletions README
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,18 +32,30 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




LICENSE
- You may use this program if you agree to the following:
- You are a non-commercial entity focused on using this for good-natured purposes only.
- You must leave the header comment and footer credit intact.
*** To change the group name in the footer, edit the group_name field in your settings. ***

INSTALLATION
- Clone this repo (git clone git://github.com/gleuch/retweet-fucker.git) into a web-accessible directory.
- Rename settings.yml.default to settings.yml
*** Change settings as needed. Be sure to add your Twitter OAuth key and secret strings! ***
- Run.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

KNOWN BUGS KNOWN BUGS
- None, at the moment. - None, at the moment.



TODO TODO
- None, at the moment. - None, at the moment.



NOTES NOTES
- With DataMapper > 0.10.0, you may get a NoMethodError on 'find_by_sql'. To fix, install the dm-ar-finders gem. - With DataMapper > 0.10.0, you may get a NoMethodError on 'find_by_sql'. To fix, install the dm-ar-finders gem.



THANKS THANKS
Props to Jamie Wilkinson (http://www.jamiedubs.com) for guidance, and Patrick Ewing (http://project.ioni.st/) for Props to Jamie Wilkinson (http://www.jamiedubs.com) for guidance, and Patrick Ewing (http://project.ioni.st/) for
additional followers idea. And always, the F.A.T. Lab gang (http://www.fffff.at) additional followers idea. And always, the F.A.T. Lab crew (http://www.fffff.at)!
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
64 changes: 55 additions & 9 deletions retweet.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
DataMapper.auto_upgrade! DataMapper.auto_upgrade!


set :sessions, true set :sessions, true
set :views, File.dirname(__FILE__) + '/views/'+ configatron.template_name
set :public, File.dirname(__FILE__) + '/public/'+ configatron.template_name
end end




helpers do helpers do
def dev?; (Sinatra::Application.environment.to_s != 'production'); end

def twitter_connect(user={}) def twitter_connect(user={})
@twitter_client = TwitterOAuth::Client.new(:consumer_key => configatron.twitter_oauth_token, :consumer_secret => configatron.twitter_oauth_secret, :token => (!user.blank? ? user.oauth_token : nil), :secret => (!user.blank? ? user.oauth_secret : nil)) rescue nil @twitter_client = TwitterOAuth::Client.new(:consumer_key => configatron.twitter_oauth_token, :consumer_secret => configatron.twitter_oauth_secret, :token => (!user.blank? ? user.oauth_token : nil), :secret => (!user.blank? ? user.oauth_secret : nil)) rescue nil
end end
Expand Down Expand Up @@ -53,7 +57,7 @@ def launch_retweet_hell(msg=false)
retweet = "RT: @#{info['screen_name']}: %s #{configatron.twitter_hashtag}" retweet = "RT: @#{info['screen_name']}: %s #{configatron.twitter_hashtag}"
retweet = retweet.gsub(/\%s/, (info['status']['text'])[0, (142-retweet.length) ]) retweet = retweet.gsub(/\%s/, (info['status']['text'])[0, (142-retweet.length) ])


@tweet = Tweet.create(:account_id => user.account_id, :tweet_id => info['status']['id'], :tweet => info['status']['text'], :retweet => retweet, :sent_at => Time.now) rescue nil @tweet = Tweet.create(:account_id => user.account_id, :screen_name => user.screen_name, :tweet_id => info['status']['id'], :tweet => info['status']['text'], :retweet => retweet, :sent_at => Time.now) rescue nil
break break
end end
else else
Expand All @@ -74,15 +78,15 @@ def launch_retweet_hell(msg=false)


# Use Twitter Retweet API if not forced. # Use Twitter Retweet API if not forced.
if msg.blank? && configatron.use_retweet_api if msg.blank? && configatron.use_retweet_api
@twitter_client.retweet(@tweet.tweet_id) @twitter_client.retweet(@tweet.tweet_id) unless dev?
# Retweet through standard method. # Retweet through standard method.
else else
@twitter_client.update(@tweet.retweet) @twitter_client.update(@tweet.retweet) unless dev?
end end


# Also auto-follow retweeted user (if not forced). (idea by Patrick Ewing -- http://github.com/hoverbird) # Also auto-follow retweeted user (if not forced). (idea by Patrick Ewing -- http://github.com/hoverbird)
if @tweet.account_id > 0 && configatron.allow_user_follow && !@twitter_client.exists?(user.account_id, @tweet.account_id) if @tweet.account_id > 0 && configatron.allow_user_follow && !@twitter_client.exists?(user.account_id, @tweet.account_id)
@twitter_client.friend(@tweet.account_id) @twitter_client.friend(@tweet.account_id) unless dev?
end end


else else
Expand All @@ -96,8 +100,48 @@ def launch_retweet_hell(msg=false)


haml (@error.blank? ? :run : :fail) haml (@error.blank? ? :run : :fail)
end end

def partial(name, options = {})
item_name, counter_name = name.to_sym, "#{name}_counter".to_sym
if collection = options.delete(:collection)
collection.enum_for(:each_with_index).collect{|item, index| partial(name, options.merge(:locals => { item_name => item, counter_name => index + 1 }))}.join
elsif object = options.delete(:object)
partial(name, options.merge(:locals => {item_name => object, counter_name => nil}))
else
haml "_#{name}".to_sym, options.merge(:layout => false)
end
end

# Modified from Rails ActiveSupport::CoreExtensions::Array::Grouping
def in_groups_of(item, number, fill_with = nil)
if fill_with == false
collection = item
else
padding = (number - item.size % number) % number
collection = item.dup.concat([fill_with] * padding)
end

if block_given?
collection.each_slice(number) { |slice| yield(slice) }
else
returning [] do |groups|
collection.each_slice(number) { |group| groups << group }
end
end
end


def user_profile_url(screen_name, at=true)
"<a href='http://www.twitter.com/#{screen_name || ''}' target='_blank'>#{at ? '@' : ''}#{screen_name || '???'}</a>"
end

end #helpers end #helpers


before do
@tweet = Tweet.first(:order => [:sent_at.desc])
@latest_users = User.all(:limit => 8, :order => [:created_at.desc])
end



# Homepage # Homepage
get '/' do get '/' do
Expand Down Expand Up @@ -158,7 +202,7 @@ def launch_retweet_hell(msg=false)


# Follow the creators (or whomever else) # Follow the creators (or whomever else)
configatron.twitter_screen_name.gsub(/\s/, '').split(',').each do |name| configatron.twitter_screen_name.gsub(/\s/, '').split(',').each do |name|
@twitter_client.friend(name) @twitter_client.friend(name) unless dev?
end end
rescue rescue
twitter_fail('An error has occured while trying to post a tweet to Twitter. Please try again.') twitter_fail('An error has occured while trying to post a tweet to Twitter. Please try again.')
Expand All @@ -172,20 +216,22 @@ def launch_retweet_hell(msg=false)
# Launch retweet hell... # Launch retweet hell...
get '/run/*' do get '/run/*' do
@title = 'Launch Retweet Hell!' @title = 'Launch Retweet Hell!'
launch = true launch = params[:splat].to_s == configatron.secret_launch_code.to_s

@error = '<strong>WTF!?</strong> You ain\'t got access to this. Fuck off.' unless launch



# Randomized retweet hell if running a cron job (recommended to use '*/1 * * * * curl -s http://example.com/run/----') # Randomized retweet hell if running a cron job (recommended to use '*/1 * * * * curl -s http://example.com/run/----')
if configatron.randomize_hell && configatron.randomize_hell_freq.is_a?(Integer) if launch && configatron.randomize_hell && configatron.randomize_hell_freq.is_a?(Integer)
unless rand(configatron.randomize_hell_freq).round == 1 unless rand(configatron.randomize_hell_freq).round == 1
@error = "Waiting patiently for a truely randomized hell." @error = "Waiting patiently for a truely randomized hell."
launch = false launch = false
end end
end end


if launch && params[:splat].to_s == configatron.secret_launch_code.to_s if launch
launch_retweet_hell launch_retweet_hell
else else
@error ||= '<strong>WTF!?</strong> You ain\'t got access to this. Fuck off.'
haml :fail haml :fail
end end
end end
Expand Down
6 changes: 5 additions & 1 deletion settings.yml.default
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,9 @@
development: &local development: &local
site_name: Retweet Game site_name: 'Retweet Game'
group_name: 'Your NON-COMMERCIAL Organization Name' # Seriously, this is for non-commercial use only!
group_website: http://www.fffff.at

template_name: default


enable_retweet_game: true enable_retweet_game: true


Expand Down
1 change: 1 addition & 0 deletions tweet.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Tweet


property :id, Serial property :id, Serial
property :account_id, Integer property :account_id, Integer
property :screen_name, String
property :tweet_id, String property :tweet_id, String
property :tweet, Text property :tweet, Text
property :retweet, Text property :retweet, Text
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions views/layout.haml → views/default/layout.haml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


%head %head
%title= (!@title.blank? ? "#{@title} / " : '') + "#{configatron.site_name} / a F.A.T. Lab Project" %title= (!@title.blank? ? "#{@title} / " : '') + "#{configatron.site_name} / a #{configatron.group_name} Project"
%meta{:"http-equiv" => 'Content-Type', :content => 'text/html; charset=utf-8'} %meta{:"http-equiv" => 'Content-Type', :content => 'text/html; charset=utf-8'}
%meta{:name => 'keywords', :content => "#{configatron.site_name}, Twitter, retweet, API, Greg Leuch, F.A.T. Lab, art, code"} %meta{:name => 'keywords', :content => "#{configatron.site_name}, Twitter, retweet, API, Greg Leuch, F.A.T. Lab, fffff.at, art, code"}
%meta{:name => 'description', :content => "Expand your Twitter reach through mass retweets #{configatron.twitter_allow_user_follow ? 'and followings' : ''} by joining #{configatron.site_name}."} %meta{:name => 'description', :content => "Expand your Twitter reach through mass retweets #{configatron.twitter_allow_user_follow ? 'and followings' : ''} by joining #{configatron.site_name}."}
%link{:rel=>'icon', :href=>'/favicon.ico'} %link{:rel=>'icon', :href=>'/favicon.ico'}
%link{:href=>'/stylesheets/screen.css', :media=>'all', :rel =>'stylesheet', :type=>'text/css'} %link{:href=>'/stylesheets/screen.css', :media=>'all', :rel =>'stylesheet', :type=>'text/css'}
Expand All @@ -31,7 +31,7 @@
#container #container
#header<> #header<>
%h1 %h1
%a{:href => '/'} The Twitter #{configatron.site_name} %a{:href => '/'}= configatron.site_name


#content_area #content_area
#content_bubble #content_bubble
Expand All @@ -44,7 +44,7 @@
- if configatron.use_donation - if configatron.use_donation
#donation_box= configatron.donation_code #donation_box= configatron.donation_code


#footer a <a class="bold" href="http://www.fffff.at">F.A.T. Lab production</a> by <a class="bold" href="http://gleuch.com">Greg Leuch</a>. no rights reserved. <a href="http://github.com/gleuch/retweet-fucker">grab the code</a> #footer a <a class="bold" href="#{configatron.group_website}">#{configatron.group_name} production</a> by <a class="bold" href="http://gleuch.com">Greg Leuch</a>. no rights reserved. <a href="http://github.com/gleuch/retweet-fucker">grab the code</a>


- if configatron.use_g_analytics == true && !configatron.g_analytics_code.blank? && configatron.g_analytics_code != 'UA-#######-##' - if configatron.use_g_analytics == true && !configatron.g_analytics_code.blank? && configatron.g_analytics_code != 'UA-#######-##'
%script{:type => "text/javascript"} var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); %script{:type => "text/javascript"} var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit b645c12

Please sign in to comment.