Permalink
Browse files

Fixed/moved the config.ru so its accesible for passenger [thanks Lena…

…ry!]

config.ru runs the app in 'production' and disables the ability to run the EDITOR,
this should make it a little safer to run not locally
  • Loading branch information...
1 parent b0ef949 commit eff9e887cb175eac02f5b90660edf9bf2a4c2747 @quirkey committed May 22, 2009
Showing with 30 additions and 17 deletions.
  1. +3 −1 .gitignore
  2. +1 −1 Manifest.txt
  3. +9 −0 config.ru
  4. +2 −0 lib/gembox.rb
  5. +4 −3 lib/gembox/app.rb
  6. +0 −8 lib/gembox/config.ru
  7. +5 −3 public/javascripts/gembox.js
  8. +6 −1 views/layout.haml
View
@@ -1,2 +1,4 @@
.DS_Store
-pkg/*
+pkg/*
+_site
+_layouts
View
@@ -2,11 +2,11 @@ History.txt
PostInstall.txt
README.rdoc
Rakefile
+config.ru
bin/gembox
lib/extensions.rb
lib/gembox.rb
lib/gembox/app.rb
-lib/gembox/config.ru
lib/gembox/gem_list.rb
lib/gembox/gems.rb
lib/gembox/view_helpers.rb
View
@@ -0,0 +1,9 @@
+# To use with thin
+# thin start -p PORT -R config.ru
+require File.join(File.dirname(__FILE__), 'lib', 'gembox')
+
+disable :run
+Gembox::App.set({
+ :environment => :production
+})
+run Gembox::App
View
@@ -2,6 +2,8 @@
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
require 'rubygems'
+require 'haml'
+require 'sass'
require 'active_support'
require 'will_paginate/array'
require 'will_paginate/view_helpers'
View
@@ -9,11 +9,12 @@ class App < ::Sinatra::Default
set :root, @@root
set :app_file, __FILE__
-
+
before do
Gembox::Gems.load
- @gems = Gembox::Gems.local_gems.paginate :page => params[:page], :per_page => 30
+ @gems = Gembox::Gems.local_gems.paginate :page => params[:page], :per_page => 30
@stats = Gembox::Gems.stats
+ @search ||= ''
end
get '/stylesheets/:stylesheet.css' do
@@ -46,7 +47,7 @@ class App < ::Sinatra::Default
action = params[:action] || 'view'
file_path = File.join(@gem.full_gem_path, params[:file])
if File.readable?(file_path)
- if action == 'edit'
+ if action == 'edit' && !production?
`$EDITOR #{file_path}`
else
content_type 'text/plain'
View
@@ -1,8 +0,0 @@
-# To use with thin
-# thin start -p PORT -R config.ru
-
-require File.join(File.dirname(__FILE__), 'gembox')
-
-disable :run
-set :env, :production
-run Gembox::App
@@ -42,9 +42,11 @@
} else {
// build controls
var $controls = $('<span class="controls"></span>');
- $('<a><img src="/images/edit.png" alt="Edit"/></a>')
- .attr('href', meta.url + '&action=edit')
- .appendTo($controls);
+ if ($('body').data('sinatra-env') != 'production') {
+ $('<a><img src="/images/edit.png" alt="Edit"/></a>')
+ .attr('href', meta.url + '&action=edit')
+ .appendTo($controls);
+ }
if (!meta.subdirs) {
$('<a><img src="/images/page_white_text.png" alt="View Raw"/></a>')
.attr('href', meta.url + '&action=view')
View
@@ -40,4 +40,9 @@
=link_to 'Sinatra.', 'http://sinatrrb.com'
%p.copyright
Hey! I'm
- =link_to 'open-source!', 'http://github.com/quirkey/gembox'
+ =link_to 'open-source!', 'http://github.com/quirkey/gembox'
+
+ :erb
+ <script type="text/javascript" charset="utf-8">
+ jQuery('body').data('sinatra-env', '<%= options.environment %>');
+ </script>

0 comments on commit eff9e88

Please sign in to comment.