Skip to content

Commit dee8063

Browse files
committed
Initial commit
0 parents  commit dee8063

File tree

12 files changed

+2242
-0
lines changed

12 files changed

+2242
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.gem

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CodeMirror for Rails 3
2+
======================
3+
4+
Generator to install current version of CodeMirror 2 into a
5+
Rails 3 project.
6+
7+
```
8+
rails generate codemirror:install
9+
```
10+
11+
TODO:
12+
* Suppport for the Rails 3.1+ asset pipline
13+
* Optionally install additional modes (currently only plain text)
14+
* View helpers?
15+
* JS initialization example for a basic CodeMirror textarea

codemirror-rails.gemspec

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Gem::Specification.new do |s|
2+
s.name = 'codemirror-rails'
3+
s.version = '0.0.0'
4+
s.date = '2011-06-17'
5+
s.authors = ['Nathan Fixler']
6+
s.email = '[email protected]'
7+
s.summary = 'Use CodeMirror with Rails 3'
8+
s.description = 'This gem provides CodeMirror assets for your Rails 3 application.'
9+
s.homepage = 'https://github.com/fixlr/codemirror-rails'
10+
11+
s.files = Dir["#{File.dirname(__FILE__)}/**/*"]
12+
end

doc/CodeMirror-LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (C) 2011 by Marijn Haverbeke <[email protected]>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

lib/codemirror-rails.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require 'codemirror/rails'

lib/codemirror/rails.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module Codemirror
2+
module Rails
3+
if ::Rails.version < "3.1"
4+
require 'codemirror/rails/railtie'
5+
end
6+
require 'codemirror/rails/version'
7+
end
8+
end

lib/codemirror/rails/railtie.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Configure Rails 3.0 to use public/javascripts/codemirror et al
2+
module Codemirror
3+
module Rails
4+
class Railtie < ::Rails::Railtie
5+
config.before_configuration do
6+
config.action_view.javascript_expansions[:defaults] << 'codemirror'
7+
end
8+
end
9+
end
10+
end

lib/codemirror/rails/version.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Codemirror
2+
module Rails
3+
VERSION = '0.0.0'
4+
CODEMIRROR_VERSION = '2.1'
5+
end
6+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'rails'
2+
3+
module Codemirror
4+
module Generators
5+
class InstallGenerator < ::Rails::Generators::Base
6+
desc "This generator installs CodeMirror #{Codemirror::Rails::CODEMIRROR_VERSION}"
7+
source_root File.expand_path('../../../../../vendor/assets/', __FILE__)
8+
9+
def copy_codemirror
10+
say_status("copying", "CodeMirror #{Codemirror::Rails::CODEMIRROR_VERSION}", :green)
11+
copy_file "javascripts/codemirror.js", "public/javascripts/codemirror.js"
12+
copy_file "stylesheets/codemirror.css", "public/stylesheets/codemirror.css"
13+
copy_file "stylesheets/codemirror/themes/default.css", "public/stylesheets/codemirror/themes/default.css"
14+
end
15+
end
16+
end
17+
end if ::Rails.version < "3.1"

0 commit comments

Comments
 (0)