bcms_tools 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/bcms_tools.gemspec +9 -8
- data/lib/bcms_tools/view_helpers.rb +54 -0
- data/lib/bcms_tools_dev.rb +1 -0
- metadata +4 -4
data/Rakefile
CHANGED
@@ -10,9 +10,9 @@ begin
|
|
10
10
|
gem.email = "contact@buzzware.com.au"
|
11
11
|
gem.homepage = "http://github.com/buzzware/bcms_tools"
|
12
12
|
gem.authors = ["buzzware"]
|
13
|
-
gem.add_dependency "buzzcore"
|
13
|
+
gem.add_dependency "buzzcore", ">= 0.3.2"
|
14
14
|
gem.add_dependency "browsercms"
|
15
|
-
gem.add_development_dependency "
|
15
|
+
gem.add_development_dependency "shoulda"
|
16
16
|
gem.files.include %w(
|
17
17
|
lib/bcms_tools/*
|
18
18
|
)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/bcms_tools.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bcms_tools}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["buzzware"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-19}
|
13
13
|
s.description = %q{Tools for BrowserCms.}
|
14
14
|
s.email = %q{contact@buzzware.com.au}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/bcms_tools/bcms_thumbnails.rb",
|
29
29
|
"lib/bcms_tools/bcms_thumbnails.rb",
|
30
30
|
"lib/bcms_tools/view_helpers.rb",
|
31
|
+
"lib/bcms_tools/view_helpers.rb",
|
31
32
|
"lib/bcms_tools_dev.rb",
|
32
33
|
"rails/init.rb",
|
33
34
|
"test/bcms_tools_test.rb",
|
@@ -48,17 +49,17 @@ Gem::Specification.new do |s|
|
|
48
49
|
s.specification_version = 3
|
49
50
|
|
50
51
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
51
|
-
s.add_runtime_dependency(%q<buzzcore>, [">= 0"])
|
52
|
+
s.add_runtime_dependency(%q<buzzcore>, [">= 0.3.2"])
|
52
53
|
s.add_runtime_dependency(%q<browsercms>, [">= 0"])
|
53
|
-
s.add_development_dependency(%q<
|
54
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
54
55
|
else
|
55
|
-
s.add_dependency(%q<buzzcore>, [">= 0"])
|
56
|
+
s.add_dependency(%q<buzzcore>, [">= 0.3.2"])
|
56
57
|
s.add_dependency(%q<browsercms>, [">= 0"])
|
57
|
-
s.add_dependency(%q<
|
58
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
58
59
|
end
|
59
60
|
else
|
60
|
-
s.add_dependency(%q<buzzcore>, [">= 0"])
|
61
|
+
s.add_dependency(%q<buzzcore>, [">= 0.3.2"])
|
61
62
|
s.add_dependency(%q<browsercms>, [">= 0"])
|
62
|
-
s.add_dependency(%q<
|
63
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
63
64
|
end
|
64
65
|
end
|
@@ -1,12 +1,66 @@
|
|
1
1
|
module ActionView
|
2
2
|
module Helpers
|
3
3
|
|
4
|
+
def google_analytics(aTrackingId = nil)
|
5
|
+
return '' if request.host.begins_with?('cms.')
|
6
|
+
aTrackingId ||= APP_CONFIG[:google_analytics_tracking_id]
|
7
|
+
return '' unless aTrackingId.to_nil
|
8
|
+
|
9
|
+
<<-EOS
|
10
|
+
<script type="text/javascript">
|
11
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
12
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript">
|
15
|
+
try {
|
16
|
+
var pageTracker = _gat._getTracker("#{aTrackingId}");
|
17
|
+
pageTracker._trackPageview();
|
18
|
+
} catch(err) {}
|
19
|
+
</script>
|
20
|
+
EOS
|
21
|
+
end
|
22
|
+
|
4
23
|
def default_content_for(name, &block)
|
5
24
|
name = name.kind_of?(Symbol) ? ":#{name}" : name
|
6
25
|
out = eval("yield #{name}", block.binding)
|
7
26
|
concat(out || capture(&block), block.binding)
|
8
27
|
end
|
9
28
|
|
29
|
+
#render_menu(), or more precisely menu_items() doesn't seem to work well
|
30
|
+
#for rendering a top menu when you want the ancestor item of the current
|
31
|
+
#page highlighted. The problem is that it compares each menu item with the
|
32
|
+
#current page, when the current page may be several levels deep under one
|
33
|
+
#of the menu items.
|
34
|
+
#
|
35
|
+
#Fortunately the :page option allows the current page to be given, so the
|
36
|
+
#correct output can be produced if we manipulate this option.
|
37
|
+
#
|
38
|
+
#This does the trick :
|
39
|
+
#
|
40
|
+
def render_menu2(aOptions=nil)
|
41
|
+
opts = {
|
42
|
+
:from_top => 0, # menu root is how many levels down from root (0 = roots immediate children)
|
43
|
+
:depth => 1, # depth of menu from menu root
|
44
|
+
:show_all_siblings => true
|
45
|
+
}
|
46
|
+
opts.merge!(aOptions) if aOptions
|
47
|
+
|
48
|
+
selected_page = opts[:page] || @page
|
49
|
+
ancestors = selected_page.ancestors
|
50
|
+
top_section = ancestors[opts[:from_top]]
|
51
|
+
opts[:path] = top_section.path
|
52
|
+
|
53
|
+
ancestors << selected_page if (selected_page.section == top_section) || (selected_page != selected_page.section.pages.first)
|
54
|
+
|
55
|
+
result_i = Math.min(opts[:from_top] + opts[:depth],ancestors.length-1)
|
56
|
+
opts[:page] = ancestors[result_i]
|
57
|
+
opts[:items] ||= menu_items(opts)
|
58
|
+
|
59
|
+
return '' if opts[:items].empty? || (opts[:items].length == 1 && !opts[:items].first[:children]) # return blank if only a single menu item
|
60
|
+
|
61
|
+
render_menu opts
|
62
|
+
end
|
63
|
+
|
10
64
|
module CaptureHelper
|
11
65
|
def set_content_for(name, content = nil, &block)
|
12
66
|
ivar = "@content_for_#{name}"
|
data/lib/bcms_tools_dev.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcms_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- buzzware
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-19 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: 0.3.2
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: browsercms
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: "0"
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: shoulda
|
37
37
|
type: :development
|
38
38
|
version_requirement:
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|