aloha-rails-improved 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/log/*.log
6
+ test/dummy/tmp/
7
+ test/dummy/.sass-cache
8
+ Gemfile.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Aloha::Rails::Improved Changelog
2
+
3
+ See full commit history here: <https://github.com/kuraga/aloha-rails-improved/commits/master>.
4
+
5
+ ## 0.1.0 (2013-02-01)
6
+
7
+ _(initial release)_
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in aloha-rails-improved.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Kurakin Alexander
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,105 @@
1
+ # Aloha::Rails::Improved
2
+
3
+ Power your Rails 3 app with the [Aloha Editor](http://aloha-editor.org/)!
4
+
5
+ ## Installation
6
+
7
+ Ruby 1.9.2 or 1.9.3 is required. Rails 3.x is a required dependency.
8
+
9
+ Add this line to your application's `Gemfile`:
10
+
11
+ gem 'aloha-rails'
12
+
13
+ Or, if you want to be on the edge:
14
+
15
+ gem 'aloha-rails', git: 'https://github.com/kuraga/aloha-rails-improved.git', branch: 'develop'
16
+
17
+ ## Basic Usage
18
+
19
+ Just make quick steps to start using Aloha Editor in your Rails app!
20
+
21
+ 1. Generate your Aloha Editor config:
22
+ ```sh
23
+ rails generate aloha:install
24
+ ```
25
+
26
+ 2. Load Aloha Editor from your layout:
27
+ ```erb
28
+ <%= javascript_include_tag 'aloha-config' %>
29
+ <%= aloha_dependencies_cdn %>
30
+ <%= aloha_require_cdn %>
31
+ ```
32
+
33
+ 3. Then write javascript to start edit a textarea:
34
+ ```javascript
35
+ $('#some-textarea').aloha();
36
+ ```
37
+
38
+ Enjoy!
39
+
40
+ ## Custom Usage
41
+
42
+ You should make these things to start using Aloha Editor in your app:
43
+
44
+ 1. Generate your Aloha Editor config: `rails generate aloha:install`. Use `--coffee` option to use CoffeeScript for js-config file.
45
+
46
+ 2. Load Aloha Editor config file.
47
+ * insert this in your layout: `<%= javascript_include_tag 'aloha-config' %>`
48
+ * _or_ require it in your asset: `//= require 'aloha-config'`
49
+
50
+ 3. Load dependencies (only [RequireJS](http://requirejs.org/) library is required now).
51
+ * _to load them all using [Aloha Editor CDN](http://cdn.aloha-editor.org/)_, just write this in your layout: `<%= aloha_dependencies_cdn %>`;
52
+ * _or_ you can _load a single dependency only via CDN_, i.e. `<%= aloha_requirejs_cdn %>`;
53
+ * _or load them manually in your own manner..._, then see [Aloha Editor's website](http://aloha-editor.org/) to choose required dependencies' versions.
54
+
55
+ 4. Load Aloha Editor:
56
+ * _to load it via CDN asynchronously using RequireJS_, write in your layout: `<%= aloha_require_cdn %>`;
57
+ * _to load it via CDN but without RequireJS_, write in your layout (you should _not_ load RequireJS library above): `<%= aloha_cdn %>`;
58
+ * _to load it from local server using RequireJS_, run `rake aloha:update` and write in your layout: `<%= aloha_require_local %>`;
59
+ * _to load it from local server but without RequireJS_, run `rake aloha:update` and write in your layout (you should _not_ load RequireJS library above): `<%= aloha_local %>`;
60
+
61
+ 5. Then write javascript to start edit a textarea: `$('#some-textarea').aloha();`.
62
+
63
+ Enjoy too!
64
+
65
+ ## Additional information
66
+
67
+ See code (and tests) for aditional information.
68
+
69
+ ## Testing
70
+
71
+ Run `rake spec` to test. See tests in `spec/` directory. You should use Rake 10+ and RSpec 2.12 to test.
72
+
73
+ ## See Also
74
+
75
+ * [Aloha Editor website](http://aloha-editor.org/)
76
+
77
+ ## Bugs List
78
+
79
+ ## ToDo List
80
+
81
+ * Generator tests.
82
+ * Asset pipeline integration.
83
+ * Automatically checking of the latest Aloha Editor's version.
84
+ * Hooks (i.e. `Aloha.onReady`).
85
+ * Plugins and their config.
86
+ * Make Travis, Badges, etc.
87
+
88
+ ## Bugs and Feedback
89
+
90
+ Follow to [Github](http://github.com/kuraga/aloha-rails-improved/issues).
91
+
92
+ ## Contributing
93
+
94
+ We encourage you to contribute! [Join us on Github](http://github.com/kuraga/aloha-rails-improved)!
95
+
96
+ Note: [Master branch](http://github.com/kuraga/aloha-rails-improved/tree/master) has a latest stable version of Aloha::Rails::Improved.
97
+ Recent changes are in [develop branch](http://github.com/kuraga/aloha-rails-improved/tree/develop).
98
+
99
+ ## License
100
+
101
+ Aloha::Rails::Improved is released under the [MIT License](http://www.opensource.org/licenses/MIT).
102
+
103
+ &copy; 2013 Kurakin Alexander (<kuraga333@mail.ru>).
104
+
105
+ <http://github.com/kuraga/aloha-rails-improved>
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ load 'lib/tasks/aloha/update.rake'
5
+
6
+ require 'rspec/core/rake_task'
7
+ desc "Run all examples"
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task :default => :spec
11
+ task :test => :spec
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/aloha/rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Kurakin Alexander']
6
+ gem.email = 'kuraga333@mail.ru'
7
+ gem.description = 'Aloha Editor in Rails'
8
+ gem.summary = 'Provides the Aloha Editor for your Rails 3 app'
9
+ gem.homepage = 'https://github.com/kuraga/aloha-rails-improved'
10
+
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.test_files = gem.files.grep(%r{^spec/})
13
+ gem.name = 'aloha-rails-improved'
14
+ gem.require_paths = ['lib']
15
+ gem.version = Aloha::Rails::VERSION
16
+
17
+ gem.add_dependency 'activesupport', '>= 3.0'
18
+ gem.add_dependency 'actionpack', '>= 3.0'
19
+
20
+ gem.add_development_dependency 'rspec', '~> 2.12'
21
+ gem.add_development_dependency 'rspec-rails', '~> 2.12'
22
+ gem.add_development_dependency 'rake', '~> 10.0'
23
+ end
@@ -0,0 +1,39 @@
1
+ module Aloha
2
+ module Rails
3
+ module Cdn
4
+
5
+ mattr_accessor :cdn_base_url
6
+ self.cdn_base_url = "http://cdn.aloha-editor.org/latest"
7
+
8
+ mattr_accessor :cdn_script_url
9
+ self.cdn_script_url = "#{self.cdn_base_url}/lib/aloha.js"
10
+
11
+ mattr_accessor :cdn_stylesheet_url
12
+ self.cdn_stylesheet_url = "#{self.cdn_base_url}/css/aloha.css"
13
+
14
+ mattr_accessor :cdn_requirejs_url
15
+ self.cdn_requirejs_url = "#{self.cdn_base_url}/lib/require.js"
16
+
17
+ def aloha_requirejs_cdn
18
+ options = {
19
+ type: 'text/javascript',
20
+ src: cdn_requirejs_url
21
+ }
22
+ content_tag :script, nil, options
23
+ end
24
+
25
+ def aloha_dependencies_cdn(options = {})
26
+ aloha_requirejs_cdn
27
+ end
28
+
29
+ def aloha_cdn(options = {})
30
+ aloha_script_tag_url(cdn_script_url, (options[:script] || {})) + aloha_stylesheet_tag_url(cdn_stylesheet_url, (options[:stylesheet] || {}))
31
+ end
32
+
33
+ def aloha_require_cdn(options = {})
34
+ aloha_require(cdn_base_url, options)
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,53 @@
1
+ require 'action_view'
2
+
3
+ require 'aloha/rails/cdn'
4
+ require 'aloha/rails/local'
5
+
6
+ module Aloha
7
+ module Rails
8
+ module Helpers
9
+
10
+ include Cdn
11
+ include Local
12
+
13
+ def aloha_script_tag_url(url, options = {})
14
+ raise TypeError, 'url must be a String' unless url.is_a? String
15
+
16
+ options = {
17
+ type: 'text/javascript',
18
+ src: url,
19
+ }.update(options)
20
+
21
+ content_tag :script, nil, options
22
+ end
23
+
24
+ def aloha_stylesheet_tag_url(url, options = {})
25
+ raise TypeError, 'url must be a String' unless url.is_a? String
26
+
27
+ options = {
28
+ rel: 'stylesheet',
29
+ type: 'text/css',
30
+ href: url
31
+ }.update(options)
32
+
33
+ content_tag :link, nil, options
34
+ end
35
+
36
+ def aloha_require(url, options = {})
37
+ raise TypeError, 'url must be a String' unless url.is_a? String
38
+
39
+ js = <<-JS
40
+ function aloha_require() {
41
+ require({
42
+ context: 'aloha',
43
+ baseUrl: '#{url}/lib'
44
+ }, ['aloha'], function (Aloha) {
45
+ });
46
+ }
47
+ JS
48
+ javascript_tag js
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,25 @@
1
+ module Aloha
2
+ module Rails
3
+
4
+ module Local
5
+
6
+ mattr_accessor :local_base_url
7
+ self.local_base_url = "http://local.aloha-editor.org/latest"
8
+
9
+ mattr_accessor :local_script_url
10
+ self.local_script_url = "#{self.local_base_url}/lib/aloha.js"
11
+
12
+ mattr_accessor :local_stylesheet_url
13
+ self.local_stylesheet_url = "#{self.local_base_url}/css/aloha.css"
14
+
15
+ def aloha_local(options = {})
16
+ aloha_script_tag_url(local_script_url, (options[:script] || {})) + aloha_stylesheet_tag_url(local_stylesheet_url, (options[:stylesheet] || {}))
17
+ end
18
+
19
+ def aloha_require_local(options = {})
20
+ aloha_require(local_base_url, options)
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ require 'rails'
2
+
3
+ module Aloha::Rails
4
+
5
+ class Railtie < ::Rails::Engine
6
+
7
+ initializer 'aloha-rails.initialize' do
8
+ ActiveSupport.on_load(:action_view) do
9
+ include Aloha::Rails::Helpers
10
+ end
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,7 @@
1
+ module Aloha
2
+ VERSION = '0.22.7'
3
+
4
+ module Rails
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ require 'aloha/rails/version'
2
+ require 'aloha/rails/railtie' if defined?(::Rails)
3
+
4
+ module Aloha
5
+ module Rails
6
+
7
+ autoload :Helpers, 'aloha/rails/helpers'
8
+
9
+ end
10
+ end
11
+
12
+ require 'aloha/rails/helpers'
13
+ require 'aloha/rails/cdn'
14
+ require 'aloha/rails/local'
@@ -0,0 +1 @@
1
+ require 'aloha/rails'
@@ -0,0 +1,5 @@
1
+ Description:
2
+ Installs Aloha configuration files:
3
+ app/assets/javascripts/aloha-config.js
4
+ or (if --coffee option is present):
5
+ app/assets/javascripts/aloha-config.js.coffee
@@ -0,0 +1,14 @@
1
+ class Aloha::InstallGenerator < Rails::Generators::Base
2
+
3
+ source_root File.expand_path('../templates', __FILE__)
4
+ class_option :coffee, type: :boolean, default: false, desc: 'Install coffeescript file instead of javascript'
5
+
6
+ def copy_config
7
+ if options[:coffee]
8
+ template 'aloha-config.js.coffee', File.join('app', 'assets', 'javascripts', 'aloha-config.js.coffee')
9
+ else
10
+ template 'aloha-config.js', File.join('app', 'assets', 'javascripts', 'aloha-config.js')
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,79 @@
1
+ ( function ( window, undefined ) {
2
+ var Aloha = window.Aloha || ( window.Aloha = {} );
3
+
4
+ Aloha.settings = {
5
+ modules: ['aloha', 'aloha/jquery'],
6
+ editables: '.editable-long-text, .editable-short-text',
7
+ logLevels: { 'error': true, 'warn': false, 'info': false, 'debug': false, 'deprecated': false },
8
+ errorhandling: false,
9
+ sidebar: {
10
+ disabled: true
11
+ },
12
+ ribbon: false,
13
+ locale: 'en',
14
+
15
+ plugins: {
16
+ load: 'common/format,common/list,common/link,common/block,common/undo,common/contenthandler,common/paste',
17
+
18
+ format: {
19
+ config: [ 'b', 'i', 'p', 'sub', 'sup', 'del', 'title', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'removeFormat' ],
20
+ editables: {
21
+ // No formatting for oneliners
22
+ '.editable-short-text': []
23
+ }
24
+ },
25
+
26
+ list: {
27
+ // all elements with no specific configuration get an UL, just for fun :)
28
+ config: [ 'ul', 'ol' ],
29
+ editables: {
30
+ // Even if this is configured it is not set because OL and UL are not allowed in H1.
31
+ '.editable-short-text': []
32
+ }
33
+ },
34
+
35
+ abbr: {
36
+ // all elements with no specific configuration get an UL, just for fun :)
37
+ config: [ 'abbr' ],
38
+ editables: {
39
+ // Even if this is configured it is not set because OL and UL are not allowed in H1.
40
+ '.editable-short-text': []
41
+ }
42
+ },
43
+
44
+ link: {
45
+ // all elements with no specific configuration may insert links
46
+ config: [ 'a' ],
47
+ editables: {
48
+ '.editable-short-text': []
49
+ },
50
+ // all links that match the targetregex will get set the target
51
+ // e.g. ^(?!.*aloha-editor.com).* matches all href except aloha-editor.com
52
+ targetregex: '^(?!.*loo.no).*',
53
+ // this target is set when either targetregex matches or not set
54
+ // e.g. _blank opens all links in new window
55
+ target: '_blank',
56
+ // the same for css class as for target
57
+ // handle change of href
58
+ onHrefChange: function ( obj, href, item ) {
59
+ var jQuery = Aloha.require( 'aloha/jquery' );
60
+ if ( item ) {
61
+ jQuery( obj ).attr( 'data-name', item.name );
62
+ } else {
63
+ jQuery( obj ).removeAttr( 'data-name' );
64
+ }
65
+ }
66
+ },
67
+
68
+ table: {
69
+ // all elements with no specific configuration are not allowed to insert tables
70
+ config: [ 'table' ],
71
+ editables: {
72
+ // Don't allow tables in top-text
73
+ '.editable-short-text': [ '' ]
74
+ }
75
+ }
76
+
77
+ }
78
+ };
79
+ } )( window );
@@ -0,0 +1,65 @@
1
+ Aloha = window.Aloha or (window.Aloha = {})
2
+
3
+ Aloha.settings =
4
+ modules: ['aloha', 'aloha/jquery']
5
+ editables: '.editable-long-text, .editable-short-text'
6
+ logLevels:
7
+ error: true
8
+ warn: false
9
+ info: false
10
+ debug: false
11
+ deprecated: false
12
+ errorhandling: false
13
+ sidebar:
14
+ disabled: true
15
+ ribbon: false
16
+ locale: 'en'
17
+ plugins:
18
+ load: 'common/format,common/list,common/link,common/block,common/undo,common/contenthandler,common/paste'
19
+
20
+ format:
21
+ config: ['b', 'i', 'p', 'sub', 'sup', 'del', 'title', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'removeFormat']
22
+ editables:
23
+ # No formatting for oneliners
24
+ '.editable-short-text': []
25
+
26
+ list:
27
+ # all elements with no specific configuration get an UL, just for fun :)
28
+ config: ['ul', 'ol']
29
+ editables:
30
+ # Even if this is configured it is not set because OL and UL are not allowed in H1.
31
+ '.editable-short-text': []
32
+
33
+ abbr:
34
+ # all elements with no specific configuration get an UL, just for fun :)
35
+ config: ['abbr']
36
+ editables:
37
+ # Even if this is configured it is not set because OL and UL are not allowed in H1.
38
+ '.editable-short-text': []
39
+
40
+ link:
41
+ # all elements with no specific configuration may insert links
42
+ config: ['a']
43
+ editables:
44
+ '.editable-short-text': []
45
+ # all links that match the targetregex will get set the target
46
+ # e.g. ^(?!.*aloha-editor.com).* matches all href except aloha-editor.com
47
+ targetregex: '^(?!.*loo.no).*'
48
+ # this target is set when either targetregex matches or not set
49
+ # e.g. _blank opens all links in new window
50
+ target: '_blank'
51
+ # the same for css class as for target
52
+ # handle change of href
53
+ onHrefChange: (obj, href, item) ->
54
+ jQuery = Aloha.require('aloha/jquery')
55
+ if item
56
+ jQuery(obj).attr 'data-name', item.name
57
+ else
58
+ jQuery(obj).removeAttr 'data-name'
59
+
60
+ table:
61
+ # all elements with no specific configuration are not allowed to insert tables
62
+ config: ['table']
63
+ editables:
64
+ # Don't allow tables in top-text
65
+ '.editable-short-text': ['']
@@ -0,0 +1,26 @@
1
+ alohaeditor_dirname = "alohaeditor-#{Aloha::VERSION}"
2
+
3
+ namespace :aloha do
4
+
5
+ desc "Update Aloha Editor to version specified in gem"
6
+ task :update do
7
+ print "Downloading zip archive ..."
8
+ puts "Downloading https://github.com/downloads/alohaeditor/Aloha-Editor/#{alohaeditor_dirname}.zip ..."
9
+ `mkdir -p tmp`
10
+ `curl -L -# https://github.com/downloads/alohaeditor/Aloha-Editor/#{alohaeditor_dirname}.zip -o tmp/#{alohaeditor_dirname}.zip`
11
+ puts " DONE"
12
+
13
+ print "Extracting core files ..."
14
+ `rm -rf tmp/#{alohaeditor_dirname}`
15
+ `unzip -u tmp/#{alohaeditor_dirname}.zip -d tmp`
16
+ puts " DONE"
17
+
18
+ # Processing of core files (i.e. removeing some plugins) goes here...
19
+
20
+ print "Copying core files ..."
21
+ `rm -rf vendor/assets/javascripts/aloha`
22
+ `mv tmp/#{alohaeditor_dirname}/aloha vendor/assets/javascripts/.`
23
+ puts " DONE"
24
+
25
+ end
26
+ end
@@ -0,0 +1,100 @@
1
+ require 'spec_helper'
2
+
3
+ describe Aloha::Rails::Cdn do
4
+
5
+ include ActionView::Helpers::TagHelper
6
+ include ActionView::Helpers::JavaScriptHelper
7
+ include Aloha::Rails::Helpers
8
+
9
+ context 'url settings' do
10
+
11
+ context 'defaults' do
12
+ it 'has Aloha Editor\'s CDN urls' do
13
+ expect(Aloha::Rails::Cdn.cdn_base_url).to eq('http://cdn.aloha-editor.org/latest')
14
+ expect(Aloha::Rails::Cdn.cdn_script_url).to eq('http://cdn.aloha-editor.org/latest/lib/aloha.js')
15
+ expect(Aloha::Rails::Cdn.cdn_stylesheet_url).to eq('http://cdn.aloha-editor.org/latest/css/aloha.css')
16
+ expect(Aloha::Rails::Cdn.cdn_requirejs_url).to eq('http://cdn.aloha-editor.org/latest/lib/require.js')
17
+ end
18
+ end
19
+
20
+ context 'configuring' do
21
+ it 'should be configurable' do
22
+ Aloha::Rails::Cdn.cdn_base_url = 'http://other-cdn.aloha-editor.org'
23
+ expect(Aloha::Rails::Cdn.cdn_base_url).to eq('http://other-cdn.aloha-editor.org')
24
+
25
+ Aloha::Rails::Cdn.cdn_script_url = 'http://other-cdn.aloha-editor.org/latest/lib/aloha.js'
26
+ expect(Aloha::Rails::Cdn.cdn_script_url).to eq('http://other-cdn.aloha-editor.org/latest/lib/aloha.js')
27
+
28
+ Aloha::Rails::Cdn.cdn_stylesheet_url = 'http://other-cdn.aloha-editor.org/latest/css/aloha.css'
29
+ expect(Aloha::Rails::Cdn.cdn_stylesheet_url).to eq('http://other-cdn.aloha-editor.org/latest/css/aloha.css')
30
+
31
+ Aloha::Rails::Cdn.cdn_requirejs_url = 'http://other-cdn.aloha-editor.org/latest/lib/require.js'
32
+ expect(Aloha::Rails::Cdn.cdn_requirejs_url).to eq('http://other-cdn.aloha-editor.org/latest/lib/require.js')
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+ context '#aloha_requirejs_cdn' do
39
+
40
+ it 'returns a javascript tag' do
41
+ expect(aloha_requirejs_cdn).to match(%r{<script.+type="text/javascript"></script>})
42
+ end
43
+
44
+ it 'script src is equal to .cdn_requirejs_url' do
45
+ Aloha::Rails::Cdn.cdn_requirejs_url = 'cdn-requirejs-url' # TODO stub
46
+ expect(aloha_requirejs_cdn).to match(%r{src="cdn-requirejs-url"})
47
+ end
48
+
49
+ end
50
+
51
+ context '#aloha_dependencies_cdn' do
52
+
53
+ it 'returns #aloha_jquery_cdn, #aloha_requirejs_cdn' do
54
+ self.should_receive(:aloha_requirejs_cdn) { '<requirejs>' }
55
+ expect(aloha_dependencies_cdn).to eq('<requirejs>')
56
+ end
57
+
58
+ end
59
+
60
+ context '#aloha_cdn' do
61
+
62
+ context 'with no options' do
63
+ it 'returns #aloha_script_tag_url, #aloha_stylesheet_tag_url' do
64
+ self.should_receive(:aloha_script_tag_url).with(self.cdn_script_url, {}) { '<script>' }
65
+ self.should_receive(:aloha_stylesheet_tag_url).with(self.cdn_stylesheet_url, {}) { '<stylesheet>' }
66
+ expect(aloha_cdn).to eq('<script><stylesheet>')
67
+ end
68
+ end
69
+
70
+ context 'with some options' do
71
+ it 'returns #aloha_script_tag_url, #aloha_stylesheet_tag_url with these options' do
72
+ self.should_receive(:aloha_script_tag_url).with(self.cdn_script_url, 'some-script-option' => 'some-script-option-value') { '<script>' }
73
+ self.should_receive(:aloha_stylesheet_tag_url).with(self.cdn_stylesheet_url, 'some-stylesheet-option' => 'some-stylesheet-option-value') { '<stylesheet>' }
74
+ expect(aloha_cdn(
75
+ script: { 'some-script-option' => 'some-script-option-value' },
76
+ stylesheet: {'some-stylesheet-option' => 'some-stylesheet-option-value' },
77
+ )).to eq('<script><stylesheet>')
78
+ end
79
+ end
80
+ end
81
+
82
+ context '#aloha_require_cdn' do
83
+
84
+ context 'with no options' do
85
+ it 'returns #aloha_require' do
86
+ self.should_receive(:aloha_require).with(self.cdn_base_url, {}) { '<aloha_require>' }
87
+ expect(aloha_require_cdn).to eq('<aloha_require>')
88
+ end
89
+ end
90
+
91
+ context 'with some options' do
92
+ it 'returns #aloha_require with these options' do
93
+ self.should_receive(:aloha_require).with(self.cdn_base_url, 'some-option' => 'some-script-value') { '<aloha_require>' }
94
+ expect(aloha_require_cdn('some-option' => 'some-script-value')).to eq('<aloha_require>')
95
+ end
96
+ end
97
+
98
+ end
99
+
100
+ end
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+
3
+ describe Aloha::Rails::Helpers do
4
+
5
+ include ActionView::Helpers::TagHelper
6
+ include ActionView::Helpers::JavaScriptHelper
7
+ include Aloha::Rails::Helpers
8
+
9
+ context '#aloha_script_tag_url' do
10
+
11
+ it 'returns a javascript tag' do
12
+ expect(aloha_script_tag_url('some-url')).to match(%r{<script.+type="text/javascript"></script>})
13
+ end
14
+
15
+ context 'with valid (String) url and no options' do
16
+ it 'returns #aloha_script_tag with this url' do
17
+ expect(aloha_script_tag_url('some-url')).to match(%r{src="some-url"})
18
+ end
19
+ end
20
+
21
+ context 'with valid (String) url and some options' do
22
+ it 'returns #aloha_script_tag with this url and these options' do
23
+ res = aloha_script_tag_url('some-url', 'other-option' => 'other-option-value')
24
+ expect(res).to match(%r{src="some-url"})
25
+ expect(res).to match(%r{other-option="other-option-value"})
26
+ end
27
+ end
28
+
29
+ context 'with non-valid (non-String) url' do
30
+ it 'raises TypeError exception' do
31
+ expect { aloha_script_tag_url(Math::PI) }.to raise_error(TypeError, 'url must be a String')
32
+ end
33
+ end
34
+
35
+ context 'with custom options' do
36
+ it 'uses these options' do
37
+ expect(aloha_script_tag_url('some-url', 'other-option' => 'other-option-value')).to match(%r{other-option="other-option-value"})
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ context '#aloha_stylesheet_tag_url' do
44
+
45
+ it 'returns a stylesheet tag' do
46
+ expect(aloha_stylesheet_tag_url('some-url')).to match(%r{<link.+rel="stylesheet" type="text/css">})
47
+ end
48
+
49
+ context 'with valid (String) url and no options' do
50
+ it 'returns #aloha_stylesheet_tag with this url' do
51
+ expect(aloha_stylesheet_tag_url('some-url')).to match(%r{href="some-url"})
52
+ end
53
+ end
54
+
55
+ context 'with valid (String) url and some options' do
56
+ it 'returns #aloha_stylesheet_tag with this url and these options' do
57
+ res = aloha_stylesheet_tag_url('some-url', 'other-option' => 'other-option-value')
58
+ expect(res).to match(%r{href="some-url"})
59
+ expect(res).to match(%r{other-option="other-option-value"})
60
+ end
61
+ end
62
+
63
+ context 'with non-valid (non-String) url' do
64
+ it 'raises TypeError exception' do
65
+ expect { aloha_stylesheet_tag_url(Math::PI) }.to raise_error(TypeError, 'url must be a String')
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+ context '#aloha_require' do
72
+
73
+ context 'with valid (String) url and no options' do
74
+ it 'returns a javascript tag' do
75
+ expect(aloha_require('some-url')).to match(%r{<script type="text/javascript">})
76
+ end
77
+ end
78
+
79
+ context 'with non-valid (non-String) url' do
80
+ it 'raises TypeError exception' do
81
+ expect { aloha_require(Math::PI) }.to raise_error(TypeError, 'url must be a String')
82
+ end
83
+ end
84
+
85
+ end
86
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe Aloha::Rails::Local do
4
+
5
+ include ActionView::Helpers::TagHelper
6
+ include ActionView::Helpers::JavaScriptHelper
7
+ include Aloha::Rails::Helpers
8
+
9
+ context 'url settings' do
10
+
11
+ context 'defaults' do
12
+ it 'has Aloha Editor\'s CDN urls' do
13
+ expect(Aloha::Rails::Local.local_base_url).to eq('http://local.aloha-editor.org/latest')
14
+ expect(Aloha::Rails::Local.local_script_url).to eq('http://local.aloha-editor.org/latest/lib/aloha.js')
15
+ expect(Aloha::Rails::Local.local_stylesheet_url).to eq('http://local.aloha-editor.org/latest/css/aloha.css')
16
+ end
17
+ end
18
+
19
+ context 'configuring' do
20
+ it 'should be configurable' do
21
+ Aloha::Rails::Local.local_base_url = 'http://other-local.aloha-editor.org'
22
+ expect(Aloha::Rails::Local.local_base_url).to eq('http://other-local.aloha-editor.org')
23
+
24
+ Aloha::Rails::Local.local_script_url = 'http://other-local.aloha-editor.org/latest/lib/aloha.js'
25
+ expect(Aloha::Rails::Local.local_script_url).to eq('http://other-local.aloha-editor.org/latest/lib/aloha.js')
26
+
27
+ Aloha::Rails::Local.local_stylesheet_url = 'http://other-local.aloha-editor.org/latest/css/aloha.css'
28
+ expect(Aloha::Rails::Local.local_stylesheet_url).to eq('http://other-local.aloha-editor.org/latest/css/aloha.css')
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ context '#aloha_local' do
35
+
36
+ context 'with no options' do
37
+ it 'returns #aloha_script_tag_url, #aloha_stylesheet_tag_url' do
38
+ self.should_receive(:aloha_script_tag_url).with(self.local_script_url, {}) { '<script>' }
39
+ self.should_receive(:aloha_stylesheet_tag_url).with(self.local_stylesheet_url, {}) { '<stylesheet>' }
40
+ expect(aloha_local).to eq('<script><stylesheet>')
41
+ end
42
+ end
43
+
44
+ context 'with some options' do
45
+ it 'returns #aloha_script_tag_url, #aloha_stylesheet_tag_url with these options' do
46
+ self.should_receive(:aloha_script_tag_url).with(self.local_script_url, 'some-script-option' => 'some-script-option-value') { '<script>' }
47
+ self.should_receive(:aloha_stylesheet_tag_url).with(self.local_stylesheet_url, 'some-stylesheet-option' => 'some-stylesheet-option-value') { '<stylesheet>' }
48
+ expect(aloha_local(
49
+ script: { 'some-script-option' => 'some-script-option-value' },
50
+ stylesheet: {'some-stylesheet-option' => 'some-stylesheet-option-value' },
51
+ )).to eq('<script><stylesheet>')
52
+ end
53
+ end
54
+ end
55
+
56
+ context '#aloha_require_local' do
57
+
58
+ context 'with no options' do
59
+ it 'returns #aloha_require' do
60
+ self.should_receive(:aloha_require).with(self.local_base_url, {}) { '<aloha_require>' }
61
+ expect(aloha_require_local).to eq('<aloha_require>')
62
+ end
63
+ end
64
+
65
+ context 'with some options' do
66
+ it 'returns #aloha_require with these options' do
67
+ self.should_receive(:aloha_require).with(self.local_base_url, 'some-option' => 'some-script-value') { '<aloha_require>' }
68
+ expect(aloha_require_local('some-option' => 'some-script-value')).to eq('<aloha_require>')
69
+ end
70
+ end
71
+ end
72
+
73
+ end
@@ -0,0 +1 @@
1
+ require 'spec_helper'
@@ -0,0 +1,17 @@
1
+ require 'bundler'
2
+
3
+ Bundler.setup
4
+
5
+ require 'active_support'
6
+ require 'action_pack'
7
+ require 'action_view'
8
+
9
+ require File.expand_path(File.join(File.dirname(__FILE__), '../lib/aloha-rails-improved'))
10
+
11
+ # Requires supporting files with custom matchers and macros, etc,
12
+ # in ./support/ and its subdirectories in alphabetic order.
13
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
14
+
15
+ RSpec.configure do |config|
16
+
17
+ end
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aloha-rails-improved
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kurakin Alexander
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: actionpack
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '3.0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '3.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.12'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.12'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec-rails
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '2.12'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '2.12'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '10.0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '10.0'
94
+ description: Aloha Editor in Rails
95
+ email: kuraga333@mail.ru
96
+ executables: []
97
+ extensions: []
98
+ extra_rdoc_files: []
99
+ files:
100
+ - .gitignore
101
+ - CHANGELOG.md
102
+ - Gemfile
103
+ - LICENSE
104
+ - README.md
105
+ - Rakefile
106
+ - aloha-rails-improved.gemspec
107
+ - lib/aloha-rails-improved.rb
108
+ - lib/aloha/rails.rb
109
+ - lib/aloha/rails/cdn.rb
110
+ - lib/aloha/rails/helpers.rb
111
+ - lib/aloha/rails/local.rb
112
+ - lib/aloha/rails/railtie.rb
113
+ - lib/aloha/rails/version.rb
114
+ - lib/generators/aloha/install/USAGE
115
+ - lib/generators/aloha/install/install_generator.rb
116
+ - lib/generators/aloha/install/templates/aloha-config.js
117
+ - lib/generators/aloha/install/templates/aloha-config.js.coffee
118
+ - lib/tasks/aloha/update.rake
119
+ - spec/aloha/rails/cdn/aloha_cdn_spec.rb
120
+ - spec/aloha/rails/helpers/helpers_spec.rb
121
+ - spec/aloha/rails/local/aloha_local_spec.rb
122
+ - spec/aloha/rails_spec.rb
123
+ - spec/spec_helper.rb
124
+ homepage: https://github.com/kuraga/aloha-rails-improved
125
+ licenses: []
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 1.8.25
145
+ signing_key:
146
+ specification_version: 3
147
+ summary: Provides the Aloha Editor for your Rails 3 app
148
+ test_files:
149
+ - spec/aloha/rails/cdn/aloha_cdn_spec.rb
150
+ - spec/aloha/rails/helpers/helpers_spec.rb
151
+ - spec/aloha/rails/local/aloha_local_spec.rb
152
+ - spec/aloha/rails_spec.rb
153
+ - spec/spec_helper.rb