Permalink
Browse files

customize block list with a .rc file

  • Loading branch information...
1 parent 95665a9 commit 3cc26eb919cd08b4f88b262a221384c6f5a87c29 Dev Purkayastha committed Nov 4, 2009
Showing with 24 additions and 3 deletions.
  1. +3 −1 README.textile
  2. +18 −2 b-productive.rb
  3. +3 −0 productity_ftwrc.sample
View
@@ -12,11 +12,13 @@ and fire off the productivity enhancing server:
sudo ruby productivity_ftw.rb
</pre>
+(you'll probably need to install the bjeanes-ghost gem first)
+
note that you *have to use sudo* cause you are taking over port 80, not sure if it's required on windows also.
h2. Adding more hosts to block
-open the <code>b-productive.rb</code> file and add to the <code>BLOCK_LIST</code> host array, a better solution is welcome, i am just lazy.
+To create your own blocklist, create a <tt>~/.productivity_ftwrc</tt> file in your home directory. See <tt>productivity_ftwrc.sample</tt> for an example of the right format.
h2. "Thank you"s
View
@@ -4,13 +4,29 @@ class Productivity
require 'rubygems'
begin
- gem 'ghost'
+ gem 'bjeanes-ghost'
require 'ghost'
rescue Gem::LoadError
puts "you need to install the ghost gem from http://github.com/bjeanes/ghost"
end
+
+ # Format of .productivity_ftwrc (saved in home dir):
+ # - Each line is a space-separated list of one or more words.
+ # - First word is the base of the subdomain.
+ # - If not qualified with .com/.net/.org, assumed to be .com
+ # - The www. prefix is assumed to be blocked.
+ # - subsequent words are subdomains to block.
+ productivity_ftwrc = "#{ENV['HOME']}/.productivity_ftwrc"
+ if File.exists?(productivity_ftwrc)
+ BLOCK_LIST = File.read(productivity_ftwrc).split("\n").map do |domain, subdomains|
+ domain += ".com" unless domain =~ /\.(org|net|com)/
+ subdomains ||= []
+ ["#{domain}", "www.#{domain}"] + subdomains.map{|subdomain| "#{subdomain}.#{domain}"}
+ end.flatten
+ else
+ BLOCK_LIST = ["facebook.com", "www.facebook.com", "www.twitter.com", "api.twitter.com", "twitter.com"]
+ end
- BLOCK_LIST = ["facebook.com", "www.facebook.com", "www.twitter.com", "api.twitter.com", "twitter.com"]
ALLOWED_ACTIONS = ["start", "stop"]
def self.start
View
@@ -0,0 +1,3 @@
+twitter api search
+facebook.com
+mls-rumors.net

0 comments on commit 3cc26eb

Please sign in to comment.