tramway-landing 3.2 → 3.3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1173a00383661feff98ffb68918d16347cf47f9a64295d0aa10825abb2a51dc2
4
- data.tar.gz: bd45201e8a212c7abbeeebf2ae9d7f83f90715cb2f531ce4d5b4f282af0019de
3
+ metadata.gz: 21e172d1a3cf9dd66b4b5a57c888757897350582b258f7afaee10f8e0e189ff8
4
+ data.tar.gz: b9ba5725b3838b201056acfb065988f91d74ca28f49ac919f77e45245a042fce
5
5
  SHA512:
6
- metadata.gz: 1af9464dc5d86e6ba1dd6ac45d7de7aa35b6f6d925d5fc69472bae4888d99bc51d38ac2a1cee575c001389011cbb08d896171159f1190e4195c44f5193be565c
7
- data.tar.gz: 0af0304af1452fd235cd0b020cb11f034e9f91d0c1f9c948b02eb9db42bd3b4ef866dd8109da102b179c1a5875d0e46bc833dd47103c1dc38f57639b02d58ae1
6
+ metadata.gz: 2bffa41e45f1cc453e703182ad19c309662c69258debc181471704f6c0cb47733afee1317068a6e0f08adb8dc275cbca14e6f27bb2590792a201cd06cd1af8bc
7
+ data.tar.gz: 29276bb24509250f6f8d29eb2eed4ef68fdf77a7cfe4dc173f9a6ee3c95bee66a57382434b7d10648c3d7371f04e4e4b0b2ce6aad650938259f0298bcec8df26
data/README.md CHANGED
@@ -232,6 +232,52 @@ How create blocks you can find here
232
232
  * [Just text](https://github.com/ulmic/tramway-dev/blob/develop/tramway-landing/docs/just_text/main.md)
233
233
  * Link to object
234
234
 
235
+ ## Tools
236
+
237
+ ### Google Tag Manager, Google Analytics, Yandex Metrika
238
+
239
+ #### 1. Add landing tools to the initializer
240
+
241
+ *config/initializers/tramway.rb*
242
+ ```ruby
243
+ Tramway::Admin.set_available_models(
244
+ ::Tramway::Landing::Block,
245
+ ::Tramway::Landing::Tool,
246
+ project: #{project_name_which_you_use_in_the_application}
247
+ )
248
+
249
+ Tramway::Admin.navbar_structure(
250
+ ::Tramway::Landing::Block,
251
+ ::Tramway::Landing::Tool
252
+ )
253
+ ```
254
+
255
+ #### 2. Click on `Tools`, create new tool with type `[Google Tag Manager, Google Analytics, Yandex Metrika]` and add account_id for your profile in this tool.
256
+
257
+ #### 3. Add to `WelcomeController` query to get `@tools`
258
+
259
+ *app/controllers/web/welcome_controller.rb*
260
+ ```ruby
261
+ class Web::WelcomeController < ApplicationController
262
+ before_action :application
263
+
264
+ layout 'tramway/landing/application'
265
+
266
+ def index
267
+ @blocks = ::Tramway::Landing::BlockDecorator.decorate ::Tramway::Landing::Block.on_main_page
268
+ @tools = ::Tramway::Landing::Tool.active
269
+ end
270
+
271
+ private
272
+
273
+ def application
274
+ @application = ::Tramway::Core.application_object
275
+ end
276
+ end
277
+ ```
278
+
279
+ And now all we need to integrate tool to your web page will be integrated automatically. **Enjoy!**
280
+
235
281
  ## Contributing
236
282
  Contribution directions go here.
237
283
 
@@ -13,8 +13,6 @@ class Tramway::Landing::BlockDecorator < ::Tramway::Core::ApplicationDecorator
13
13
  def show_associations
14
14
  [:forms]
15
15
  end
16
-
17
- delegate :human_view_state_event_name, to: :model_class
18
16
  end
19
17
 
20
18
  decorate_association :forms
@@ -39,7 +37,7 @@ class Tramway::Landing::BlockDecorator < ::Tramway::Core::ApplicationDecorator
39
37
  end
40
38
 
41
39
  def view_state
42
- object.human_view_state_name
40
+ object.view_state
43
41
  end
44
42
 
45
43
  def link
@@ -0,0 +1,3 @@
1
+ class Tramway::Landing::ToolDecorator < Tramway::Core::ApplicationDecorator
2
+ delegate_attributes :title, :account_id
3
+ end
@@ -0,0 +1,10 @@
1
+ class Admin::Tramway::Landing::ToolForm < Tramway::Core::ApplicationForm
2
+ properties :title, :account_id
3
+
4
+ def initialize(object)
5
+ super(object).tap do
6
+ form_properties title: :default,
7
+ account_id: :string
8
+ end
9
+ end
10
+ end
@@ -10,16 +10,16 @@ class Tramway::Landing::Block < ::Tramway::Landing::ApplicationRecord
10
10
 
11
11
  uploader :background, :photo, extensions: %i[jpg jpeg gif png]
12
12
 
13
- state_machine :view_state, initial: :published do
14
- state :published
13
+ aasm :view_state do
14
+ state :published, initial: true
15
15
  state :hidden
16
16
 
17
17
  event :publish do
18
- transition hidden: :published
18
+ transitions from: :hidden, to: :published
19
19
  end
20
20
 
21
21
  event :hide do
22
- transition published: :hidden
22
+ transitions from: :published, to: :hidden
23
23
  end
24
24
  end
25
25
 
@@ -0,0 +1,7 @@
1
+ class Tramway::Landing::Tool < Tramway::Core::ApplicationRecord
2
+ enumerize :title, in: [ :google_tag_manager, :google_analytics, :yandex_direct ]
3
+
4
+ def with_body_fragment?
5
+ title.google_tag_manager?
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ = render 'layouts/tramway/landing/meta'
2
+ %title
3
+ = yield(:title).present? ? yield(:title) : @application.title
4
+ = stylesheet_link_tag 'tramway/landing/application', media: 'all'
5
+ = javascript_include_tag 'tramway/landing/application'
6
+ = javascript_include_tag 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js', integrity: 'sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl', crossorigin: 'anonymous'
7
+ = javascript_include_tag 'https://code.jquery.com/jquery-3.2.1.slim.min.js', integrity: 'sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN', crossorigin: 'anonymous'
8
+ = javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js', integrity: 'sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q', crossorigin: 'anonymous'
9
+ = csrf_meta_tags
10
+ - if @application&.favicon.present?
11
+ = favicon_link_tag @application.favicon
12
+ - ::Tramway::Landing.head_content.each do |content|
13
+ - self.instance_exec &content
14
+ - @tools&.each do |tool|
15
+ = render "layouts/tramway/landing/tools/#{tool.title}_head", account_id: tool.account_id
@@ -1,5 +1,5 @@
1
1
  %meta{ content: 'text/html; charset=UTF-8', http: { equiv: 'Content-Type' } }
2
2
  %meta{ content: "width=device-width, initial-scale=1, maximum-scale=0.8", name: "viewport" }
3
- - main_image = @application.main_image.present? ? "/#{@application.main_image}" : yield(:main_image)
3
+ - main_image = @application&.main_image.present? ? "/#{@application.main_image}" : yield(:main_image)
4
4
  %meta{ property: 'vk:image', content: main_image }
5
5
  %meta{ property: 'og:image', content: main_image }
@@ -1,6 +1,6 @@
1
- - if Tramway::Landing.navbar_for(@application_engine || @application.name)
1
+ - if Tramway::Landing.navbar_for(@application_engine || @application&.name)
2
2
  %nav.navbar.navbar-expand-lg.navbar-dark.indigo.scrolling-navbar.fixed-top
3
- = link_to @application.public_name || yield(:application_name), '/', class: 'navbar-brand'
3
+ = link_to @application&.public_name || yield(:application_name), '/', class: 'navbar-brand'
4
4
  %button.navbar-toggler{ type: :button, data: { toggle: :collapse, target: '#navbarSupportedContent' }, aria: { controls: 'navbarSupportedContent', expanded: 'false', label: 'Toggle navigation' } }
5
5
  - if @links&.any?
6
6
  = fa_icon :bars
@@ -1,20 +1,11 @@
1
1
  !!!
2
2
  %html
3
3
  %head
4
- = render 'layouts/tramway/landing/meta'
5
- %title
6
- = yield(:title).present? ? yield(:title) : @application.title
7
- = stylesheet_link_tag 'tramway/landing/application', media: 'all'
8
- = javascript_include_tag 'tramway/landing/application'
9
- = javascript_include_tag 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js', integrity: 'sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl', crossorigin: 'anonymous'
10
- = javascript_include_tag 'https://code.jquery.com/jquery-3.2.1.slim.min.js', integrity: 'sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN', crossorigin: 'anonymous'
11
- = javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js', integrity: 'sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q', crossorigin: 'anonymous'
12
- = csrf_meta_tags
13
- - if @application.favicon.present?
14
- = favicon_link_tag @application.favicon
15
- - ::Tramway::Landing.head_content.each do |content|
16
- - self.instance_exec &content
17
- %body{ class: @application.name }
4
+ = render 'layouts/tramway/landing/head'
5
+ %body{ class: @application&.name }
6
+ - @tools&.each do |tool|
7
+ - if tool.with_body_fragment?
8
+ = render "layouts/tramway/landing/tools/#{tool.title}_body", account_id: tool.account_id
18
9
  = stylesheet_link_tag 'https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.4.5/css/mdb.min.css'
19
10
  = javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.4.5/js/mdb.js'
20
11
  = javascript_include_tag 'https://cdn.rawgit.com/CezarLuiz0/anchor.js/master/dist/anchor.min.js'
@@ -0,0 +1,4 @@
1
+ / Google Tag Manager (noscript)
2
+ %noscript
3
+ %iframe{height: "0", src: "https://www.googletagmanager.com/ns.html?id=#{account_id}", style: "display:none;visibility:hidden", width: "0"}
4
+ / End Google Tag Manager (noscript)
@@ -0,0 +1,8 @@
1
+ / Google Tag Manager
2
+ :javascript
3
+ (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
4
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
5
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
6
+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
7
+ })(window,document,'script','dataLayer','#{account_id}');
8
+ / End Google Tag Manager
@@ -2,6 +2,7 @@ ru:
2
2
  activerecord:
