voidtools 0.1 → 0.2.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/Readme.md +25 -9
- data/lib/voidtools.rb +23 -15
- data/lib/voidtools/{datamapper → dm}/form_helpers.rb +0 -0
- data/lib/voidtools/dm/name_url.rb +16 -0
- data/lib/voidtools/dm/paginable.rb +26 -0
- data/lib/voidtools/sinatra/sinatra.rb +2 -0
- data/lib/voidtools/sinatra/view_helpers.rb +15 -0
- data/lib/voidtools/version.rb +1 -1
- metadata +11 -6
data/Readme.md
CHANGED
@@ -1,14 +1,30 @@
|
|
1
|
-
|
1
|
+
# Voidtools
|
2
|
+
#### growing toolset for Rails 3 dm+jquery+haml+warden setup flavored with:
|
2
3
|
|
3
|
-
|
4
|
+
---
|
4
5
|
|
5
|
-
|
6
|
-
- error_messages_for
|
6
|
+
### DataMapper
|
7
|
+
- `error_messages_for`
|
7
8
|
|
8
|
-
|
9
|
-
-
|
9
|
+
### Haml
|
10
|
+
- soon...
|
10
11
|
|
11
|
-
|
12
|
-
-
|
12
|
+
### Warden, Devise
|
13
|
+
- soon...
|
13
14
|
|
14
|
-
ruby 1.9 required
|
15
|
+
note: ruby 1.9 required
|
16
|
+
|
17
|
+
## DataMapper
|
18
|
+
### error_messages_for
|
19
|
+
|
20
|
+
in your form view:
|
21
|
+
|
22
|
+
`error_messages_for :resource`
|
23
|
+
|
24
|
+
or
|
25
|
+
|
26
|
+
`error_messages_for @resource`
|
27
|
+
|
28
|
+
### Build & install
|
29
|
+
|
30
|
+
gem build voidtools.gemspec; gem install voidtools-0.1.2.gem
|
data/lib/voidtools.rb
CHANGED
@@ -2,24 +2,32 @@ module Voidtools
|
|
2
2
|
|
3
3
|
# namespace our plugin and inherit from Rails::Railtie
|
4
4
|
# to get our plugin into the initialization process
|
5
|
-
|
5
|
+
if defined?(Rails)
|
6
|
+
class Railtie < Rails::Railtie
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
# configure our plugin on boot. other extension points such
|
9
|
+
# as configuration, rake tasks, etc, are also available
|
10
|
+
initializer "voidtools.initialize" do |app|
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
# subscribe to all rails notifications: controllers, AR, etc.
|
13
|
+
# ActiveSupport::Notifications.subscribe do |*args|
|
14
|
+
# event = ActiveSupport::Notifications::Event.new(*args)
|
15
|
+
# puts "Voidrails - got notification: #{event.inspect}"
|
16
|
+
# end
|
17
|
+
require 'voidtools/dm/form_helpers'
|
18
|
+
ActiveSupport.on_load(:action_view) do
|
19
|
+
module ApplicationHelper
|
20
|
+
include Voidtools::FormHelpers
|
21
|
+
end
|
22
|
+
end
|
23
|
+
# require 'voidtools/dm/name_url'
|
24
|
+
# require 'voidtools/dm/paginable'
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
29
|
+
if defined?(Sinatra)
|
30
|
+
path = File.expand_path "../", __FILE__
|
31
|
+
require "#{path}/voidtools/sinatra/sinatra"
|
32
|
+
end
|
25
33
|
end
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Voidtools
|
2
|
+
module NameUrl
|
3
|
+
def generate_name_url
|
4
|
+
nurl = name.gsub(/\./, '').gsub(/'|"/, ' ').gsub(/\s+/, '_').gsub(/_-_/, '_').downcase
|
5
|
+
update(name_url: nurl)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class NameUrler
|
10
|
+
def self.generate(klass, options={})
|
11
|
+
klass.all(options).each do |model|
|
12
|
+
model.generate_name_url
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Voidtools
|
2
|
+
|
3
|
+
module Paginable
|
4
|
+
|
5
|
+
PER_PAGE = 70
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
base.send :extend, ClassMethods
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def paginate(options)
|
13
|
+
page = options[:page].to_i
|
14
|
+
options.delete :page
|
15
|
+
all( options.merge(limit: PER_PAGE, offset: PER_PAGE*page) )
|
16
|
+
end
|
17
|
+
|
18
|
+
def pages
|
19
|
+
all.count/PER_PAGE
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Voidtools
|
2
|
+
module Sinatra
|
3
|
+
module ViewHelpers
|
4
|
+
def link_to(label, path)
|
5
|
+
haml_tag :a, { href: path } do
|
6
|
+
haml_concat label
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def image_tag(url, options={})
|
11
|
+
haml_tag :img, options.merge(src: url)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/voidtools/version.rb
CHANGED
metadata
CHANGED
@@ -4,8 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
9
10
|
platform: ruby
|
10
11
|
authors:
|
11
12
|
- Francesco 'makevoid' Canessa
|
@@ -13,11 +14,11 @@ autorequire:
|
|
13
14
|
bindir: bin
|
14
15
|
cert_chain: []
|
15
16
|
|
16
|
-
date: 2010-
|
17
|
+
date: 2010-12-23 00:00:00 +01:00
|
17
18
|
default_executable:
|
18
19
|
dependencies: []
|
19
20
|
|
20
|
-
description: "
|
21
|
+
description: "custom rails3 toolset setup with helpers for: datamapper, jquery, haml and warden"
|
21
22
|
email: makevoid@gmail.com
|
22
23
|
executables: []
|
23
24
|
|
@@ -27,7 +28,11 @@ extra_rdoc_files: []
|
|
27
28
|
|
28
29
|
files:
|
29
30
|
- Readme.md
|
30
|
-
- lib/voidtools/
|
31
|
+
- lib/voidtools/dm/form_helpers.rb
|
32
|
+
- lib/voidtools/dm/name_url.rb
|
33
|
+
- lib/voidtools/dm/paginable.rb
|
34
|
+
- lib/voidtools/sinatra/sinatra.rb
|
35
|
+
- lib/voidtools/sinatra/view_helpers.rb
|
31
36
|
- lib/voidtools/version.rb
|
32
37
|
- lib/voidtools.rb
|
33
38
|
has_rdoc: true
|
@@ -61,6 +66,6 @@ rubyforge_project: voidtools
|
|
61
66
|
rubygems_version: 1.3.7
|
62
67
|
signing_key:
|
63
68
|
specification_version: 3
|
64
|
-
summary:
|
69
|
+
summary: custom rails3 toolset - for dm+jquery+haml+warden setup
|
65
70
|
test_files: []
|
66
71
|
|