Skip to content

Commit

Permalink
added featured pages to exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
Pete Skomoroch committed Jun 21, 2009
1 parent d48d0a8 commit 9bdecf6
Show file tree
Hide file tree
Showing 19 changed files with 206 additions and 284 deletions.
2 changes: 0 additions & 2 deletions app/controllers/application_controller.rb
Expand Up @@ -7,8 +7,6 @@ class ApplicationController < ActionController::Base
protect_from_forgery # See ActionController::RequestForgeryProtection for details
Rubaidh::GoogleAnalytics.tracker_id = APP_CONFIG['tracker_id']



# Scrub sensitive parameters from your log
# filter_parameter_logging :password

Expand Down
61 changes: 0 additions & 61 deletions app/controllers/daily_timelines_controller.rb
Expand Up @@ -23,65 +23,4 @@ def show
end
end

# # GET /daily_timelines/new
# # GET /daily_timelines/new.xml
# def new
# @daily_timeline = DailyTimeline.new
#
# respond_to do |format|
# format.html # new.html.erb
# format.xml { render :xml => @daily_timeline }
# end
# end
#
# # GET /daily_timelines/1/edit
# def edit
# @daily_timeline = DailyTimeline.find(params[:id])
# end
#
# # POST /daily_timelines
# # POST /daily_timelines.xml
# def create
# @daily_timeline = DailyTimeline.new(params[:daily_timeline])
#
# respond_to do |format|
# if @daily_timeline.save
# flash[:notice] = 'DailyTimeline was successfully created.'
# format.html { redirect_to(@daily_timeline) }
# format.xml { render :xml => @daily_timeline, :status => :created, :location => @daily_timeline }
# else
# format.html { render :action => "new" }
# format.xml { render :xml => @daily_timeline.errors, :status => :unprocessable_entity }
# end
# end
# end
#
# # PUT /daily_timelines/1
# # PUT /daily_timelines/1.xml
# def update
# @daily_timeline = DailyTimeline.find(params[:id])
#
# respond_to do |format|
# if @daily_timeline.update_attributes(params[:daily_timeline])
# flash[:notice] = 'DailyTimeline was successfully updated.'
# format.html { redirect_to(@daily_timeline) }
# format.xml { head :ok }
# else
# format.html { render :action => "edit" }
# format.xml { render :xml => @daily_timeline.errors, :status => :unprocessable_entity }
# end
# end
# end
#
# # DELETE /daily_timelines/1
# # DELETE /daily_timelines/1.xml
# def destroy
# @daily_timeline = DailyTimeline.find(params[:id])
# @daily_timeline.destroy
#
# respond_to do |format|
# format.html { redirect_to(daily_timelines_url) }
# format.xml { head :ok }
# end
# end
end
61 changes: 0 additions & 61 deletions app/controllers/daily_trends_controller.rb
Expand Up @@ -30,65 +30,4 @@ def show
end
end

# # GET /daily_trends/new
# # GET /daily_trends/new.xml
# def new
# @daily_trend = DailyTrend.new
#
# respond_to do |format|
# format.html # new.html.erb
# format.xml { render :xml => @daily_trend }
# end
# end
#
# # GET /daily_trends/1/edit
# def edit
# @daily_trend = DailyTrend.find(params[:id])
# end
#
# # POST /daily_trends
# # POST /daily_trends.xml
# def create
# @daily_trend = DailyTrend.new(params[:daily_trend])
#
# respond_to do |format|
# if @daily_trend.save
# flash[:notice] = 'DailyTrend was successfully created.'
# format.html { redirect_to(@daily_trend) }
# format.xml { render :xml => @daily_trend, :status => :created, :location => @daily_trend }
# else
# format.html { render :action => "new" }
# format.xml { render :xml => @daily_trend.errors, :status => :unprocessable_entity }
# end
# end
# end
#
# # PUT /daily_trends/1
# # PUT /daily_trends/1.xml
# def update
# @daily_trend = DailyTrend.find(params[:id])
#
# respond_to do |format|
# if @daily_trend.update_attributes(params[:daily_trend])
# flash[:notice] = 'DailyTrend was successfully updated.'
# format.html { redirect_to(@daily_trend) }
# format.xml { head :ok }
# else
# format.html { render :action => "edit" }
# format.xml { render :xml => @daily_trend.errors, :status => :unprocessable_entity }
# end
# end
# end
#
# # DELETE /daily_trends/1
# # DELETE /daily_trends/1.xml
# def destroy
# @daily_trend = DailyTrend.find(params[:id])
# @daily_trend.destroy
#
# respond_to do |format|
# format.html { redirect_to(daily_trends_url) }
# format.xml { head :ok }
# end
# end
end
95 changes: 2 additions & 93 deletions app/controllers/pages_controller.rb
Expand Up @@ -7,16 +7,6 @@ class PagesController < ApplicationController
caches_page :show
caches_page :csv


# def to_param
# "#{self.id}-#{self.title.parameterize}"
# end

# def to_param
# require 'unicode'
# "#{id}"+Unicode::normalize_KD("-"+title+"-").downcase.gsub(/[^a-z0-9\s_-]+/,'').gsub(/[\s_-]+/,'-')[0..-2]
# end


def auto_complete_for_search_query
# look for autosuggest results in memcached
Expand All @@ -30,27 +20,12 @@ def index
if params[:search]
@pages = Page.title_like(params["search"]["query"]).paginate(:page => params[:page], :order => 'monthly_trend DESC', :per_page => APP_CONFIG['articles_per_page'])
else
@pages = Page.paginate(:page => params[:page], :conditions => ["pages.id NOT IN (?)", APP_CONFIG['blacklist']], :order => 'monthly_trend DESC', :per_page => APP_CONFIG['articles_per_page'])
@pages = Page.paginate(:page => params[:page], :conditions => ["pages.id NOT IN (?) and page_id NOT IN (select page_id from featured_pages)", APP_CONFIG['blacklist']], :order => 'monthly_trend DESC', :per_page => APP_CONFIG['articles_per_page'])
end

# TODO: News @page needs to tie to this if selection random article...
# # random mover
# @page = Page.find(:all,:limit => 20, :order => 'monthly_trend DESC', :conditions => ["id NOT IN (?)", APP_CONFIG['blacklist']] ).rand

# # Top Mover
# @page = Page.find(:first, :order => 'monthly_trend DESC', :conditions => ["id NOT IN (?)", APP_CONFIG['blacklist']] )

# random rising, rotates
@page = DailyTrend.find(:all, :limit => 20 , :order => 'trend DESC', :conditions => ["page_id NOT IN (?)", APP_CONFIG['blacklist']] ).rand.page

# # fastest rising
# @page = DailyTrend.find(:first, :order => 'trend DESC', :conditions => ["page_id NOT IN (?)", APP_CONFIG['blacklist']] ).page

# @rising = DailyTrend.find(:all, :limit => 20, :order => 'trend DESC')
# @dropping = DailyTrend.find(:all, :limit => 6, :order => 'trend ASC')




unless params[:page]
params[:page]='1'
end
Expand All @@ -60,9 +35,6 @@ def index
format.xml { render :xml => @pages }
format.atom { render :layout => false}
end



end

# GET /pages/1
Expand All @@ -88,68 +60,5 @@ def csv
:disposition => 'attachment'

end



# # GET /pages/new
# # GET /pages/new.xml
# def new
# @page = Page.new
#
# respond_to do |format|
# format.html # new.html.erb
# format.xml { render :xml => @page }
# end
# end
#
# # GET /pages/1/edit
# def edit
# @page = Page.find(params[:id])
# end
#
# # POST /pages
# # POST /pages.xml
# def create
# @page = Page.new(params[:page])
#
# respond_to do |format|
# if @page.save
# flash[:notice] = 'Page was successfully created.'
# format.html { redirect_to(@page) }
# format.xml { render :xml => @page, :status => :created, :location => @page }
# else
# format.html { render :action => "new" }
# format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
# end
# end
# end
#
# # PUT /pages/1
# # PUT /pages/1.xml
# def update
# @page = Page.find(params[:id])
#
# respond_to do |format|
# if @page.update_attributes(params[:page])
# flash[:notice] = 'Page was successfully updated.'
# format.html { redirect_to(@page) }
# format.xml { head :ok }
# else
# format.html { render :action => "edit" }
# format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
# end
# end
# end
#
# # DELETE /pages/1
# # DELETE /pages/1.xml
# def destroy
# @page = Page.find(params[:id])
# @page.destroy
#
# respond_to do |format|
# format.html { redirect_to(pages_url) }
# format.xml { head :ok }
# end
# end
end
61 changes: 0 additions & 61 deletions app/controllers/weekly_trends_controller.rb
Expand Up @@ -21,65 +21,4 @@ def show
end
end

