rails-redactorjs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.md +53 -0
  5. data/Rakefile +2 -0
  6. data/lib/rails-redactorjs.rb +14 -0
  7. data/lib/rails-redactorjs/configuration.rb +54 -0
  8. data/lib/rails-redactorjs/engine.rb +11 -0
  9. data/lib/rails-redactorjs/helper.rb +15 -0
  10. data/lib/rails-redactorjs/version.rb +5 -0
  11. data/rails-redactorjs.gemspec +17 -0
  12. data/vendor/assets/javascripts/rails-redactorjs/css/docstyle.css +123 -0
  13. data/vendor/assets/javascripts/rails-redactorjs/css/style.css +119 -0
  14. data/vendor/assets/javascripts/rails-redactorjs/css/wym.css +136 -0
  15. data/vendor/assets/javascripts/rails-redactorjs/index.js +1 -0
  16. data/vendor/assets/javascripts/rails-redactorjs/langs/by.js +72 -0
  17. data/vendor/assets/javascripts/rails-redactorjs/langs/de.js +75 -0
  18. data/vendor/assets/javascripts/rails-redactorjs/langs/en.js +76 -0
  19. data/vendor/assets/javascripts/rails-redactorjs/langs/es.js +76 -0
  20. data/vendor/assets/javascripts/rails-redactorjs/langs/fr.js +74 -0
  21. data/vendor/assets/javascripts/rails-redactorjs/langs/hu.js +76 -0
  22. data/vendor/assets/javascripts/rails-redactorjs/langs/it.js +76 -0
  23. data/vendor/assets/javascripts/rails-redactorjs/langs/ja.js +76 -0
  24. data/vendor/assets/javascripts/rails-redactorjs/langs/lv.js +74 -0
  25. data/vendor/assets/javascripts/rails-redactorjs/langs/nl.js +76 -0
  26. data/vendor/assets/javascripts/rails-redactorjs/langs/pl.js +75 -0
  27. data/vendor/assets/javascripts/rails-redactorjs/langs/pt_br.js +81 -0
  28. data/vendor/assets/javascripts/rails-redactorjs/langs/ru.js +75 -0
  29. data/vendor/assets/javascripts/rails-redactorjs/langs/sq.js +76 -0
  30. data/vendor/assets/javascripts/rails-redactorjs/langs/tr.js +76 -0
  31. data/vendor/assets/javascripts/rails-redactorjs/langs/ua.js +75 -0
  32. data/vendor/assets/javascripts/rails-redactorjs/langs/zh_cn.js +77 -0
  33. data/vendor/assets/javascripts/rails-redactorjs/langs/zh_tw.js +76 -0
  34. data/vendor/assets/javascripts/rails-redactorjs/plugins/file.html +3 -0
  35. data/vendor/assets/javascripts/rails-redactorjs/plugins/image.html +39 -0
  36. data/vendor/assets/javascripts/rails-redactorjs/plugins/image_edit.html +35 -0
  37. data/vendor/assets/javascripts/rails-redactorjs/plugins/link.html +74 -0
  38. data/vendor/assets/javascripts/rails-redactorjs/plugins/table.html +25 -0
  39. data/vendor/assets/javascripts/rails-redactorjs/plugins/video.html +15 -0
  40. data/vendor/assets/javascripts/rails-redactorjs/redactor.js +2259 -0
  41. data/vendor/assets/javascripts/rails-redactorjs/redactor.min.js +1 -0
  42. data/vendor/assets/javascripts/rails-redactorjs/toolbars/default.js +214 -0
  43. data/vendor/assets/javascripts/rails-redactorjs/toolbars/mini.js +103 -0
  44. data/vendor/assets/stylesheets/rails-redactorjs/css/redactor.css +368 -0
  45. data/vendor/assets/stylesheets/rails-redactorjs/img/icons.png +0 -0
  46. data/vendor/assets/stylesheets/rails-redactorjs/index.css +1 -0
  47. metadata +95 -0
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails-redactorjs.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Sammy
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Rails 3.2 Integration for Redactor
2
+
3
+ The rails-redactorjs gem integrates the [Redactor](http://redactorjs.com/) editor with the Rails 3.2 asset pipeline.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rails-redactorjs', :git => "git://github.com/SammyLin/rails-redactorjs.git"
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rails-redactorjs
18
+
19
+ Create a `config/redactorjs.yml` file with your global configuration options:
20
+
21
+ lang: 'zh_tw'
22
+ autoresize: true
23
+
24
+ See the [Redactor Documentation](http://redactorjs.com/docs/settings/) for a full list of configuration options.
25
+
26
+ ### Include the Redactor assets
27
+
28
+ Add to your `application.js`:
29
+
30
+ //= require rails-redactorjs
31
+
32
+ Add to your `application.css`:
33
+
34
+ *= require rails-redactorjs
35
+
36
+ ### Initialize Redactor
37
+
38
+ For each textarea that you want to use with Redactor, add the "redactor" class and ensure it has a unique ID:
39
+
40
+ <%= text_area_tag :editor, "", :class => "redactor", :rows => 40, :cols => 120 %>
41
+
42
+ Then invoke the `redactorjs` helper to initialize Redactor:
43
+
44
+ <%= redactorjs %>
45
+
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ require "rails-redactorjs/version"
2
+
3
+ module Rails
4
+ module Redactorjs
5
+ # Your code goes here...
6
+ require 'rails-redactorjs/engine'
7
+ require 'rails-redactorjs/helper'
8
+ require 'rails-redactorjs/configuration'
9
+
10
+ def self.configuration
11
+ @configuration ||= Configuration.load(::Rails.root.join("config/redactorjs.yml"))
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,54 @@
1
+ module Rails
2
+ module Redactorjs
3
+ class Configuration
4
+ class Function < String
5
+ def encode_json(encoder)
6
+ self
7
+ end
8
+ end
9
+
10
+ def self.defaults
11
+ {
12
+
13
+ }
14
+ end
15
+
16
+ attr_reader :options
17
+
18
+ def initialize(options)
19
+ @options = options
20
+ end
21
+
22
+ def options_for_redactorjs
23
+ result = {}
24
+
25
+ options.each do |key, value|
26
+ if value.is_a?(Array) && value.all? { |v| v.is_a?(String) }
27
+ result[key] = value.join(",")
28
+ elsif value.to_s.starts_with?("function(")
29
+ result[key] = Function.new(value)
30
+ else
31
+ result[key] = value
32
+ end
33
+ end
34
+
35
+ result
36
+ end
37
+
38
+ def merge(options)
39
+ self.class.new(self.options.merge(options))
40
+ end
41
+
42
+ def load(filename)
43
+ options.merge!(YAML::load(ERB.new(IO.read(filename)).result))
44
+ end
45
+
46
+ def self.load(filename)
47
+ config = new(defaults)
48
+ config.load(filename) if File.exists?(filename)
49
+ config
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,11 @@
1
+ module Rails
2
+ module Redactorjs
3
+ class Engine < Rails::Engine
4
+ initializer "helper" do |app|
5
+ ActiveSupport.on_load(:action_view) do
6
+ include Rails::Redactorjs::Helpers
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Rails
2
+ module Redactorjs
3
+ module Helpers
4
+ def redactorjs(options={})
5
+ javascript_tag { redactorjs_javascript(options) }
6
+ end
7
+
8
+ # Returns the JavaScript code required to initialize Redactorjs.
9
+ def redactorjs_javascript(options={})
10
+ configuration = Redactorjs.configuration.merge(options)
11
+ "$(document).ready(function(){$('.redactor').redactor(#{configuration.options_for_redactorjs.to_json});});".html_safe
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module Rails
2
+ module Redactorjs
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/rails-redactorjs/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Sammy"]
6
+ gem.email = ["sammylintw@gmail.com"]
7
+ gem.description = "The rails-redactorjs gem integrates the Redactor editor"
8
+ gem.summary = ""
9
+ gem.homepage = "https://github.com/SammyLin/rails-redactorjs"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "rails-redactorjs"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Rails::Redactorjs::VERSION
17
+ end
@@ -0,0 +1,123 @@
1
+ html {
2
+ padding: 0;
3
+ margin: 0;
4
+ }
5
+ body {
6
+ font-family: "PT Sans", "Trebuchet MS", Verdana, Arial, Tahoma, sans-serif;
7
+ font-size: 17px;
8
+ margin: 0;
9
+ padding: 0;
10
+ overflow-x: hidden;
11
+ background: #f4f4f4;
12
+ }
13
+ #page {
14
+ max-width: 900px;
15
+ width: 74%;
16
+ margin: 20px auto;
17
+ padding: 15px 50px;
18
+ background: #fff;
19
+ border: 1px solid #ddd;
20
+ }
21
+ #page:focus {
22
+ outline: none;
23
+ }
24
+
25
+ ::selection {
26
+ background-color: #333;
27
+ color: #fff;
28
+ text-shadow: none;
29
+ }
30
+
31
+ div,
32
+ p,
33
+ ul,
34
+ ol,
35
+ table,
36
+ dl,
37
+ blockquote,
38
+ pre,
39
+ iframe,
40
+ object,
41
+ hr {
42
+ margin-bottom: 15px;
43
+ line-height: 1.5em;
44
+ }
45
+ blockquote {
46
+ margin-left: 3em;
47
+ font-style: italic;
48
+ color: #777;
49
+ }
50
+ ul, ol {
51
+ padding-left: 2em;
52
+ }
53
+ ul ul,
54
+ ol ol,
55
+ ul ol,
56
+ ol ul {
57
+ border: none;
58
+ margin: 2px !important;
59
+ padding: 0;
60
+ padding-left: 2em;
61
+ }
62
+ dl dt { font-weight: bold; }
63
+ dd { margin-left: 1em;}
64
+
65
+ table {
66
+ border-collapse: collapse;
67
+ font-size: 1em;
68
+ }
69
+ table td {
70
+ border: 1px solid #ddd;
71
+ padding: 5px;
72
+ }
73
+ table thead td {
74
+ border-bottom: 2px solid #000 !important;
75
+ font-weight: bold;
76
+ }
77
+ code, pre {
78
+ font-family: monospace sans-serif;
79
+ }
80
+ code {
81
+ background-color: #d8d7d7;
82
+ }
83
+ pre {
84
+ padding: 1em;
85
+ border: 1px dashed #ccc;
86
+ background: #f5f5f5;
87
+ overflow: auto;
88
+ }
89
+ hr {
90
+ display: block;
91
+ height: 1px;
92
+ border: 0;
93
+ border-top: 1px solid #ccc;
94
+ }
95
+
96
+ h1, h2, h3, h4,h5 {
97
+ font-weight: bold;
98
+ }
99
+
100
+ h1 {
101
+ font-size: 36px;
102
+ line-height: 40px;
103
+ margin-bottom: 10px;
104
+ }
105
+ h2 {
106
+ font-size: 30px;
107
+ line-height: 36px;
108
+ margin-bottom: 15px;
109
+ }
110
+ h3 {
111
+ font-size: 24px;
112
+ line-height: 30px;
113
+ margin-bottom: 10px;
114
+ }
115
+ h4 {
116
+ font-size: 18px;
117
+ line-height: 24px;
118
+ margin-bottom: 10px;
119
+ }
120
+ h4 {
121
+ font-size: 1em;
122
+ margin-bottom: 10px;
123
+ }
@@ -0,0 +1,119 @@
1
+ html {
2
+ padding: 0;
3
+ margin: 0;
4
+ }
5
+ body {
6
+ font-family: "PT Sans", "Trebuchet MS", Verdana, Arial, Tahoma, sans-serif;
7
+ font-size: 17px;
8
+ margin: 0;
9
+ padding: 0;
10
+ overflow-x: hidden;
11
+ background: #fff;
12
+ }
13
+ #page {
14
+ margin: 20px;
15
+ background: #fff;
16
+ }
17
+ #page:focus {
18
+ outline: none;
19
+ }
20
+
21
+ ::selection {
22
+ background-color: #333;
23
+ color: #fff;
24
+ text-shadow: none;
25
+ }
26
+
27
+ div,
28
+ p,
29
+ ul,
30
+ ol,
31
+ table,
32
+ dl,
33
+ blockquote,
34
+ pre,
35
+ iframe,
36
+ object,
37
+ hr {
38
+ margin-bottom: 15px;
39
+ line-height: 1.5em;
40
+ }
41
+ blockquote {
42
+ margin-left: 3em;
43
+ font-style: italic;
44
+ color: #777;
45
+ }
46
+ ul, ol {
47
+ padding-left: 2em;
48
+ }
49
+ ul ul,
50
+ ol ol,
51
+ ul ol,
52
+ ol ul {
53
+ border: none;
54
+ margin: 2px !important;
55
+ padding: 0;
56
+ padding-left: 2em;
57
+ }
58
+ dl dt { font-weight: bold; }
59
+ dd { margin-left: 1em;}
60
+
61
+ table {
62
+ border-collapse: collapse;
63
+ font-size: 1em;
64
+ }
65
+ table td {
66
+ border: 1px solid #ddd;
67
+ padding: 5px;
68
+ }
69
+ table thead td {
70
+ border-bottom: 2px solid #000 !important;
71
+ font-weight: bold;
72
+ }
73
+ code, pre {
74
+ font-family: monospace sans-serif;
75
+ }
76
+ code {
77
+ background-color: #d8d7d7;
78
+ }
79
+ pre {
80
+ padding: 1em;
81
+ border: 1px dashed #ccc;
82
+ background: #f5f5f5;
83
+ overflow: auto;
84
+ }
85
+ hr {
86
+ display: block;
87
+ height: 1px;
88
+ border: 0;
89
+ border-top: 1px solid #ccc;
90
+ }
91
+
92
+ h1, h2, h3, h4,h5 {
93
+ font-weight: bold;
94
+ }
95
+
96
+ h1 {
97
+ font-size: 36px;
98
+ line-height: 40px;
99
+ margin-bottom: 10px;
100
+ }
101
+ h2 {
102
+ font-size: 30px;
103
+ line-height: 36px;
104
+ margin-bottom: 15px;
105
+ }
106
+ h3 {
107
+ font-size: 24px;
108
+ line-height: 30px;
109
+ margin-bottom: 10px;
110
+ }
111
+ h4 {
112
+ font-size: 18px;
113
+ line-height: 24px;
114
+ margin-bottom: 10px;
115
+ }
116
+ h4 {
117
+ font-size: 1em;
118
+ margin-bottom: 10px;
119
+ }