ecm_links2 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +52 -0
- data/Rakefile +25 -0
- data/app/controllers/ecm/links/categories_controller.rb +11 -0
- data/app/decorators/ecm/links/category_decorator.rb +17 -0
- data/app/helpers/ecm/links/categories_helper.rb +5 -0
- data/app/helpers/ecm/links/links_helper.rb +5 -0
- data/app/helpers/ecm/links_helper.rb +7 -0
- data/app/models/ecm/links/category.rb +102 -0
- data/app/models/ecm/links/link.rb +63 -0
- data/app/views/ecm/links/_link_footer.html.erb +14 -0
- data/app/views/ecm/links/categories/_category.html.erb +22 -0
- data/app/views/ecm/links/categories/_category_in_index.html.erb +5 -0
- data/app/views/ecm/links/categories/index.html.erb +5 -0
- data/app/views/ecm/links/categories/show.html.erb +9 -0
- data/app/views/ecm/links/links/_link.html.erb +1 -0
- data/app/views/ecm/links/links/_link_in_table.html.erb +5 -0
- data/app/views/ecm/links/links/_table.html.erb +7 -0
- data/config/locales/ecm.links.category.de.yml +26 -0
- data/config/locales/ecm.links.category.en.yml +26 -0
- data/config/locales/ecm.links.de.yml +9 -0
- data/config/locales/ecm.links.en.yml +9 -0
- data/config/locales/ecm.links.link.de.yml +18 -0
- data/config/locales/ecm.links.link.en.yml +18 -0
- data/db/migrate/001_create_ecm_links_categories.rb +26 -0
- data/db/migrate/002_create_ecm_links_links.rb +19 -0
- data/lib/ecm/links/active_admin/ecm_links_categories.rb +121 -0
- data/lib/ecm/links/active_admin/ecm_links_links.rb +56 -0
- data/lib/ecm/links/configuration.rb +33 -0
- data/lib/ecm/links/engine.rb +12 -0
- data/lib/ecm/links/routing.rb +36 -0
- data/lib/ecm/links/version.rb +5 -0
- data/lib/ecm_links2.rb +21 -0
- data/lib/generators/ecm/links/install/install_generator.rb +15 -0
- data/lib/generators/ecm/links/install/templates/ecm_links.rb +29 -0
- data/lib/generators/ecm/links/locales/locales_generator.rb +20 -0
- data/lib/tasks/ecm_links_tasks.rake +50 -0
- metadata +479 -0
@@ -0,0 +1,121 @@
|
|
1
|
+
include ActiveAdmin::ActsAsList::Helper if defined?(ActiveAdmin)
|
2
|
+
include ActiveAdmin::AwesomeNestedSet::Helper if defined?(ActiveAdmin)
|
3
|
+
|
4
|
+
ActiveAdmin.register Ecm::Links::Category do
|
5
|
+
# menu entry settings
|
6
|
+
menu :parent => Proc.new { I18n.t('ecm.links.active_admin.menu') }.call
|
7
|
+
|
8
|
+
# awesome nested set
|
9
|
+
sortable_tree_member_actions
|
10
|
+
|
11
|
+
permit_params :link_footer_column,
|
12
|
+
:locale,
|
13
|
+
:long_description,
|
14
|
+
:markup_language,
|
15
|
+
:name,
|
16
|
+
:parent_id,
|
17
|
+
:short_description,
|
18
|
+
ecm_links_links_attributes: [
|
19
|
+
:description,
|
20
|
+
:ecm_links_category_id,
|
21
|
+
:markup_language,
|
22
|
+
:name,
|
23
|
+
:position,
|
24
|
+
:url
|
25
|
+
]
|
26
|
+
|
27
|
+
|
28
|
+
form do |f|
|
29
|
+
f.inputs do
|
30
|
+
f.input :parent, :as => :select, :collection => nested_set_options(Ecm::Links::Category, f.object) { |c| "#{'    ' * c.level} |-- #{c.to_s}".html_safe }
|
31
|
+
f.input :locale, :as => :select, :collection => I18n.available_locales.map(&:to_s)
|
32
|
+
f.input :name
|
33
|
+
f.input :short_description
|
34
|
+
f.input :long_description
|
35
|
+
end
|
36
|
+
|
37
|
+
f.inputs do
|
38
|
+
f.input :markup_language, :as => :select, :collection => Ecm::Links::Configuration.markup_languages.map(&:to_s)
|
39
|
+
f.input :link_footer_column, :as => :select, :collection => (1..Ecm::Links::Configuration.link_footer_columns).to_a
|
40
|
+
end
|
41
|
+
|
42
|
+
f.inputs do
|
43
|
+
f.has_many :ecm_links_links do |l|
|
44
|
+
if l.object.persisted?
|
45
|
+
l.input :_destroy, :as => :boolean, :label => I18n.t('active_admin.delete')
|
46
|
+
end
|
47
|
+
l.input :name
|
48
|
+
l.input :url
|
49
|
+
l.input :description
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
f.actions
|
54
|
+
end
|
55
|
+
|
56
|
+
index :as => :nested_set do
|
57
|
+
selectable_column
|
58
|
+
sortable_tree_columns
|
59
|
+
column :locale
|
60
|
+
column :name do |c|
|
61
|
+
span(:style => "margin-left: #{30 * c.level}px") { c.name }
|
62
|
+
end
|
63
|
+
column :short_description
|
64
|
+
column :ecm_links_links_count
|
65
|
+
column :link_footer_column
|
66
|
+
column :created_at
|
67
|
+
column :updated_at
|
68
|
+
actions
|
69
|
+
end
|
70
|
+
|
71
|
+
show do
|
72
|
+
attributes_table do
|
73
|
+
row :parent
|
74
|
+
row :locale
|
75
|
+
row :name
|
76
|
+
row :ecm_links_links_count
|
77
|
+
row :markup_language
|
78
|
+
row :link_footer_column
|
79
|
+
row :created_at
|
80
|
+
row :updated_at
|
81
|
+
end
|
82
|
+
|
83
|
+
panel Ecm::Links::Category.human_attribute_name(:short_description) do
|
84
|
+
div { ecm_links_category.short_description }
|
85
|
+
end
|
86
|
+
|
87
|
+
panel Ecm::Links::Category.human_attribute_name(:long_description) do
|
88
|
+
div { ecm_links_category.long_description }
|
89
|
+
end
|
90
|
+
|
91
|
+
panel Ecm::Links::Category.human_attribute_name(:children) do
|
92
|
+
table_for ecm_links_category.descendants, :i18n => Ecm::Links::Category do
|
93
|
+
sortable_tree_columns
|
94
|
+
column(:name) { |child| link_to child, [:admin, child], :style => "margin-left: #{30 * (child.level - ecm_links_category.level - 1)}px" }
|
95
|
+
column :short_description
|
96
|
+
column :ecm_links_links_count
|
97
|
+
column :link_footer_column
|
98
|
+
column :created_at
|
99
|
+
column :updated_at
|
100
|
+
column do |child|
|
101
|
+
link_to(I18n.t('active_admin.view'), [:admin, child], :class => "member_link view_link") +
|
102
|
+
link_to(I18n.t('active_admin.edit'), [:edit, :admin, child], :class => "member_link edit_link")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
panel Ecm::Links::Category.human_attribute_name(:ecm_links_links) do
|
108
|
+
table_for ecm_links_category.ecm_links_links, :i18n => Ecm::Links::Link do
|
109
|
+
sortable_columns
|
110
|
+
column(:name) { |link| link_to link.name, [:admin, link] }
|
111
|
+
column(:url) { |link| link_to link.url, link.url }
|
112
|
+
column :created_at
|
113
|
+
column :updated_at
|
114
|
+
column do |link|
|
115
|
+
link_to(I18n.t('active_admin.view'), [:admin, link], :class => "member_link view_link") +
|
116
|
+
link_to(I18n.t('active_admin.edit'), [:edit, :admin, link], :class => "member_link edit_link")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end if defined?(ActiveAdmin)
|
@@ -0,0 +1,56 @@
|
|
1
|
+
include ActiveAdmin::ActsAsList::Helper if defined?(ActiveAdmin)
|
2
|
+
|
3
|
+
ActiveAdmin.register Ecm::Links::Link do
|
4
|
+
# menu entry settings
|
5
|
+
menu :parent => Proc.new { I18n.t('ecm.links.active_admin.menu') }.call
|
6
|
+
|
7
|
+
permit_params :description,
|
8
|
+
:ecm_links_category_id,
|
9
|
+
:markup_language,
|
10
|
+
:name,
|
11
|
+
:position,
|
12
|
+
:url
|
13
|
+
|
14
|
+
# acts as list
|
15
|
+
sortable_member_actions
|
16
|
+
|
17
|
+
form do |f|
|
18
|
+
f.inputs do
|
19
|
+
f.input :ecm_links_category, :as => :select, :collection => nested_set_options(Ecm::Links::Category) { |c| "#{'    ' * c.level} |-- #{c.to_s}".html_safe }
|
20
|
+
f.input :name
|
21
|
+
f.input :url
|
22
|
+
f.input :description
|
23
|
+
end
|
24
|
+
|
25
|
+
f.inputs do
|
26
|
+
f.input :markup_language, :as => :select, :collection => Ecm::Links::Link::MARKUP_LANGUAGES
|
27
|
+
end
|
28
|
+
|
29
|
+
f.actions
|
30
|
+
end
|
31
|
+
|
32
|
+
index do
|
33
|
+
selectable_column
|
34
|
+
column :ecm_links_category
|
35
|
+
column :name
|
36
|
+
column :url
|
37
|
+
column :created_at
|
38
|
+
column :updated_at
|
39
|
+
actions
|
40
|
+
end
|
41
|
+
|
42
|
+
show do
|
43
|
+
attributes_table do
|
44
|
+
row :ecm_links_category
|
45
|
+
row :name
|
46
|
+
row :url
|
47
|
+
row :markup_language
|
48
|
+
row :created_at
|
49
|
+
row :updated_at
|
50
|
+
end
|
51
|
+
|
52
|
+
panel Ecm::Links::Link.human_attribute_name(:description) do
|
53
|
+
div { ecm_links_link.description }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end if defined?(ActiveAdmin)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'active_support/core_ext/module/delegation'
|
2
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
3
|
+
require 'active_support/hash_with_indifferent_access'
|
4
|
+
|
5
|
+
module Ecm
|
6
|
+
module Links
|
7
|
+
module Configuration
|
8
|
+
def configure
|
9
|
+
yield self
|
10
|
+
end
|
11
|
+
|
12
|
+
mattr_accessor :link_footer_columns do
|
13
|
+
4
|
14
|
+
end
|
15
|
+
|
16
|
+
mattr_accessor :link_footer_column_css_classes do
|
17
|
+
'link-footer-column col-lg-3'
|
18
|
+
end
|
19
|
+
|
20
|
+
mattr_accessor :base_controller do
|
21
|
+
'ApplicationController'
|
22
|
+
end
|
23
|
+
|
24
|
+
mattr_accessor :default_markup_language do
|
25
|
+
'textile'
|
26
|
+
end
|
27
|
+
|
28
|
+
mattr_accessor :markup_languages do
|
29
|
+
['textile']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Ecm
|
2
|
+
module Links
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
# active admin
|
5
|
+
initializer :ecm_links_engine do
|
6
|
+
::ActiveAdmin.setup do |active_admin_config|
|
7
|
+
active_admin_config.load_paths += Dir[File.dirname(__FILE__) + '/active_admin']
|
8
|
+
end
|
9
|
+
end if defined?(::ActiveAdmin)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Ecm
|
2
|
+
module Links
|
3
|
+
class Routing
|
4
|
+
# Creates the routes for categories. You can pass options to
|
5
|
+
# specify the actions for categories.
|
6
|
+
#
|
7
|
+
# Ecm::Links::Routing.routes(self, { :links_category_actions => [ :index ]})
|
8
|
+
#
|
9
|
+
# This will only create the index action for link categories.
|
10
|
+
def self.routes(router, options = {})
|
11
|
+
options.reverse_merge!({
|
12
|
+
links_category_actions: [:index, :show]
|
13
|
+
})
|
14
|
+
|
15
|
+
router.resources :ecm_links_categories, only: options[:links_category_actions], :controller => 'ecm/links/categories'
|
16
|
+
end
|
17
|
+
# # Creates the routes for links and categories. You can pass options to
|
18
|
+
# # specify the actions for both links and/or categories.
|
19
|
+
# #
|
20
|
+
# # Ecm::Links::Routing.routes(self, { :link_category_actions => [ :show ]})
|
21
|
+
# #
|
22
|
+
# # This will only create the show action for link categories, but omit the index action.
|
23
|
+
# def self.routes(router, options = {})
|
24
|
+
# options.reverse_merge!(
|
25
|
+
# { :link_category_actions => [:index, :show],
|
26
|
+
# :link_actions => [:index, :show]
|
27
|
+
# }
|
28
|
+
# )
|
29
|
+
#
|
30
|
+
# router.resources :ecm_links_categories, :only => options[:link_category_actions], :controller => 'ecm/links/link_categories'
|
31
|
+
# router.resources :ecm_links_links,:only => options[:link_actions], :controller => 'ecm/products/links'
|
32
|
+
# end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
data/lib/ecm_links2.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'active_admin-acts_as_list'
|
2
|
+
require 'active_admin-awesome_nested_set'
|
3
|
+
require 'acts_as_list'
|
4
|
+
require 'awesome_nested_set'
|
5
|
+
require 'awesome_nested_set-tools'
|
6
|
+
require 'friendly_id'
|
7
|
+
require 'draper'
|
8
|
+
|
9
|
+
require 'ecm/links/engine'
|
10
|
+
require 'ecm/links/configuration'
|
11
|
+
require 'ecm/links/routing'
|
12
|
+
|
13
|
+
module Ecm
|
14
|
+
module Links
|
15
|
+
extend Configuration
|
16
|
+
|
17
|
+
def self.table_name_prefix
|
18
|
+
'ecm_links_'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ecm
|
2
|
+
module Links
|
3
|
+
module Generators
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
desc "Generates the intializer"
|
6
|
+
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
def generate_intializer
|
10
|
+
copy_file "ecm_links.rb", "config/initializers/ecm_links.rb"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Ecm::Links.configure do |config|
|
2
|
+
# Configure your link footer columns here.
|
3
|
+
#
|
4
|
+
# Default: config.link_footer_columns = 4
|
5
|
+
#
|
6
|
+
config.link_footer_columns = 4
|
7
|
+
|
8
|
+
# Configure your link footer colum css classes here.
|
9
|
+
#
|
10
|
+
# Default: config.link_footer_column_css_classes = %w[ link-footer-column col-lg-3 ]
|
11
|
+
#
|
12
|
+
config.link_footer_column_css_classes = %w[ link-footer-column col-lg-3 ]
|
13
|
+
|
14
|
+
# Set the base controller for the contact form
|
15
|
+
#
|
16
|
+
# Default: config.base_controller = 'ApplicationController'
|
17
|
+
#
|
18
|
+
config.base_controller = 'ApplicationController'
|
19
|
+
|
20
|
+
# Accepted markup languages
|
21
|
+
#
|
22
|
+
# default: config.markup_languages = %w[ textile ]
|
23
|
+
config.markup_languages = %w[ textile ]
|
24
|
+
|
25
|
+
# Default markup language
|
26
|
+
#
|
27
|
+
# default: config.default_markup_language = 'textile'
|
28
|
+
config.default_markup_language = 'textile'
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Ecm
|
2
|
+
module Links
|
3
|
+
module Generators
|
4
|
+
class LocalesGenerator < Rails::Generators::Base
|
5
|
+
desc "Copies the locale files to your application"
|
6
|
+
|
7
|
+
source_root File.expand_path('../../../../../../config/locales', __FILE__)
|
8
|
+
|
9
|
+
def generate_locales
|
10
|
+
copy_file "ecm.links.category.en.yml", "config/locales/ecm.links.category.en.yml"
|
11
|
+
copy_file "ecm.links.category.de.yml", "config/locales/ecm.links.category.de.yml"
|
12
|
+
copy_file "ecm.links.en.yml", "config/locales/ecm.links.en.yml"
|
13
|
+
copy_file "ecm.links.de.yml", "config/locales/ecm.links.de.yml"
|
14
|
+
copy_file "ecm.links.link.en.yml", "config/locales/ecm.links.link.en.yml"
|
15
|
+
copy_file "ecm.links.link.de.yml", "config/locales/ecm.links.link.de.yml"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
namespace :ecm_links do
|
2
|
+
namespace :db do
|
3
|
+
desc "Purges and creates example data"
|
4
|
+
task :populate!, [] => [:environment] do |t, args|
|
5
|
+
|
6
|
+
Rake::Task["ecm_links:db:clear!"].execute
|
7
|
+
Rake::Task["ecm_links:db:populate"].execute
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Clears all data!"
|
11
|
+
task :clear!, [] => [:environment] do |t, args|
|
12
|
+
Ecm::Links::Category.delete_all
|
13
|
+
Ecm::Links::Link.delete_all
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Creates example_data"
|
17
|
+
task :populate, [] => [:environment] do |t, args|
|
18
|
+
require "ffaker"
|
19
|
+
require "forgery"
|
20
|
+
|
21
|
+
# Create example categories
|
22
|
+
5.times do
|
23
|
+
Ecm::Links::Category.create! do |c|
|
24
|
+
c.locale = I18n.available_locales.map(&:to_s).choice
|
25
|
+
c.name = "#{Faker::Company.name} Category"
|
26
|
+
c.link_footer_column = [nil, 1, 2, 3, 4].choice
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
50.times do
|
31
|
+
Ecm::Links::Category.create! do |c|
|
32
|
+
c.parent = Ecm::Links::Category.all.choice
|
33
|
+
c.name = "#{Faker::Company.name} Category"
|
34
|
+
c.link_footer_column = [nil, 1, 2, 3, 4].choice
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Create example links
|
39
|
+
categories = Ecm::Links::Category.all
|
40
|
+
50.times do
|
41
|
+
Ecm::Links::Link.create! do |l|
|
42
|
+
l.name ="#{Faker::Company.name} Link"
|
43
|
+
l.url = "#{Faker::Internet.http_url} Link"
|
44
|
+
l.description = Faker::Lorem.paragraph(rand(3))
|
45
|
+
l.ecm_links_category = categories.choice
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|