Skip to content
Browse files

REsolved conflicted routes.rb

  • Loading branch information...
2 parents 6590c3c + f3fc7e2 commit 031e146f64f8c9a220b66ada9a733bb1f3429b3a @paulmwatson committed Apr 29, 2009
View
89 app/controllers/badwords_controller.rb
@@ -0,0 +1,89 @@
+class BadwordsController < ApplicationController
+ layout 'base'
+ # GET /badwords
+ # GET /badwords.xml
+ def index
+ @badwords = Badword.find(:all)
+ @badword = Badword.new
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @badwords }
+ end
+ end
+
+ # GET /badwords/1
+ # GET /badwords/1.xml
+# def show
+# @badword = Badword.find(params[:id])
+
+# respond_to do |format|
+# format.html # show.html.erb
+# format.xml { render :xml => @badword }
+# end
+# end
+
+# # GET /badwords/new
+# # GET /badwords/new.xml
+# def new
+# @badword = Badword.new
+
+# respond_to do |format|
+# format.html # new.html.erb
+# format.xml { render :xml => @badword }
+# end
+# end
+
+# # GET /badwords/1/edit
+# def edit
+# @badword = Badword.find(params[:id])
+# end
+
+ # POST /badwords
+ # POST /badwords.xml
+ def create
+ @badword = Badword.new(params[:badword])
+ @badword.phrase_id = -1
+
+ respond_to do |format|
+ if @badword.save
+ flash[:notice] = 'Skipped Phrase was successfully created.'
+ format.html { redirect_to(badwords_url) }
+ format.xml { render :xml => @badword, :status => :created, :location => @badword }
+ else
+ flash[:notice] = 'Skipped Phrase creation failed'
+ format.html { redirect_to(badwords_url) }
+ format.xml { render :xml => @badword.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /badwords/1
+ # PUT /badwords/1.xml
+# def update
+# @badword = Badword.find(params[:id])
+
+# respond_to do |format|
+# if @badword.update_attributes(params[:badword])
+# flash[:notice] = 'Badword was successfully updated.'
+# format.html { redirect_to(@badword) }
+# format.xml { head :ok }
+# else
+# format.html { render :action => "edit" }
+# format.xml { render :xml => @badword.errors, :status => :unprocessable_entity }
+# end
+# end
+# end
+
+# # DELETE /badwords/1
+# # DELETE /badwords/1.xml
+# def destroy
+# @badword = Badword.find(params[:id])
+# @badword.destroy
+
+# respond_to do |format|
+# format.html { redirect_to(badwords_url) }
+# format.xml { head :ok }
+# end
+# end
+end
View
2 app/helpers/badwords_helper.rb
@@ -0,0 +1,2 @@
+module BadwordsHelper
+end
View
12 app/models/badword.rb
@@ -0,0 +1,12 @@
+class Badword < ActiveRecord::Base
+ set_table_name "blacklist"
+
+ validates_presence_of :term
+ validates_uniqueness_of :term
+
+ before_save :dont_save_phrases
+
+ def dont_save_phrases
+ return false if Phrase.find_by_title(self.term)
+ end
+end
View
13 app/views/badwords/index.html.erb
@@ -0,0 +1,13 @@
+<div class="intro info">
+ <h2>Skipped phrases</h2>
+ <%- form_for(@badword) do |f| %>
+ <%= f.text_field :term, :value => "Add a new phrase to skip" %>
+ <%= f.submit 'Submit' %>
+ <%- end %>
+We currently ignore the following phrases:
+</div>
+<ul>
+ <% for badword in @badwords %>
+ <li><%= badword.term %></li>
+ <% end %>
+</ul>
View
2 app/views/layouts/base.html.erb
@@ -44,4 +44,4 @@
<noscript><p><img alt="Clicky" width="1" height="1" src="http://static.getclicky.com/81343-db10.gif" /></p></noscript>
<%- end -%>
</body>
-</html>
+</html>
View
3 config/routes.rb
@@ -1,7 +1,10 @@
ActionController::Routing::Routes.draw do |map|
+ map.resources :badwords
+
map.connect '/removed_list/', :controller => 'mentions', :action => 'removed_list'
map.connect '/mention/remove/:mention_id', :controller => 'mentions', :action => 'remove'
map.connect '/mention/unremove/:mention_id', :controller => 'mentions', :action => 'unremove'
+
map.connect '/cities/check/', :controller => 'cities', :action => 'check'
map.connect '/cities/create/', :controller => 'cities', :action => 'create'
map.connect '/cities/add/', :controller => 'cities', :action => 'new'
View
43 lib/tasks/sickcity.rake
@@ -0,0 +1,43 @@
+require 'curb'
+require 'nokogiri'
+
+namespace "sickcity" do
+
+ desc %{Clean noisy tweets}
+ task :clean_noisy_tweets => :environment do |t|
+ count = 0
+ Mention.find(:all, :conditions => 'message is NOT NULL').each do |m|
+ destroy = false
+ # Commenting out tweet-fetching code for now
+ #puts m
+ #tweet_id = m.link.split('/').last
+ #twitter_url = "http://twitter.com/statuses/show/#{tweet_id}.xml"
+ #puts twitter_url
+ #doc = Curl::Easy.perform(twitter_url)
+ #parsed_doc = Nokogiri.parse(doc.body_str)
+ #puts parsed_doc
+
+ #text = parsed_doc.search("text").inner_html
+ text = m.message
+ if text =~ /^RT\s/ || text =~ /http/ || text =~ /^\@/ || (text =~ /\s\#/ && !(text =~ /\s\#sickcity/))
+ destroy = true
+ end
+
+ if !destroy
+ Badword.all.each do |badword|
+ if text =~ /#{Regexp.escape(badword.term)}/
+ destroy = true
+ end
+ break if destroy == true
+ end
+ end
+
+ if destroy
+ count += 1
+ puts "Deleting: #{m.message}"
+ m.destroy
+ end
+ end
+ puts "Deleted Count: #{count}"
+ end
+end
View
4 public/stylesheets/main.css
@@ -362,7 +362,7 @@ h2
input[type='text']
{
- width: 30%;
+ width: 70%;
margin: 15px 0;
padding: 5px;
font-size: larger;
@@ -387,4 +387,4 @@ p.notice
margin-top: 10px;
padding: 5px;
-moz-border-radius: 3px;
-}
+}
View
54 public/stylesheets/scaffold.css
@@ -0,0 +1,54 @@
+body { background-color: #fff; color: #333; }
+
+body, p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+}
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px;
+}
+
+a { color: #000; }
+a:visited { color: #666; }
+a:hover { color: #fff; background-color:#000; }
+
+.fieldWithErrors {
+ padding: 2px;
+ background-color: red;
+ display: table;
+}
+
+#errorExplanation {
+ width: 400px;
+ border: 2px solid red;
+ padding: 7px;
+ padding-bottom: 12px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+}
+
+#errorExplanation h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ background-color: #c00;
+ color: #fff;
+}
+
+#errorExplanation p {
+ color: #333;
+ margin-bottom: 0;
+ padding: 5px;
+}
+
+#errorExplanation ul li {
+ font-size: 12px;
+ list-style: square;
+}
+
View
7 test/fixtures/badwords.yml
@@ -0,0 +1,7 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+# one:
+# column: value
+#
+# two:
+# column: value
View
45 test/functional/badwords_controller_test.rb
@@ -0,0 +1,45 @@
+require 'test_helper'
+
+class BadwordsControllerTest < ActionController::TestCase
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:badwords)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create badword" do
+ assert_difference('Badword.count') do
+ post :create, :badword => { }
+ end
+
+ assert_redirected_to badword_path(assigns(:badword))
+ end
+
+ test "should show badword" do
+ get :show, :id => badwords(:one).id
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, :id => badwords(:one).id
+ assert_response :success
+ end
+
+ test "should update badword" do
+ put :update, :id => badwords(:one).id, :badword => { }
+ assert_redirected_to badword_path(assigns(:badword))
+ end
+
+ test "should destroy badword" do
+ assert_difference('Badword.count', -1) do
+ delete :destroy, :id => badwords(:one).id
+ end
+
+ assert_redirected_to badwords_path
+ end
+end
View
8 test/unit/badword_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class BadwordTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end

0 comments on commit 031e146

Please sign in to comment.
Something went wrong with that request. Please try again.