bamboo_legals 0.0.6 → 0.0.7

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.
Files changed (36) hide show
  1. checksums.yaml +5 -5
  2. data/bamboo_legals-0.0.1.gem +0 -0
  3. data/bamboo_legals-0.0.2.gem +0 -0
  4. data/bamboo_legals-0.0.3.gem +0 -0
  5. data/bamboo_legals-0.0.4.gem +0 -0
  6. data/bamboo_legals-0.0.5.gem +0 -0
  7. data/bamboo_legals.gemspec +33 -0
  8. data/bamboo_legals_lib/bamboo_legals.rb +36 -0
  9. data/bamboo_legals_lib/generators/controller.rb +21 -0
  10. data/bamboo_legals_lib/generators/manual.rb +47 -0
  11. data/bamboo_legals_lib/generators/migration.rb +21 -0
  12. data/bamboo_legals_lib/generators/model.rb +20 -0
  13. data/bamboo_legals_lib/generators/routes.rb +28 -0
  14. data/bamboo_legals_lib/generators/views.rb +37 -0
  15. data/bamboo_legals_lib/templates/monolingual/admin_legals_controller.txt +51 -0
  16. data/bamboo_legals_lib/templates/monolingual/admin_views/_form.txt +33 -0
  17. data/bamboo_legals_lib/templates/monolingual/admin_views/_legal.txt +15 -0
  18. data/bamboo_legals_lib/templates/monolingual/admin_views/edit.txt +15 -0
  19. data/bamboo_legals_lib/templates/monolingual/admin_views/index.txt +31 -0
  20. data/bamboo_legals_lib/templates/monolingual/admin_views/new.txt +15 -0
  21. data/bamboo_legals_lib/templates/monolingual/legal.txt +26 -0
  22. data/bamboo_legals_lib/templates/monolingual/legals_controller.txt +5 -0
  23. data/bamboo_legals_lib/templates/monolingual/views/_index.txt +7 -0
  24. data/bamboo_legals_lib/templates/monolingual/views/show.txt +12 -0
  25. data/bamboo_legals_lib/templates/multilingual/admin_legals_controller.txt +56 -0
  26. data/bamboo_legals_lib/templates/multilingual/admin_views/_form.txt +43 -0
  27. data/bamboo_legals_lib/templates/multilingual/admin_views/edit.txt +13 -0
  28. data/bamboo_legals_lib/templates/multilingual/admin_views/index.txt +43 -0
  29. data/bamboo_legals_lib/templates/multilingual/admin_views/new.txt +13 -0
  30. data/bamboo_legals_lib/templates/multilingual/legal.txt +32 -0
  31. data/bamboo_legals_lib/templates/multilingual/legal_translation.txt +18 -0
  32. data/bamboo_legals_lib/templates/multilingual/legals_controller.txt +5 -0
  33. data/bamboo_legals_lib/templates/multilingual/views/_footer_legal.txt +6 -0
  34. data/bamboo_legals_lib/templates/multilingual/views/show.html.txt +17 -0
  35. data/readme.md +0 -0
  36. metadata +65 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 928113bb4a58d8824f2148c11de321a9d082a448
4
- data.tar.gz: 497357ac00a05c577aaacaef87bf68b5e25d33e5
2
+ SHA256:
3
+ metadata.gz: 955077c2b41e87e68132fdcbf0314d558dcc1f74bcc1dc20015b01decf9cf950
4
+ data.tar.gz: e02b6103dbeb747dc2e345ef1e7c6855b8aace2e88c94603eb434823a97b72bd
5
5
  SHA512:
