simply_load 0.0.2
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 +4 -0
- data/Gemfile +4 -0
- data/README +26 -0
- data/Rakefile +1 -0
- data/app/helpers/simply_load_helper.rb +14 -0
- data/lib/generators/simply_load/USAGE +8 -0
- data/lib/generators/simply_load/simply_load_generator.rb +8 -0
- data/lib/generators/simply_load/templates/simply_load.js +12 -0
- data/lib/simply_load/version.rb +3 -0
- data/lib/simply_load.rb +8 -0
- data/simply_load.gemspec +21 -0
- metadata +75 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Simply load is really just a short way to write a JQuery load method to populate a page.
|
2
|
+
|
3
|
+
Why did I make a gem out of this little thing? I just thought it was fun to load pieces of html at random or have a little form widget without having to actually instantiate the object on a completely unrelated controller method.
|
4
|
+
Anyway, hope you guys like it and sure there is always room for improvement.
|
5
|
+
|
6
|
+
Installing:
|
7
|
+
|
8
|
+
Add this to you Gemfile:
|
9
|
+
|
10
|
+
gem 'simply_load'
|
11
|
+
|
12
|
+
The run:
|
13
|
+
|
14
|
+
bundle install
|
15
|
+
|
16
|
+
As simply_load uses some javascript files, you will require to install them for use:
|
17
|
+
|
18
|
+
rails g simply_load
|
19
|
+
|
20
|
+
Using:
|
21
|
+
|
22
|
+
On any of your views just use this code:
|
23
|
+
|
24
|
+
<%= simply_load url_to_load, "Loading content if no block is provided", {other options} %>
|
25
|
+
|
26
|
+
Hope you like it!!
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module SimplyLoadHelper
|
2
|
+
|
3
|
+
def simply_load(url, content_or_options_with_block = nil, options = {}, escape = true, &block)
|
4
|
+
options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) and block_given?
|
5
|
+
options[:class] = "#{options[:class]} simply_load".strip
|
6
|
+
options.merge!(:"data-href" => url)
|
7
|
+
if block_given?
|
8
|
+
content_tag :div, capture(&block), options, escape
|
9
|
+
else
|
10
|
+
content_tag :div, content_or_options_with_block, options, escape
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Description:
|
2
|
+
This will copy the required javascript file to the Rails application ("public/javascripts/simply_load.js" or "app/assets/javascripts/simply_load.js")
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails generate simply_load
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
public/javascripts/simply_load.js or app/assets/javascripts/simply_load.js
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class SimplyLoadGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
4
|
+
def generate_javascript
|
5
|
+
copy_file "simply_load.js", (Rails::VERSION::STRING.starts_with?("3.1") ? "app/assets/javascripts/simply_load.js" : "public/javascripts/simply_load.js")
|
6
|
+
end
|
7
|
+
|
8
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
$(document).ready(function() {
|
2
|
+
|
3
|
+
// Load content into the elements with the auto_load class via Ajax
|
4
|
+
auto_load_content($(this));
|
5
|
+
|
6
|
+
});
|
7
|
+
|
8
|
+
function auto_load_content(element){
|
9
|
+
$.each($(element.find('.simply_load')), function(){
|
10
|
+
$(this).load($(this).attr('data-href'));
|
11
|
+
});
|
12
|
+
}
|
data/lib/simply_load.rb
ADDED
data/simply_load.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "simply_load/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "simply_load"
|
7
|
+
s.version = SimplyLoad::VERSION
|
8
|
+
s.authors = ["Firebait"]
|
9
|
+
s.email = ["marcotapiag@gmail.com"]
|
10
|
+
s.homepage = "http://firebait.com"
|
11
|
+
s.summary = %q{simply_load adds a view helper method that simplyfies the loading of content via ajax. Very useful when you need to create a complex view with multiple instances of objects and models.}
|
12
|
+
s.description = %q{simply_load adds a view helper method that simplyfies the loading of content via ajax.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "simply_load"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.add_dependency('jquery-rails')
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simply_load
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.2
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Firebait
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-07-13 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: jquery-rails
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
description: simply_load adds a view helper method that simplyfies the loading of content via ajax.
|
27
|
+
email:
|
28
|
+
- marcotapiag@gmail.com
|
29
|
+
executables: []
|
30
|
+
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files: []
|
34
|
+
|
35
|
+
files:
|
36
|
+
- .gitignore
|
37
|
+
- Gemfile
|
38
|
+
- README
|
39
|
+
- Rakefile
|
40
|
+
- app/helpers/simply_load_helper.rb
|
41
|
+
- lib/generators/simply_load/USAGE
|
42
|
+
- lib/generators/simply_load/simply_load_generator.rb
|
43
|
+
- lib/generators/simply_load/templates/simply_load.js
|
44
|
+
- lib/simply_load.rb
|
45
|
+
- lib/simply_load/version.rb
|
46
|
+
- simply_load.gemspec
|
47
|
+
homepage: http://firebait.com
|
48
|
+
licenses: []
|
49
|
+
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project: simply_load
|
70
|
+
rubygems_version: 1.8.5
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: simply_load adds a view helper method that simplyfies the loading of content via ajax. Very useful when you need to create a complex view with multiple instances of objects and models.
|
74
|
+
test_files: []
|
75
|
+
|