bamboo_legals 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bamboo_legals_lib/generators/controller.rb +21 -0
- data/bamboo_legals_lib/generators/manual.rb +39 -0
- data/bamboo_legals_lib/generators/migration.rb +21 -0
- data/bamboo_legals_lib/generators/model.rb +20 -0
- data/bamboo_legals_lib/generators/routes.rb +28 -0
- data/bamboo_legals_lib/generators/views.rb +37 -0
- metadata +49 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 5015b767af2696eed60d7c0514ee76cac12c6dd7
|
|
4
|
+
data.tar.gz: c07162bdf608efd53491092d2683676b1ef5d1d0
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: fd76731d2f4e973a8dfadf3832401b52eda70e8a192586496bfa24b2ecfc26d14d8df5459dcd6266464d25855b31adbddedbe2841770d9f944c696d3e0ca9c2f
|
|
7
|
+
data.tar.gz: 97400f3511dc8c7c2f1bbf34cc92b8acea2b45ec27cf774d6ca8c896ba13297858a956bcf8952a99c01f1aad8b79d0f5fe02b98aed3c9140a63b44b345af69ab
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
def create_admin_controller(type)
|
|
2
|
+
# find the legal controller
|
|
3
|
+
controller_path = "app/controllers/admin/legals_controller.rb"
|
|
4
|
+
template_controller_path = "bamboo_legals/bamboo_legals_lib/templates/#{type}/admin_legals_controller.txt"
|
|
5
|
+
|
|
6
|
+
new_controller_text = File.open(template_controller_path).read
|
|
7
|
+
File.write(controller_path, new_controller_text)
|
|
8
|
+
|
|
9
|
+
puts "++ Created -> #{controller_path}"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def create_controller(type)
|
|
13
|
+
# find the legal controller
|
|
14
|
+
controller_path = "app/controllers/legals_controller.rb"
|
|
15
|
+
template_controller_path = "bamboo_legals/bamboo_legals_lib/templates/#{type}/legals_controller.txt"
|
|
16
|
+
|
|
17
|
+
new_controller_text = File.open(template_controller_path).read
|
|
18
|
+
File.write(controller_path, new_controller_text)
|
|
19
|
+
|
|
20
|
+
puts "++ Created -> #{controller_path}"
|
|
21
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
def print_manual
|
|
2
|
+
puts ""
|
|
3
|
+
puts "++ Add locales"
|
|
4
|
+
puts """
|
|
5
|
+
admin_nav:
|
|
6
|
+
legals: \"Legal Pages\"
|
|
7
|
+
|
|
8
|
+
activerecord:
|
|
9
|
+
attributes:
|
|
10
|
+
legal:
|
|
11
|
+
is_visible: \"Page is visible?\"
|
|
12
|
+
title: \"Title\"
|
|
13
|
+
content: \"Content\"
|
|
14
|
+
created_at: \"Created at\"
|
|
15
|
+
errors:
|
|
16
|
+
models:
|
|
17
|
+
legal:
|
|
18
|
+
attributes:
|
|
19
|
+
title:
|
|
20
|
+
blank: \"Title can't be blank!\"
|
|
21
|
+
content:
|
|
22
|
+
blank: \"Content can't be blank!\"
|
|
23
|
+
"""
|
|
24
|
+
puts ""
|
|
25
|
+
puts "++ Add to app/views/layouts/admin/_navigation.html.erb"
|
|
26
|
+
puts """
|
|
27
|
+
<% if current_admin.permitted?(:legals) %>
|
|
28
|
+
<%= active_link_to admin_legals_path, class: 'sidebar__link', active: :inclusive, class_active: 'active-link' do %>
|
|
29
|
+
<%= inline_svg \"icons/nav/court.svg\", class: 'sidebar__icon', width: 16, height: 16 %>
|
|
30
|
+
<%= t(\"admin_nav.legals\") %>
|
|
31
|
+
<% end %>
|
|
32
|
+
<% end %>
|
|
33
|
+
"""
|
|
34
|
+
puts ""
|
|
35
|
+
puts "++ Run"
|
|
36
|
+
puts """
|
|
37
|
+
rake db:migrate
|
|
38
|
+
"""
|
|
39
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
def overwrite_migration
|
|
2
|
+
# find the legal migration
|
|
3
|
+
migrations_path = "db/migrate/"
|
|
4
|
+
migration_path = "#{migrations_path}#{Dir.entries(migrations_path).grep(/_create_legals.rb$/).first}"
|
|
5
|
+
|
|
6
|
+
new_migration_text = ""
|
|
7
|
+
migration = File.open(migration_path).read
|
|
8
|
+
migration.each_line do |line|
|
|
9
|
+
# add detault: true to migration
|
|
10
|
+
if line.include?("t.boolean :is_visible")
|
|
11
|
+
new_migration_text += " t.boolean :is_visible, default: true \n"
|
|
12
|
+
else
|
|
13
|
+
new_migration_text += line
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# rewrite the migration file
|
|
18
|
+
File.write(migration_path, new_migration_text)
|
|
19
|
+
|
|
20
|
+
puts "++ Changed -> #{migration_path}"
|
|
21
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
def overwrite_model(type)
|
|
2
|
+
# find the legal model
|
|
3
|
+
model_path = "app/models/legal.rb"
|
|
4
|
+
template_model_path = "bamboo_legals/bamboo_legals_lib/templates/#{type}/legal.txt"
|
|
5
|
+
|
|
6
|
+
new_model_text = File.open(template_model_path).read
|
|
7
|
+
File.write(model_path, new_model_text)
|
|
8
|
+
|
|
9
|
+
puts "++ Changed -> #{model_path}"
|
|
10
|
+
|
|
11
|
+
if type == "multilingual"
|
|
12
|
+
model_translation_path = "app/models/legal_translation.rb"
|
|
13
|
+
template_model_translation_path = "bamboo_legals/bamboo_legals_lib/templates/#{type}/legal_translation.txt"
|
|
14
|
+
|
|
15
|
+
new_model_translation_text = File.open(template_model_translation_path).read
|
|
16
|
+
File.write(model_translation_path, new_model_translation_text)
|
|
17
|
+
|
|
18
|
+
puts "++ Changed -> #{model_translation_path}"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
def overwrite_routes
|
|
2
|
+
# find the routes
|
|
3
|
+
route_path = "config/routes.rb"
|
|
4
|
+
|
|
5
|
+
# text that will overwrite namespace :admin do
|
|
6
|
+
to_add = """ resources :legals, only: [:show]
|
|
7
|
+
namespace :admin do
|
|
8
|
+
resources :legals, except: [:show] do
|
|
9
|
+
collection { patch :sort }
|
|
10
|
+
end
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
new_routes_text = ""
|
|
14
|
+
routes = File.open(route_path).read
|
|
15
|
+
routes.each_line do |line|
|
|
16
|
+
# add routes for legal
|
|
17
|
+
if line.include?("namespace :admin do")
|
|
18
|
+
new_routes_text += to_add
|
|
19
|
+
else
|
|
20
|
+
new_routes_text += line
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# rewrite the routes file
|
|
25
|
+
File.write(route_path, new_routes_text)
|
|
26
|
+
|
|
27
|
+
puts "++ Changed -> #{route_path}"
|
|
28
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
def create_admin_views(type)
|
|
2
|
+
admin_view_dir_path = 'app/views/admin/legals/'
|
|
3
|
+
|
|
4
|
+
# create directory for legal views in admin
|
|
5
|
+
Dir.mkdir admin_view_dir_path
|
|
6
|
+
|
|
7
|
+
# find all template views
|
|
8
|
+
template_views_path = "bamboo_legals/bamboo_legals_lib/templates/#{type}/admin_views/"
|
|
9
|
+
Dir.entries(template_views_path).each do |template|
|
|
10
|
+
next if template == "." or template == ".."
|
|
11
|
+
|
|
12
|
+
new_text = File.open("#{template_views_path}#{template}").read
|
|
13
|
+
new_file_name = "#{admin_view_dir_path}#{template.split(".")[0]}.html.erb"
|
|
14
|
+
File.write(new_file_name, new_text)
|
|
15
|
+
|
|
16
|
+
puts "++ Created -> #{new_file_name}"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def create_views(type)
|
|
21
|
+
view_dir_path = 'app/views/legals/'
|
|
22
|
+
|
|
23
|
+
# create directory for legal views
|
|
24
|
+
Dir.mkdir view_dir_path
|
|
25
|
+
|
|
26
|
+
# find all template views
|
|
27
|
+
template_views_path = "bamboo_legals/bamboo_legals_lib/templates/#{type}/views/"
|
|
28
|
+
Dir.entries(template_views_path).each do |template|
|
|
29
|
+
next if template == "." or template == ".."
|
|
30
|
+
|
|
31
|
+
new_text = File.open("#{template_views_path}#{template}").read
|
|
32
|
+
new_file_name = "#{view_dir_path}#{template.split(".")[0]}.html.erb"
|
|
33
|
+
File.write(new_file_name, new_text)
|
|
34
|
+
|
|
35
|
+
puts "++ Created -> #{new_file_name}"
|
|
36
|
+
end
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bamboo_legals
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mislav Kvesić
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-09-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: It should generate monolingual and multilingual legals for big_bamboom
|
|
14
|
+
email: kvesic.mislav@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- bamboo_legals_lib/generators/controller.rb
|
|
20
|
+
- bamboo_legals_lib/generators/manual.rb
|
|
21
|
+
- bamboo_legals_lib/generators/migration.rb
|
|
22
|
+
- bamboo_legals_lib/generators/model.rb
|
|
23
|
+
- bamboo_legals_lib/generators/routes.rb
|
|
24
|
+
- bamboo_legals_lib/generators/views.rb
|
|
25
|
+
homepage: https://rubygems.org/gems/bamboo_legals
|
|
26
|
+
licenses:
|
|
27
|
+
- MIT
|
|
28
|
+
metadata: {}
|
|
29
|
+
post_install_message:
|
|
30
|
+
rdoc_options: []
|
|
31
|
+
require_paths:
|
|
32
|
+
- lib
|
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '0'
|
|
43
|
+
requirements: []
|
|
44
|
+
rubyforge_project:
|
|
45
|
+
rubygems_version: 2.6.14
|
|
46
|
+
signing_key:
|
|
47
|
+
specification_version: 4
|
|
48
|
+
summary: Bamboo Legals!
|
|
49
|
+
test_files: []
|