-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f940171
Showing
11 changed files
with
3,097 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
*.gem | ||
*.rbc | ||
.bundle | ||
.config | ||
.yardoc | ||
.idea | ||
Gemfile.lock | ||
InstalledFiles | ||
_yardoc | ||
coverage | ||
doc/ | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in hallo_rails.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2012 Nico | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# HalloRails | ||
|
||
Full readme coming soon... | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
gem 'hallo_rails' | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install hallo_rails | ||
|
||
## Usage | ||
|
||
TODO: Write usage instructions here | ||
|
||
## Contributing | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Added some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create new Pull Request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env rake | ||
require "bundler/gem_tasks" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- encoding: utf-8 -*- | ||
require File.expand_path('../lib/hallo_rails/version', __FILE__) | ||
|
||
Gem::Specification.new do |gem| | ||
gem.authors = ["Nico"] | ||
gem.email = ["[email protected]"] | ||
gem.description = %q{ Use the Hallo editor to edit content in a Rails app. } | ||
gem.summary = %q{ Use the Hallo editor to edit content in a Rails app. } | ||
gem.homepage = "" | ||
|
||
gem.files = `git ls-files`.split($\) | ||
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } | ||
gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) | ||
gem.name = "hallo_rails" | ||
gem.require_paths = ["lib"] | ||
gem.version = HalloRails::VERSION | ||
|
||
gem.add_dependency 'rails', '>= 3.1.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require "hallo_rails/version" | ||
|
||
class Railtie < Rails::Railtie | ||
initializer "hallo_rails.view_helpers" do | ||
ActionView::Base.send :include, HalloRails::ViewHelpers | ||
end | ||
end | ||
|
||
|
||
module HalloRails | ||
|
||
module Rails | ||
class Engine < ::Rails::Engine | ||
end | ||
end | ||
|
||
module ViewHelpers | ||
|
||
def editable object, method, options = {} | ||
object_name = object.class.to_s.underscore | ||
options.reverse_merge! tag: :div, | ||
content: object.send(method), | ||
update_url: "#{locale_prefix}/#{object_name.pluralize}/#{object.to_param}", | ||
blank_text: "<i>Click to Edit</i>".html_safe | ||
|
||
content_tag options[:tag], options[:content].present? ? options[:content] : options[:blank_text], | ||
class: "#{'editable' if !options.has_key?(:editable) or options[:editable]}", | ||
id: "#{object_name}_#{method.to_s}", | ||
data: { update_url: options[:update_url], model: object_name, method: method.to_s } | ||
end | ||
|
||
|
||
def form_editable object, method, options = {} | ||
object_name = object.class.to_s.underscore | ||
options.reverse_merge! tag: :div, | ||
content: object.send(method), | ||
blank_text: "<i>Click to Edit</i>".html_safe | ||
|
||
content_tag( options[:tag], options[:content].present? ? options[:content] : options[:blank_text], | ||
class: 'form_editable', | ||
id: "#{object_name}_#{method.to_s}", | ||
data: { model: object_name, method: method.to_s }) + | ||
text_area_tag( "#{object_name}[#{method}]", options[:content], style: "display:none" ) | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module HalloRails | ||
VERSION = "0.0.1" | ||
end |
Oops, something went wrong.