rails_medium_editor_insert_plugin 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.lock +86 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +139 -0
  10. data/Rakefile +6 -0
  11. data/app/assets/javascripts/medium-editor-js.js +1 -0
  12. data/app/assets/stylesheets/medium-editor-style.scss +3 -0
  13. data/bin/console +14 -0
  14. data/bin/setup +8 -0
  15. data/lib/rails_medium_editor_insert_plugin.rb +7 -0
  16. data/lib/rails_medium_editor_insert_plugin/version.rb +3 -0
  17. data/rails_medium_editor_insert_plugin.gemspec +31 -0
  18. data/vendor/assets/javascripts/medium_editor_js/handlebars.js +29 -0
  19. data/vendor/assets/javascripts/medium_editor_js/jquery-fileupload.js +1477 -0
  20. data/vendor/assets/javascripts/medium_editor_js/jquery-iframe-transport.js +217 -0
  21. data/vendor/assets/javascripts/medium_editor_js/jquery-sortable.js +693 -0
  22. data/vendor/assets/javascripts/medium_editor_js/jquery-ui-widget.js +572 -0
  23. data/vendor/assets/javascripts/medium_editor_js/medium-editor-insert-plugin.js +2091 -0
  24. data/vendor/assets/javascripts/medium_editor_js/medium-editor.js +7054 -0
  25. data/vendor/assets/javascripts/rails-medium-editor-insert-plugin.js +7 -0
  26. data/vendor/assets/stylesheets/medium-editor.scss +3 -0
  27. data/vendor/assets/stylesheets/medium_editor_style/_flat.scss +62 -0
  28. data/vendor/assets/stylesheets/medium_editor_style/_medium-editor.scss +182 -0
  29. data/vendor/assets/stylesheets/medium_editor_style/medium-editor-insert-plugin-frontend.scss +72 -0
  30. data/vendor/assets/stylesheets/medium_editor_style/medium-editor-insert-plugin.scss +209 -0
  31. data/vendor/assets/stylesheets/medium_editor_style/medium-editor-style.scss +4 -0
  32. metadata +130 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f044aa4a76539ae5724a41629cea4ae6f33ba63840a108c4f98bc540c708d79d
