qui-toolbar 0.0.1

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: toolbar
2
+
3
+ Gem for rails to create nice toolbar with a few lines o code.
4
+
5
+ See: {http://q.saepia.net}[http://q.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-toolbar"
7
+ gemspec.summary = "qUI: rails helpers for generating toolbars"
8
+ gemspec.description = "qUI: rails helpers for generating toolbars"
9
+ gemspec.email = "marcin@saepia.net"
10
+ gemspec.homepage = "http://q.saepia.net"
11
+ gemspec.authors = ["Marcin Lewandowski"]
12
+ gemspec.version = "0.0.1"
13
+ gemspec.files = Rake::FileList.new [ "MIT-LICENSE", "Rakefile", "public/stylesheets/qui/*", "lib/*", "rails/*", "README.rdoc" ]
14
+ end
15
+ rescue LoadError
16
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
17
+ end
@@ -0,0 +1,37 @@
1
+ module QUI
2
+ module Toolbar
3
+ class Base
4
+ include ActionView::Helpers::UrlHelper
5
+ include ActionView::Helpers::AssetTagHelper
6
+ include ActionView::Helpers::TagHelper
7
+
8
+ def initialize(binding)
9
+ @binding = binding
10
+ @controller = eval("controller", @binding)
11
+ end
12
+
13
+ def create
14
+ add_toolbar_link_to({ :controller => @controller.class.to_s.gsub("Controller", "").tableize, :action => "new" })
15
+ end
16
+
17
+ protected
18
+ def toolbar_link_to(description, url, options = {})
19
+ if description.is_a? Symbol
20
+ d = I18n.t(description)
21
+ else
22
+ d = description
23
+ end
24
+
25
+ if options[:icon]
26
+ options[:icon_alt] ||= ""
27
+ d = image_tag(File.join("qui/toolbar/", options[:icon]), :alt => options[:icon_alt]) + d
28
+ end
29
+ link_to d, url, options
30
+ end
31
+
32
+ def add_toolbar_link_to(url)
33
+ toolbar_link_to :"toolbar.create", url, :icon => "create.png"
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,22 @@
1
+ module QUI
2
+ module Toolbar
3
+ module MainHelper
4
+ def toolbar(options = {}, &b)
5
+ @toolbar_count ||= 0
6
+ raise RuntimeError, "@toolbar_count must be integer" unless @toolbar_count.is_a? Fixnum
7
+
8
+
9
+ contents = capture do
10
+ yield QUI::Toolbar::Base.new b.binding
11
+ end
12
+
13
+ options[:html_options] ||= {}
14
+ options[:html_options][:id] ||= "toolbar_#{@toolbar_count}"
15
+
16
+ @toolbar_count += 1
17
+
18
+ concat content_tag(:div, contents, options[:html_options].merge({:class => "toolbar"}))
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,2 @@
1
+ require 'qui-toolbar-main-helper.rb'
2
+ require 'qui-toolbar-base.rb'
@@ -0,0 +1,27 @@
1
+ div.toolbar {
2
+ margin-bottom: 20px;
3
+ }
4
+
5
+ div.toolbar a {
6
+ text-decoration: none;
7
+ padding: 6px;
8
+ padding-bottom: 8px;
9
+ color: #333;
10
+ border-top: 1px solid #f0f0f0;
11
+ border-left: 1px solid #f0f0f0;
12
+ border-bottom: 1px solid #d0d0d0;
13
+ border-right: 1px solid #d0d0d0;
14
+ }
15
+
16
+ div.toolbar a img {
17
+ vertical-align: middle;
18
+ margin-right: 4px;
19
+ }
20
+
21
+ div.toolbar a:hover {
22
+ background: #eff2f7;
23
+ }
24
+
25
+ div.toolbar a:active {
26
+ color: #f00;
27
+ }
data/rails/init.rb ADDED
@@ -0,0 +1,12 @@
1
+ ActionView::Base.send :include, QUI::Toolbar::MainHelper
2
+
3
+ unless File.exists?(File.join(Rails.root, 'public/stylesheets/qui/toolbar.css'))
4
+ $stderr.puts "Copying CSS for qui-toolbar..."
5
+ $stderr.puts "- public/stylesheets/qui/toolbar.css"
6
+
7
+ FileUtils.mkdir_p File.join(Rails.root, 'public/stylesheets/qui')
8
+ FileUtils.cp File.dirname(__FILE__) + "/../public/stylesheets/qui/toolbar.css", File.join(Rails.root, 'public/stylesheets/qui')
9
+ end
10
+
11
+
12
+
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qui-toolbar
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Marcin Lewandowski
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-12 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: "qUI: rails helpers for generating toolbars"
23
+ email: marcin@saepia.net
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.rdoc
30
+ files:
31
+ - MIT-LICENSE
32
+ - README.rdoc
33
+ - Rakefile
34
+ - lib/qui-toolbar-base.rb
35
+ - lib/qui-toolbar-main-helper.rb
36
+ - lib/qui-toolbar.rb
37
+ - public/stylesheets/qui/toolbar.css
38
+ - rails/init.rb
39
+ has_rdoc: true
40
+ homepage: http://q.saepia.net
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options:
45
+ - --charset=UTF-8
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.3.7
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: "qUI: rails helpers for generating toolbars"
73
+ test_files: []
74
+