hallo_rails 0.0.1

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,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .idea
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hallo_rails.gemspec
4
+ gemspec
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
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -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
@@ -0,0 +1,3 @@
1
+ module HalloRails
2
+ VERSION = "0.0.1"
3
+ end
@@ -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