tiny_core 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/tiny_core +6 -0
- data/lib/tiny_core/build.rb +10 -0
- data/lib/tiny_core/helpers/bread_crumb_helper.rb +36 -0
- data/lib/tiny_core/helpers/tabs_helper.rb +38 -0
- data/lib/tiny_core.rb +5 -0
- metadata +71 -0
data/bin/tiny_core
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module TinyCore
|
2
|
+
module BreadCrumbHelper
|
3
|
+
def bread_crumb
|
4
|
+
items = [%{<a href="/">#{I18n.t('breadcrumb.home')}</a>}]
|
5
|
+
sofar = ''
|
6
|
+
elements = request.request_uri.split('?').first.split('/')
|
7
|
+
parent_model = nil
|
8
|
+
for i in 1...elements.size
|
9
|
+
sofar += '/' + elements[i]
|
10
|
+
|
11
|
+
parent_model, link_text = begin
|
12
|
+
next_model = if parent_model
|
13
|
+
parent_model.instance_eval("#{elements[i - 1]}.from_param!('#{elements[i]}')")
|
14
|
+
else
|
15
|
+
eval("#{elements[i - 1].singularize.camelize}.from_param!('#{elements[i]}')")
|
16
|
+
end
|
17
|
+
[next_model, next_model.respond_to?(:name) ? next_model.name : next_model.to_param]
|
18
|
+
rescue Exception => e
|
19
|
+
[parent_model, I18n.t("breadcrumb.#{elements[i]}")]
|
20
|
+
end
|
21
|
+
|
22
|
+
if sofar == request.path
|
23
|
+
items << "<strong>" + link_text + '</strong>'
|
24
|
+
else
|
25
|
+
items << "<a href='#{sofar}'>" + link_text + '</a>'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
content_tag :ul do
|
30
|
+
items.collect { |item| content_tag(:li) { item } }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
ActionController::Base.send :helper, TinyCore::BreadCrumbHelper
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module TinyCore
|
2
|
+
module TabsHelper
|
3
|
+
def tabs(options = {}, &block)
|
4
|
+
yield builder = TabsBuilder.new(self, options)
|
5
|
+
concat(builder.build!)
|
6
|
+
end
|
7
|
+
|
8
|
+
class TabsBuilder
|
9
|
+
def initialize(template, options)
|
10
|
+
@template = template
|
11
|
+
@options = options
|
12
|
+
@tabs = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def tab(name, text, url)
|
16
|
+
@tabs << { :name => name, :text => text, :url => url }
|
17
|
+
end
|
18
|
+
|
19
|
+
def build!
|
20
|
+
@template.content_tag(:ul, :class => 'tabs') do
|
21
|
+
@tabs.collect do |tab|
|
22
|
+
if tab[:name] == @options[:selected]
|
23
|
+
@template.content_tag(:li, :class => 'selected') do
|
24
|
+
@template.content_tag(:span) { tab[:text] }
|
25
|
+
end
|
26
|
+
else
|
27
|
+
@template.content_tag(:li) do
|
28
|
+
@template.link_to tab[:text], tab[:url]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
ActionController::Base.send :helper, TinyCore::TabsHelper
|
data/lib/tiny_core.rb
ADDED
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tiny_core
|
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
|
+
- Thomas Kadauke
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-19 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email: tkadauke@imedo.de
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- bin/tiny_core
|
32
|
+
- lib/tiny_core/build.rb
|
33
|
+
- lib/tiny_core/helpers/bread_crumb_helper.rb
|
34
|
+
- lib/tiny_core/helpers/tabs_helper.rb
|
35
|
+
- lib/tiny_core.rb
|
36
|
+
has_rdoc: true
|
37
|
+
homepage:
|
38
|
+
licenses: []
|
39
|
+
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
hash: 3
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.3.7
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Insert description here
|
70
|
+
test_files: []
|
71
|
+
|