Skip to content

Commit

Permalink
Merge pull request #1 from pixelhandler/with-assets
Browse files Browse the repository at this point in the history
Also serve public directory for assets
  • Loading branch information
pixelhandler committed May 29, 2016
2 parents f16232a + ad09455 commit a46b634
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# public assets are added via rsync through deployment
/public/*
/logs/*
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# blog-index
# sinatra-redis-server

Sinatra app to serve index page for pixelhandler.com from Redis
Sinatra app to serve index.html page from Redis and assets from public folder.

sudo su - deploy
rackup -E production -p 4567 -s thin -D

Or in development:

rackup -p 4567 -s thin

A log file is generated at /logs/sinatra.log

## Links

- [lightning-strategy-examples/#example-sinatra-app]

[lightning-strategy-examples/#example-sinatra-app]: http://ember-cli-deploy.github.io/ember-cli-deploy/docs/v0.6.x/lightning-strategy-examples/#example-sinatra-app
28 changes: 21 additions & 7 deletions app.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
require 'sinatra'
require 'redis'

def bootstrap_index(index_key)
redis = Redis.new(:password => "#{ENV['REDIS_SECRET']}")
project = "pixelhandler-blog"
index_key ||= redis.get("#{project}:index:current")
redis.get("#{project}:index:#{index_key}")
end
set :public_folder, 'public'

get '/*' do
content_type 'text/html'
bootstrap_index(params[:index_key])
get_html(params[:revision_key])
end

def get_html(revision_key)
redis = store
project = "passenger"
revision_key = params[:revision_key] || redis.get("#{project}:index:current")
redis.get("#{project}:index:#{revision_key}")
end

def store
if ENV['REDIS_URL'].nil? || ENV['REDIS_URL'].empty?
redis = Redis.new()
else
if !ENV['REDIS_SECRET'].nil?
redis = Redis.new(:url => ENV['REDIS_URL'], :password => ENV['REDIS_SECRET'])
else
redis = Redis.new(:url => ENV['REDIS_URL'])
end
end
end

0 comments on commit a46b634

Please sign in to comment.