Skip to content
This repository
Browse code

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...
commit eff9e887cb175eac02f5b90660edf9bf2a4c2747 1 parent b0ef949
Aaron Quint authored May 22, 2009
4  .gitignore
... ...
@@ -1,2 +1,4 @@
1 1
 .DS_Store
2  
-pkg/*
  2
+pkg/*
  3
+_site
  4
+_layouts
2  Manifest.txt
@@ -2,11 +2,11 @@ History.txt
2 2
 PostInstall.txt
3 3
 README.rdoc
4 4
 Rakefile
  5
+config.ru
5 6
 bin/gembox
6 7
 lib/extensions.rb
7 8
 lib/gembox.rb
8 9
 lib/gembox/app.rb
9  
-lib/gembox/config.ru
10 10
 lib/gembox/gem_list.rb
11 11
 lib/gembox/gems.rb
12 12
 lib/gembox/view_helpers.rb
9  config.ru
... ...
@@ -0,0 +1,9 @@
  1
+# To use with thin 
  2
+#  thin start -p PORT -R config.ru
  3
+require File.join(File.dirname(__FILE__), 'lib', 'gembox')
  4
+
  5
+disable :run
  6
+Gembox::App.set({
  7
+  :environment => :production
  8
+})
  9
+run Gembox::App
2  lib/gembox.rb
@@ -2,6 +2,8 @@
2 2
   $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3 3
 
4 4
 require 'rubygems'
  5
+require 'haml'
  6
+require 'sass'
5 7
 require 'active_support'
6 8
 require 'will_paginate/array'
7 9
 require 'will_paginate/view_helpers'
7  lib/gembox/app.rb
@@ -9,11 +9,12 @@ class App < ::Sinatra::Default
9 9
 
10 10
     set :root,  @@root    
11 11
     set :app_file, __FILE__
12  
-    
  12
+        
13 13
     before do
14 14
       Gembox::Gems.load
15  
-      @gems = Gembox::Gems.local_gems.paginate :page => params[:page], :per_page => 30
  15
+      @gems  = Gembox::Gems.local_gems.paginate :page => params[:page], :per_page => 30
16 16
       @stats = Gembox::Gems.stats
  17
+      @search ||= ''
17 18
     end
18 19
 
19 20
     get '/stylesheets/:stylesheet.css' do
@@ -46,7 +47,7 @@ class App < ::Sinatra::Default
46 47
         action = params[:action] || 'view'
47 48
         file_path = File.join(@gem.full_gem_path, params[:file])
48 49
         if File.readable?(file_path)
49  
-          if action == 'edit'
  50
+          if action == 'edit' && !production?
50 51
             `$EDITOR #{file_path}`
51 52
           else
52 53
             content_type 'text/plain'
8  lib/gembox/config.ru
... ...
@@ -1,8 +0,0 @@
1  
-# To use with thin 
2  
-#  thin start -p PORT -R config.ru
3  
-
4  
-require File.join(File.dirname(__FILE__), 'gembox')
5  
-
6  
-disable :run
7  
-set :env, :production
8  
-run Gembox::App
8  public/javascripts/gembox.js
@@ -42,9 +42,11 @@
42 42
           } else {
43 43
             // build controls
44 44
             var $controls = $('<span class="controls"></span>');
45  
-            $('<a><img src="/images/edit.png" alt="Edit"/></a>')
46  
-            .attr('href', meta.url + '&action=edit')
47  
-            .appendTo($controls);
  45
+            if ($('body').data('sinatra-env') != 'production') {
  46
+              $('<a><img src="/images/edit.png" alt="Edit"/></a>')
  47
+                .attr('href', meta.url + '&action=edit')
  48
+                .appendTo($controls);
  49
+            }
48 50
             if (!meta.subdirs) {
49 51
               $('<a><img src="/images/page_white_text.png" alt="View Raw"/></a>')
50 52
               .attr('href', meta.url + '&action=view')
7  views/layout.haml
@@ -40,4 +40,9 @@
40 40
           =link_to 'Sinatra.', 'http://sinatrrb.com'
41 41
         %p.copyright 
42 42
           Hey! I'm 
43  
-          =link_to 'open-source!', 'http://github.com/quirkey/gembox'
  43
+          =link_to 'open-source!', 'http://github.com/quirkey/gembox'
  44
+
  45
+      :erb
  46
+        <script type="text/javascript" charset="utf-8">
  47
+          jQuery('body').data('sinatra-env', '<%= options.environment %>');
  48
+        </script>

0 notes on commit eff9e88

Please sign in to comment.
Something went wrong with that request. Please try again.