Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit dee80636bb48019bc7bbb10d31a4f9a8166bfd7b @fixlr committed Jun 20, 2011
@@ -0,0 +1 @@
+*.gem
@@ -0,0 +1,15 @@
+CodeMirror for Rails 3
+======================
+
+Generator to install current version of CodeMirror 2 into a
+Rails 3 project.
+
+```
+rails generate codemirror:install
+```
+
+TODO:
+ * Suppport for the Rails 3.1+ asset pipline
+ * Optionally install additional modes (currently only plain text)
+ * View helpers?
+ * JS initialization example for a basic CodeMirror textarea
@@ -0,0 +1,12 @@
+Gem::Specification.new do |s|
+ s.name = 'codemirror-rails'
+ s.version = '0.0.0'
+ s.date = '2011-06-17'
+ s.authors = ['Nathan Fixler']
+ s.email = 'nathan@fixler.org'
+ s.summary = 'Use CodeMirror with Rails 3'
+ s.description = 'This gem provides CodeMirror assets for your Rails 3 application.'
+ s.homepage = 'https://github.com/fixlr/codemirror-rails'
+
+ s.files = Dir["#{File.dirname(__FILE__)}/**/*"]
+end
@@ -0,0 +1,19 @@
+Copyright (C) 2011 by Marijn Haverbeke <marijnh@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
@@ -0,0 +1 @@
+require 'codemirror/rails'
@@ -0,0 +1,8 @@
+module Codemirror
+ module Rails
+ if ::Rails.version < "3.1"
+ require 'codemirror/rails/railtie'
+ end
+ require 'codemirror/rails/version'
+ end
+end
@@ -0,0 +1,10 @@
+# Configure Rails 3.0 to use public/javascripts/codemirror et al
+module Codemirror
+ module Rails
+ class Railtie < ::Rails::Railtie
+ config.before_configuration do
+ config.action_view.javascript_expansions[:defaults] << 'codemirror'
+ end
+ end
+ end
+end
@@ -0,0 +1,6 @@
+module Codemirror
+ module Rails
+ VERSION = '0.0.0'
+ CODEMIRROR_VERSION = '2.1'
+ end
+end
@@ -0,0 +1,17 @@
+require 'rails'
+
+module Codemirror
+ module Generators
+ class InstallGenerator < ::Rails::Generators::Base
+ desc "This generator installs CodeMirror #{Codemirror::Rails::CODEMIRROR_VERSION}"
+ source_root File.expand_path('../../../../../vendor/assets/', __FILE__)
+
+ def copy_codemirror
+ say_status("copying", "CodeMirror #{Codemirror::Rails::CODEMIRROR_VERSION}", :green)
+ copy_file "javascripts/codemirror.js", "public/javascripts/codemirror.js"
+ copy_file "stylesheets/codemirror.css", "public/stylesheets/codemirror.css"
+ copy_file "stylesheets/codemirror/themes/default.css", "public/stylesheets/codemirror/themes/default.css"
+ end
+ end
+ end
+end if ::Rails.version < "3.1"
Oops, something went wrong.

0 comments on commit dee8063

Please sign in to comment.