3
3
  models:
4
4
  tramway/landing/block: Блок
5
+ tramway/landing/tool: Инструмент
5
6
  attributes:
6
7
  tramway/landing/block:
7
8
  name: Название
@@ -26,6 +27,9 @@ ru:
26
27
  tramway/landing/form:
27
28
  title: Название формы
28
29
  form_name: Класс формы
30
+ tramway/landing/tool:
31
+ title: Выберите сервис
32
+ account_id: ID в системе
29
33
  cases:
30
34
  tramway/landing/block:
31
35
  plural: Блоки
@@ -33,6 +37,9 @@ ru:
33
37
  tramway/landing/form:
34
38
  plural: Публичные формы
35
39
  genitive: публичную форму
40
+ tramway/landing/tool:
41
+ plural: Инструменты
42
+ genitive: инструмент
36
43
  enumerize:
37
44
  tramway/landing/block:
38
45
  block_type:
@@ -54,4 +61,4 @@ ru:
54
61
  not_exist: Отсутствует
55
62
  errors:
56
63
  messages:
57
- extension_whitelist_error: неверный формата, расширение файла должно быть jpg, jpeg, gif или png.
64
+ extension_whitelist_error: неверный формата, расширение файла должно быть jpg, jpeg, gif или png.
@@ -3,13 +3,12 @@ ru:
3
3
  tramway/landing/block:
