Skip to content

#386 Add Twitter Card markup to Individual team pages #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
language: ruby
rvm:
- 2.1.2
- 2.1.3
bundler_args: "--without development production autotest"
services:
- mongodb
- redis-server
before_install:
- wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.13.deb
- sudo dpkg --purge elasticsearch
- sudo dpkg -i elasticsearch-0.90.13.deb
- sudo service elasticsearch start
- gem update --system
Expand Down
10 changes: 10 additions & 0 deletions app/jobs/index_protip_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class IndexProtipJob
include Sidekiq::Worker

sidekiq_options queue: :high

def perform(protip_id)
protip = Protip.find(protip_id)
protip.tire.update_index unless protip.user.banned?
end
end
16 changes: 10 additions & 6 deletions app/jobs/search_sync_job.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
class SearchSyncJob
include Sidekiq::Worker
sidekiq_options queue: :search_sync

sidekiq_options queue: :medium

# TODO refactor this, when we drop Tire.
def perform
return if duplicate_job? # Skip if there is more enqueued jobs

number_of_protips_in_index = Protip.tire.search { query { all } }.total
number_of_protips_in_database = Protip.count

Expand All @@ -13,7 +15,7 @@ def perform
query { all }
end.map { |protip| protip.id.to_i }

protips_in_database = Protip.select(:id).map(&:id)
protips_in_database = Protip.pluck(:id)

#now that we know the sets in db and index, calculate the missing records
nonexistent_protips = (protips_in_index - protips_in_database)
Expand All @@ -24,10 +26,12 @@ def perform
end

unindexed_protips.each do |unindexed_protip_id|
IndexProtip.perform_async(unindexed_protip_id)
IndexProtipJob.perform_async(unindexed_protip_id)
end

puts "removed #{nonexistent_protips.count} protips and added #{unindexed_protips.count} protips"
end
end

def duplicate_job?
Sidekiq::Queue.new('search_sync').size > 2
end
end
1 change: 1 addition & 0 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
!!! 5
%html.no-js{lang: 'en'}
%head
=metamagic
/[if IE] <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
%meta{ content: 'text/html; charset=UTF-8', 'http-equiv' => 'Content-Type' }
%title= page_title(yield(:page_title))
Expand Down
9 changes: 9 additions & 0 deletions app/views/teams/premium.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
- if ENV['ENABLE_TWITTER_CARDS']
- meta twitter: {card: "summary"}
- meta twitter: {site: "@coderwall"}
- meta twitter: {title: sanitize(@team.name)}
- meta twitter: {url: teamname_path(@team.slug)}
- meta twitter: {description: @team.about}
- meta twitter: {image: @team.avatar_url}
- meta twitter: {creator: {id: @team.twitter}}

-content_for :head do
=stylesheet_link_tag 'premium-teams'

Expand Down
1 change: 1 addition & 0 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ production:
:queues:
- [low, 1]
- [default, 2]
- [search_sync, 2]
- [medium, 3]
- [high, 4]
- [urgent, 5]
Expand Down