6
- metadata.gz: a8c9cab594bacc8b84a46a69be08c77becd15fc9011de37e796a37e826ccbed3eb6b69e55a3ef078be64d1246a0f15ffe600711c67811cdb91f59480f8d46d2c
7
- data.tar.gz: fd7f450405a6ecbbed3a853bf9f794265bd4f8f19d9cfe3e015fd914a7f5d9620e1f72e7d839b349115683a8b0ffd89fd4d357c3cbdf3236ae38ce728b084c15
6
+ metadata.gz: f92076c4cc215051c8f230a9ddb5cc23ceed3cea35b9286221205515f1d897c8441ed1532a1c9f431e008a07556548aacf8207dfc63e169b3911c645ebe609a5
7
+ data.tar.gz: 58a4b3925dbb6bb8facf53812c46d833f800b8901da1757d5f4d27551310b9b9ee298bd5e4b774d1b85ef766cb1ce4bc788a5c23720f1250361909a0a3d41ff1
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'bamboo_legals'
7
+ s.version = '0.0.7'
8
+ s.date = '2020-09-10'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = "Bamboo Legals!"
11
+ s.description = "It should generate monolingual and multilingual legals for big_bamboom"
12
+ s.authors = ["Mislav Kvesić"]
13
+ s.email = 'kvesic.mislav@gmail.com'
14
+ s.require_paths = ['bamboo_legals_lib']
15
+ #s.files = Dir["{bin,lib}/**/*"]
16
+ # s.files = [
17
+ # "bamboo_legals_lib/generators/controller.rb",
18
+ # "bamboo_legals_lib/generators/manual.rb",
19
+ # "bamboo_legals_lib/generators/migration.rb",
20
+ # "bamboo_legals_lib/generators/model.rb",
21
+ # "bamboo_legals_lib/generators/routes.rb",
22
+ # "bamboo_legals_lib/generators/views.rb",
23
+ # ]
24
+ s.homepage = 'https://rubygems.org/gems/bamboo_legals'
25
+ s.license = 'MIT'
26
+ #s.executables << 'add_bamboo_legals'
27
+
28
+ s.add_development_dependency "bundler", "~> 1.3"
29
+ s.add_development_dependency "rake"
30
+
31
+ s.files = `git ls-files`.split($/)
32
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
33
+ end
@@ -0,0 +1,36 @@
1
+ require 'fileutils'
2
+
3
+ require_relative 'generators/migration'
4
+ require_relative 'generators/model'
5
+ require_relative 'generators/controller'
6
+ require_relative 'generators/views'
7
+ require_relative 'generators/routes'
8
+ require_relative 'generators/manual'
9
+
10
+ def run_generator(get_type)
11
+ if get_type == "monolingual" or get_type == "mono"
12
+ type = "monolingual"
13
+
14
+ `rails g model Legal title:string content:text is_visible:boolean position:integer`
15
+ elsif get_type == "multilingual" or get_type == "multi"
16
+ type = "multilingual"
17
+
18
+ `rails g model Legal is_visible:boolean position:integer`
19
+ `rails g model LegalTranslation title:string content:text language_id:string position:integer legal_id:integer`
20
+ end
21
+
22
+ if type
23
+ overwrite_migration
24
+ overwrite_model(type)
25
+
26
+ create_admin_controller(type)
27
+ create_controller(type)
28
+ create_admin_views(type)
29
+ create_views(type)
30
+
31
+ overwrite_routes
32
+ print_manual(type)
33
+ end
34
+
35
+ end
36
+
@@ -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,47 @@
1
+ def print_manual(type)
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
+ if type == "multilingual"
35
+ puts ""
36
+ puts "++ Maybe you are missing some helpers..."
37
+ puts """
38
+ look here: https://gitlab.com/bamboolab/b4b/-/blob/master/app/helpers/admin/language_helper.rb
39
+ """
40
+ end
41
+
42
+ puts ""
43
+ puts "++ Run"
44
+ puts """
45
+ rake db:migrate
46
+ """
47
+ 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
@@ -0,0 +1,51 @@
1
+ class Admin::LegalsController < Admin::BaseController
2
+ before_action :set_legal, only: [:edit, :update, :destroy]
3
+
4
+ def index
5
+ @legals = Legal.all
6
+ end
7
+
8
+ def new
9
+ @legal = Legal.new
10
+ end
11
+
12
+ def edit
13
+ end
14
+
15
+ def create
16
+ @legal = Legal.new(legal_params)
17
+ if @legal.save
18
+ redirect_to admin_legals_path, notice: t('saved_successfully')
19
+ else
20
+ render :new
21
+ end
22
+ end
23
+
24
+ def update
25
+ if @legal.update(legal_params)
26
+ redirect_to admin_legals_path, notice: t('saved_successfully')
27
+ else
28
+ render :edit
29
+ end
30
+ end
31
+
32
+ def destroy
33
+ redirect_to admin_legals_path, alert: t('deleted_successfully')
34
+ end
35
+
36
+ def sort
37
+ params[:legal].each_with_index do |id, index|
38
+ Legal.where(id: id).update_all(position: index + 1)
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def set_legal
45
+ @legal = Legal.find{ |t| t.title.parameterize == params[:id]}
46
+ end
47
+
48
+ def legal_params
49
+ params.require(:legal).permit(:title, :content, :is_visible)
50
+ end
51
+ end
@@ -0,0 +1,33 @@
1
+ <%= form_for [:admin, @legal], url: (@legal.new_record? ? admin_legals_path : admin_legal_path(id: @legal)), :html => {role: 'form', class: 'form'} do |f| %>
2
+ <fieldset class="form__fieldset">
3
+ <%=render partial: 'layouts/error_messages', as: :object, object: @legal %>
4
+ </fieldset>
5
+
6
+ <fieldset class="form__fieldset">
7
+ <div class="form__field">
8
+ <%= f.label :title, class: 'label' %>
9
+ <%= f.text_field :title, class: 'input' %>
10
+ </div>
11
+
12
+ <div class="form__field">
13
+ <%= f.label :content, class: 'label' %>
14
+ <%= f.text_area :content, class: 'input tinymce' %>
15
+ </div>
16
+
17
+ <div class="form__field input__field--text">
18
+ <%= f.check_box :is_visible, class: "input" %>
19
+ <%= f.label :is_visible, class: 'label' %>
20
+ </div>
21
+ </fieldset>
22
+ <fieldset class="form__fieldset">
23
+ <div class="field">
24
+ <%=f.submit t('save'), class: 'btn btn--full', data: {disable_with: '...'} %>
25
+ </div>
26
+ </fieldset>
27
+ <% end %>
28
+
29
+ <script>
30
+ $(document).ready(function(){
31
+ load_tiny();
32
+ });
33
+ </script>
@@ -0,0 +1,15 @@
1
+ <tr id=<%= dom_id(legal) %> class="table__item--wrap">
2
+ <td class="table__item col col--1"> <%#= image_tag("icons/dragndrop.png", height: '32', width: '32') %> </td>
3
+ <td class="table__item col col--1"><%= legal.title %></td>
4
+ <td class="table__item col col--1"><%= raw(legal.is_visible ? "&#10004;" : "&#10006;") %></td>
5
+ <td class="table__item col col--1" data-sort="<%= legal.created_at.strftime("%Y%m%d") %>"><%= legal.created_at.strftime("%d.%m.%Y.") %></td>
6
+ <td class="table__item table__icon--wrap col col--1">
7
+ <%= link_to edit_admin_legal_path(legal), class: "table__icon", "data-tooltip" => t('edit_tooltip') do %>
8
+ <%= inline_svg "icons/pen-group-3.svg" %>
9
+ <% end %>
10
+
11
+ <%= link_to [:admin, legal], method: :delete, data: { confirm: t('delete_confirm') }, class: "table__icon", "data-tooltip" => t('delete_tooltip') do %>
12
+ <%= inline_svg "icons/trash-simple.svg" %>
13
+ <% end %>
14
+ </td>
15
+ </tr>
@@ -0,0 +1,15 @@
1
+ <header class="header header--small">
2
+ <%= link_to admin_legals_path, class: "btn btn--back" do %>
3
+ <div class="arrow--left"></div>
4
+ <% end %>
5
+
6
+ <div class="header__content">
7
+ <h1><%= t('admin_nav.legals') %></h1>
8
+ <span class="main__subtitle"><%= t('edit') %></span>
9
+ </div>
10
+ </header>
11
+
12
+
13
+ <section class="section section--padded section--8">
14
+ <%= render 'form' %>
15
+ </section>
@@ -0,0 +1,31 @@
1
+ <header class="header header--double">
2
+ <h1><%= t('admin_nav.legal') %></h1>
3
+ <%= link_to t('create'), new_admin_legal_path, class: "btn btn--primary btn--large" %>
4
+ </header>
5
+
6
+ <section class="section section--12 section--double">
7
+
8
+ <table class="datatable table__icon--4">
9
+ <thead>
10
+ <tr class="table__head--wrap">
11
+ <td class="table__item col col--1"> </td>
12
+ <th class="table__head col col--1"><%= t('activerecord.attributes.legal.title') %></th>
13
+ <th class="table__head col col--1"><%= t('activerecord.attributes.legal.is_visible') %> </th>
14
+ <th class="table__head col col--1"><%= t('activerecord.attributes.legal.created_at') %> </th>
15
+ <th class="table__head col col--1"><%= t('actions') %></th>
16
+ </tr>
17
+ </thead>
18
+
19
+ <tbody class="sortable" data-url='<%=sort_admin_legals_path %>' >
20
+ <% @legals.each do |legal| %>
21
+ <%= render "legal", legal: legal %>
22
+ <% end %>
23
+ </tbody>
24
+ </table>
25
+ </section>
26
+
27
+ <script>
28
+ $(function(){
29
+ // init_datatable("<%= I18n.locale %>");
30
+ })
31
+ </script>
@@ -0,0 +1,15 @@
1
+ <header class="header header--small">
2
+ <%= link_to admin_legals_path, class: "btn btn--back" do %>
3
+ <div class="arrow--left"></div>
4
+ <% end %>
5
+
6
+ <div class="header__content">
7
+ <h1><%= t('admin_nav.legals') %></h1>
8
+ <span class="main__subtitle"><%= t('new') %></span>
9
+ </div>
10
+ </header>
11
+
12
+
13
+ <section class="section section--padded section--8">
14
+ <%= render 'form' %>
15
+ </section>
@@ -0,0 +1,26 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: legals
4
+ #
5
+ # id :bigint not null, primary key
6
+ # title :string
7
+ # content :text
8
+ # position :integer
9
+ # is_visible :boolean default("true")
10
+ # created_at :datetime not null
11
+ # updated_at :datetime not null
12
+ #
13
+ class Legal < ApplicationRecord
14
+ include LogActions
15
+ default_scope { order(:position) }
16
+ validates_presence_of :title, :content
17
+
18
+ def self.all_visible
19
+ where(is_visible: true)
20
+ end
21
+
22
+ def to_param
23
+ "#{self.title.parameterize}"
24
+ end
25
+
26
+ end
@@ -0,0 +1,5 @@
1
+ class LegalsController < ApplicationController
2
+ def show
3
+ @legal = Legal.find{ |t| t.title.parameterize == params[:id]}
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ <% unless @legals.blank? %>
2
+ <nav class="nav--footer nav--legal">
3
+ <% @legals.each do |legal| %>
4
+ <%= link_to legal.title, legal_path(legal), class: 'nav__link' %>
5
+ <% end %>
6
+ </nav>
7
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <!-- SEO -->
2
+ <% content_for :title, "#{@legal.title}" %>
3
+ <% content_for :description, truncate(strip_tags(@legal.content), length: 160 ) %>
4
+
5
+ <div class="layout--main">
6
+ <div class="section">
7
+ <h1><%= @legal.title %></h1>
8
+ </div>
9
+ <article class="article">
10
+ <%= raw @legal.content %>
11
+ </article>
12
+ </div>
@@ -0,0 +1,56 @@
1
+ class Admin::LegalsController < Admin::BaseController
2
+ before_action :set_legal, only: [:show, :edit, :update, :destroy]
3
+
4
+ def index
5
+ @legals = Legal.all
6
+ end
7
+
8
+ def new
9
+ @legal = Legal.new
10
+ end
11
+
12
+ def create
13
+ @legal = Legal.new(legal_params)
14
+
15
+ if @legal.save
16
+ redirect_to admin_legals_path, notice: t('saved_successfully')
17
+ else
18
+ render :new
19
+ end
20
+ end
21
+
22
+ def edit
23
+ end
24
+
25
+ def update
26
+ if @legal.update(legal_params)
27
+ redirect_to admin_legals_path, notice: t('saved_successfully')
28
+ else
29
+ render :edit
30
+ end
31
+ end
32
+
33
+ def destroy
34
+ if @legal.destroy
35
+ redirect_to admin_legals_path, notice: t('deleted')
36
+ else
37
+ redirect_to admin_legals_path, alert: t('not_deleted')
38
+ end
39
+ end
40
+
41
+ def sort
42
+ params[:legal].each_with_index do |id, index|
43
+ Legal.where(id: id).update_all(position: index + 1)
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def set_legal
50
+ @legal = LegalTranslation.find{|t| t.title.parameterize == params[:id]}.legal
51
+ end
52
+
53
+ def legal_params
54
+ params.require(:legal).permit(:is_visible, legal_translations_attributes: [:id, :title, :content, :language_id, :position, :keywords])
55
+ end
56
+ end
@@ -0,0 +1,43 @@
1
+ <%= form_for [:admin, @legal], url: (@legal.new_record? ? admin_legals_path : admin_legal_path(id: @legal)), :html => {role: 'form', class: 'form'} do |f| %>
2
+ <fieldset class="form__fieldset">
3
+ <%=render partial: 'layouts/error_messages', as: :object, object: @legal %>
4
+ </fieldset>
5
+
6
+ <fieldset class="form__fieldset">
7
+ <div class="form__field">
8
+ <%= f.fields_for :legal_translations do |ff| %>
9
+ <%= language_title(ff) %>
10
+
11
+ <div class="form__field">
12
+ <%= ff.label :title, class: 'label' %>
13
+ <%= ff.text_field :title, class: 'input' %>
14
+ </div>
15
+
16
+ <div class="form__field">
17
+ <%= ff.label :content, class: 'label' %>
18
+ <%= ff.text_area :content, class: 'input tinymce' %>
19
+ </div>
20
+
21
+ <%= ff.hidden_field :language_id, value: language_value(ff) %>
22
+ <%= ff.hidden_field :position, value: ff.options[:child_index] %>
23
+ <% end %>
24
+
25
+ <div class="form__field input__field--text">
26
+ <%= f.label :is_visible, class: 'label' %>
27
+ <%= f.check_box :is_visible, class: 'input' %>
28
+ </div>
29
+
30
+ </fieldset>
31
+
32
+ <fieldset class="form__fieldset">
33
+ <div class="field">
34
+ <%=f.submit t('save'), class: 'btn btn--full', data: {disable_with: '...'} %>
35
+ </div>
36
+ </fieldset>
37
+ <% end %>
38
+
39
+ <script>
40
+ $(document).ready(function(){
41
+ load_tiny("hr");
42
+ });
43
+ </script>
@@ -0,0 +1,13 @@
1
+ <header class="header header--small">
2
+ <%= link_to admin_legals_path, class: "btn btn--back" do %>
3
+ <div class="arrow--left"></div>
4
+ <% end %>
5
+
6
+ <div class="header__content">
7
+ <h1><%= t('admin_nav.legals') %></h1>
8
+ </div>
9
+ </header>
10
+
11
+ <div class="section section--padded section__wrap--8 js_part">
12
+ <%= render 'form' %>
13
+ </div>
@@ -0,0 +1,43 @@
1
+ <header class="header header--double">
2
+ <h1><%= t('admin_nav.legals') %></h1>
3
+ <%= link_to t('create'), new_admin_legal_path, class: "btn btn--primary btn--large" %>
4
+ </header>
5
+
6
+ <section class="section section--12 section--double">
7
+
8
+ <table class="datatable custom-table table__icon--4">
9
+ <thead>
10
+ <tr class="table__head--wrap">
11
+ <th class="table__head col col--1"> <%= t('drag_and_drop') %> </th>
12
+ <th class="table__head col col--1"><%= t('activerecord.attributes.legal_translation.title') %></th>
13
+ <th class="table__head col col--1"><%= t('activerecord.attributes.legal.created_at') %> </th>
14
+ <th class="table__head col col--1"><%= t('actions') %></th>
15
+ </tr>
16
+ </thead>
17
+
18
+ <tbody class="sortable" data-url='<%=sort_admin_legals_path %>' >
19
+ <% @legals.each do |legal| %>
20
+ <tr id=<%= dom_id(legal) %> class="table__item--wrap">
21
+ <td class="table__item col col--1"> <%#= image_tag("icons/dragndrop.png", height: '32', width: '32') %> </td>
22
+ <td class="table__item col col--1"><%= legal.translate.title %></td>
23
+ <td class="table__item col col--1" data-sort="<%= legal.created_at.strftime("%Y%m%d") %>"><%= legal.created_at.strftime("%d.%m.%Y.") %></td>
24
+ <td class="table__item table__icon--wrap col col--1">
25
+ <%= link_to edit_admin_legal_path(legal), class: "table__icon" do %>
26
+ <%= inline_svg "icons/pen-group-3.svg" %>
27
+ <% end %>
28
+
29
+ <%= link_to [:admin, legal], method: :delete, data: { confirm: t('delete_confirm') }, class: "table__icon" do %>
30
+ <%= inline_svg "icons/trash-simple.svg" %>
31
+ <% end %>
32
+ </td>
33
+ </tr>
34
+ <% end %>
35
+ </tbody>
36
+ </table>
37
+ </section>
38
+
39
+ <script>
40
+ $(function(){
41
+ // init_datatable("<%= I18n.locale %>");
42
+ })
43
+ </script>
@@ -0,0 +1,13 @@
1
+ <header class="header header--small">
2
+ <%= link_to admin_legals_path, class: "btn btn--back" do %>
3
+ <div class="arrow--left"></div>
4
+ <% end %>
5
+
6
+ <div class="header__content">
7
+ <h1><%= t('admin_nav.legals') %></h1>
8
+ </div>
9
+ </header>
10
+
11
+ <div class="section section--padded section__wrap--8 js_part">
12
+ <%= render 'form' %>
13
+ </div>
@@ -0,0 +1,32 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: legals
4
+ #
5
+ # id :bigint not null, primary key
6
+ # position :integer
7
+ # is_visible :boolean default("true")
8
+ # created_at :datetime not null
9
+ # updated_at :datetime not null
10
+ #
11
+ class Legal < ApplicationRecord
12
+ include LogActions
13
+
14
+ has_many :legal_translations, dependent: :destroy
15
+ accepts_nested_attributes_for :legal_translations
16
+
17
+ include TranslationsInitializer
18
+ def to_param
19
+ "#{self.legal_translations.find_by(language_id: I18n.locale).title.parameterize}"
20
+ end
21
+
22
+ def translate(language_id=I18n.locale.to_s)
23
+ # commented code can be to added to app/models/concerns/translation_initializer.rb
24
+ # so other models can use it
25
+ #def translate(language_id=I18n.locale.to_s)
26
+ # translations = eval("#{self.model_name.param_key}_translations")
27
+ # translations.find_by(language_id: language_id)
28
+ #end
29
+
30
+ legal_translations.find_by(language_id: language_id)
31
+ end
32
+ end
@@ -0,0 +1,18 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: legal_translations
4
+ #
5
+ # id :bigint not null, primary key
6
+ # title :string
7
+ # content :text
8
+ # legal_id :integer
9
+ # language_id :string
10
+ # position :integer
11
+ # keywords :string
12
+ # created_at :datetime not null
13
+ # updated_at :datetime not null
14
+ #
15
+ class LegalTranslation < ApplicationRecord
16
+ belongs_to :legal
17
+ default_scope { order(:position) }
18
+ end
@@ -0,0 +1,5 @@
1
+ class LegalsController < ApplicationController
2
+ def show
3
+ @legal = LegalTranslation.find{|t| t.title.parameterize == params[:id]}.legal
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ <h5><%= t('help') %></h5>
2
+ <ul class="footer__list">
3
+ <% @legals.each do |legal| %>
4
+ <li> <%= link_to legal.translate.title, legal_path(legal) %>
5
+ <% end %>
6
+ </ul>
@@ -0,0 +1,17 @@
1
+ <!-- SEO -->
2
+ <% content_for :title, "#{@legal.translate.title}" %>
3
+ <% content_for :description, truncate(strip_tags(@legal.translate.content), length: 160 ) %>
4
+
5
+ <div class="layout--full">
6
+ <div class="layout--main">
7
+ <div class="text--center">
8
+
9
+ <h2><%= @legal.translate.title %></h2>
10
+
11
+ <div class="post__text">
12
+ <%= raw @legal.translate.content %>
13
+ </div>
14
+
15
+ </div>
16
+ </div>
17
+ </div>
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bamboo_legals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mislav Kvesić
@@ -9,7 +9,35 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2020-09-10 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: It should generate monolingual and multilingual legals for big_bamboom
14
42
  email: kvesic.mislav@gmail.com
15
43
  executables:
@@ -17,7 +45,41 @@ executables:
17
45
  extensions: []
18
46
  extra_rdoc_files: []
19
47
  files:
48
+ - bamboo_legals-0.0.1.gem
49
+ - bamboo_legals-0.0.2.gem
50
+ - bamboo_legals-0.0.3.gem
51
+ - bamboo_legals-0.0.4.gem
52
+ - bamboo_legals-0.0.5.gem
53
+ - bamboo_legals.gemspec
54
+ - bamboo_legals_lib/bamboo_legals.rb
55
+ - bamboo_legals_lib/generators/controller.rb
56
+ - bamboo_legals_lib/generators/manual.rb
57
+ - bamboo_legals_lib/generators/migration.rb
58
+ - bamboo_legals_lib/generators/model.rb
59
+ - bamboo_legals_lib/generators/routes.rb
60
+ - bamboo_legals_lib/generators/views.rb
61
+ - bamboo_legals_lib/templates/monolingual/admin_legals_controller.txt
62
+ - bamboo_legals_lib/templates/monolingual/admin_views/_form.txt
63
+ - bamboo_legals_lib/templates/monolingual/admin_views/_legal.txt
64
+ - bamboo_legals_lib/templates/monolingual/admin_views/edit.txt
65
+ - bamboo_legals_lib/templates/monolingual/admin_views/index.txt
66
+ - bamboo_legals_lib/templates/monolingual/admin_views/new.txt
67
+ - bamboo_legals_lib/templates/monolingual/legal.txt
68
+ - bamboo_legals_lib/templates/monolingual/legals_controller.txt
69
+ - bamboo_legals_lib/templates/monolingual/views/_index.txt
70
+ - bamboo_legals_lib/templates/monolingual/views/show.txt
71
+ - bamboo_legals_lib/templates/multilingual/admin_legals_controller.txt
72
+ - bamboo_legals_lib/templates/multilingual/admin_views/_form.txt
73
+ - bamboo_legals_lib/templates/multilingual/admin_views/edit.txt
74
+ - bamboo_legals_lib/templates/multilingual/admin_views/index.txt
75
+ - bamboo_legals_lib/templates/multilingual/admin_views/new.txt
76
+ - bamboo_legals_lib/templates/multilingual/legal.txt
77
+ - bamboo_legals_lib/templates/multilingual/legal_translation.txt
78
+ - bamboo_legals_lib/templates/multilingual/legals_controller.txt
79
+ - bamboo_legals_lib/templates/multilingual/views/_footer_legal.txt
80
+ - bamboo_legals_lib/templates/multilingual/views/show.html.txt
20
81
  - bin/add_bamboo_legals
82
+ - readme.md
21
83
  homepage: https://rubygems.org/gems/bamboo_legals
22
84
  licenses:
23
85
  - MIT
@@ -37,8 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
37
99
  - !ruby/object:Gem::Version
38
100
  version: '0'
39
101
  requirements: []
40
- rubyforge_project:
41
- rubygems_version: 2.6.14
102
+ rubygems_version: 3.1.4
42
103
  signing_key:
43
104
  specification_version: 4
44
105
  summary: Bamboo Legals!