Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'cedar-unicorn'

  • Loading branch information...
commit 61b50cd5e1fa1c7d8917f40b972c9a7eb24b8685 2 parents a17ec4b + 873b622
@mislav authored
View
4 .gitignore
@@ -1,2 +1,6 @@
+.bundle
+.env
+.ruby-version
config.local.yml
+vendor/
tmp
View
8 Gemfile
@@ -1,12 +1,9 @@
source 'https://rubygems.org'
+ruby '2.1.2'
gem 'sinatra'
-group :development do
- gem 'shotgun'
- gem 'thin'
-end
-
+gem 'unicorn'
gem 'haml'
gem 'compass'
gem 'activesupport'
@@ -23,3 +20,4 @@ gem 'rake'
gem 'never-forget'
gem 'dalli'
gem 'metriks-middleware'
+gem 'rack-cache'
View
20 Gemfile.lock
@@ -16,10 +16,8 @@ GEM
hashie (>= 0.4.0)
compass (0.10.6)
haml (>= 3.0.4)
- daemons (1.1.2)
dalli (2.0.3)
erubis (2.7.0)
- eventmachine (0.12.10)
faraday (0.8.0)
multipart-post (~> 1.1)
faraday_middleware (0.8.7)
@@ -28,6 +26,7 @@ GEM
hashie (1.1.0)
hitimes (1.2.0)
i18n (0.5.0)
+ kgio (2.9.2)
metriks (0.9.9.4)
atomic (~> 1.0)
avl_tree (~> 1.1.2)
@@ -46,20 +45,21 @@ GEM
mingo (>= 0.2)
rack
rack (1.4.5)
+ rack-cache (1.2)
+ rack (>= 0.4)
rack-protection (1.2.0)
rack
+ raindrops (0.13.0)
rake (0.9.2)
- shotgun (0.9)
- rack (>= 1.0)
sinatra (1.3.2)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
- thin (1.2.11)
- daemons (>= 1.0.9)
- eventmachine (>= 0.12.6)
- rack (>= 1.0.0)
tilt (1.3.3)
+ unicorn (4.8.3)
+ kgio (~> 2.6)
+ rack
+ raindrops (~> 0.7)
will_paginate (3.0.0)
PLATFORMS
@@ -80,8 +80,8 @@ DEPENDENCIES
mingo
mongo_ext
never-forget
+ rack-cache
rake
- shotgun
sinatra
- thin
+ unicorn
will_paginate (~> 3.0.0)
View
1  Procfile
@@ -0,0 +1 @@
+web: bundle exec unicorn -p $PORT -E $RACK_ENV -c ./config.unicorn.rb
View
28 app.rb
@@ -17,6 +17,7 @@
require 'sass'
require 'compass'
require_relative 'models'
+require 'yaml'
require 'choices'
require 'json'
require 'metriks/middleware'
@@ -43,6 +44,21 @@
ENV['MEMCACHE_USERNAME'] = ENV['MEMCACHIER_USERNAME']
ENV['MEMCACHE_PASSWORD'] = ENV['MEMCACHIER_PASSWORD']
+configure :production do
+ require 'rack/cache'
+ memcached = "memcached://%s:%s@%s" % [
+ ENV['MEMCACHE_USERNAME'],
+ ENV['MEMCACHE_PASSWORD'],
+ ENV['MEMCACHE_SERVERS']
+ ]
+ use Rack::Cache, allow_reload: true,
+ metastore: "#{memcached}/meta",
+ entitystore: "#{memcached}/body?compress=true"
+end
+
+require 'rack/deflater'
+use Rack::Deflater
+
Instagram.configure do |config|
for key, value in settings.instagram
config.send("#{key}=", value)
@@ -281,6 +297,14 @@ def photos_by_tag(tag)
end
end
+configure :production do
+ before do
+ if request.get? && request.host != 'instagram.mislav.net'
+ redirect "http://instagram.mislav.net#{request.fullpath}", 301
+ end
+ end
+end
+
get '/' do
@photos = popular_photos
@title = "Instagram popular photos"
@@ -467,7 +491,7 @@ def photos_by_tag(tag)
= instalink @title
- if root_path?
%a{ href: "/popular.atom", class: 'feed' }
- %img{ src: '/feed.png', alt: 'feed', width: 14, height: 14 }
+ %img{ src: "#{asset_host}/feed.png", alt: 'feed', width: 14, height: 14 }
- if root_path? or search_path?
%form{ action: '/search', method: 'get' }
@@ -483,7 +507,7 @@ def photos_by_tag(tag)
•
%a{ href: atom_path(@user), class: 'feed' }
%span photo feed
- %img{ src: '/feed.png', alt: '', width: 14, height: 14 }
+ %img{ src: "#{asset_host}/feed.png", alt: '', width: 14, height: 14 }
- if @tags and @tags.any?
%ol.tags
View
2  config.unicorn.rb
@@ -0,0 +1,2 @@
+worker_processes 4
+timeout 30
Please sign in to comment.
Something went wrong with that request. Please try again.