redactor-rails 0.2.5 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -31,12 +31,12 @@ Create a `config/redactor.yml` file with your global configuration options, like
31
31
  lang: 'zh_tw'
32
32
  autoresize: true
33
33
  buttons:
34
- - html
35
- - '|'
36
- - formatting
37
- - '|'
38
- - bold
39
- - italic
34
+ - html
35
+ - '|'
36
+ - formatting
37
+ - '|'
38
+ - bold
39
+ - italic
40
40
 
41
41
  If You Want To setup a new language in Redactor you should do two things:
42
42
 
@@ -1,6 +1,6 @@
1
1
  class RedactorRails::PicturesController < ApplicationController
2
2
  def index
3
- @pictures = RedactorRails.picture_model.find_all
3
+ @pictures = RedactorRails.picture_model.find_all({})
4
4
  render :json => @pictures.to_json
5
5
 
6
6
  end
@@ -0,0 +1,18 @@
1
+ require 'rails/generators'
2
+ module Redactor
3
+ module Generators
4
+ class ConfigGenerator < ::Rails::Generators::Base
5
+ desc "Generates redactor-rails config"
6
+
7
+ def self.source_root
8
+ @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
9
+ end
10
+
11
+
12
+ def create_config
13
+ template "config.js",
14
+ File.join('app/assets/javascripts/redactor-rails', "config.js")
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ $(document).ready(
2
+ function(){
3
+ var csrf_token = $('meta[name=csrf-token]').attr('content');
4
+ var csrf_param = $('meta[name=csrf-param]').attr('content');
5
+ var params;
6
+ if (csrf_param !== undefined && csrf_token !== undefined) {
7
+ params = csrf_param + "=" + encodeURIComponent(csrf_token);
8
+ }
9
+ $('.redactor').redactor(
10
+ { "imageUpload":"/redactor_rails/pictures?" + params,
11
+ "imageGetJson":"/redactor_rails/pictures",
12
+ "path":"/assets/redactor-rails",
13
+ "css":"style.css"}
14
+ );
15
+ });
@@ -13,15 +13,10 @@ module RedactorRails
13
13
  require 'redactor-rails/orm/active_record'
14
14
  require 'redactor-rails/engine'
15
15
  require 'redactor-rails/helper'
16
- require 'redactor-rails/configuration'
17
16
 
18
17
  mattr_accessor :image_file_types
19
18
  @@image_file_types = ["jpg", "jpeg", "png", "gif", "tiff"]
20
19
 
21
- def self.configuration
22
- @configuration ||= Configuration.load(::Rails.root.join("config/redactor.yml"))
23
- end
24
-
25
20
 
26
21
  def self.picture_model
27
22
  RedactorRails::Picture.to_adapter
@@ -1,14 +1,5 @@
1
1
  module RedactorRails
2
2
  module Helpers
3
- def redactor(options={})
4
- javascript_tag { redactor_javascript(options) }
5
- end
6
-
7
- # Returns the JavaScript code required to initialize RedactorRailsjs.
8
- def redactor_javascript(options={})
9
- configuration = RedactorRails.configuration.merge(options)
10
- "$(document).ready(function(){$('.redactor').redactor(#{configuration.options_for_redactor.to_json});});".html_safe
11
- end
12
3
  # Setting Redactor Language
13
4
  def redactor_lang(lang = 'en')
14
5
  javascript_include_tag "redactor-rails/langs/#{lang}.js"
@@ -25,7 +25,8 @@ module RedactorRails
25
25
 
26
26
  def as_json(options = nil)
27
27
  options = {
28
- :methods => as_json_methods
28
+ :methods => as_json_methods,
29
+ :root => false
29
30
  }
30
31
 
31
32
  super options
@@ -1,3 +1,3 @@
1
1
  module RedactorRails
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3"
3
3
  end
@@ -0,0 +1,15 @@
1
+ $(document).ready(
2
+ function(){
3
+ var csrf_token = $('meta[name=csrf-token]').attr('content');
4
+ var csrf_param = $('meta[name=csrf-param]').attr('content');
5
+ var params;
6
+ if (csrf_param !== undefined && csrf_token !== undefined) {
7
+ params = csrf_param + "=" + encodeURIComponent(csrf_token);
8
+ }
9
+ $('.redactor').redactor(
10
+ { "imageUpload":"/redactor_rails/pictures?" + params,
11
+ "imageGetJson":"/redactor_rails/pictures",
12
+ "path":"/assets/redactor-rails",
13
+ "css":"style.css"}
14
+ );
15
+ });
@@ -1 +1,2 @@
1
1
  //= require ./redactor.min
