refinerycms-footer-menu 1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,13 @@
1
+ ::ApplicationController.class_eval do
2
+
3
+ before_filter :find_footer_pages_for_menu
4
+
5
+ protected
6
+
7
+ def find_footer_pages_for_menu
8
+ @menu_footer_pages = ::Refinery::Menu.new(::Refinery::Page.fast_footer_menu)
9
+ # Don't use /footer url prefix
10
+ @menu_footer_pages.each {|mi| mi[:url][:path].reject!{ |path| path =~ /footer/ } if mi[:url].include?('path')}
11
+ end
12
+
13
+ end
@@ -0,0 +1,27 @@
1
+ ::Refinery::Page.class_eval do
2
+ def self.fast_footer_menu(columns = [])
3
+ # First, apply a filter to determine which pages to show.
4
+ # We need to join to the page's slug to avoid multiple queries.
5
+ return nil if (footer_page_id = ::Refinery::Page.select(:id).find_by_link_url('/footer')).nil?
6
+
7
+ pages = includes(:slug, :slugs).order('lft ASC').where(:parent_id => footer_page_id)
8
+
9
+ # Now we only want to select particular columns to avoid any further queries.
10
+ # Title and menu_title are retrieved in the next block below so they are not here.
11
+ (menu_columns | columns).each do |column|
12
+ pages = pages.select(arel_table[column.to_sym])
13
+ end
14
+
15
+ # We have to get title and menu_title from the translations table.
16
+ # To avoid calling globalize3 an extra time, we get title as page_title
17
+ # and we get menu_title as page_menu_title.
18
+ # These is used in 'to_refinery_menu_item' in the Page model.
19
+ %w(title menu_title).each do |column|
20
+ pages = pages.joins(:translations).select(
21
+ "#{translation_class.table_name}.#{column} as page_#{column}"
22
+ )
23
+ end
24
+
25
+ pages
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ <%
2
+ # Collect the root items.
3
+ # ::Refinery::Menu is smart enough to remember all of the items in the original collection.
4
+ if (roots = @menu_footer_pages).present?
5
+ dom_id ||= 'footer_menu'
6
+ css = [(css || 'footer-menu'), 'clearfix'].flatten.join(' ')
7
+ hide_children = true
8
+ -%>
9
+ <nav id='<%= dom_id %>' class='<%= css %>'>
10
+ <ul>
11
+ <%= render :partial => '/refinery/menu_branch', :collection => roots.uniq,
12
+ :locals => {
13
+ :hide_children => hide_children,
14
+ :sibling_count => (roots.length - 1),
15
+ :menu_levels => local_assigns[:menu_levels],
16
+ :apply_css => false #if you don't care about class='first' class='last' or class='selected' set apply_css to false for speed.
17
+ } -%>
18
+ </ul>
19
+ </nav>
20
+ <% end -%>
@@ -0,0 +1,15 @@
1
+ url = "/footer"
2
+ if defined?(::Refinery::Page) && ::Refinery::Page.where(:link_url => url).empty?
3
+ page = ::Refinery::Page.create(
4
+ :title => 'Footer',
5
+ :link_url => url,
6
+ :deletable => false,
7
+ :position => ((::Refinery::Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
8
+ :menu_match => "^#{url}(\/|\/.+?|)$",
9
+ :show_in_menu => false
10
+ )
11
+ Refinery::Pages.default_parts.each do |default_page_part|
12
+ page.parts.create(:title => default_page_part, :body => nil)
13
+ end
14
+ end
15
+
@@ -0,0 +1,13 @@
1
+ module Refinery
2
+ class FooterMenuGenerator < Rails::Generators::Base
3
+
4
+ def append_load_seed_data
5
+ create_file 'db/seeds.rb' unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
6
+ append_file 'db/seeds.rb', :verbose => true do
7
+ <<-EOH
8
+ Refinery::FooterMenu::Engine.load_seed
9
+ EOH
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ require 'refinerycms-core'
2
+
3
+ module Refinery
4
+ autoload :FooterMenuGenerator, 'generators/refinery/footer_menu_generator'
5
+
6
+ module FooterMenu
7
+ require 'refinery/footer-menu/engine'
8
+
9
+ class << self
10
+ attr_writer :root
11
+
12
+ def root
13
+ @root ||= Pathname.new(File.expand_path('../../../', __FILE__))
14
+ end
15
+
16
+ def factory_paths
17
+ @factory_paths ||= [ root.join('spec', 'factories').to_s ]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,28 @@
1
+ module Refinery
2
+ module FooterMenu
3
+ class Engine < Rails::Engine
4
+ include Refinery::Engine
5
+ isolate_namespace Refinery::FooterMenu
6
+
7
+ engine_name :refinery_footer_menu
8
+
9
+ initializer "register refinerycms_footer_menu plugin" do |app|
10
+ Refinery::Plugin.register do |plugin|
11
+ plugin.name = "footer-menu"
12
+ plugin.pathname = root
13
+ plugin.hide_from_menu = true
14
+ end
15
+ end
16
+
17
+ config.after_initialize do
18
+ Refinery.register_engine(Refinery::FooterMenu)
19
+ end
20
+
21
+ after_inclusion do
22
+ Dir.glob(File.join(File.dirname(__FILE__), "../../../app/**/*_decorator*.rb")) do |c|
23
+ Rails.configuration.cache_classes ? require(c) : load(c)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1 @@
1
+ require 'refinery/footer-menu'
@@ -0,0 +1,13 @@
1
+ namespace :refinery do
2
+
3
+ namespace :'footer-menu' do
4
+
5
+ # call this task by running: rake refinery:footer-menu:my_task
6
+ # desc "Description of my task below"
7
+ # task :my_task => :environment do
8
+ # # add your logic here
9
+ # end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,3 @@
1
+ # Footer Menu engine for Refinery CMS.
2
+
3
+ The footer shows children of a page with the link_url "/footer".
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-footer-menu
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Marian Andre
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: refinerycms-core
16
+ requirement: &70331192599560 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70331192599560
25
+ - !ruby/object:Gem::Dependency
26
+ name: refinerycms-testing
27
+ requirement: &70331192598240 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70331192598240
36
+ description: Ruby on Rails Footer Menu engine for Refinery CMS
37
+ email: marian@bitflut.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - app/decorators/controllers/application_decorator.rb
43
+ - app/decorators/models/refinery/page_decorator.rb
44
+ - app/views/refinery/_footer.html.erb
45
+ - db/seeds.rb
46
+ - lib/generators/refinery/footer_menu_generator.rb
47
+ - lib/refinery/footer-menu/engine.rb
48
+ - lib/refinery/footer-menu.rb
49
+ - lib/refinerycms-footer-menu.rb
50
+ - lib/tasks/refinery/footer-menu.rake
51
+ - readme.md
52
+ homepage: http://github.com/bitflut/refinerycms-footer-menu
53
+ licenses: []
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 1.8.15
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: Footer Menu engine for Refinery CMS
76
+ test_files: []