motr 0.0.2 → 0.0.3

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.
@@ -0,0 +1,2 @@
1
+ en:
2
+ motr:
@@ -0,0 +1,14 @@
1
+ module Motr
2
+ module Generators
3
+ class CompassGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ desc "Generates starter files in app/assets/stylesheets for using Compass in your app"
7
+
8
+ def copy_files
9
+ directory File.expand_path("../../templates/compass", __FILE__), "app/assets/stylesheets"
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ module Motr
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ desc "Creates an initializer for Motr and copy locale files to your application."
7
+
8
+ def copy_initializer
9
+ template "motr.rb", "config/initializers/motr.rb"
10
+ end
11
+
12
+ def copy_locale
13
+ copy_file "../../../config/locales/en.yml", "config/locales/motr.en.yml"
14
+ end
15
+
16
+ def show_post_install_notes
17
+ readme "post_install" if behavior == :invoke
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ module Motr
2
+ module Generators
3
+ class MotrGenerator < Rails::Generators::NamedBase
4
+ namespace "motr"
5
+ source_root File.expand_path("../templates", __FILE__)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,19 @@
1
+ /*
2
+ IE css. Because IE sucks.
3
+ */
4
+
5
+ @import "includes/base";
6
+ /////////////////////////////////////
7
+ // Disable browser specific items in
8
+ // css since this is an ie only stylesheet
9
+ /////////////////////////////////////
10
+ $experimental-support-for-mozilla:false;
11
+ $experimental-support-for-webkit:false;
12
+ $experimental-support-for-opera:false;
13
+ $experimental-support-for-khtml:false;
14
+ /////////////////////////////////////
15
+ // PIE Support
16
+ /////////////////////////////////////
17
+ $experimental-support-for-pie:true;
18
+ $pie-behavior: url("/stylesheets/PIE.htc");
19
+ @import "includes/mixins";
@@ -0,0 +1,77 @@
1
+ /*
2
+ Sets up any compass imports, as well as variables used throughout css files. This way all files can access the libraries, but without
3
+ adding additional code to every css file.
4
+ */
5
+
6
+ ////////////////////////////////////////////////
7
+ // Import Blueprint defaults
8
+ ////////////////////////////////////////////////
9
+ @import "blueprint/grid";
10
+ @import "blueprint/typography";
11
+ @import "blueprint/form";
12
+ @import "blueprint/interaction";
13
+ @import "blueprint/debug";
14
+
15
+ ////////////////////////////////////////////////
16
+ // Blueprint grid setup.
17
+ ////////////////////////////////////////////////
18
+
19
+ $blueprint-container-size: 970px;
20
+ $blueprint-grid-margin: 10px;
21
+ $blueprint-grid-width:30px;
22
+
23
+ /////////////////////////////////////////////////
24
+ // Import CSS3 Goodness
25
+ /////////////////////////////////////////////////
26
+ @import "compass/utilities/sprites";
27
+ @import "compass/css3/text-shadow";
28
+ @import "compass/css3/box-shadow";
29
+ @import "compass/css3/border-radius";
30
+ @import "compass/css3/gradient";
31
+ @import "compass/css3/font-face";
32
+ @import "compass/css3/pie";
33
+ @import "compass/css3/opacity";
34
+ @import "compass/utilities/general/min";
35
+ @import "compass/utilities/lists";
36
+ @import "compass/typography/vertical_rhythm";
37
+
38
+ $experimental-support-for-pie: false; // Enable this in ie.css so mixins can enable pie.
39
+ $legacy-support-for-ie6: false;
40
+
41
+ $default-text-shadow-color:black;
42
+ $default-text-shadow-h-offset:1px;
43
+ $default-text-shadow-v-offset:1px;
44
+ $default-text-shadow-blur:1px;
45
+ $default-border-radius:10px;
46
+
47
+ $blueprint-font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;
48
+
49
+ // Default color vars
50
+ $font-color: #333;
51
+
52
+ // Default blueprint colors (defaults listed)
53
+ // Links
54
+ $link-color:blue;
55
+ $link-hover-color:darken(desaturate(blue, 10%), 15%);
56
+ $link-focus-color: $link-hover-color;
57
+ $link-active-color: blue;
58
+ $link-visited-color: darken(blue, 20%);
59
+
60
+ // Notifications
61
+ $feedback-border-color: #dddddd;
62
+ $success-color: #3e5a3d;
63
+ $success-bg-color: #ddf5c4;
64
+ $success-border-color: #a7da74;
65
+ $notice-color: #514721;
66
+ $notice-bg-color: #fff6bf;
67
+ $notice-border-color: #ffd324;
68
+ $info-color: #be9109;
69
+ $info-bg-color: #fbf1d2;
70
+ $info-border-color: #ffcc33;
71
+ $error-color: #bd132a;
72
+ $error-bg-color: #fde0e4;
73
+ $error-border-color: #E41D38;
74
+
75
+ // Table colors
76
+ $blueprint-table-header-color: darken(blue, 15%);
77
+ $blueprint-table-stripe-color: $light_blue;
@@ -0,0 +1,173 @@
1
+ /*
2
+ Defaults file for layouts, sets up the grid, forms, and typography. Used as a separate file so only css files which
3
+ manage layouts include the extra code.
4
+ */
5
+ // Import libraries
6
+ @import "includes/base";
7
+ @import "includes/mixins";
8
+ // Reset
9
+ @import "blueprint/reset";
10
+
11
+ ////////////////////////////////////////////////
12
+ // Debugging
13
+ ////////////////////////////////////////////////
14
+ @if($debug){
15
+ #wrapper{ @include showgrid("/images/grid.png"); background-position-x:10px; }
16
+ }
17
+
18
+ ///////////////////////////////////////////////
19
+ // Setup typography
20
+ ///////////////////////////////////////////////
21
+
22
+ @include blueprint-typography;
23
+ ///////////////////////////////////////////////
24
+ // Setup forms and buttons
25
+ ///////////////////////////////////////////////
26
+
27
+ form{ @include blueprint-form-borders;
28
+ @include blueprint-form-layout;
29
+
30
+ ol.split{
31
+ display:block;
32
+ clear:both;
33
+ margin:-.5em 0px;
34
+ @include pie-clearfix;
35
+
36
+ li{
37
+ float:left;
38
+ margin:0px 1em 0px 0px;
39
+ vertical-align:middle;
40
+
41
+ label,
42
+ input[type=text],
43
+ input[type=password],
44
+ input[type=email]{
45
+ display:block;
46
+ }
47
+
48
+ select{ margin:.75em 0px; }
49
+
50
+ }
51
+ }
52
+ ol{
53
+ list-style-type:none !important;
54
+ margin:0px;
55
+ padding:0px;
56
+ padding-right:10px;
57
+
58
+ li{ padding:.5em 0px;
59
+ &.clear{ clear:both; }
60
+ &.buttons{ clear:both; padding:.25em 0px 0px 0px; }
61
+ &.inline label{ display:inline !important; }
62
+ &.multifield{
63
+ input, select{ display:inline !important; }
64
+ }
65
+
66
+ ol{ @extend ol.split; }
67
+ }
68
+
69
+ label{ display:block; }
70
+ }
71
+
72
+ ol.inline li.label{ display:inline !important; }
73
+ label abbr{
74
+ outline:none;
75
+ border:none;
76
+ color:red;
77
+ }
78
+ input[type=text],
79
+ input[type=password],
80
+ input[type=email],
81
+ textarea{
82
+ @include border-radius(2px); padding:.65em;
83
+ &:focus{
84
+ outline:none;
85
+ border-color:#333;
86
+ }
87
+ }
88
+ select{ border-style:solid !important;
89
+ &:focus{ outline:none; }
90
+ }
91
+ select[multiple=multiple]{
92
+ @include border-radius(2px);
93
+ border-color:#ccc;
94
+ }
95
+ input[type=checkbox],
96
+ input[type=radio]{
97
+ display:inline;
98
+ margin-right:1em;
99
+ vertical-align:baseline;
100
+ width:auto;
101
+ }
102
+
103
+ span.field_with_errors{
104
+ padding:0px;
105
+ line-height:1;
106
+ margin:0px;
107
+ position:relative;
108
+
109
+ input[type=text],
110
+ input[type=password],
111
+ input[type=email],
112
+ textarea{
113
+ border:1px solid $error-border-color;
114
+ background:$error-bg-color;
115
+ margin-bottom:0px;
116
+ }
117
+
118
+ span.error_for_field{
119
+ line-height:.75em;
120
+ font-size:.9em;
121
+ font-style:italic;
122
+ color:$error-color;
123
+ display:block;
124
+ }
125
+ }
126
+ }
127
+
128
+ a.button{ @include anchor-button; }
129
+ button.button{ @include button-button; position:relative; }
130
+ a.button, button.button{ @extend .button; }
131
+
132
+ ////////////////////////////////////
133
+ // Notifications
134
+ ////////////////////////////////////
135
+ div.error,
136
+ div.notice,
137
+ div.success,
138
+ div.alert{
139
+ padding: .8em;
140
+ border-width:.17em;
141
+ border-style:solid;
142
+ position:relative;
143
+ }
144
+
145
+ .error, .alert { background-color:$error-bg-color !important; border-color:$error-border-color; color:$error-color; }
146
+ .notice { background-color:$info-bg-color !important; border-color:$info-border-color; color:$info-color; }
147
+ .success { background-color:$success-bg-color !important; border-color:$success-border-color; color:$success-color; }
148
+
149
+ div.flash_message{
150
+
151
+ @include border-radius(5px);
152
+ background-repeat:no-repeat;
153
+ padding-left:35px;
154
+ background-position:10px 45%;
155
+ text-align:left;
156
+ padding:0px;
157
+ height:32px;
158
+ text-indent:35px;
159
+ line-height:32px;
160
+ margin-bottom:1.5em;
161
+
162
+ span{
163
+ position:absolute;
164
+ top:0px;
165
+ right:1em;
166
+ cursor:pointer;
167
+ cursor:hand;
168
+ font-family:'Arial Black';
169
+ @include opacity(0.5);
170
+
171
+ &:hover{ @include opacity(1); }
172
+ }
173
+ }
@@ -0,0 +1,40 @@
1
+ @function font($name, $base_url){
2
+ @include font-face($name, font-files('#{$base_url}.woff', woff, '#{$base_url}.ttf', truetype), '#{$base_url}.eot');
3
+ }
4
+
5
+ @mixin pie_option{
6
+ @if $experimental-support-for-pie{ @include pie; }
7
+ }
8
+
9
+ @mixin gradient($start:blue, $end:false, $darken:6%){
10
+ @if not $end{ $end:darken($start, $darken); }
11
+ @include background(linear-gradient($start, $end));
12
+ }
13
+
14
+ // Wireframing
15
+ @mixin wf($color:#dedede){
16
+ @if($debug or $wireframe){
17
+ background-color:$color; position:relative;
18
+ span.wireframe_title{ position:absolute; bottom:0px; left:0px; font-size:10px; background:lighten($color, 5%); border:1px solid darken($color, 10%); padding:.25em; }
19
+ }
20
+ }
21
+
22
+ ////////////////////////////////////
23
+ // Button defaults.
24
+ ////////////////////////////////////
25
+
26
+ @import "blueprint/buttons";
27
+ // Button defaults
28
+ $blueprint-button-font-family:$blueprint-font-family;
29
+ $blueprint-button-background-color:#333;
30
+ $blueprint-button-border-color:darken($blueprint-button-background-color, 10%);
31
+ $blueprint-button-font-color:#fff;
32
+ $blueprint-button-hover-background-color:#555;
33
+ $blueprint-button-hover-border-color:darken($blueprint-button-hover-background-color, 10%);
34
+ $blueprint-button-hover-font-color:$blueprint-button-font-color;
35
+ $blueprint-button-active-background-color:#444;
36
+ $blueprint-button-active-border-color:darken($blueprint-button-active-background-color, 10%);
37
+ $blueprint-button-active-font-color:white;
38
+
39
+ .button{ @include button-colors; @include button-active-colors; @include button-hover-colors; }
40
+ .rounded{ @include border-radius(10px); @include pie_option; }
@@ -0,0 +1 @@
1
+ @import 'includes/defaults';
@@ -0,0 +1,25 @@
1
+ ##
2
+ # Configures Motr, including extensions/modules.
3
+ # See information below for more info
4
+ #
5
+ Motr.configure do |config|
6
+
7
+ # => Forms configuration
8
+ # Configures various options for the form builder
9
+ # config.forms.do |forms|
10
+ # The html class to be used when wrapping a field with an error
11
+ # forms.error_class = 'field_with_errors'
12
+ #
13
+ # The html class to be added to the "message" on each field
14
+ # forms.message_error_class = 'errors_for_field'
15
+ #
16
+ # The ERB based error template to be used when wrapping an errored field
17
+ # It provides the methods "error_class", "message_error_class", and "messages" (array of errors)
18
+ # forms.error_template = %{ <span class="<%= error_class %>"><%= html_tag %><span class="<%= message_error_class %>"><%= [messages].flatten.join(",") %></span>}
19
+ #
20
+ # The default form builder to use site-wide
21
+ # forms.default_builder = Motr::Forms::Builder
22
+ #
23
+ # end
24
+
25
+ end
@@ -0,0 +1,8 @@
1
+
2
+ ===============================================================================
3
+
4
+ Final configuration:
5
+
6
+ Nada right now.. easy enough?
7
+
8
+ ===============================================================================
@@ -2,8 +2,15 @@ require 'rails'
2
2
  require 'active_support/dependencies'
