Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

disabling updates/friending unless in production mode. making templat…

…able, adding in a few special options for templating. moving default into /default folder. updating README.
  • Loading branch information...
commit b645c120c5a8bef35e07401859d18dde1bcd2094 1 parent 7c354a7
@gleuch authored
View
20 README
@@ -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
- None, at the moment.
-
TODO
- None, at the moment.
-
NOTES
- With DataMapper > 0.10.0, you may get a NoMethodError on 'find_by_sql'. To fix, install the dm-ar-finders gem.
-
THANKS
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)!
View
0  public/favicon.ico → public/default/favicon.ico
File renamed without changes
View
0  public/images/bubble_bottom.png → public/default/images/bubble_bottom.png
File renamed without changes
View
0  public/images/bubble_pointer.png → public/default/images/bubble_pointer.png
File renamed without changes
View
0  public/images/bubble_repeat.png → public/default/images/bubble_repeat.png
File renamed without changes
View
0  public/images/bubble_top.png → public/default/images/bubble_top.png
File renamed without changes
View
0  public/images/rt_bird.png → public/default/images/rt_bird.png
File renamed without changes
View
0  public/robots.txt → public/default/robots.txt
File renamed without changes
View
0  public/stylesheets/screen.css → public/default/stylesheets/screen.css
File renamed without changes
View
64 retweet.rb
@@ -14,10 +14,14 @@
DataMapper.auto_upgrade!
set :sessions, true
+ set :views, File.dirname(__FILE__) + '/views/'+ configatron.template_name
+ set :public, File.dirname(__FILE__) + '/public/'+ configatron.template_name
end
helpers do
+ def dev?; (Sinatra::Application.environment.to_s != 'production'); end
+
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
end
@@ -53,7 +57,7 @@ def launch_retweet_hell(msg=false)
retweet = "RT: @#{info['screen_name']}: %s #{configatron.twitter_hashtag}"
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
end
else
@@ -74,15 +78,15 @@ def launch_retweet_hell(msg=false)
# Use Twitter Retweet API if not forced.
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.
else
- @twitter_client.update(@tweet.retweet)
+ @twitter_client.update(@tweet.retweet) unless dev?
end
# 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)
- @twitter_client.friend(@tweet.account_id)
+ @twitter_client.friend(@tweet.account_id) unless dev?
end
else
@@ -96,8 +100,48 @@ def launch_retweet_hell(msg=false)
haml (@error.blank? ? :run : :fail)
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
+before do
+ @tweet = Tweet.first(:order => [:sent_at.desc])
+ @latest_users = User.all(:limit => 8, :order => [:created_at.desc])
+end
+
# Homepage
get '/' do
@@ -158,7 +202,7 @@ def launch_retweet_hell(msg=false)
# Follow the creators (or whomever else)
configatron.twitter_screen_name.gsub(/\s/, '').split(',').each do |name|
- @twitter_client.friend(name)
+ @twitter_client.friend(name) unless dev?
end
rescue
twitter_fail('An error has occured while trying to post a tweet to Twitter. Please try again.')
@@ -172,20 +216,22 @@ def launch_retweet_hell(msg=false)
# Launch retweet hell...
get '/run/*' do
@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/----')
- 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
@error = "Waiting patiently for a truely randomized hell."
launch = false
end
end
- if launch && params[:splat].to_s == configatron.secret_launch_code.to_s
+ if launch
launch_retweet_hell
else
- @error ||= '<strong>WTF!?</strong> You ain\'t got access to this. Fuck off.'
haml :fail
end
end
View
6 settings.yml.default
@@ -1,5 +1,9 @@
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
View
1  tweet.rb
@@ -3,6 +3,7 @@ class Tweet
property :id, Serial
property :account_id, Integer
+ property :screen_name, String
property :tweet_id, String
property :tweet, Text
property :retweet, Text
View
0  views/fail.haml → views/default/fail.haml
File renamed without changes
View
0  views/home.haml → views/default/home.haml
File renamed without changes
View
8 views/layout.haml → views/default/layout.haml
@@ -20,9 +20,9 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%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{: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}."}
%link{:rel=>'icon', :href=>'/favicon.ico'}
%link{:href=>'/stylesheets/screen.css', :media=>'all', :rel =>'stylesheet', :type=>'text/css'}
@@ -31,7 +31,7 @@
#container
#header<>
%h1
- %a{:href => '/'} The Twitter #{configatron.site_name}
+ %a{:href => '/'}= configatron.site_name
#content_area
#content_bubble
@@ -44,7 +44,7 @@
- if configatron.use_donation
#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-#######-##'
%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"));
View
0  views/run.haml → views/default/run.haml
File renamed without changes
View
0  views/thanks.haml → views/default/thanks.haml
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.