4
4
  published: Опубликованные
5
5
  hidden: Скрытые
6
- activerecord:
7
- state_machines:
8
- tramway/landing/block:
9
- view_state:
10
- states:
11
- published: Виден
12
- hidden: Скрытый
13
- events:
14
- publish: Показать на сайте
15
- hide: Скрыть с сайта
6
+ state_machines:
7
+ tramway/landing/block:
8
+ view_state:
9
+ states:
10
+ published: Виден
11
+ hidden: Скрытый
12
+ events:
13
+ publish: Показать на сайте
14
+ hide: Скрыть с сайта
@@ -26,6 +26,7 @@ module Tramway::Landing::Generators
26
26
  add_values_to_tramway_landing_blocks
27
27
  add_page_id_to_tramway_landing_blocks
28
28
  create_tramway_landing_forms
29
+ create_tramway_landing_tools
29
30
  ]
30
31
 
31
32
  migrations.each do |migration|
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateTramwayLandingTools < ActiveRecord::Migration[5.1]
4
+ def change
5
+ create_table :tramway_landing_tools do |t|
6
+ t.text :title
7
+ t.text :account_id
8
+ t.jsonb :options
9
+ t.text :state, default: :active
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Landing
5
- VERSION = '3.2'
5
+ VERSION = '3.3.0.2'
6
6
  end
