sugar 0.0.23 → 0.0.25
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/Rakefile +3 -0
- data/VERSION +1 -1
- data/lib/sugar/actionview.rb +33 -12
- data/sugar.gemspec +1 -1
- metadata +1 -1
    
        data/Rakefile
    CHANGED
    
    
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.0. | 
| 1 | 
            +
            0.0.25
         | 
    
        data/lib/sugar/actionview.rb
    CHANGED
    
    | @@ -11,16 +11,17 @@ module Sugar | |
| 11 11 | 
             
                end
         | 
| 12 12 |  | 
| 13 13 | 
             
                def default_page_title
         | 
| 14 | 
            -
                  case action_name
         | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 14 | 
            +
                  text = case action_name
         | 
| 15 | 
            +
                         when 'index'
         | 
| 16 | 
            +
                           controller_name.camelize
         | 
| 17 | 
            +
                         when 'new', 'create'
         | 
| 18 | 
            +
                           t("#{t('new', :default => 'New')} #{controller_name.classify.constantize.human_name}")
         | 
| 19 | 
            +
                         when 'edit', 'update'
         | 
| 20 | 
            +
                           t("#{t('editing', :default => 'Editing')} #{controller_name.classify.constantize.human_name}")
         | 
| 21 | 
            +
                         else
         | 
| 22 | 
            +
                           t("#{controller_name}.#{view_name}.title")
         | 
| 23 | 
            +
                         end
         | 
| 24 | 
            +
                  %(<span class="trasnlation_missing">#{text}</span>)
         | 
| 24 25 | 
             
                end
         | 
| 25 26 |  | 
| 26 27 | 
             
                # Return page title for use in layout
         | 
| @@ -32,6 +33,11 @@ module Sugar | |
| 32 33 | 
             
                           end
         | 
| 33 34 | 
             
                end
         | 
| 34 35 |  | 
| 36 | 
            +
                def html_page_title(default = false, separator = ' | ')
         | 
| 37 | 
            +
                  default ||= t('application.title')
         | 
| 38 | 
            +
                  [page_title, default].compat.join(separator)
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 35 41 | 
             
                # Put submit with proper text
         | 
| 36 42 | 
             
                def submit(form, title = nil)
         | 
| 37 43 | 
             
                  title ||= t("#{controller.controller_name}.#{view_name}.submit",
         | 
| @@ -94,7 +100,7 @@ module Sugar | |
| 94 100 |  | 
| 95 101 | 
             
                def button_to_delete(something, title = nil)
         | 
| 96 102 | 
             
                  title ||= t('.delete',
         | 
| 97 | 
            -
                              :default =>  | 
| 103 | 
            +
                              :default => %(Delete #{(something.is_a?(Array) ? something.last : something).class.human_name}))
         | 
| 98 104 | 
             
                  button_to(title,
         | 
| 99 105 | 
             
                            polymorphic_path(something),
         | 
| 100 106 | 
             
                            :class => 'delete action',
         | 
| @@ -146,7 +152,22 @@ module Sugar | |
| 146 152 | 
             
                  end
         | 
| 147 153 | 
             
                end
         | 
| 148 154 |  | 
| 149 | 
            -
             | 
| 155 | 
            +
                def human(*args)
         | 
| 156 | 
            +
                  if args.size == 2
         | 
| 157 | 
            +
                    args.first.human_attribute_name(args.second.to_s)
         | 
| 158 | 
            +
                  else
         | 
| 159 | 
            +
                    args.first.human_name
         | 
| 160 | 
            +
                  end
         | 
| 161 | 
            +
                end
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                def zebra
         | 
| 164 | 
            +
                  {:class => cycle('even', 'odd')}
         | 
| 165 | 
            +
                end
         | 
| 150 166 |  | 
| 167 | 
            +
                def translatable(text, key = nil)
         | 
| 168 | 
            +
                  key ||= ".#{text.gsub(/[\s\.,-]+/, '_').downcase}"
         | 
| 169 | 
            +
                  translate(key, :default => text)
         | 
| 170 | 
            +
                end
         | 
| 171 | 
            +
              end
         | 
| 151 172 | 
             
            end
         | 
| 152 173 |  | 
    
        data/sugar.gemspec
    CHANGED