qui-common-helpers 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ All portions Copyright (c) 2007 Tim Harper
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,7 @@
1
+ =QUI: tabs
2
+
3
+ Gem for rails to create nice tabs with a few lines o code.
4
+
5
+ See: {http://qui.saepia.net}[http://qui.saepia.net] for details.
6
+
7
+ Copyright (c) 2010 [Marcin Lewandowski], released under the MIT license.
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'jeweler'
5
+ Jeweler::Tasks.new do |gemspec|
6
+ gemspec.name = "qui-common-helpers"
7
+ gemspec.summary = "qUI: some common helpers used by other gems"
8
+ gemspec.description = "qUI: some common helpers used by other gems"
9
+ gemspec.email = "marcin@saepia.net"
10
+ gemspec.homepage = "http://q.saepia.net"
11
+ gemspec.authors = ["Marcin Lewandowski"]
12
+ gemspec.version = "0.0.2"
13
+ gemspec.files = Rake::FileList.new [ "MIT-LICENSE", "Rakefile", "lib/*" ]
14
+ end
15
+ rescue LoadError
16
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
17
+ end
@@ -0,0 +1,64 @@
1
+ module QUI
2
+ module CommonHelpers
3
+ module MainHelper
4
+ def edit_image_tag
5
+ image_tag("icons/16x16/edit.png", :alt => t(:editAsAction))
6
+ end
7
+
8
+ def link_to_edit(object)
9
+ link_to(edit_image_tag, send("edit_#{section}_#{object.class.to_s.tableize.singularize}_path", object), :title => t(:editAsAction))
10
+ end
11
+
12
+ def delete_image_tag
13
+ image_tag("icons/16x16/delete.png", :alt => t(:deleteAsAction))
14
+ end
15
+
16
+ def link_to_delete(object)
17
+ link_to(delete_image_tag, [ section, object ], :title => t(:deleteAsAction), :method => :delete, :confirm => t(:deleteConfirmation))
18
+ end
19
+
20
+ def link_to_object(object, description = nil)
21
+ description = object.link_default_description if description.nil?
22
+
23
+ if defined?(:section)
24
+ link_to description, [ section, object ]
25
+ else
26
+ link_to description, object
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ ActionView::Base.send :include, QUI::CommonHelpers::MainHelper
34
+
35
+
36
+
37
+ module QUI
38
+ module CommonHelpers
39
+ module Model
40
+ def self.included(base) # :nodoc:
41
+ base.extend ClassMethods
42
+
43
+ define_method :link_default_description do
44
+ if self.class.respond_to?(:link_default_description_field)
45
+ send(self.class.link_default_description_field)
46
+ else
47
+ "#{self.class.human_name} ##{id}"
48
+ end
49
+ end
50
+ end
51
+
52
+ module ClassMethods
53
+ def has_link_default_description(field)
54
+ @link_default_description_field = field
55
+ class << self
56
+ attr_reader :link_default_description_field
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ ActiveRecord::Base.send :include, QUI::CommonHelpers::Model
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qui-common-helpers
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Marcin Lewandowski
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-18 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: "qUI: some common helpers used by other gems"
23
+ email: marcin@saepia.net
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.rdoc
30
+ files:
31
+ - MIT-LICENSE
32
+ - Rakefile
33
+ - lib/qui-common-helpers.rb
34
+ - README.rdoc
35
+ has_rdoc: true
36
+ homepage: http://q.saepia.net
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options:
41
+ - --charset=UTF-8
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ hash: 3
50
+ segments:
51
+ - 0
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.3.7
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: "qUI: some common helpers used by other gems"
69
+ test_files: []
70
+