m_d_e-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +65 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/m_d_e.js.coffee +40 -0
- data/app/assets/stylesheets/m_d_e.css +20 -0
- data/app/views/m_d_e/_editor.html +4 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/m_d_e/rails.rb +8 -0
- data/lib/m_d_e/rails/engine.rb +6 -0
- data/lib/m_d_e/rails/version.rb +5 -0
- data/m_d_e-rails.gemspec +25 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0fd4fcefc199c4d0700895865bf4fc04eab0379d
|
4
|
+
data.tar.gz: 4d77842375ab2686b5656bd1db2a1aea57d79105
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a22fdd02ab4c2fc6e6090bc074b273fa721367dcb33a6580ba17c88041fce3ae11230e8232e59afcdee89257d5d2cca740120727a01fc646187c7cb6b30182a9
|
7
|
+
data.tar.gz: e05e8834eabd6852cde88271850fa9f874491bc4bc259094c622d4814e56fec2dded3527caa85ef51bb1a5c0c543b2bbb6e8b8251c3051370363ba95f8d7798f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# MDE::Rails
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/m_d_e/rails`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'm_d_e-rails'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install m_d_e-rails
|
22
|
+
$ gem install ace-rails-ap
|
23
|
+
$ gem install marked-rails
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
1. `application.js` or other `.js` file associated with view where you need editor:
|
28
|
+
|
29
|
+
```javascript
|
30
|
+
//=require 'm_d_e'
|
31
|
+
...
|
32
|
+
editor = new Editor('textarea_id') // hidden textarea
|
33
|
+
```
|
34
|
+
|
35
|
+
2. `application.css`:
|
36
|
+
|
37
|
+
```css
|
38
|
+
//=require 'm_d_e'
|
39
|
+
```
|
40
|
+
|
41
|
+
3. `view.html.erb`
|
42
|
+
|
43
|
+
```html
|
44
|
+
<textarea id="textarea_id"></textarea>
|
45
|
+
...
|
46
|
+
<%= render 'm_d_e/editor' %>
|
47
|
+
```
|
48
|
+
|
49
|
+
## Coming
|
50
|
+
|
51
|
+
* UI elements to set theme, stuff like that.
|
52
|
+
|
53
|
+
## Development
|
54
|
+
|
55
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
56
|
+
|
57
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it ( https://github.com/[my-github-username]/m_d_e-rails/fork )
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#= require 'marked'
|
2
|
+
#= require 'ace/ace'
|
3
|
+
#= require 'ace/worker-html'
|
4
|
+
#= require 'ace/theme-solarized_dark'
|
5
|
+
#= require 'ace/mode-markdown'
|
6
|
+
#
|
7
|
+
class window.Editor
|
8
|
+
constructor: (input_field) ->
|
9
|
+
@input_field = input_field
|
10
|
+
$("##{@input_field}").css('visibility', 'hidden')
|
11
|
+
@theme_prefix = 'ace/theme/'
|
12
|
+
@ttimer = null
|
13
|
+
@aedit = ace.edit('mde_editor')
|
14
|
+
@aedit.setValue($("##{@input_field}").val())
|
15
|
+
mdm = require('ace/mode/markdown').Mode
|
16
|
+
@aedit.getSession().setMode(new mdm())
|
17
|
+
|
18
|
+
this.setTheme 'solarized_light'
|
19
|
+
$('#mde_preview').html(marked @aedit.getValue() )
|
20
|
+
|
21
|
+
@aedit.getSession().on 'change', this._change.bind(this)
|
22
|
+
@aedit.getSession().on 'changeScrollTop', this._syncScrolls.bind(this)
|
23
|
+
|
24
|
+
window.editor = this
|
25
|
+
|
26
|
+
_change: (e)->
|
27
|
+
clearTimeout(@ttimer) if @ttimer
|
28
|
+
@ttimer = window.setTimeout(() ->
|
29
|
+
$('#mde_preview').html(marked editor.aedit.getValue())
|
30
|
+
true
|
31
|
+
, 1000)
|
32
|
+
$("##{@input_field}").val(editor.aedit.getValue())
|
33
|
+
true
|
34
|
+
|
35
|
+
setTheme: (name) ->
|
36
|
+
@aedit.setTheme @theme_prefix + name
|
37
|
+
|
38
|
+
_syncScrolls: (val) ->
|
39
|
+
fs = parseInt $('#mde_editor').css('font-size')
|
40
|
+
$('#mde_preview').scrollTop(val * fs)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#mde_editor {
|
2
|
+
width: 48%;
|
3
|
+
height: 500px;
|
4
|
+
float: left;
|
5
|
+
}
|
6
|
+
#mde_preview {
|
7
|
+
width: 48%;
|
8
|
+
height: 500px;
|
9
|
+
overflow-y: scroll;
|
10
|
+
float: right;
|
11
|
+
border: 1px dotted #999;
|
12
|
+
margin-top: 5px;
|
13
|
+
font-size: 10px;
|
14
|
+
}
|
15
|
+
#mde {
|
16
|
+
overflow: auto;
|
17
|
+
margin: 10px 0;
|
18
|
+
}
|
19
|
+
#mde:before{ overflow: auto; }
|
20
|
+
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "m_d_e/rails"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/m_d_e/rails.rb
ADDED
data/m_d_e-rails.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'm_d_e/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "m_d_e-rails"
|
8
|
+
spec.version = MDE::Rails::VERSION
|
9
|
+
spec.authors = ["d-theus"]
|
10
|
+
spec.email = ["slma0x02@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = 'Markdown editor for rails'
|
13
|
+
spec.description = 'Two sided editor with preview. Using ace editor and marked parser, coffee.'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_dependency "coffee-rails"
|
23
|
+
spec.add_dependency "ace-rails-ap"
|
24
|
+
spec.add_dependency "marked-rails"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: m_d_e-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- d-theus
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coffee-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ace-rails-ap
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: marked-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Two sided editor with preview. Using ace editor and marked parser, coffee.
|
84
|
+
email:
|
85
|
+
- slma0x02@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- README.md
|
93
|
+
- Rakefile
|
94
|
+
- app/assets/javascripts/m_d_e.js.coffee
|
95
|
+
- app/assets/stylesheets/m_d_e.css
|
96
|
+
- app/views/m_d_e/_editor.html
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- lib/m_d_e/rails.rb
|
100
|
+
- lib/m_d_e/rails/engine.rb
|
101
|
+
- lib/m_d_e/rails/version.rb
|
102
|
+
- m_d_e-rails.gemspec
|
103
|
+
homepage:
|
104
|
+
licenses: []
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.4.5
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Markdown editor for rails
|
126
|
+
test_files: []
|