motr 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +26 -0
- data/Rakefile +34 -0
- data/app/helpers/motr_helper.rb +7 -0
- data/lib/config/locales/en.yml +3 -0
- data/lib/motr.rb +20 -0
- data/lib/motr/errors/invalid_options.rb +13 -0
- data/lib/motr/errors/motr_error.rb +19 -0
- data/lib/motr/forms.rb +31 -0
- data/lib/motr/forms/base.rb +18 -0
- data/lib/motr/forms/builder.rb +28 -0
- data/lib/motr/forms/helpers.rb +30 -0
- data/lib/motr/helpers/layout_helpers.rb +153 -0
- data/lib/motr/helpers/navigation.rb +104 -0
- data/lib/motr/rails.rb +10 -0
- data/lib/motr/version.rb +3 -0
- metadata +141 -0
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 Brent Kirby / kurb media, llc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
= Motr
|
2
|
+
|
3
|
+
{Official Documentation}[http://rubydoc.info/github/kurbmedia/motr/master/frames]
|
4
|
+
|
5
|
+
Motr is a basic Rails engine which adds additional functionality to your applications. The {core Motr}[http://github.com/kurbmedia/motr] engine
|
6
|
+
provides a number of helpers and functionality geared towards bringing the ease of Rails back-end development, to the front-end.
|
7
|
+
|
8
|
+
Rails view helpers and form builders are convenient an easy to use, however some aren't very design/html friendly (whose idea was it to
|
9
|
+
wrap fields with errors in a div?). The goal is to keep html valid and sensible where possible, and make things like javascript integration
|
10
|
+
easier and more efficient.
|
11
|
+
|
12
|
+
Additional documentation will be provided shortly, as a few final methods are added. For now check out the
|
13
|
+
documentation provided at {rubydoc.info}[http://rubydoc.info/github/kurbmedia/motr/master/frames].
|
14
|
+
|
15
|
+
== Contributing
|
16
|
+
|
17
|
+
Motr is maintained and funded by {kurb media}[http://kurbmedia.com/], and was designed for our own internal use, so (like Rails itself), it is
|
18
|
+
opinionated in how it works. However, additions / enhancements / alternative methods are more than welcome and encouraged. We also welcome
|
19
|
+
feature requests, especially from designers/front-end developers who spend a lot of time working along-side Rails developers.
|
20
|
+
|
21
|
+
== License
|
22
|
+
|
23
|
+
Motr is Copyright © 2010-2011 kurb media, llc.
|
24
|
+
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file. Donations in the form of beer, cash, or
|
25
|
+
1980's movie memorabilia are welcomed (and encouraged!).
|
26
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
Bundler::GemHelper.install_tasks
|
10
|
+
|
11
|
+
require 'rake'
|
12
|
+
require 'rake/rdoctask'
|
13
|
+
|
14
|
+
require 'rspec/core'
|
15
|
+
require 'rspec/core/rake_task'
|
16
|
+
|
17
|
+
RSpec::Core::RakeTask.new(:spec)
|
18
|
+
|
19
|
+
task :default => :spec
|
20
|
+
|
21
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
22
|
+
rdoc.rdoc_dir = 'rdoc'
|
23
|
+
rdoc.title = 'motr'
|
24
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
25
|
+
rdoc.rdoc_files.include('README.rdoc')
|
26
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
desc "Run watchr"
|
32
|
+
task :watchr do
|
33
|
+
`watchr .watchr`
|
34
|
+
end
|
data/lib/motr.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'active_support/dependencies'
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
module Motr
|
6
|
+
|
7
|
+
module Helpers
|
8
|
+
autoload :LayoutHelpers, 'motr/helpers/layout_helpers'
|
9
|
+
autoload :Navigation, 'motr/helpers/navigation'
|
10
|
+
end
|
11
|
+
|
12
|
+
module Errors
|
13
|
+
autoload :MotrError, 'motr/errors/motr_error'
|
14
|
+
autoload :InvalidOptions, 'motr/errors/invalid_options'
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'motr/forms'
|
20
|
+
require 'motr/rails'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Motr #:nodoc
|
2
|
+
module Errors #:nodoc
|
3
|
+
|
4
|
+
# Default parent Motr error for all custom errors. This handles the base
|
5
|
+
# key for the translations and provides the convenience method for
|
6
|
+
# translating the messages.
|
7
|
+
class MotrError < StandardError
|
8
|
+
BASE_KEY = "motr.errors"
|
9
|
+
##
|
10
|
+
# Translate an error message
|
11
|
+
# @param [String] key The i18n message key
|
12
|
+
# @param [Hash] options Options to pass to the i18n library
|
13
|
+
#
|
14
|
+
def translate(key, options)
|
15
|
+
::I18n.translate("#{BASE_KEY}.#{key}", options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/motr/forms.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Motr
|
2
|
+
|
3
|
+
module Forms
|
4
|
+
|
5
|
+
autoload :Base, 'motr/forms/base'
|
6
|
+
autoload :Helpers, 'motr/forms/helpers'
|
7
|
+
autoload :Builder, 'motr/forms/builder'
|
8
|
+
|
9
|
+
# The class to be applied to the wrapper that wraps the entire field
|
10
|
+
mattr_accessor :error_class
|
11
|
+
@@error_class = 'field_with_errors'
|
12
|
+
|
13
|
+
# The class to be applied to the error message element
|
14
|
+
mattr_accessor :message_error_class
|
15
|
+
@@message_error_class = 'errors_for_field'
|
16
|
+
|
17
|
+
# An ERB template to be used when rendering a field with errors
|
18
|
+
mattr_accessor :error_template
|
19
|
+
@@error_template = %{
|
20
|
+
<span class="<%= error_class %>">
|
21
|
+
<%= html_tag %>
|
22
|
+
<span class="<%= message_error_class %>"><%= [messages].flatten.join(",") %></span>
|
23
|
+
</span>}
|
24
|
+
|
25
|
+
# Setup the default form builder
|
26
|
+
mattr_accessor :default_builder
|
27
|
+
@@default_builder = Motr::Forms::Builder
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Motr
|
2
|
+
|
3
|
+
module Forms
|
4
|
+
|
5
|
+
class Base < ActionView::Helpers::FormBuilder
|
6
|
+
|
7
|
+
def render_field_with_errors(html_tag, messages)
|
8
|
+
error_class = Motr::Forms.error_class
|
9
|
+
message_error_class = Motr::Forms.message_error_class
|
10
|
+
render_binding = binding
|
11
|
+
renderer = ERB.new(Motr::Forms.error_template)
|
12
|
+
renderer.result(render_binding).to_s.html_safe
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Motr
|
2
|
+
|
3
|
+
module Forms
|
4
|
+
##
|
5
|
+
#
|
6
|
+
# Default Motr form builder. Extends the passed input tags to include additional
|
7
|
+
# html attributes, primarily for javascript integration.
|
8
|
+
#
|
9
|
+
class Builder < Motr::Forms::Base
|
10
|
+
|
11
|
+
# Access the template object
|
12
|
+
attr_accessor :template
|
13
|
+
# Tracks the order in which fields are used in the form, this allows the easy rebuilding of the submitted form
|
14
|
+
# data when submitted since normally the hash isn't ordered.
|
15
|
+
attr_accessor :field_order
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
# Convenience method to use the +content_tag+ method from our template
|
20
|
+
#
|
21
|
+
def content_tag(tag, content, options = {}, escape = true, &block) #:nodoc:
|
22
|
+
@template.content_tag(tag, content, options, escape, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Motr
|
2
|
+
module Forms
|
3
|
+
##
|
4
|
+
#
|
5
|
+
# # Custom form helpers and modifications
|
6
|
+
#
|
7
|
+
module Helpers
|
8
|
+
|
9
|
+
##
|
10
|
+
#
|
11
|
+
# Cusomizes the default form_for helper to add additional functionality
|
12
|
+
# (see ActionView::Helpers::FormHelper for more information)
|
13
|
+
#
|
14
|
+
# @option options [Boolean] :validate Adds a data-validatable attribute to the form for javascript hooks
|
15
|
+
#
|
16
|
+
def motr_form(record, options = {}, &block)
|
17
|
+
|
18
|
+
raise ArgumentError, "Missing block" unless block_given?
|
19
|
+
|
20
|
+
options.reverse_merge!(:builder => Motr::Forms.default_builder)
|
21
|
+
options[:html] ||= {}
|
22
|
+
options[:html].merge!('data-validatable' => true) if options.delete(:validate)
|
23
|
+
form_for(record, options, &block)
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
module Motr
|
2
|
+
module Helpers
|
3
|
+
##
|
4
|
+
#
|
5
|
+
# # Convenience helpers generally used in layout files
|
6
|
+
#
|
7
|
+
module LayoutHelpers
|
8
|
+
|
9
|
+
##
|
10
|
+
# Include javascript libraries from local and external resources.
|
11
|
+
# This method extends +javascript_include_tag+ to support loading libraries from sources
|
12
|
+
# such as Google's CDN, or javascripts packaged by motr
|
13
|
+
#
|
14
|
+
# When loading libraries from Google CDN, uncompressed versions will be used in any environment
|
15
|
+
# besides production. In production environments, minified versions will be used.
|
16
|
+
#
|
17
|
+
# @param [Array] *args An argument list containing a the libraries to load, and any load options
|
18
|
+
# @return [String] A javscript "script" tag
|
19
|
+
# @example
|
20
|
+
# include_javascripts(:jquery => '5.0', :source => :google) #=> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"...
|
21
|
+
#
|
22
|
+
def include_javascripts(*args)
|
23
|
+
|
24
|
+
options = args.extract_options!
|
25
|
+
source = options.delete(:source)
|
26
|
+
cache = options.delete(:cache) || false
|
27
|
+
|
28
|
+
if !source.nil? && source.to_s.match(/google/i) && !args.empty?
|
29
|
+
raise Motr::Errors::InvalidOptions.new("When using Google as a :source, all arguments must be in the hash format { :library => :version }.")
|
30
|
+
elsif source.nil? && args.empty? && !options.empty?
|
31
|
+
raise Motr::Errors::InvalidOptions.new("Missing :source attribute for `include_javascripts`. When passing a library/version hash as an argument, a source (cdn) is required.")
|
32
|
+
end
|
33
|
+
|
34
|
+
response = ""
|
35
|
+
|
36
|
+
unless source.nil?
|
37
|
+
options.stringify_keys!.each do |lib|
|
38
|
+
response << javascript_include_tag(js_load_path(*lib), :cache => false)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
response << javascript_include_tag(*args.map(&:to_s), :cache => cache)
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
#
|
47
|
+
# Allows easy assigning of meta tags from templates
|
48
|
+
# @param [Symbol] name Name of the meta tag (ie: keywords / description)
|
49
|
+
# @param [String] content The content to be used in the meta tag
|
50
|
+
# @return [String] A html meta tag with the name and content attributes set
|
51
|
+
#
|
52
|
+
def meta_tag(name, content = nil)
|
53
|
+
return _retrieve_variable(:"__#{name}") if content.nil?
|
54
|
+
content = tag(:meta, :name => name, :content => content)
|
55
|
+
_create_variable(:"__#{name}", content, false)
|
56
|
+
content
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
#
|
61
|
+
# Creates a page id to be used for identifying a page for CSS/design purposes. If a variable
|
62
|
+
# is defined, it will be used. If not, one will be generated from the current controller/action.
|
63
|
+
#
|
64
|
+
# @param [String] content The string to be used as the page id.
|
65
|
+
# @return [String] The assigned page id
|
66
|
+
# @example Create a page_id and use it in the body tag
|
67
|
+
# <%= page_id('home') %>
|
68
|
+
#
|
69
|
+
# <body id="<%= page_id %>"> #=> <body id="home">
|
70
|
+
#
|
71
|
+
# @example Defaulting page id to controller/action
|
72
|
+
# # IndexController#home
|
73
|
+
# <body id="<%= page_id %>"> #=> <body id="index_home">
|
74
|
+
#
|
75
|
+
#
|
76
|
+
def page_id(content = nil)
|
77
|
+
_create_variable(:__page_id, content, false) and return unless content.nil?
|
78
|
+
return _retrieve_variable(:__page_id) if content_for?(:__page_id)
|
79
|
+
cname = controller.class.to_s.gsub(/controller$/i,'').underscore.split("/").join('_')
|
80
|
+
aname = controller.action_name
|
81
|
+
"#{cname}_#{aname}"
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
#
|
86
|
+
# Convenience method for content_for allowing for single-line variable creation. Also defines a method that can be
|
87
|
+
# re-used within a template.
|
88
|
+
#
|
89
|
+
# @param [Symbol] var_name The name of the variable to create
|
90
|
+
# @param [String] content The content that variable defines
|
91
|
+
# @return [String] An empty string. Use the newly created method from +var_name+ to return the value
|
92
|
+
#
|
93
|
+
# @example Setting a "page_class" variable
|
94
|
+
# <% set_var(:page_class, 'cool') %>
|
95
|
+
# <%= page_class %> #=> 'cool'
|
96
|
+
#
|
97
|
+
#
|
98
|
+
def set_var(var_name, content)
|
99
|
+
_create_variable("#{var_name}", content) and return ''
|
100
|
+
end
|
101
|
+
|
102
|
+
##
|
103
|
+
#
|
104
|
+
# Configures a "robots" meta tag based on the rails environment. In environments other than 'production'
|
105
|
+
# it sets the value to "noindex, nofollow" for each page that uses the layout in which it is called. This
|
106
|
+
# helps prevent spiders from crawling / indexing content when used on staging sites.
|
107
|
+
#
|
108
|
+
# @return [String] A html meta tag for "robots" with the appropriate content attribute set
|
109
|
+
#
|
110
|
+
def robot_meta_tag
|
111
|
+
tag(:meta, :name => 'robots', :content => (Rails.env.eql?('production') ? 'index, follow' : 'noindex, nofollow'))
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def _create_variable(var, content, create_method = true) #:nodoc:
|
117
|
+
content_for(var.to_sym) do
|
118
|
+
content
|
119
|
+
end
|
120
|
+
return '' unless create_method
|
121
|
+
class_eval <<-MAKE_VAR, __FILE__, __LINE__ + 1
|
122
|
+
def #{var}
|
123
|
+
content_for(:#{var})
|
124
|
+
end
|
125
|
+
public :#{var}
|
126
|
+
MAKE_VAR
|
127
|
+
end
|
128
|
+
|
129
|
+
def js_load_path(libname, version) #:nodoc:
|
130
|
+
#
|
131
|
+
# @todo Make this considerably cleaner and more flexible
|
132
|
+
# possibly use google's cdn loader directly
|
133
|
+
#
|
134
|
+
minify = Rails.env.eql?('production') ? "min." : ""
|
135
|
+
google_base = "https://ajax.googleapis.com/ajax/libs/%s/%s/%s"
|
136
|
+
jqtools_base = "http://cdn.jquerytools.org/%s/all/jquery.tools.min.js"
|
137
|
+
|
138
|
+
return jqtools_base % (version || "1.2.5") if libname.downcase == "jquerytools"
|
139
|
+
|
140
|
+
filename = libname.match(/jqueryui/i) ? "jquery-ui" : libname
|
141
|
+
google_base % [libname, version, "#{filename}.#{minify}js"]
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
def _retrieve_variable(var) #:nodoc:
|
146
|
+
(content_for?(var.to_sym) ? content_for(var.to_sym) : "")
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
module Motr
|
2
|
+
module Helpers
|
3
|
+
##
|
4
|
+
#
|
5
|
+
# Convenience helpers for building navigation lists, and defining 'on' states.
|
6
|
+
#
|
7
|
+
module Navigation
|
8
|
+
|
9
|
+
##
|
10
|
+
#
|
11
|
+
# Creates a link wrapped in a list item, to be used within a list-based navigation.
|
12
|
+
#
|
13
|
+
# @param [String] text The text used within the link
|
14
|
+
# @param [String] path The url used as the link's +href+ attribute
|
15
|
+
# @param [Hash] attrs Hash of attributes to be applied to the link. This format is the same as Rail's +link_to+ helper
|
16
|
+
# @option attrs [String] :active_class The class to use if this link is 'active'. Defaults to "on"
|
17
|
+
# @option attrs [Proc] :proc A callback which, when called, determines the active state of the link
|
18
|
+
# @option attrs [Regex] :matcher A regular expression to be matched against +path+
|
19
|
+
# @param [Symbol] wrapper The html tag to be used as the wrapper. Defaults to +:li+
|
20
|
+
#
|
21
|
+
# @example Create a list item link to any page
|
22
|
+
# nav_link_to('Home Page', '/home') #=> <li><a href="/home">Home Page</a>
|
23
|
+
#
|
24
|
+
# @example 'Active state' functionality for the current page
|
25
|
+
# nav_link_to('Current Page', '/current_url') #=> <li class="on"><a href="/current_url" class="on">Current Page</a></li>
|
26
|
+
#
|
27
|
+
def nav_link_to(text, path, attrs = {}, wrapper = :li)
|
28
|
+
|
29
|
+
link_attrs = update_link_attrs(path, attrs)
|
30
|
+
wrapper_attrs = link_attrs.delete(:wrapper)
|
31
|
+
content_tag(wrapper, link_to(text, path, link_attrs), wrapper_attrs)
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
alias :nav_link :nav_link_to
|
36
|
+
|
37
|
+
##
|
38
|
+
#
|
39
|
+
# Creates a navigational list format, including a parent list / wrapper. Useful for nested list navigation
|
40
|
+
# @param [String] text The text used within the link
|
41
|
+
# @param [String] path The url used as the link's +href+ attribute
|
42
|
+
# @param [Hash] attrs Hash of attributes to be applied to the link. This format is the same as Rail's +link_to+ helper
|
43
|
+
# @option attrs [String] :active_class The class to use if this link is 'active'. Defaults to "on"
|
44
|
+
# @option attrs [Proc] :proc A callback which, when called, determines the active state of the link
|
45
|
+
# @option attrs [Regex] :matcher A regular expression to be matched against +path+
|
46
|
+
# @param [Symbol] wrapper The html tag to be used as the wrapper. Defaults to +:li+
|
47
|
+
# @param [Symbol] container The element that will be used as a container for the nested list
|
48
|
+
# @param [Block] &block A block containing the content of the nested items
|
49
|
+
#
|
50
|
+
# @example Create a nested list navigation
|
51
|
+
# navigation('Home Page', '/home') do
|
52
|
+
# nav_link_to('Sub Page', '/about')
|
53
|
+
# end
|
54
|
+
# @example
|
55
|
+
# <li><a href="/home">Home Page</a>
|
56
|
+
# <ol>
|
57
|
+
# <li><a href="/about">Sub Page</a></li>
|
58
|
+
# </ol>
|
59
|
+
# </li>
|
60
|
+
#
|
61
|
+
def navigation(text, path, attrs = {}, wrapper = :li, container = :ol, &block)
|
62
|
+
|
63
|
+
wrapper_attrs = attrs.delete(:wrapper)
|
64
|
+
parent_link = nav_link_to(text, path, attrs)
|
65
|
+
child_links = content_tag(container, capture(&block), wrapper_attrs)
|
66
|
+
link_attrs = update_link_attrs(path, attrs.merge(:wrapper => (attrs.delete(:item) || {}) ))
|
67
|
+
|
68
|
+
content_tag(wrapper, (parent_link << child_links), wrapper_attrs)
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def update_link_attrs(path, attrs)
|
75
|
+
|
76
|
+
proc = attrs.delete(:proc)
|
77
|
+
regex = attrs.delete(:matcher)
|
78
|
+
klasses = attrs.delete(:class).try(:split, ' ')
|
79
|
+
on_class = attrs.delete(:active_class) || "on"
|
80
|
+
wrapper_attrs = attrs.delete(:wrapper) || {}
|
81
|
+
wklasses = wrapper_attrs[:class].try(:split, ' ')
|
82
|
+
|
83
|
+
klasses ||= []
|
84
|
+
wklasses ||= []
|
85
|
+
|
86
|
+
if proc && proc.call(path)
|
87
|
+
klasses << on_class
|
88
|
+
wklasses << on_class
|
89
|
+
elsif regex && path.match(regex)
|
90
|
+
klasses << on_class
|
91
|
+
wklasses << on_class
|
92
|
+
end
|
93
|
+
|
94
|
+
attrs.merge!(:class => klasses.join(" ")) unless klasses.compact.empty?
|
95
|
+
wrapper_attrs.merge!(:class => wklasses.join(" ")) unless wklasses.compact.empty?
|
96
|
+
|
97
|
+
attrs.merge!(:wrapper => wrapper_attrs)
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
data/lib/motr/rails.rb
ADDED
data/lib/motr/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brent Kirby
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-30 00:00:00 -04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec-rails
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - "="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.5.0
|
24
|
+
type: :development
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mocha
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - "="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.9.12
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: capybara
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - "="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.4.0
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: watchr
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - "="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0.7"
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: activemodel
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "3.0"
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rails
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "3.0"
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *id006
|
82
|
+
description: motr is a Rails engine aimed at simplifying routine development. The core motr engine includes various helpers, utilities, and modifications to rails core.
|
83
|
+
email:
|
84
|
+
- dev@kurbmedia.com
|
85
|
+
executables: []
|
86
|
+
|
87
|
+
extensions: []
|
88
|
+
|
89
|
+
extra_rdoc_files: []
|
90
|
+
|
91
|
+
files:
|
92
|
+
- app/helpers/motr_helper.rb
|
93
|
+
- lib/config/locales/en.yml
|
94
|
+
- lib/motr/errors/invalid_options.rb
|
95
|
+
- lib/motr/errors/motr_error.rb
|
96
|
+
- lib/motr/forms/base.rb
|
97
|
+
- lib/motr/forms/builder.rb
|
98
|
+
- lib/motr/forms/helpers.rb
|
99
|
+
- lib/motr/forms.rb
|
100
|
+
- lib/motr/helpers/layout_helpers.rb
|
101
|
+
- lib/motr/helpers/navigation.rb
|
102
|
+
- lib/motr/rails.rb
|
103
|
+
- lib/motr/version.rb
|
104
|
+
- lib/motr.rb
|
105
|
+
- MIT-LICENSE
|
106
|
+
- Rakefile
|
107
|
+
- Gemfile
|
108
|
+
- README.rdoc
|
109
|
+
has_rdoc: true
|
110
|
+
homepage: http://github.com/kurbmedia/motr
|
111
|
+
licenses: []
|
112
|
+
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 1164898289255422466
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
version: "0"
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: "0"
|
133
|
+
requirements: []
|
134
|
+
|
135
|
+
rubyforge_project: motr
|
136
|
+
rubygems_version: 1.6.2
|
137
|
+
signing_key:
|
138
|
+
specification_version: 3
|
139
|
+
summary: motr is a Rails engine aimed at simplifying routine development
|
140
|
+
test_files: []
|
141
|
+
|