-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from pixelhandler/with-assets
Also serve public directory for assets
- Loading branch information
Showing
3 changed files
with
40 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |