tramway-landing 1.8 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +84 -8
  3. data/Rakefile +3 -5
  4. data/app/controllers/tramway/landing/application_controller.rb +2 -0
  5. data/app/decorators/tramway/landing/block_decorator.rb +5 -3
  6. data/app/decorators/tramway/landing/block_types/cards_decorator.rb +2 -0
  7. data/app/decorators/tramway/landing/block_types/features_decorator.rb +3 -1
  8. data/app/decorators/tramway/landing/link_decorator.rb +2 -0
  9. data/app/decorators/tramway/landing/navbar_decorator.rb +2 -0
  10. data/app/forms/tramway/landing/block_form.rb +12 -13
  11. data/app/helpers/tramway/landing/application_helper.rb +2 -0
  12. data/app/jobs/tramway/landing/application_job.rb +2 -0
  13. data/app/mailers/tramway/landing/application_mailer.rb +2 -0
  14. data/app/models/tramway/landing/application_record.rb +2 -0
  15. data/app/models/tramway/landing/block.rb +16 -14
  16. data/app/uploaders/tramway/landing/photo_versions.rb +2 -0
  17. data/config/initializers/assets.rb +4 -2
  18. data/config/initializers/tramway.rb +2 -0
  19. data/config/locales/models.yml +4 -3
  20. data/config/routes.rb +2 -0
  21. data/lib/tasks/tramway/landing_tasks.rake +2 -0
  22. data/lib/tramway/landing/engine.rb +2 -0
  23. data/lib/tramway/landing/generates/install_generator.rb +12 -10
  24. data/lib/tramway/landing/generates/templates/add_anchor_to_tramway_landing_blocks.rb +2 -0
  25. data/lib/tramway/landing/generates/templates/add_button_to_tramway_landing_blocks.rb +2 -0
  26. data/lib/tramway/landing/generates/templates/add_description_to_tramway_landing_blocks.rb +2 -0
  27. data/lib/tramway/landing/generates/templates/add_link_object_id_to_tramway_landing_blocks.rb +2 -0
  28. data/lib/tramway/landing/generates/templates/add_link_object_type_to_tramway_landing_blocks.rb +2 -0
  29. data/lib/tramway/landing/generates/templates/add_navbar_link_to_tramway_landing_blocks.rb +2 -0
  30. data/lib/tramway/landing/generates/templates/add_view_name_to_tramway_landing_blocks.rb +2 -0
  31. data/lib/tramway/landing/generates/templates/create_tramway_landing_blocks.rb +2 -0
  32. data/lib/tramway/landing/version.rb +3 -1
  33. data/lib/tramway/landing.rb +3 -1
  34. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e74664af83fb56c8127c0ccb38dcfe389dda475a82b0b555bda93b7d94d56094
4
- data.tar.gz: a95df8d21c49dfc28fa6b5652fdae5e2f54ace6d7511de1091e70b22d5638cf9
3
+ metadata.gz: df3212d34d48f9939cf2ec801429d8fe85b00f09dac5e8216e307dc998704941
4
+ data.tar.gz: cc2367afc4f7ad7829c7fd8202a33acd297e7cfaefd558c9ae8c6ef639d0ad91
5
5
  SHA512:
6
- metadata.gz: d13d3a202bec874c370ca73d378c74895442ede071e74c7aa2924668ecf0f9760adca4b70cb4ca45a0887fbec7867965033f1deb274040e7f24a2047f1c30ea0
7
- data.tar.gz: faa355ec8ff76a08ec3de1ce1120619288f47a0fcd0eba76e6c9c5a62495150234bab7518624af08c050676f4017fa7130145e61712e2fca31b1a580a1d2c0d1
6
+ metadata.gz: 6ae5bbaaa6cb943b25cf37e96b468012c9c8405040f1bedb31f4ad0b32c96b3ebf573e62136a4fbea19faf5fb9a0309b000d2845e51ad1d39b3ec1e62229e446
7
+ data.tar.gz: 2ebbb863f7ffbdd5698d9d2b12130544cb0a73d5a77a16458a09e2088c6ae5644fa6611de2462f8b030917528094151d6b61391aeb42da82e840d7999cca7c57
data/README.md CHANGED
@@ -1,8 +1,25 @@
1
1
  # Tramway::Landing
2
2
  Short description and motivation.
3
3
 
4
- ## Usage
5
- How to use my plugin.
4
+ ## Description
5
+
6
+ Tramway-landing provides several types of blocks for main page.
7
+
8
+ List of blocks:
9
+
10
+ * Header
11
+ * Footer
12
+ * Block with text and image
13
+ * Block with text, image and button
14
+ * Cards
15
+ * Features list
16
+ * Contacts
17
+ * News
18
+ * Block with text and button
19
+ * View
20
+ * Just text
21
+
22
+ All block's previews you can see at the bottom of this Readme
6
23
 
7
24
  ## Installation
8
25
  Add this line to your application's Gemfile:
@@ -11,16 +28,75 @@ Add this line to your application's Gemfile:
11
28
  gem 'tramway-landing'
12
29
  ```
13
30
 
14
- And then execute:
15
- ```bash
16
- $ bundle
31
+ Then run:
32
+
33
+ ```shell
34
+ rails g tramway:landing:install
35
+ rails db:migrate
36
+ ```
37
+
38
+ *config/initializers/tramway.rb*
39
+ ```ruby
40
+ Tramway::Admin.set_available_models ::Tramway::Landing::Block, project: #{project_name_which_you_use_in_the_application}
41
+ ```
42
+
43
+ Run server `rails s`
44
+ Open `localhost:3000/admin`
45
+ Click on `Block`, add new block with type `Header`
46
+ Click `Show` in the block menu
47
+
48
+ Then create your main page controller `rails g controller web/welcome`
49
+
50
+ *app/controllers/web/welcome_controller.rb*
51
+ ```ruby
52
+ class Web::WelcomeController < ApplicationController
53
+ def index
54
+ @blocks = ::Tramway::Landing::BlockDecorator.decorate ::Tramway::Landing::Block.on_main_page
55
+ end
56
+ end
17
57
  ```
18
58
 
19
- Or install it yourself as:
20
- ```bash
21
- $ gem install tramway-landing
59
+ *config/routes.rb*
60
+ ```ruby
61
+ # ...
62
+ root to: 'web/welcome#index'
63
+ # ...
22
64
  ```
23
65
 
66
+ *app/views/web/welcome/index.html.haml*
67
+ ```haml
68
+ = content_for :head_content do
69
+ -# your content for <head>
70
+
71
+ = content_for :title do
72
+ -# your content for <title>
73
+
74
+ = content_for :application_tagline do
75
+ -# tagline in the header type block
76
+
77
+ = content_for :address do
78
+ -# main address info
79
+
80
+ = content_for :phone do
81
+ -# main phone info
82
+
83
+ = content_for :footer_links do
84
+ -# list of footer links
85
+
86
+ = content_for :footer_logo do
87
+ -# list of footer logos
88
+
89
+ = content_for :latitude do
90
+ -# latitude for contacts block type map
91
+
92
+ = content_for :longtitude do
93
+ -# longtitude for contacts block type map
94
+
95
+ -# everything you want on the main page
96
+ ```
97
+
98
+ Then all your showing blocks will be on the main page.
99
+
24
100
  ## Contributing
25
101
  Contribution directions go here.
26
102
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'bundler/setup'
3
5
  rescue LoadError
@@ -14,14 +16,11 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
16
  rdoc.rdoc_files.include('lib/**/*.rb')
15
17
  end
16
18
 
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
19
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
18
20
  load 'rails/tasks/engine.rake'
19
21
 
20
-
21
22
  load 'rails/tasks/statistics.rake'
22
23
 
23
-
24
-
25
24
  require 'bundler/gem_tasks'
26
25
 
27
26
  require 'rake/testtask'
@@ -32,5 +31,4 @@ Rake::TestTask.new(:test) do |t|
32
31
  t.verbose = false
33
32
  end
34
33
 
35
-
36
34
  task default: :test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Landing
3
5
  class ApplicationController < ActionController::Base
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Landing::BlockDecorator < ::Tramway::Core::ApplicationDecorator
2
4
  class << self
3
5
  def collections
4
- [ :all ]
6
+ [:all]
5
7
  end
6
8
 
7
9
  def list_attributes
8
- [ :position, :view_state, :block_type ]
10
+ %i[position view_state block_type]
9
11
  end
10
12
 
11
13
  delegate :human_view_state_event_name, to: :model_class
@@ -18,7 +20,7 @@ class Tramway::Landing::BlockDecorator < ::Tramway::Core::ApplicationDecorator
18
20
  delegate :description, to: :object
19
21
  delegate :anchor, to: :object
20
22
  delegate :view_name, to: :object
21
-
23
+
22
24
  def block_type
23
25
  object.block_type_text
24
26
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Landing::BlockTypes::CardsDecorator < ::Tramway::Core::ApplicationDecorator
2
4
  def image; end
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Landing::BlockTypes::FeaturesDecorator < ::Tramway::Core::ApplicationDecorator
2
4
  def icon; end
3
5
 
@@ -18,7 +20,7 @@ class Tramway::Landing::BlockTypes::FeaturesDecorator < ::Tramway::Core::Applica
18
20
  "##{anchor}"
19
21
  else
20
22
  if external_link.present?
21
- if external_link.match?(/^https?:\/\//)
23
+ if external_link.match?(%r{^https?://})
22
24
  external_link
23
25
  else
24
26
  "http://#{external_link}"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Landing::LinkDecorator < ::Tramway::Core::ApplicationDecorator
2
4
  def title; end
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Landing::NavbarDecorator < ::Tramway::Core::ApplicationDecoratedCollection
2
4
  def initialize(array)
3
5
  original = if array.any? { |obj| obj.is_a? Hash }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Landing::BlockForm < ::Tramway::Core::ExtendedApplicationForm
2
4
  properties :title,
3
5
  :background,
@@ -16,28 +18,25 @@ class Tramway::Landing::BlockForm < ::Tramway::Core::ExtendedApplicationForm
16
18
  def initialize(object = nil)
17
19
  super(object).tap do
18
20
  form_properties title: :string,
19
- background: :file,
20
- position: :numeric,
21
- block_type: :default,
22
- navbar_link: :default,
23
- anchor: :string,
24
- description: :ckeditor,
25
- link_object_type: :default,
26
- link_object_id: :numeric,
27
- button_title: :string,
28
- button_link: :string,
29
- view_name: :string
21
+ background: :file,
22
+ position: :numeric,
23
+ block_type: :default,
24
+ navbar_link: :default,
25
+ anchor: :string,
26
+ description: :ckeditor,
27
+ button_title: :string,
28
+ button_link: :string
30
29
  end
31
30
  end
32
31
 
33
32
  def button_title
34
33
  model.button ||= {}
35
- model.button['title'] || ""
34
+ model.button['title'] || ''
36
35
  end
37
36
 
38
37
  def button_link
39
38
  model.button ||= {}
40
- model.button['link'] || ""
39
+ model.button['link'] || ''
41
40
  end
42
41
 
43
42
  def button_title=(value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Landing
3
5
  module ApplicationHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Landing
3
5
  class ApplicationJob < ActiveJob::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Landing
3
5
  class ApplicationMailer < ActionMailer::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Landing
3
5
  class ApplicationRecord < ::Tramway::Core::ApplicationRecord
@@ -1,19 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Landing::Block < ::Tramway::Landing::ApplicationRecord
2
- enumerize :block_type, in: [
3
- :header,
4
- :footer,
5
- :page,
6
- :cards,
7
- :features,
8
- :contacts,
9
- :news,
10
- :link,
11
- :page_with_button,
12
- :just_text,
13
- :view
4
+ enumerize :block_type, in: %i[
5
+ header
6
+ footer
7
+ page
8
+ cards
9
+ features
10
+ contacts
11
+ news
12
+ link
13
+ page_with_button
14
+ just_text
15
+ view
14
16
  ]
15
- enumerize :navbar_link, in: [ :exist, :not_exist ], default: :not_exist
16
- enumerize :link_object_type, in: [ 'Tramway::SportSchool::Document', 'Tramway::Page::Page' ]
17
+ enumerize :navbar_link, in: %i[exist not_exist], default: :not_exist
18
+ enumerize :link_object_type, in: ['Tramway::SportSchool::Document', 'Tramway::Page::Page']
17
19
 
18
20
  mount_uploader :background, PhotoUploader
19
21
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway::Landing::PhotoVersions
2
4
  extend ActiveSupport::Concern
3
5
 
@@ -1,2 +1,4 @@
1
- Rails.application.config.assets.precompile += %w( tramway/landing/footer.js )
2
- Rails.application.config.assets.precompile += %w( tramway/landing/smooth-scroll.js )
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.config.assets.precompile += %w[tramway/landing/footer.js]
4
+ Rails.application.config.assets.precompile += %w[tramway/landing/smooth-scroll.js]
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ::Tramway::Admin.set_available_models(::Tramway::Landing::Block, project: :landing)
@@ -5,7 +5,7 @@ ru:
5
5
  attributes:
6
6
  tramway/landing/block:
7
7
  title: Название
8
- background: Изображение на фоне
8
+ background: Изображение
9
9
  position: Позиция на странице
10
10
  block_type: Тип блока
11
11
  view_state: Видимость на сайте
@@ -14,8 +14,8 @@ ru:
14
14
  description: Описание
15
15
  link_object_type: Тип объекта, на который делается ссылка
16
16
  link_object_id: ID объекта, на который делается ссылка
17
- button_title: Наименование кнопки
18
- button_link: Ссылка кнопки
17
+ button_title: Наименование кнопки (только для Типа блока "Свободный блок с кнопкой")
18
+ button_link: Ссылка кнопки (только для Типа блока "Свободный блок с кнопкой")
19
19
  view_name: Название вьюхи
20
20
  cases:
21
21
  tramway/landing/block:
@@ -35,6 +35,7 @@ ru:
35
35
  link: Ссылка на объект
36
36
  just_text_with_button: Просто текст
37
37
  view: Вьюха (программируется)
38
+ just_text: Просто текст
38
39
  navbar_link:
39
40
  exist: Присутствует
40
41
  not_exist: Отсутствует
data/config/routes.rb CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Tramway::Landing::Engine.routes.draw do
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # desc "Explaining what the task does"
2
4
  # task :tramway_landing do
3
5
  # # Task goes here
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Landing
3
5
  class Engine < ::Rails::Engine
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators'
2
4
  require 'tramway/core/generators/install_generator'
3
5
 
4
6
  module Tramway::Landing::Generators
5
7
  class InstallGenerator < ::Tramway::Core::Generators::InstallGenerator
6
8
  include Rails::Generators::Migration
7
- source_root File.expand_path('../templates', __FILE__)
9
+ source_root File.expand_path('templates', __dir__)
8
10
 
9
11
  def self.next_migration_number(path)
10
12
  next_migration_number = current_migration_number(path) + 1
@@ -12,15 +14,15 @@ module Tramway::Landing::Generators
12
14
  end
13
15
 
14
16
  def copy_migrations
15
- migrations = [
16
- :create_tramway_landing_blocks,
17
- :add_navbar_link_to_tramway_landing_blocks,
18
- :add_anchor_to_tramway_landing_blocks,
19
- :add_description_to_tramway_landing_blocks,
20
- :add_link_object_id_to_tramway_landing_blocks,
21
- :add_link_object_type_to_tramway_landing_blocks,
22
- :add_button_to_tramway_landing_blocks,
23
- :add_view_name_to_tramway_landing_blocks
17
+ migrations = %i[
18
+ create_tramway_landing_blocks
19
+ add_navbar_link_to_tramway_landing_blocks
20
+ add_anchor_to_tramway_landing_blocks
21
+ add_description_to_tramway_landing_blocks
22
+ add_link_object_id_to_tramway_landing_blocks
23
+ add_link_object_type_to_tramway_landing_blocks
24
+ add_button_to_tramway_landing_blocks
25
+ add_view_name_to_tramway_landing_blocks
24
26
  ]
25
27
 
26
28
  migrations.each do |migration|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddAnchorToTramwayLandingBlocks < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_landing_blocks, :anchor, :text
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddButtonToTramwayLandingBlocks < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_landing_blocks, :button, :jsonb
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddDescriptionToTramwayLandingBlocks < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_landing_blocks, :description, :text
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddLinkObjectIdToTramwayLandingBlocks < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_landing_blocks, :link_object_id, :integer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddLinkObjectTypeToTramwayLandingBlocks < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_landing_blocks, :link_object_type, :text
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddNavbarLinkToTramwayLandingBlocks < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_landing_blocks, :navbar_link, :text, default: :not_exist
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddViewNameToTramwayLandingBlocks < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  add_column :tramway_landing_blocks, :view_name, :text
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateTramwayLandingBlocks < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  create_table :tramway_landing_blocks do |t|
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Landing
3
- VERSION = '1.8'
5
+ VERSION = '1.8.1'
4
6
  end
5
7
  end
@@ -1,4 +1,6 @@
1
- require "tramway/landing/engine"
1
+ # frozen_string_literal: true
2
+
3
+ require 'tramway/landing/engine'
2
4
  require 'tramway/landing/generates/install_generator'
3
5
 
4
6
  module Tramway
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-landing
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.8'
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-10 00:00:00.000000000 Z
11
+ date: 2019-12-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Landing Engine for your Rails projects
14
14
  email: