Skip to content

Commit

Permalink
Merge branch 'master' of [email protected]:engineyard/rails_dev_directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben committed May 6, 2010
2 parents 5d0068f + 8ca9179 commit b26f0a1
Show file tree
Hide file tree
Showing 982 changed files with 79,629 additions and 72,699 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ db/sphinx
public/javascripts/common.js
public/javascripts/locales.js
config/site_config.yml
Capfile
config/deploy.rb
25 changes: 25 additions & 0 deletions app/controllers/admin/top_cities_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class Admin::TopCitiesController < ApplicationController
inherit_resources
before_filter :admin_required
layout 'admin'

def sort
TopCity.order(params[:top_city])
index! do |wants|
wants.js { render :partial => 'top_city', :collection => @top_cities }
end
end

def create
create! { admin_top_cities_path }
end

def update
update! { admin_top_cities_path }
end

protected
def collection
@top_cities ||= end_of_association_chain.all(:order => 'position')
end
end
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class ApplicationController < ActionController::Base
include SslRequirement
include ExceptionNotifiable

helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class HomeController < ApplicationController
def show
@homepage = Homepage.first
@page = Page.find_by_url('home')
@page_url = 'home'
@page = Page.find_by_url(@page_url)
@page_content = @page
end
end
4 changes: 3 additions & 1 deletion app/controllers/my/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ def show
if logged_in?
@provider = current_user.provider if logged_in?
else
@page = Page.find_by_url('home')
@page_url = 'home'
@page = Page.find_by_url(@page_url)
@page_content = @page
render 'home/show'
end
end
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/my/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ def edit
end

def update
if @user.update_attributes(params[:user].merge({:password_confirmation => params[:user][:password]}))
@user.attributes = params[:user].merge({:password_confirmation => params[:user][:password]})
if @user == current_user
@user.password = params[:user][:password]
@user.password_confirmation = params[:user][:password]
end
if @user.save
flash[:notice] = I18n.t("company_profile.users.saved_successfully", :user => @user.email)
redirect_to my_users_path
else
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/top_cities_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class TopCitiesController < ApplicationController

def index
@top_cities = TopCity.all(:order => "position")
end

def show
@top_city = TopCity.find_by_slug(params[:id])
@providers = Provider.paginate(:conditions => {
:city => @top_city.city,
:state_province => @top_city.state,
:country => @top_city.country}, :page => params[:page])
render :template => 'providers/index'
end
end
2 changes: 2 additions & 0 deletions app/helpers/admin/top_cities_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Admin::TopCitiesHelper
end
2 changes: 2 additions & 0 deletions app/helpers/top_cities_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module TopCitiesHelper
end
23 changes: 23 additions & 0 deletions app/models/page.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'open-uri'
require 'nokogiri'
class Page < ActiveRecord::Base

validates_presence_of :title, :url
Expand All @@ -13,6 +15,27 @@ def self.find(*args)
end
end

def self.open_url(value)
open(value)
end

def url=(value)
if value[0,4] == 'http'
doc = Nokogiri::HTML(Page.open_url(value))
inline_url = doc.css("meta[name='page']").first['content']
super(inline_url)
else
super
end
end

def robots
out = []
out << 'noindex' if noindex?
out << 'nofollow' if nofollow?
out.join(', ')
end

def to_param
url
end
Expand Down
10 changes: 5 additions & 5 deletions app/models/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def self.search(params)
group = nil

if params[:service_ids].not.blank? and params[:service_ids].is_a?(Array)
joins = :provided_services
conditions[0] << " and provided_services.service_id IN (?)"
conditions << params[:service_ids].collect { |t| t.to_i }
group = "provider_id"
params[:service_ids].each do |id|
conditions[0] << " and EXISTS (select * from provided_services where service_id = ? and provider_id = providers.id)"
conditions << id.to_i
end
end

if params[:location].not.blank?
Expand Down Expand Up @@ -214,7 +214,7 @@ def set_first_user_provider
end

def send_owner_welcome
Notification.create_provider_welcome(user) if user
Notification.deliver_provider_welcome(user) if user
end

def owner_name
Expand Down
4 changes: 2 additions & 2 deletions app/models/rfp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def budget=(price)

private
def add_checked_requested_services
Service.checked.each do |tech_type|
requested_services << RequestedService.create!(:name => tech_type.name)
Service.checked.each do |service|
requested_services << RequestedService.create!(:name => service.name)
end
end

Expand Down
18 changes: 18 additions & 0 deletions app/models/top_city.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class TopCity < ActiveRecord::Base

validates_presence_of :city, :country, :slug

before_validation :set_slug

def self.order(ids)
update_all(
['position = FIND_IN_SET(id, ?)', ids.join(',')],
{ :id => ids }
)
end

private
def set_slug
self.slug = city.downcase.gsub(/[^a-z]/, '-') if self.slug.blank?
end
end
2 changes: 1 addition & 1 deletion app/views/admin/endorsements/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%- if @provider.nil? -%>
<h2><%= t('navigation.endorsements') %></h2>
<%- else -%>
<h2><%= t('endorsement.endorsements_for', :company_name => @provider.company_name) %></h2>
<h2><%= t('endorsement.endorsements_for', :company_name => @provider.company_name.to_s) %></h2>
<%- end -%>

<%- if @endorsements.empty? -%>
Expand Down
38 changes: 34 additions & 4 deletions app/views/admin/pages/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,42 @@
<%= f.error_messages %>

<fieldset>
<%= f.label :title, t("page.title") %> <%= f.text_field :title %> <br />
<%= f.label :url, t("page.url") %> <%= f.text_field :url %> <em><%= t('page.maps_to') %></em> <br />
<%= f.label :keywords, t("page.keywords") %> <%= f.text_area :keywords, :class => "small-text" %> <br />
<%= f.label :description, t("page.description") %> <%= f.text_area :description, :class => "small-text" %> <br />
<%= f.label :content, "#{t("page.content")}<br/> <em>#{t('page.accepts_textile')}</em>" %> <%= f.text_area :content %> <br />
</fieldset>

<fieldset>
<%= f.label :title, t("page.title") %> <%= f.text_field :title %> <br />
<%= f.label :keywords, t("page.keywords") %>

<%= f.radio_button :enable_keywords, false, :id => 'global-keywords' %>
<%= label_tag 'global-keywords', t('page.global_keywords'), :class => 'inline' %>

<%= f.radio_button :enable_keywords, true, :id => 'custom-keywords' %>
<%= label_tag 'custom-keywords', t('page.custom_keywords'), :class => 'inline' %>

<%= f.text_field :keywords %> <br />

<%= f.label :canonical, t('page.robots') %>

<%= f.check_box :noindex %>
<%= f.label :noindex, t('page.noindex'), :class => 'inline' %>

<%= f.check_box :nofollow %>
<%= f.label :nofollow, t('page.nofollow'), :class => 'inline' %>

<%= f.check_box :enable_canonical %>
<%= f.label :enable_canonical, t('page.canonical'), :class => 'inline' %>

<%= f.text_field :canonical %> <br />


<%= f.label :description, t("page.description") %> <%= f.text_area :description, :class => "small-text" %> <br />
</fieldset>

<fieldset>
<%= f.label :content, "#{t("page.content")}<br/> <em>#{t('page.accepts_textile')}</em>" %> <%= f.text_area :content %> <br />
</fieldset>


<%= f.submit t('forms.save') %>
<% end -%>
13 changes: 13 additions & 0 deletions app/views/admin/top_cities/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<% form_for [:admin, @top_city] do |f| -%>

<%= f.error_messages %>

<fieldset>
<%= f.label :slug, t('top_city.slug') %> <%= f.text_field :slug %> <br/>
<%= f.label :city %> <%= f.text_field :city %> <br/>
<%= f.label :state %> <%= f.select :state, ([[t('provider.outside_us')]] + State::NAMES), :include_blank => true %> <br/>
<%= f.label :country, t('provider.country') %> <%= f.localized_country_select :country, [:US, :CA, :FR, :DE, :IE, :ES, :GB], :include_blank => t('provider.choose_country') %> <br />
</fieldset>

<%= f.submit t('forms.save') %> <%= t('forms.or') %> <%= link_to t('forms.cancel'), admin_top_cities_path %>
<% end -%>
9 changes: 9 additions & 0 deletions app/views/admin/top_cities/_top_city.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<tr>
<td>
<%= top_city.city %>, <%= "#{State.by_code(top_city.state)}, " if top_city.state.not.blank? %><%= t("countries.#{top_city.country}") %>
(<%= link_to t('general.edit'), edit_admin_top_city_path(top_city) %>)
</td>
<td>
<%= link_to t('general.delete'), [:admin, top_city], :method => :delete, :confirm => t('general.confirm') %>
</td>
</tr>
3 changes: 3 additions & 0 deletions app/views/admin/top_cities/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h2><%= t('navigation.top_cities') %></h2>

<%= render 'form' %>
31 changes: 31 additions & 0 deletions app/views/admin/top_cities/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<h2><%= t('navigation.top_cities') %></h2>

<ul>
<li><%= link_to t('top_city.add_new'), new_admin_top_city_path %></li>
<li><%= link_to t('general.sort_list'), sort_admin_top_cities_path, :class => 'sort' %></li>
</ul>

<ul class="sortable">
<%- @top_cities.each do |top_city| -%>
<li id="<%= dom_id(top_city) %>">
<%= top_city.city %>,
<%= "#{State.by_code(top_city.state)}, " if top_city.state.not.blank? %>
<%= t("countries.#{top_city.country}") %>
</li>
<%- end -%>
</ul>

<%- if @top_cities.empty? -%>
<p><%= t('top_city.no_cities') %></p>
<%- else -%>
<table class="sorted">
<tr>
<th><%= t('top_city.city') %></th>
<th>&nbsp;</th>
</tr>
<tbody class="sorted-list">
<%= render :partial => 'top_city', :collection => @top_cities %>
</tbody>

</table>
<%- end -%>
3 changes: 3 additions & 0 deletions app/views/admin/top_cities/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h2><%= t('navigation.top_cities') %></h2>

<%= render 'form' %>
2 changes: 1 addition & 1 deletion app/views/endorsements/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2><%= t('endorsement.endorsements_for', :company => @provider.company_name) %></h2>
<h2><%= t('endorsement.endorsements_for', :company_name => @provider.company_name) %></h2>

<%- if @endorsements.empty? -%>
<p><%= t('provider.no_endorsements')%></p>
Expand Down
1 change: 1 addition & 0 deletions app/views/home/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<%- content_for :keywords do -%><meta name="keywords" content="<%= @page.keywords if @page %>"><%- end -%>
<%- content_for :description do -%><meta name="description" content="<%= @page.description if @page %>"><%- end -%>


<div class="welcome">
<h1><%= t('home.welcome') %></h1>
<div><%= t('home.description') %></div>
Expand Down
11 changes: 8 additions & 3 deletions app/views/layouts/admin.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title><%= t('general.site_title') %></title>
<%= stylesheet_link_tag 'emastic/reset-min', 'emastic/type-min', 'formy/form.css', 'common', 'admin' %>
<%= javascript_include_tag :defaults, 'locales', 'datepicker', 'jquery.tooltip' %>
<%= javascript_include_tag :defaults, 'locales', 'datepicker', 'jquery.tooltip', 'admin' %>
<script type="text/javascript" charset="utf-8">
AUTH_TOKEN = '<%= u(form_authenticity_token) %>';
</script>
<!--[if IE]><%= stylesheet_link_tag 'emastic/ie-min' %><![endif]-->
</head>

Expand All @@ -26,9 +29,10 @@

<ul>
<li><%= link_to t('navigation.dashboard'), admin_dashboard_path %></li>
<li><%= link_to t('navigation.rfps'), admin_rfps_path %></li>
<li><%= link_to t('navigation.endorsements'), admin_endorsements_path %></li>
<li><%= link_to t('navigation.rfps'), admin_rfps_path %></li>
<li><%= link_to t('navigation.endorsements'), admin_endorsements_path %></li>
<li><%= link_to t('navigation.providers'), admin_providers_path %></li>
<li><%= link_to t('navigation.top_cities'), admin_top_cities_path %></li>
</ul>

<h3><%= t('navigation.system_admin') %></h3>
Expand All @@ -38,6 +42,7 @@
<li><%= link_to t('navigation.services'), admin_services_path %></li>
<li><%= link_to t('navigation.users'), admin_users_path %></li>
<li><%= link_to t('navigation.csvs'), admin_csv_path %></li>
<li><%= link_to t('navigation.config'), admin_config_path %></li>
</ul>
</div>
<div class="fluid">
Expand Down
13 changes: 11 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- <%= "#{controller.controller_name}/#{controller.action_name}" %> -->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="verify-v1" content="pKVc1U5A5PwMZedJQBomhabl0pj0fa5bhYHML+abQVo=" />
Expand All @@ -13,7 +12,8 @@
<%- end -%>
<%= t('general.site_title') %>
</title>
<%- if @page_content and @page_content.keywords.to_s.not.empty? -%>
<meta name="page" content="<%= @page_url || "#{controller.controller_name}/#{controller.action_name}" %>"/>
<%- if @page_content and @page_content.enable_keywords? -%>
<meta name="keywords" content="<%= @page_content.keywords %>">
<%- else -%>
<%= yield :keywords %>
Expand All @@ -23,6 +23,14 @@
<%- else -%>
<%= yield :description %>
<%- end -%>
<%- if @page_content and @page_content.enable_canonical? -%>
<link href="<%= @page_content.canonical %>" rel="canonical" />
<%- end -%>
<%- if @page_content and @page_content.robots.not.blank? -%>
<meta name="robots" content="<%= @page_content.robots %>">
<%- end -%>


<%= stylesheet_link_tag "emastic/reset-min", "emastic/type-min", "formy/form.css", "common", "jquery", "jquery.tooltip", "application" %>
<%= javascript_include_tag :defaults, 'datepicker', 'jquery.bgiframe', 'jquery.dimensions', 'jquery.delegate', 'jquery.tooltip', 'jquery.delay', 'locales' %>
<!--[if IE]><%= stylesheet_link_tag 'emastic/ie-min' %><![endif]-->
Expand Down Expand Up @@ -82,6 +90,7 @@
<li><%= link_to t('general.terms'), '/pages/terms-of-use', :rel => "nofollow" %></li>
<li><%= link_to t('home.full_listing'), providers_path %></li>
<li><%= link_to t('home.by_location'), by_location_providers_path %></li>
<li><%= link_to t('home.top_cities'), top_cities_path %></li>
</ul>
<p class="attribution">
<%= t('general.copyright') %>
Expand Down
Loading

0 comments on commit b26f0a1

Please sign in to comment.