3
3
  require 'set'
4
4
 
5
+ require 'motr/forms'
6
+
5
7
  module Motr
6
8
 
9
+ module Controller
10
+ autoload :Responder, 'motr/controller/responder'
11
+ autoload :ScriptEvents, 'motr/controller/script_events'
12
+ end
13
+
7
14
  module Helpers
8
15
  autoload :LayoutHelpers, 'motr/helpers/layout_helpers'
9
16
  autoload :Navigation, 'motr/helpers/navigation'
@@ -14,8 +21,17 @@ module Motr
14
21
  autoload :MotrError, 'motr/errors/motr_error'
15
22
  autoload :InvalidOptions, 'motr/errors/invalid_options'
16
23
  end
24
+
25
+ # Support initializer configuration
26
+ def self.configure #:nodoc:
27
+ yield self
28
+ end
29
+
30
+ # Support configuration of the forms module
31
+ def self.forms #:nodoc:
32
+ yield Motr::Forms
33
+ end
17
34
 
18
35
  end
19
36
 
20
- require 'motr/forms'
21
37
  require 'motr/rails'
@@ -0,0 +1,37 @@
1
+ require 'action_controller/base'
2
+
3
+ module Motr
4
+ module Controller
5
+
6
+ ##
7
+ #
8
+ # A custom responder which extends the default functionality of respond_with to handle
9
+ # more advanced javascript functionality, as well as flash messages.
10
+ #
11
+ # Slightly modeled after José Valim's Responders gem (https://github.com/plataformatec/responders)
12
+ #
13
+ # @see (https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/metal/responder.rb) for more info
14
+ #
15
+ class Responder < ActionController::Responder
16
+
17
+ def initialize(controller, resources, options = {}) #:nodoc:
18
+ super
19
+ flash = (format == :js) ? controller.flash : controller.flash.now
20
+ [:success, :notice, :error].each do |key|
21
+ flash[key] = options.delete(key) if options[key].present?
22
+ end
23
+ end
24
+
25
+ ##
26
+ # Override to_js to set a +X-Flash-Messages+ header to be utilized by an ajax response.
27
+ #
28
+ def to_js #:nodoc:
29
+ flash = controller.flash.now
30
+ controller.response['X-Flash-Messages'] = flash.to_json if [:success, :notice, :error].detect{ |key| flash[key].present? }
31
+ defined?(super) ? super : to_format
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,77 @@
1
+ require 'action_controller/base'
2
+
3
+ module Motr
4
+ module Controller
5
+
6
+ ##
7
+ # Enables triggering javascript events from controllers. This helps with extraction of javascript from
8
+ # actual view templates. Since by default Rails' respond_with will render a html template on a js request
9
+ # where there is no .js.erb template, we can capture that content and trigger a javascript event with it.
10
+ #
11
+ # @option options [Symbol] :type The type of callback to use (only supports :jquery right now)
12
+ #
13
+ # @example
14
+ # In your controller:
15
+ # controller SomeResourceController < ApplicationController
16
+ # respond_to :html, :js
17
+ # enable_script_events :only => :create
18
+ #
19
+ # def create
20
+ # # some create functionality here
21
+ # # @some_resource.name = "Test"
22
+ # respond_with(@some_resource)
23
+ # end
24
+ #
25
+ # end
26
+ #
27
+ # With the view "create.html.erb"
28
+ #
29
+ # <div id="resource"><%= @some_resource.name %></div>
30
+ #
31
+ # Will return (where the last param is an object notation of any params passed (after filtering))
32
+ #
33
+ # jQuery.trigger("some_resource:create", "<div id=\"resource\">Test</div>", {});
34
+ #
35
+ #
36
+ module ScriptEvents
37
+
38
+ def enable_script_events(options = {}) #:nodoc:
39
+
40
+
41
+ after_filter(options) do
42
+
43
+ # TODO: Possibly support other js libraries? I mean... does anyone care? I don't
44
+ #event_type = options.delete(:type) || :jquery
45
+ event_type = :jquery
46
+ callback_str = case event_type.to_s
47
+ when 'prototype' then "alert('sorry, no prototype love');"
48
+ else "jQuery.event.trigger('%s:%s', [%s, %s]);"
49
+ end
50
+
51
+ return true unless response.content_type.to_s.match(/javascript/i)
52
+ response_params = request.filtered_parameters.dup
53
+
54
+ cname = response_params.delete('controller').to_s.underscore
55
+ aname = response_params.delete('action').to_s
56
+ escape_map = {
57
+ '\\' => '\\\\',
58
+ '</' => '<\/',
59
+ "\r\n" => '\n',
60
+ "\n" => '\n',
61
+ "\r" => '\n',
62
+ '"' => '\\"',
63
+ "'" => "\\'" }
64
+
65
+ response_params.delete("format")
66
+ json_params = response_params.to_json#.gsub(/(\\|<\/|\r\n|[\n\r"'])/) { escape_map[$1] }
67
+ old_body = response.body.gsub(/(\\|<\/|\r\n|[\n\r"'])/) { escape_map[$1] }
68
+ response.body = callback_str % [cname, aname, old_body.inspect, json_params.html_safe]
69
+
70
+ end
71
+
72
+ end
73
+
74
+ end
75
+
76
+ end
77
+ end
@@ -54,7 +54,8 @@ module Motr
54
54
  # @return [Boolean]
55
55
  #
56
56
  def errors_on_attribute?(method)
57
- !(@object.nil? || @object.errors.empty? || !@object.errors.key?(method.to_sym) || [@object.errors[method.to_sym]].flatten.empty?)
57
+ return false if @object.nil?
58
+ !(@object.errors.empty? || !@object.errors.key?(method.to_sym) || [@object.errors[method.to_sym]].flatten.empty?)
58
59
  end
59
60
 
60
61
  ##
@@ -81,6 +82,17 @@ module Motr
81
82
  if_condition ? !!condition : !condition
82
83
  end
83
84
 
85
+ ##
86
+ #
87
+ # Checks an options hash to determine if a required method/attribute was overridden manually
88
+ # @param [Hash] options The options hash to check
89
+ #
90
+ #
91
+ def required_by_option?(options)
92
+ req = (options.is_a?(Hash) ? options.stringify_keys[:required] : options)
93
+ !(req.to_s === 'false' || req.nil?)
94
+ end
95
+
84
96
  ##
85
97
  #
86
98
  # Wrapper method used by all form fields to customize the output
@@ -92,7 +104,7 @@ module Motr
92
104
  # @return [String] Rendered HTML tag for the element
93
105
  #
94
106
  def render_field_as_custom(helper_method, method, *args)
95
-
107
+
96
108
  @current_field_type = helper_method
97
109
 
98
110
  options = args.extract_options!
@@ -109,11 +121,12 @@ module Motr
109
121
  # Add a required attribute to the field if it is required
110
122
  # Skip if false was passed as the required option
111
123
  #
112
- options[:required] = "required" if attribute_required?(method) && options[:required].to_s != 'false'
124
+ options[:required] = "required" if attribute_required?(method) && options.delete(:required).to_s != 'false'
113
125
  options['data-validates-uniqueness'] = "true" if validates_uniqueness?(method)
114
126
 
115
- result = send(:"_super_#{helper_method}", method, *(args << options))
116
- render_field_with_errors(method, result, @object.errors[method])
127
+ result = send(:"_super_#{helper_method}", method, *(args << options))
128
+ messages = @object.nil? ? [] : @object.errors[method]
129
+ render_field_with_errors(method, result, messages)
117
130
 
118
131
  end
119
132
 
@@ -29,19 +29,19 @@ module Motr
29
29
  text ||= method.to_s.humanize
30
30
 
31
31
  options.stringify_keys!
32
- klasses = (options.delete([:class]) || "").split(" ")
32
+ klasses = (options.delete(['class']) || "").split(" ")
33
33
  klasses << Motr::Forms.error_class if errors_on_attribute?(method)
34
- options[:class] = klasses.join(" ") unless klasses.compact.empty?
34
+ options['class'] = klasses.join(" ") unless klasses.compact.empty?
35
35
 
36
- text = "#{text} <abbr title='Required'>*</abbr>".html_safe if attribute_required?(method)
36
+ text = "#{text} <abbr title='Required'>*</abbr>".html_safe if attribute_required?(method) || required_by_option?(options.delete('required'))
37
37
  super(method, text, options, &block)
38
38
 
39
39
  end
40
40
 
41
41
  ##
42
42
  #
43
- # Creates a button tag to be used in a form instead of the default submit
44
- # This makes CSS styling easier
43
+ # Creates a button tag to be used in a form instead of the default input[type=submit]
44
+ # to help make CSS styling easier
45
45
  #
46
46
  # @param [String] value The text for the button
47
47
  # @param [Hash] options HTML options to be passed to the button
@@ -52,12 +52,63 @@ module Motr
52
52
  value, options = nil, value if value.is_a?(Hash)
53
53
  value ||= submit_default_value
54
54
 
55
- value = [image_tag(icon, :class => 'icon'), value].join(' ') if icon = options.delete(:icon)
56
-
55
+ value = [image_tag(icon, :class => 'icon'), value].join(' ') if icon = options.delete(:icon)
56
+ klasses = (options.delete(:class) || "").split(" ")
57
+ klasses << "button"
58
+ options['class'] = klasses.join(" ")
57
59
  content_tag(:button, value.to_s.html_safe, options.reverse_merge!({ "type" => "submit", "name" => "commit" }))
58
60
 
59
61
  end
60
62
 
63
+ ##
64
+ #
65
+ # Generate a select tag with the 50 US states as options
66
+ #
67
+ # @param [Symbol] method The object method/attribute to be used
68
+ # @param [Hash] options Same as Rails' select options hash
69
+ # @option options [Symbol] :international Include an international option
70
+ # @option options [Symbol] :abbreviate Use an abbreviated version of the state name for the value
71
+ # @param [Hash] html_options Same as Rails' html_options hash
72
+ #
73
+ # @return [String] HTML select tag
74
+ #
75
+ def state_select(method, options = {}, html_options = {})
76
+ abbr = options.delete(:abbreviate)
77
+ abbr = !(abbr.nil? || abbr === false)
78
+ select(method, @template.options_for_select(options_for_state_select(abbr, options.delete(:international)), @object.try(:state)), options, html_options)
79
+ end
80
+
81
+ protected
82
+
83
+ ##
84
+ #
85
+ # Returns a list of US states as an array
86
+ #
87
+ # @param [Boolean] abbreviate Abbreviate the value
88
+ # @param [Boolean, String] incl_international Include an additional state for "International"
89
+ #
90
+ # @return [Array] An array of states
91
+ #
92
+ def options_for_state_select(abbreviate = false, incl_international = false)
93
+ incl_international ||= false
94
+ state_list = [
95
+ ['Alabama', "AL"],['Alaska', "AK"],['Arizona', "AZ"],['Arkansas', "AR"],['California', "CA"],['Colorado', "CO"],
96
+ ['Connecticut', "CT"],['District of Columbia', "DC"],['Delaware', "DE"],['Florida', "FL"],['Georgia', "GA"],
97
+ ['Hawaii', "HI"],['Idaho', "ID"],['Illinois', "IL"],['Indiana', "IN"],['Iowa', "IA"],['Kansas', "KS"],['Kentucky', "KY"],
98
+ ['Louisiana', "LA"],['Maine', "ME"],['Maryland', "MD"],['Massachusetts', "MA"],['Michigan', "MI"],['Minnesota', "MN"],
99
+ ['Mississippi', "MS"],['Missouri', "MO"],['Montana', "MT"],['Nebraska', "NE"],['Nevada', "NV"],['New Hampshire', "NH"],
100
+ ['New Jersey', "NJ"],['New Mexico', "NM"],['New York', "NY"],['North Carolina', "NC"],['North Dakota', "ND"],
101
+ ['Ohio', "OH"],['Oklahoma', "OK"],['Oregon', "OR"],['Pennsylvania', "PA"],['Rhode Island', "RI"],['South Carolina', "SC"],
102
+ ['South Dakota', "SD"],['Tennessee', "TN"],['Texas', "TX"],['Utah', "UT"],['Vermont', "VT"],['Virginia', "VA"],['Washington', "WA"],
103
+ ['West Virginia', "WV"],['Wisconsin', "WI"],['Wyoming', "WY"]
104
+
105
+ ].map do |state|
106
+ (abbreviate ? state : [state.first, state.first])
107
+ end
108
+ state_list << ['International', incl_international] unless incl_international === false
109
+ state_list
110
+ end
111
+
61
112
  end
62
113
 
63
114
  end
@@ -53,7 +53,9 @@ module Motr
53
53
 
54
54
  wrapper = attrs.delete(:wrapper) || :div
55
55
  closer = attrs.delete(:closer)
56
- closer ||= "<span>X</span>" unless closer === false
56
+ unless closer === false
57
+ closer ||= "<span>X</span>"
58
+ end
57
59
  klasses = (attrs.delete(:class) || "").split(" ")
58
60
  klasses << "flash_message"
59
61
  content = ""
@@ -61,7 +63,7 @@ module Motr
61
63
  flash.each_key do |k|
62
64
  klasses << "flash_message_#{k.to_s.underscore}"
63
65
  msg_attrs = attrs.merge(:class => [k.to_s, klasses].flatten.join(' '))
64
- content.concat content_tag(wrapper, "#{flash[k]} #{closer}", msg_attrs)
66
+ content.concat content_tag(wrapper, "#{flash[k]} #{closer}".html_safe, msg_attrs).html_safe
65
67
  end
66
68
 
67
69
  content.html_safe
@@ -39,7 +39,7 @@ module Motr
39
39
  end
40
40
  end
41
41
  response << javascript_include_tag(*args.map(&:to_s), :cache => cache)
42
-
42
+ response.html_safe
43
43
  end
44
44
 
45
45
  ##
@@ -81,6 +81,24 @@ module Motr
81
81
  "#{cname}_#{aname}"
82
82
  end
83
83
 
84
+ ##
85
+ #
86
+ # Convenienve method to create a page title for the <title></title> tag.
87
+ #
88
+ # @param [String] content The text for the page title
89
+ # @return [String] The provided content
90
+ # @example Set the page title from a view template
91
+ # <%= page_title('This is my page title') %>
92
+ #
93
+ # # In the layout:
94
+ # <title><%= page_title %></title> #=> <title>This is my page title</title>
95
+ #
96
+ def page_title(content = nil)
97
+ _create_variable(:__page_title, content, false) and return unless content.nil?
98
+ return _retrieve_variable(:__page_title) if content_for?(:__page_title)
99
+ return ""
100
+ end
101
+
84
102
  ##
85
103
  #
86
104
  # Convenience method for content_for allowing for single-line variable creation. Also defines a method that can be
@@ -28,7 +28,8 @@ module Motr
28
28
 
29
29
  link_attrs = update_link_attrs(path, attrs)
30
30
  wrapper_attrs = link_attrs.delete(:wrapper)
31
- content_tag(wrapper, link_to(text, path, link_attrs), wrapper_attrs)
31
+ child_link = link_to(text, path, link_attrs)
32
+ wrapper === false ? child_link : content_tag(wrapper, child_link, wrapper_attrs)
32
33
 
33
34
  end
34
35
 
@@ -60,10 +61,10 @@ module Motr
60
61
  #
61
62
  def navigation(text, path, attrs = {}, wrapper = :li, container = :ol, &block)
62
63
 
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)
64
+ wrapper_attrs = attrs.delete(:wrapper)
66
65
  link_attrs = update_link_attrs(path, attrs.merge(:wrapper => (attrs.delete(:item) || {}) ))
66
+ parent_link = nav_link_to(text, path, attrs, false)
67
+ child_links = content_tag(container, capture(&block), wrapper_attrs)
67
68
 
68
69
  content_tag(wrapper, (parent_link << child_links), wrapper_attrs)
69
70
 
@@ -8,6 +8,10 @@ module Motr
8
8
 
9
9
  initializer :after_initialize do
10
10
  ActionView::Base.send :default_form_builder=, Motr::Forms.default_builder
11
+ ApplicationController.class_eval do
12
+ self.responder = Motr::Controller::Responder
13
+ end
14
+ ActionController::Base.extend Motr::Controller::ScriptEvents
11
15
  end
12
16
 
13
17
  end
@@ -1,3 +1,3 @@
1
1
  module Motr #:nodoc:
2
- VERSION = "0.0.2".freeze
2
+ VERSION = "0.0.3".freeze
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: motr
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brent Kirby
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-02 00:00:00 -04:00
13
+ date: 2011-05-04 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -113,6 +113,18 @@ extra_rdoc_files: []
113
113
  files:
114
114
  - app/helpers/motr_helper.rb
115
115
  - lib/config/locales/en.yml
116
+ - lib/generator/motr/compass_generator.rb
117
+ - lib/generator/motr/install_generator.rb
118
+ - lib/generator/motr/motr_generator.rb
119
+ - lib/generator/templates/compass/ie.scss
120
+ - lib/generator/templates/compass/includes/_base.scss
121
+ - lib/generator/templates/compass/includes/_defaults.scss
122
+ - lib/generator/templates/compass/includes/_mixins.scss
123
+ - lib/generator/templates/compass/screen.scss
124
+ - lib/generator/templates/motr.rb
125
+ - lib/generator/templates/post_install
126
+ - lib/motr/controller/responder.rb
127
+ - lib/motr/controller/script_events.rb
116
128
  - lib/motr/errors/invalid_options.rb
117
129
  - lib/motr/errors/motr_error.rb
118
130
  - lib/motr/forms/base.rb
@@ -125,6 +137,7 @@ files:
125
137
  - lib/motr/rails.rb
126
138
  - lib/motr/version.rb
127
139
  - lib/motr.rb
140
+ - config/en.yml
128
141
  - MIT-LICENSE
129
142
  - Rakefile
130
143
  - Gemfile
@@ -143,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
156
  requirements:
144
157
  - - ">="
145
158
  - !ruby/object:Gem::Version
146
- hash: -1045787232198311107
159
+ hash: 2716753183944900755
147
160
  segments:
148
161
  - 0
149
162
  version: "0"