4
+ data.tar.gz: c259e8aa21d221b917dd0e6225d28ec8f1302f2c2f67f9ee594cfb83b3d105d4
5
+ SHA512:
6
+ metadata.gz: 391e2d8b91df1de119a4efb661cb3a03a672dd5a08c5e5a6de9479d8c52f2ddeac378a1ad08f73c6d3d468ecf5eb0f055dcf996e61b55218c5dd97c3172e2cd2
7
+ data.tar.gz: 17e97f5d06ef460d4f78430ed860e4206370909e87c936740927556aebfe923a2b1354a792eb9111401337daaa91bf4729be6bfd9a37aa57600266dc81ceb80d
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at jomar.barnobal@outlook.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in rails_medium_editor_insert_plugin.gemspec
6
+ gemspec
@@ -0,0 +1,86 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rails_medium_editor_insert_plugin (0.1.0)
5
+ railties (>= 4.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (5.2.0)
11
+ actionview (= 5.2.0)
12
+ activesupport (= 5.2.0)
13
+ rack (~> 2.0)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview (5.2.0)
18
+ activesupport (= 5.2.0)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
23
+ activesupport (5.2.0)
24
+ concurrent-ruby (~> 1.0, >= 1.0.2)
25
+ i18n (>= 0.7, < 2)
26
+ minitest (~> 5.1)
27
+ tzinfo (~> 1.1)
28
+ builder (3.2.3)
29
+ concurrent-ruby (1.0.5)
30
+ crass (1.0.4)
31
+ diff-lcs (1.3)
32
+ erubi (1.7.1)
33
+ i18n (1.0.1)
34
+ concurrent-ruby (~> 1.0)
35
+ loofah (2.2.2)
36
+ crass (~> 1.0.2)
37
+ nokogiri (>= 1.5.9)
38
+ method_source (0.9.0)
39
+ mini_portile2 (2.3.0)
40
+ minitest (5.11.3)
41
+ nokogiri (1.8.2)
42
+ mini_portile2 (~> 2.3.0)
43
+ rack (2.0.5)
44
+ rack-test (1.0.0)
45
+ rack (>= 1.0, < 3)
46
+ rails-dom-testing (2.0.3)
47
+ activesupport (>= 4.2.0)
48
+ nokogiri (>= 1.6)
49
+ rails-html-sanitizer (1.0.4)
50
+ loofah (~> 2.2, >= 2.2.2)
51
+ railties (5.2.0)
52
+ actionpack (= 5.2.0)
53
+ activesupport (= 5.2.0)
54
+ method_source
55
+ rake (>= 0.8.7)
56
+ thor (>= 0.18.1, < 2.0)
57
+ rake (10.5.0)
58
+ rspec (3.7.0)
59
+ rspec-core (~> 3.7.0)
60
+ rspec-expectations (~> 3.7.0)
61
+ rspec-mocks (~> 3.7.0)
62
+ rspec-core (3.7.1)
63
+ rspec-support (~> 3.7.0)
64
+ rspec-expectations (3.7.0)
65
+ diff-lcs (>= 1.2.0, < 2.0)
66
+ rspec-support (~> 3.7.0)
67
+ rspec-mocks (3.7.0)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.7.0)
70
+ rspec-support (3.7.1)
71
+ thor (0.20.0)
72
+ thread_safe (0.3.6)
73
+ tzinfo (1.2.5)
74
+ thread_safe (~> 0.1)
75
+
76
+ PLATFORMS
77
+ ruby
78
+
79
+ DEPENDENCIES
80
+ bundler (~> 1.16)
81
+ rails_medium_editor_insert_plugin!
82
+ rake (~> 10.0)
83
+ rspec (~> 3.0)
84
+
85
+ BUNDLED WITH
86
+ 1.16.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 jomarbarnobal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,139 @@
1
+ # Rails-Medium-Editor-Insert-Plugin
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'rails_medium_editor_insert_plugin'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rails_medium_editor_insert_plugin
18
+
19
+ ## Usage
20
+
21
+ This gem need a font-awesome gem
22
+
23
+ $ gem "font-awesome-rails"
24
+
25
+ after installing gem add this into your:
26
+
27
+ /assets/javascripts/application.js
28
+
29
+ //= require medium-editor-js
30
+
31
+ /assets/stylesheets/applications.css
32
+
33
+ *= require medium-editor-style
34
+ *= require font-awesome
35
+
36
+
37
+ ## Using this gem in you rails app
38
+
39
+ Inside of your rails form
40
+
41
+ <%= form_with model: @post, class: 'editor-form', local: true do |post|%>
42
+ # forn_with is for rails 5+
43
+ <div class="field">
44
+ <div class="control">
45
+ <%= post.text_area :body, class: 'editable'%>
46
+ </div>
47
+ </div>
48
+
49
+ <%= post.submit 'Publish', class: 'button is-primary is-rounded'%>
50
+
51
+ <% end %>
52
+
53
+ and initialize your editor
54
+
55
+ $(document).on('turbolinks:load', function(){
56
+
57
+ var editor = new MediumEditor('.editable',{
58
+ placeholder: {
59
+ text: "Write a story"
60
+ }
61
+ });
62
+
63
+
64
+ $(function () {
65
+ $('.editable').mediumInsert({
66
+ editor: editor,
67
+ enabled: true,
68
+
69
+ addons: {
70
+ images: {
71
+ fileUploadOptions: {
72
+ url: '/images/upload', // your uploading image routes: post "images/upload" => "posts#upload"
73
+ type: 'post',
74
+ acceptFileTypes: /(.|\/)(gif|jpe?g|png)$/i
75
+ },
76
+ fileDeleteOptions: {
77
+ url: '/image/delete',
78
+ type: 'delete'
79
+ }
80
+ }
81
+ }
82
+ });
83
+ });
84
+ })
85
+
86
+
87
+ ## Add image upload in your rails app controller
88
+
89
+ You can use any of this gem for file upload
90
+
91
+ [carrierwave link](https://github.com/carrierwaveuploader/carrierwave)
92
+
93
+ [paperclip link](https://github.com/thoughtbot/paperclip)
94
+
95
+
96
+ Create a method inside of you controller like this.
97
+
98
+
99
+
100
+ def upload
101
+ # image = current_user.posts.new(image: params[:files].first) -> // if you are using devise
102
+ image = Posts.new(image: params[:files].first)
103
+ image.save
104
+ url_response = {
105
+ files: [
106
+ {
107
+ url: @image.image.url,
108
+ thumbnail_url: @image.image.url,
109
+ name: @image.image_identifier,
110
+ type: "image/jpeg",
111
+ size: 0
112
+ }
113
+ ]
114
+ }
115
+ render :json => url_response
116
+ end
117
+
118
+ Your routes should something like this
119
+
120
+ post "images/upload" => "posts#upload"
121
+
122
+
123
+ This code block comes from this man [ mwlang ](https://github.com/mwlang/medium-editor-insert-plugin-rails) big thanks to him
124
+
125
+ ## Development
126
+
127
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
128
+
129
+ 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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
130
+
131
+ ## Contributing
132
+
133
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rails_medium_editor_insert_plugin. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
134
+
135
+ ## License
136
+
137
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
138
+
139
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1 @@
1
+ //= require rails-medium-editor-insert-plugin
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require medium-editor
3
+ */
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rails_medium_editor_insert_plugin"
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(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ require 'rails'
2
+ require 'rails_medium_editor_insert_plugin/version'
3
+
4
+ module RailsMediumEditorInsertPlugin
5
+ class Engine < Rails::Engine
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module RailsMediumEditorInsertPlugin
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "rails_medium_editor_insert_plugin/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails_medium_editor_insert_plugin"
8
+ spec.version = RailsMediumEditorInsertPlugin::VERSION
9
+ spec.authors = ["jomarbarnobal"]
10
+ spec.email = ["jomar.barnobal@outlook.com"]
11
+
12
+ spec.summary = %q{Write a short summary, because RubyGems requires one.}
13
+ spec.description = %q{Write a longer description or delete this line.}
14
+ spec.homepage = "https://github.com/jbarnobal/rails_medium_editor_insert_plugin"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_dependency 'railties', '>= 4.0'
28
+ spec.add_development_dependency "bundler", "~> 1.16"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.0"
31
+ end