7
7
  end
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: '3.2'
4
+ version: 3.3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - moshinaan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-12 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Landing Engine for your Rails projects
14
14
  email:
@@ -38,20 +38,25 @@ files:
38
38
  - app/decorators/tramway/landing/form_decorator.rb
39
39
  - app/decorators/tramway/landing/navbar/link_decorator.rb
40
40
  - app/decorators/tramway/landing/navbar_decorator.rb
41
+ - app/decorators/tramway/landing/tool_decorator.rb
41
42
  - app/forms/admin/tramway/landing/block_form.rb
42
43
  - app/forms/admin/tramway/landing/form_form.rb
44
+ - app/forms/admin/tramway/landing/tool_form.rb
43
45
  - app/helpers/tramway/landing/application_helper.rb
44
46
  - app/jobs/tramway/landing/application_job.rb
45
47
  - app/mailers/tramway/landing/application_mailer.rb
46
48
  - app/models/tramway/landing/application_record.rb
47
49
  - app/models/tramway/landing/block.rb
48
50
  - app/models/tramway/landing/form.rb
51
+ - app/models/tramway/landing/tool.rb
49
52
  - app/uploaders/tramway/landing/photo_versions.rb
53
+ - app/views/layouts/tramway/landing/_head.html.haml
50
54
  - app/views/layouts/tramway/landing/_meta.html.haml
51
55
  - app/views/layouts/tramway/landing/_navbar.html.haml
52
- - app/views/layouts/tramway/landing/_yandex_metrika.html.haml
53
56
  - app/views/layouts/tramway/landing/application.html.haml
54
57
  - app/views/layouts/tramway/landing/navbar/_link.html.haml
58
+ - app/views/layouts/tramway/landing/tools/_google_tag_manager_body.html.haml
59
+ - app/views/layouts/tramway/landing/tools/_google_tag_manager_head.html.haml
55
60
  - app/views/tramway/landing/blocks/block_types/_cards.html.haml
56
61
  - app/views/tramway/landing/blocks/block_types/_contacts.html.haml
57
62
  - app/views/tramway/landing/blocks/block_types/_features.html.haml
@@ -94,6 +99,7 @@ files:
94
99
  - lib/tramway/landing/generates/templates/add_view_name_to_tramway_landing_blocks.rb
95
100
  - lib/tramway/landing/generates/templates/create_tramway_landing_blocks.rb
96
101
  - lib/tramway/landing/generates/templates/create_tramway_landing_forms.rb
102
+ - lib/tramway/landing/generates/templates/create_tramway_landing_tools.rb
97
103
  - lib/tramway/landing/version.rb
98
104
  homepage: https://github.com/kalashnikovisme/tramway-landing
99
105
  licenses:
@@ -114,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
120
  - !ruby/object:Gem::Version
115
121
  version: '0'
116
122
  requirements: []
117
- rubygems_version: 3.1.2
123
+ rubygems_version: 3.1.4
118
124
  signing_key:
119
125
  specification_version: 4
120
126
  summary: Landing Engine for your Rails projects
@@ -1,30 +0,0 @@
1
- / Yandex.Metrika counter
2
- :javascript
3
- (function (d, w, c) {
4
- (w[c] = w[c] || []).push(function() {
5
- try {
6
- w.yaCounter49054148 = new Ya.Metrika({
7
- id:49054148,
8
- clickmap:true,
9
- trackLinks:true,
10
- accurateTrackBounce:true,
11
- webvisor:true
12
- });
13
- } catch(e) { }
14
- });
15
-
16
- var n = d.getElementsByTagName("script")[0],
17
- s = d.createElement("script"),
18
- f = function () { n.parentNode.insertBefore(s, n); };
19
- s.type = "text/javascript";
20
- s.async = true;
21
- s.src = "https://mc.yandex.ru/metrika/watch.js";
22
-
23
- if (w.opera == "[object Opera]") {
24
- d.addEventListener("DOMContentLoaded", f, false);
25
- } else { f(); }
26
- })(document, window, "yandex_metrika_callbacks");
27
- %noscript
28
- %div
29
- %img{alt: "", src: "https://mc.yandex.ru/watch/49054148", style: "position:absolute; left:-9999px;"}/
30
- / /Yandex.Metrika counter