2
+ //= require ./config
@@ -63,7 +63,7 @@ RELANG['hr'] = {
63
63
  align_right: 'Poravnaj desno',
64
64
  align_justify: 'Od ruba do ruba',
65
65
  horizontalrule: 'Horizontalna crta',
66
- fullscreen: 'Prikaz preko �itavog ekrana',
66
+ fullscreen: 'Prikaz preko èitavog ekrana',
67
67
  deleted: 'Izbrisano',
68
68
  anchor: 'Sidro'
69
69
  };
@@ -0,0 +1,20 @@
1
+ html, body {
2
+ margin: 0;
3
+ padding: 0;
4
+ }
5
+
6
+
7
+ /* =Typography
8
+ -----------------------------------------------------------------------------*/
9
+ body {
10
+ font-family: Helvetica, Arial, sans-serif;
11
+ font-size: 14px;
12
+ }
13
+
14
+
15
+ /* =Layout
16
+ -----------------------------------------------------------------------------*/
17
+ #page {
18
+ width: 960px;
19
+ margin: 50px auto;
20
+ }
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redactor-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 5
10
- version: 0.2.5
8
+ - 3
9
+ version: "0.3"
11
10
  platform: ruby
12
11
  authors:
13
12
  - Sammy
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2012-07-17 00:00:00 Z
17
+ date: 2012-08-07 00:00:00 Z
19
18
  dependencies:
20
19
  - !ruby/object:Gem::Dependency
21
20
  name: mime-types
@@ -62,14 +61,15 @@ files:
62
61
  - Rakefile
63
62
  - app/controller/redactor_rails/pictures_controller.rb
64
63
  - config/routes.rb
64
+ - lib/generators/redactor/config_generator.rb
65
65
  - lib/generators/redactor/install_generator.rb
66
66
  - lib/generators/redactor/templates/active_record/carrierwave/migration.rb
67
67
  - lib/generators/redactor/templates/active_record/carrierwave/redactor/asset.rb
68
68
  - lib/generators/redactor/templates/active_record/carrierwave/redactor/picture.rb
69
69
  - lib/generators/redactor/templates/base/carrierwave/uploaders/redactor_rails_picture_uploader.rb
70
+ - lib/generators/redactor/templates/config.js
70
71
  - lib/redactor-rails.rb
71
72
  - lib/redactor-rails/backend/carrierwave.rb
72
- - lib/redactor-rails/configuration.rb
73
73
  - lib/redactor-rails/engine.rb
74
74
  - lib/redactor-rails/helper.rb
75
75
  - lib/redactor-rails/http.rb
@@ -77,6 +77,7 @@ files:
77
77
  - lib/redactor-rails/orm/base.rb
78
78
  - lib/redactor-rails/version.rb
79
79
  - redactor-rails.gemspec
80
+ - vendor/assets/javascripts/redactor-rails/config.js
80
81
  - vendor/assets/javascripts/redactor-rails/css/docstyle.css
81
82
  - vendor/assets/javascripts/redactor-rails/css/style.css
82
83
  - vendor/assets/javascripts/redactor-rails/css/wym.css
@@ -108,6 +109,7 @@ files:
108
109
  - vendor/assets/javascripts/redactor-rails/redactor.js
109
110
  - vendor/assets/javascripts/redactor-rails/redactor.min.js
110
111
  - vendor/assets/stylesheets/redactor-rails/css/redactor.css
112
+ - vendor/assets/stylesheets/redactor-rails/css/style.css
111
113
  - vendor/assets/stylesheets/redactor-rails/img/icons.png
112
114
  - vendor/assets/stylesheets/redactor-rails/index.css
113
115
  homepage: https://github.com/SammyLin/redactor-rails
@@ -1,42 +0,0 @@
1
- module RedactorRails
2
- class Configuration
3
- class Function < String
4
- def encode_json(encoder)
5
- self
6
- end
7
- end
8
-
9
- def self.defaults
10
- {
11
- imageUpload: '/redactor_rails/pictures',
12
- imageGetJson: '/redactor_rails/pictures'
13
- }
14
- end
15
-
16
- attr_reader :options
17
-
18
- def initialize(options)
19
- @options = options
20
- end
21
-
22
-
23
- def options_for_redactor
24
- options
25
- end
26
-
27
- def merge(options)
28
- self.class.new(self.options.merge(options))
29
- end
30
-
31
- def load(filename)
32
- options.merge!(YAML::load(ERB.new(IO.read(filename)).result))
33
- end
34
-
35
- def self.load(filename)
36
- config = new(defaults)
37
- config.load(filename) if File.exists?(filename)
38
- config
39
- end
40
-
41
- end
42
- end