hallo_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/hallo_rails.gemspec +19 -0
- data/lib/hallo_rails/version.rb +3 -0
- data/lib/hallo_rails.rb +48 -0
- data/vendor/assets/javascripts/hallo.js +2810 -0
- data/vendor/assets/javascripts/hallo_rails.js.coffee +48 -0
- data/vendor/assets/javascripts/rangy-core.js +94 -0
- metadata +78 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Nico
|
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,29 @@
|
|
1
|
+
# HalloRails
|
2
|
+
|
3
|
+
Full readme coming soon...
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'hallo_rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install hallo_rails
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/hallo_rails.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/hallo_rails/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Nico"]
|
6
|
+
gem.email = ["nico.ritsche@gmail.com"]
|
7
|
+
gem.description = %q{ Use the Hallo editor to edit content in a Rails app. }
|
8
|
+
gem.summary = %q{ Use the Hallo editor to edit content in a Rails app. }
|
9
|
+
gem.homepage = ""
|
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 = "hallo_rails"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = HalloRails::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'rails', '>= 3.1.0'
|
19
|
+
end
|
data/lib/hallo_rails.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "hallo_rails/version"
|
2
|
+
|
3
|
+
class Railtie < Rails::Railtie
|
4
|
+
initializer "hallo_rails.view_helpers" do
|
5
|
+
ActionView::Base.send :include, HalloRails::ViewHelpers
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
module HalloRails
|
11
|
+
|
12
|
+
module Rails
|
13
|
+
class Engine < ::Rails::Engine
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module ViewHelpers
|
18
|
+
|
19
|
+
def editable object, method, options = {}
|
20
|
+
object_name = object.class.to_s.underscore
|
21
|
+
options.reverse_merge! tag: :div,
|
22
|
+
content: object.send(method),
|
23
|
+
update_url: "#{locale_prefix}/#{object_name.pluralize}/#{object.to_param}",
|
24
|
+
blank_text: "<i>Click to Edit</i>".html_safe
|
25
|
+
|
26
|
+
content_tag options[:tag], options[:content].present? ? options[:content] : options[:blank_text],
|
27
|
+
class: "#{'editable' if !options.has_key?(:editable) or options[:editable]}",
|
28
|
+
id: "#{object_name}_#{method.to_s}",
|
29
|
+
data: { update_url: options[:update_url], model: object_name, method: method.to_s }
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def form_editable object, method, options = {}
|
34
|
+
object_name = object.class.to_s.underscore
|
35
|
+
options.reverse_merge! tag: :div,
|
36
|
+
content: object.send(method),
|
37
|
+
blank_text: "<i>Click to Edit</i>".html_safe
|
38
|
+
|
39
|
+
content_tag( options[:tag], options[:content].present? ? options[:content] : options[:blank_text],
|
40
|
+
class: 'form_editable',
|
41
|
+
id: "#{object_name}_#{method.to_s}",
|
42
|
+
data: { model: object_name, method: method.to_s }) +
|
43
|
+
text_area_tag( "#{object_name}[#{method}]", options[:content], style: "display:none" )
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|