# # GET /weekly_trends/new
# # GET /weekly_trends/new.xml
# def new
# @weekly_trend = WeeklyTrend.new
#
# respond_to do |format|
# format.html # new.html.erb
# format.xml { render :xml => @weekly_trend }
# end
# end
#
# # GET /weekly_trends/1/edit
# def edit
# @weekly_trend = WeeklyTrend.find(params[:id])
# end
#
# # POST /weekly_trends
# # POST /weekly_trends.xml
# def create
# @weekly_trend = WeeklyTrend.new(params[:weekly_trend])
#
# respond_to do |format|
# if @weekly_trend.save
# flash[:notice] = 'WeeklyTrend was successfully created.'
# format.html { redirect_to(@weekly_trend) }
# format.xml { render :xml => @weekly_trend, :status => :created, :location => @weekly_trend }
# else
# format.html { render :action => "new" }
# format.xml { render :xml => @weekly_trend.errors, :status => :unprocessable_entity }
# end
# end
# end
#
# # PUT /weekly_trends/1
# # PUT /weekly_trends/1.xml
# def update
# @weekly_trend = WeeklyTrend.find(params[:id])
#
# respond_to do |format|
# if @weekly_trend.update_attributes(params[:weekly_trend])
# flash[:notice] = 'WeeklyTrend was successfully updated.'
# format.html { redirect_to(@weekly_trend) }
# format.xml { head :ok }
# else
# format.html { render :action => "edit" }
# format.xml { render :xml => @weekly_trend.errors, :status => :unprocessable_entity }
# end
# end
# end
#
# # DELETE /weekly_trends/1
# # DELETE /weekly_trends/1.xml
# def destroy
# @weekly_trend = WeeklyTrend.find(params[:id])
# @weekly_trend.destroy
#
# respond_to do |format|
# format.html { redirect_to(weekly_trends_url) }
# format.xml { head :ok }
# end
# end
end
3 changes: 3 additions & 0 deletions app/models/featured_page.rb
@@ -0,0 +1,3 @@
class FeaturedPage < ActiveRecord::Base
belongs_to :page
end
2 changes: 1 addition & 1 deletion app/models/page.rb
Expand Up @@ -4,7 +4,7 @@ class Page < ActiveRecord::Base
has_one :person
has_one :company
has_one :weekly_trend
named_scope :title_like, lambda { |query| { :conditions => ['title like ? and id NOT IN (?)', "#{query}%", APP_CONFIG['blacklist']], :order => '`monthly_trend` DESC', :limit => 14 } }
named_scope :title_like, lambda { |query| { :conditions => ['title like ? and id NOT IN (?) and page_id NOT IN (select page_id from featured_pages)', "#{query}%", APP_CONFIG['blacklist']], :order => '`monthly_trend` DESC', :limit => 14 } }
named_scope :full_title_like, lambda { |query| { :conditions => ['title like ? and id NOT IN (?)', "%#{query}%", APP_CONFIG['blacklist']], :order => '`monthly_trend` DESC', :limit => 14 } }


Expand Down
2 changes: 1 addition & 1 deletion app/views/pages/index.html.erb
Expand Up @@ -71,7 +71,7 @@
<th>Trend</th>
<th>Article</th>
</tr>
<% DailyTrend.find(:all, :limit => 20,:conditions => ["page_id NOT IN (?)", APP_CONFIG['blacklist']], :order => 'trend DESC').each_with_index do |rising, index| %>
<% DailyTrend.find(:all, :limit => 20,:conditions => ["page_id NOT IN (?) and page_id NOT IN (select page_id from featured_pages)", APP_CONFIG['blacklist']], :order => 'trend DESC').each_with_index do |rising, index| %>
<tr>
<td><%= link_to image_tag(rising.page.sparkline('888888', 30).to_url, :alt => 'Rising Trend data for ' + rising.page.title), rising.page %></td>
<td><%= link_to truncate(rising.page.title,20), rising.page, :class => "title" %></td>
Expand Down
2 changes: 1 addition & 1 deletion config/deploy.rb.sample
Expand Up @@ -56,7 +56,7 @@ set :ec2onrails_config, {

# Any extra Ubuntu packages to install if desired
# If you don't want to install extra packages then remove this.
:packages => ["logwatch", "imagemagick"],
:packages => ["logwatch", "imagemagick", "s3cmd", "python-beautifulsoup", "python-mysqldb"],

# Any extra RubyGems to install if desired: can be "gemname" or if a
# particular version is desired "gemname -v 1.0.1"
Expand Down
13 changes: 13 additions & 0 deletions db/migrate/20090621034525_create_featured_pages.rb
@@ -0,0 +1,13 @@
class CreateFeaturedPages < ActiveRecord::Migration
def self.up
create_table :featured_pages do |t|
t.references :page

t.timestamps
end
end

def self.down
drop_table :featured_pages
end
end
8 changes: 7 additions & 1 deletion db/schema.rb
Expand Up @@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20090619212730) do
ActiveRecord::Schema.define(:version => 20090621034525) do

create_table "companies", :force => true do |t|
t.integer "page_id"
Expand Down Expand Up @@ -38,6 +38,12 @@

add_index "daily_trends", ["page_id", "trend"], :name => "daily_trends_index"

create_table "featured_pages", :force => true do |t|
t.integer "page_id"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "new_daily_timelines", :force => true do |t|
t.integer "page_id"
t.text "dates"
Expand Down

0 comments on commit 9bdecf6

Please sign in to comment.