c80_news_tz 0.1.1.19 → 0.1.1.21

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 (32) hide show
  1. checksums.yaml +4 -4
  2. data/app/admin/c80_news_tz/banners01.rb +50 -0
  3. data/app/admin/c80_news_tz/banners02.rb +50 -0
  4. data/app/admin/c80_news_tz/banners03.rb +50 -0
  5. data/app/assets/javascripts/c80_news_tz/frontend/nabbers.js +53 -0
  6. data/app/controllers/c80_news_tz/banners_controller.rb +48 -0
  7. data/app/helpers/c80_news_tz/advertisers_helper.rb +30 -0
  8. data/app/helpers/c80_news_tz/application_helper.rb +8 -0
  9. data/app/helpers/c80_news_tz/banners_helper.rb +95 -0
  10. data/app/helpers/c80_news_tz/blurbs_helper.rb +14 -0
  11. data/app/helpers/c80_news_tz/publications_helper.rb +2 -1
  12. data/app/models/c80_news_tz/banner01.rb +34 -0
  13. data/app/models/c80_news_tz/banner02.rb +34 -0
  14. data/app/models/c80_news_tz/banner03.rb +39 -0
  15. data/app/models/c80_news_tz/banner_validator.rb +16 -0
  16. data/app/models/c80_news_tz/fact.rb +48 -0
  17. data/app/models/c80_news_tz/r_advertiser.rb +34 -0
  18. data/app/models/c80_news_tz/r_blurb.rb +55 -6
  19. data/app/uploaders/c80_news_tz/bimage01_uploader.rb +44 -0
  20. data/app/uploaders/c80_news_tz/bimage02_uploader.rb +44 -0
  21. data/app/uploaders/c80_news_tz/bimage03_uploader.rb +44 -0
  22. data/app/uploaders/c80_news_tz/r_alogo_uploader.rb +11 -2
  23. data/app/views/c80_news_tz/banners/counter.html.erb +1 -0
  24. data/app/views/shared/_banner_01.html.erb +7 -0
  25. data/app/views/shared/_banner_02.html.erb +3 -0
  26. data/app/views/shared/_banner_03.html.erb +3 -0
  27. data/config/routes.rb +1 -0
  28. data/db/migrate/20160309194444_create_banners01.rb +14 -0
  29. data/db/migrate/20160310110000_create_banners02.rb +14 -0
  30. data/db/migrate/20160310114242_create_banners03.rb +14 -0
  31. data/lib/c80_news_tz/version.rb +1 -1
  32. metadata +24 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a0f668c3dc59e8d30d94346ccf26593481b0849
4
- data.tar.gz: 795d636d35a71bcc89bd7c8acdd8883288d68eac
3
+ metadata.gz: 15f192a8810ee8e908dda8d442f54e4eaf7f8f15
4
+ data.tar.gz: d7aed5c07568f7a4e3c33a5c4197a54fd522faf9
5
5
  SHA512:
6
- metadata.gz: bf27bbad97a44b79f4fff931f2afa6f2a6712716ec3e8d8b1586d54dade8f99897e13f6a0dfda93808d97a839c0991849e5e398cfbea43c95914e61c59ec4845
7
- data.tar.gz: 5c9b791dd6374432cfd3eb4ac6fadc86ff96cea5b8eff92df1b8db079dca371f46a293c7d2d2f128e9fb892dc85f8cb0b9c30f51b595ab628600b9292c589778
6
+ metadata.gz: 7de32164e50f27bf30c091240376769e33b519905a5bc5483b37f85fbffd0e7712dc9e1818be8e81fbbe48b535913d2c10a6ade76f27f013747f66740868fda5
7
+ data.tar.gz: b207cfb134caa3fc127026c0df61b2e90531ba5351e077e8936de762cbe29d3aca72f80ffcad1c2b61944ce1fa7d392ccd3e3821545fa511d56fecafb59bf77d
@@ -0,0 +1,50 @@
1
+ ActiveAdmin.register C80NewsTz::Banner01, :as => 'Banner01' do
2
+
3
+ menu :label => "Рекламный блок №1", :parent => 'Баннеры'
4
+
5
+ permit_params :title,
6
+ :image,
7
+ :href,
8
+ :is_active
9
+
10
+ config.sort_order = 'title_asc'
11
+
12
+ filter :title
13
+ filter :href
14
+ filter :is_active
15
+
16
+ # controller do
17
+ # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
18
+ # end
19
+
20
+ index do
21
+ selectable_column
22
+ id_column
23
+ column :title
24
+ column :image do |a|
25
+ if a.image.present?
26
+ "#{image_tag("#{a.image.thumb_preview.url}")}".html_safe
27
+ end
28
+ end
29
+ column :href
30
+ column :is_active
31
+ column :shown
32
+ column :clicks
33
+
34
+ actions
35
+ end
36
+
37
+ form(:html => {:multipart => true}) do |f|
38
+
39
+ f.inputs "Свойства" do
40
+
41
+ f.input :title
42
+ f.input :href
43
+ f.input :image, :hint => "#{image_tag("#{f.object.image.thumb_preview.url}")}".html_safe
44
+ f.input :is_active
45
+ end
46
+
47
+ f.actions
48
+ end
49
+
50
+ end
@@ -0,0 +1,50 @@
1
+ ActiveAdmin.register C80NewsTz::Banner02, :as => 'Banner02' do
2
+
3
+ menu :label => "Рекламный блок №2", :parent => 'Баннеры'
4
+
5
+ permit_params :title,
6
+ :image,
7
+ :href,
8
+ :is_active
9
+
10
+ config.sort_order = 'title_asc'
11
+
12
+ filter :title
13
+ filter :href
14
+ filter :is_active
15
+
16
+ # controller do
17
+ # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
18
+ # end
19
+
20
+ index do
21
+ selectable_column
22
+ id_column
23
+ column :title
24
+ column :image do |a|
25
+ if a.image.present?
26
+ "#{image_tag("#{a.image.thumb_preview.url}")}".html_safe
27
+ end
28
+ end
29
+ column :href
30
+ column :is_active
31
+ column :shown
32
+ column :clicks
33
+
34
+ actions
35
+ end
36
+
37
+ form(:html => {:multipart => true}) do |f|
38
+
39
+ f.inputs "Свойства" do
40
+
41
+ f.input :title
42
+ f.input :href
43
+ f.input :image, :hint => "#{image_tag("#{f.object.image.thumb_preview.url}")}".html_safe
44
+ f.input :is_active
45
+ end
46
+
47
+ f.actions
48
+ end
49
+
50
+ end
@@ -0,0 +1,50 @@
1
+ ActiveAdmin.register C80NewsTz::Banner03, :as => 'Banner03' do
2
+
3
+ menu :label => "Рекламный блок №3", :parent => 'Баннеры'
4
+
5
+ permit_params :title,
6
+ :image,
7
+ :href,
8
+ :is_active
9
+
10
+ config.sort_order = 'title_asc'
11
+
12
+ filter :title
13
+ filter :href
14
+ filter :is_active
15
+
16
+ # controller do
17
+ # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
18
+ # end
19
+
20
+ index do
21
+ selectable_column
22
+ id_column
23
+ column :title
24
+ column :image do |a|
25
+ if a.image.present?
26
+ "#{image_tag("#{a.image.thumb_preview.url}")}".html_safe
27
+ end
28
+ end
29
+ column :href
30
+ column :is_active
31
+ column :shown
32
+ column :clicks
33
+
34
+ actions
35
+ end
36
+
37
+ form(:html => {:multipart => true}) do |f|
38
+
39
+ f.inputs "Свойства" do
40
+
41
+ f.input :title
42
+ f.input :href
43
+ f.input :image, :hint => "#{image_tag("#{f.object.image.thumb_preview.url}")}".html_safe
44
+ f.input :is_active
45
+ end
46
+
47
+ f.actions
48
+ end
49
+
50
+ end
@@ -0,0 +1,53 @@
1
+ /* считаем клики по wow-картинкам */
2
+
3
+ $(document).ready(function () {
4
+
5
+ var prefixes_array = ['rb01', 'rb02', 'rb03'];
6
+ var iprefix, i$rb;
7
+ for (var i = 0; i < prefixes_array.length; i++) {
8
+
9
+ // prefix является:
10
+ // - id ссылки, в которую завёрнута картинка
11
+ // - префиксом класса, в который вставлен id wow-картинки
12
+ iprefix = prefixes_array[i];
13
+
14
+ i$rb = $("#" + iprefix);
15
+ if (i$rb.length == 1) {
16
+
17
+ var bc = (function () {
18
+
19
+ var _init = function ($rb) {
20
+
21
+ $rb.click(function (event) {
22
+ event.preventDefault();
23
+
24
+ $.ajax({
25
+ url: '/rb',
26
+ type: 'POST',
27
+ data: {c: $rb.attr('class')},
28
+ dataType: 'text'
29
+ });
30
+
31
+ window.location.href = $rb.attr('href');
32
+
33
+ //var $a = $('<a href="'+$rb.attr('href')+'" target="_blank">go!</a>');
34
+ //$(document).append(a);
35
+ //$a[0].click(); // => всплывающее окно заблокировано
36
+
37
+ });
38
+
39
+ };
40
+
41
+ return {
42
+ init: _init
43
+ }
44
+
45
+ })();
46
+
47
+ bc.init(i$rb);
48
+
49
+ }
50
+
51
+ }
52
+
53
+ });
@@ -0,0 +1,48 @@
1
+ module C80NewsTz
2
+
3
+ # считает клики по баннерам
4
+ class BannersController < ActionController::Base
5
+
6
+ # считает клики по баннерам
7
+ def counter
8
+
9
+ # TODO_MY:: реализовать защиту от накручивания, быстрых повторных кликов с того же ip, левых запросов
10
+
11
+ # params[:c] = $
12
+ # где строка вида rb{(\d\d)}_{(\d+)}:
13
+ # $1: часть имени класса баннера
14
+ # $2: id баннера в базе
15
+
16
+ s = params[:c]
17
+ rex = /(?<=rb)(\d\d)_(\d+)/
18
+ result = s[rex]
19
+
20
+ if result.present?
21
+
22
+ # извлекаем данные
23
+ class_part_name = result[$1]
24
+ banner_id = result[$2]
25
+ Rails.logger.debug("<BannersController.counter> class_part_name = #{class_part_name}, banner_id = #{banner_id}")
26
+
27
+ # фиксируем баннер
28
+ b = nil
29
+ if class_part_name == '01'
30
+ b = Banner01.find(banner_id)
31
+ elsif class_part_name == '02'
32
+ b = Banner02.find(banner_id)
33
+ elsif class_part_name == '03'
34
+ b = Banner03.find(banner_id)
35
+ end
36
+
37
+ # увеличиваем счётчик на единицу
38
+ if b.present?
39
+ b.clicks += 1
40
+ b.save!
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,30 @@
1
+ module C80NewsTz
2
+ module AdvertisersHelper
3
+
4
+ # собрать информацию для отрисовки логотипа компании в блоке "публикации рекламодателя"
5
+ # отрисовка логотипа происходит с помощью метода render_image_link_lazy_holder
6
+ # если логотипа нет - вернёт nil
7
+ def arrange_logo_for_aapub(advertiser)
8
+ # :alt_image => pub.title,
9
+ # :image => photo_preview,
10
+ # :ww => ww,
11
+ # :hh => hh,
12
+ # :a_href => url_for_fact(pub)
13
+
14
+ result = nil
15
+
16
+ if advertiser.logo_for_aapub.present?
17
+ result = {
18
+ :alt_image => advertiser.title,
19
+ :image => advertiser.logo_for_aapub,
20
+ :ww => 282,
21
+ :hh => 82,
22
+ :a_href => apph_url_for_advertiser(advertiser.slug)
23
+ }
24
+ end
25
+
26
+ result
27
+ end
28
+
29
+ end
30
+ end
@@ -22,5 +22,13 @@ module C80NewsTz
22
22
  "#{root_url}issues/#{issue_id}"
23
23
  end
24
24
 
25
+ def apph_url_for_advertiser(advertiser_slug)
26
+ "#{root_url}publishers/#{advertiser_slug}"
27
+ end
28
+
29
+ def apph_url_for_blurb(blurb)
30
+ "#{root_url}publications/#{blurb.slug}"
31
+ end
32
+
25
33
  end
26
34
  end
@@ -0,0 +1,95 @@
1
+ module C80NewsTz
2
+ module BannersHelper
3
+
4
+ # рендер баннера в рекламном блоке 1
5
+ def render_banner_01
6
+
7
+ # извлечём баннер
8
+ b = Banner01.random_active
9
+
10
+ if b.present?
11
+
12
+ # увеличим счётчик показов
13
+ b.shown += 1
14
+ b.save!
15
+
16
+ # соберём информацию для рендера view
17
+ vp = {
18
+ alt_image: b.title,
19
+ image: b.image.thumb_fill,
20
+ ww: 1200, # ширина\высота совпадает с шириной\высотой, указанной в Bimage01Uploader
21
+ hh: 165,
22
+ a_href: b.href,
23
+ aid: 'rb01', # используется js для подсчёта кликов
24
+ a_class: "rb01_#{b.id}"
25
+ }
26
+
27
+ render :partial => 'shared/banner_01',
28
+ :locals => {
29
+ :vp => vp
30
+ }
31
+ end
32
+ end
33
+
34
+ # рендер баннера в рекламном блоке 2
35
+ def render_banner_02
36
+
37
+ # извлечём баннер
38
+ b = Banner02.random_active
39
+
40
+ if b.present?
41
+
42
+ # увеличим счётчик показов
43
+ b.shown += 1
44
+ b.save!
45
+
46
+ # соберём информацию для рендера view
47
+ vp = {
48
+ alt_image: b.title,
49
+ image: b.image.thumb_fill,
50
+ ww: 812, # ширина\высота совпадает с шириной\высотой, указанной в Bimage02Uploader
51
+ hh: 130,
52
+ a_href: b.href,
53
+ aid: 'rb02', # используется js для подсчёта кликов
54
+ a_class: "rb02_#{b.id}"
55
+ }
56
+
57
+ render :partial => 'shared/banner_02',
58
+ :locals => {
59
+ :vp => vp
60
+ }
61
+ end
62
+ end
63
+
64
+ # рендер баннера в рекламном блоке 3
65
+ def render_banner_03
66
+
67
+ # извлечём баннер
68
+ b = Banner03.random_active
69
+
70
+ if b.present?
71
+
72
+ # увеличим счётчик показов
73
+ b.shown += 1
74
+ b.save!
75
+
76
+ # соберём информацию для рендера view
77
+ vp = {
78
+ alt_image: b.title,
79
+ image: b.image.thumb_fill,
80
+ ww: 287, # ширина\высота совпадает с шириной\высотой, указанной в Bimage03Uploader
81
+ hh: 321,
82
+ a_href: b.href,
83
+ aid: 'rb03', # используется js для подсчёта кликов
84
+ a_class: "rb03_#{b.id}"
85
+ }
86
+
87
+ render :partial => 'shared/banner_03',
88
+ :locals => {
89
+ :vp => vp
90
+ }
91
+ end
92
+ end
93
+
94
+ end
95
+ end
@@ -0,0 +1,14 @@
1
+ module C80NewsTz
2
+ module BlurbsHelper
3
+
4
+ # собрать информацию для отрисовки preview блока публикации рекламодателя в блоке "публикации рекламодателя"
5
+ def arrange_blurb_preview_for_rblock(blurb)
6
+ result = {
7
+ title: blurb.title,
8
+ time: local_time(blurb[:created_at], format: '%H:%M %d.%m.%Y'),
9
+ href: apph_url_for_blurb(blurb)
10
+ }
11
+ end
12
+
13
+ end
14
+ end
@@ -76,7 +76,8 @@ module C80NewsTz
76
76
  title: pub.title,
77
77
  rubric: pub.rubric_title,
78
78
  time: local_time(pub[:created_at], format: '%H:%M %d.%m.%Y'),
79
- comments_count: 12
79
+ comments_count: 12,
80
+ href: url_for_fact(pub) # TODO_MY:: используется в _simple_preview_list.html.erb, надо использовать везде
80
81
  }
81
82
 
82
83
  result
@@ -0,0 +1,34 @@
1
+ # баннер в самом верху страницы
2
+ module C80NewsTz
3
+ class Banner01 < ActiveRecord::Base
4
+ mount_uploader :image, Bimage01Uploader
5
+ validates_with BannerValidator
6
+
7
+ before_save :before_save_format_href
8
+
9
+ # выдать рандомный активный баннер
10
+ # если такового нету - вернётся null
11
+ def self.random_active
12
+ result = nil
13
+ a = self.where(:is_active => true)
14
+ if a.count > 0
15
+ b = a.offset(rand(a.count)).first
16
+ if b.image.present?
17
+ result = b
18
+ end
19
+ end
20
+ result
21
+ end
22
+
23
+ private
24
+
25
+ # каждая ссылка должна начинаться с http://
26
+ def before_save_format_href
27
+ str = 'http://'
28
+ if self.href[0..6] != str
29
+ self.href = "#{str}#{self.href}"
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ # баннер в области №2, перед содержимым страницы
2
+ module C80NewsTz
3
+ class Banner02 < ActiveRecord::Base
4
+ mount_uploader :image, Bimage02Uploader
5
+ validates_with BannerValidator
6
+
7
+ before_save :before_save_format_href
8
+
9
+ # выдать рандомный активный баннер
10
+ # если такового нету - вернётся null
11
+ def self.random_active
12
+ result = nil
13
+ a = self.where(:is_active => true)
14
+ if a.count > 0
15
+ b = a.offset(rand(a.count)).first
16
+ if b.image.present?
17
+ result = b
18
+ end
19
+ end
20
+ result
21
+ end
22
+
23
+ private
24
+
25
+ # каждая ссылка должна начинаться с http://
26
+ def before_save_format_href
27
+ str = 'http://'
28
+ if self.href[0..6] != str
29
+ self.href = "#{str}#{self.href}"
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,39 @@
1
+ # баннер в области №3, справа от главной публикации
2
+ module C80NewsTz
3
+ class Banner03 < ActiveRecord::Base
4
+ mount_uploader :image, Bimage03Uploader
5
+ validates_with BannerValidator
6
+
7
+ before_save :before_save_format_href
8
+
9
+ # выдать рандомный активный баннер
10
+ # если такового нету - вернётся null
11
+ def self.random_active
12
+ result = nil
13
+ a = self.where(:is_active => true)
14
+ if a.count > 0
15
+ b = a.offset(rand(a.count)).first
16
+ if b.image.present?
17
+ result = b
18
+ end
19
+ end
20
+ result
21
+ end
22
+
23
+ # выдать количество активных баннеров
24
+ def self.count_active
25
+ self.where(:is_active => true).count
26
+ end
27
+
28
+ private
29
+
30
+ # каждая ссылка должна начинаться с http://
31
+ def before_save_format_href
32
+ str = 'http://'
33
+ if self.href[0..6] != str
34
+ self.href = "#{str}#{self.href}"
35
+ end
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,16 @@
1
+ module C80NewsTz
2
+ class BannerValidator < ActiveModel::Validator
3
+ def validate(record)
4
+ unless record.title.present?
5
+ record.errors[:title] = 'Укажите название'
6
+ end
7
+ unless record.href.present?
8
+ record.errors[:href] = 'Укажите ссылку'
9
+ end
10
+ unless record.image.present?
11
+ record.errors[:image] = 'Загрузите картинку'
12
+ end
13
+ puts record.errors.as_json
14
+ end
15
+ end
16
+ end
@@ -61,6 +61,36 @@ module C80NewsTz
61
61
  result
62
62
  end
63
63
 
64
+ # выдать id первой попавшейся рубрики
65
+ # если рубрики у публикации нету - выдать невероятное число 999999
66
+ def rubric_id
67
+ result = 999999
68
+ if rubrics.count > 0
69
+ result = rubrics.first.id
70
+ end
71
+ result
72
+ end
73
+
74
+ # выдать id первого попавшегося номера
75
+ # если номера у публикации нету - выдать невероятное число 999999
76
+ def issue_id
77
+ result = 999999
78
+ if issues.count > 0
79
+ result = issues.first.id
80
+ end
81
+ result
82
+ end
83
+
84
+ # выдать название номера, которому принадлежит новость
85
+ # если чего-то не хватает - выдаётся пустая строка
86
+ def issue_title
87
+ result = ""
88
+ if issues.count > 0
89
+ result = issues.first.number
90
+ end
91
+ result
92
+ end
93
+
64
94
  # выдать логотип первой попавшейся компании
65
95
  # если чего-то нету - выдаётся nil
66
96
  def company_logo
@@ -99,5 +129,23 @@ module C80NewsTz
99
129
  self.joins(:rubrics).where(:c80_news_tz_rubrics => {:slug => rubric_slug})
100
130
  end
101
131
 
132
+ # выдать нужное количество публикаций из той же рубрики
133
+ def self.similar_rubric_pubs(pub, count)
134
+ r = self.joins(:rubrics)
135
+ .where(:c80_news_tz_rubrics => {:id => pub.rubric_id})
136
+ .where.not(:c80_news_tz_facts => {:id => pub.id})
137
+ .limit(count)
138
+ r
139
+ end
140
+
141
+ # выдать нужное количество публикаций из того же номера
142
+ def self.similar_issue_pubs(pub, count)
143
+ r = self.joins(:issues)
144
+ .where(:c80_news_tz_issues => {:id => pub.issue_id})
145
+ .where.not(:c80_news_tz_facts => {:id => pub.id})
146
+ .limit(count)
147
+ r
148
+ end
149
+
102
150
  end
103
151
  end
@@ -26,5 +26,39 @@ module C80NewsTz
26
26
  # name_changed? || super
27
27
  end
28
28
 
29
+ # выдать путь до лого для вставки в блок "публикации рекламодателя"
30
+ # иначе вернёт nil
31
+ def logo_for_aapub
32
+ result = nil
33
+ if logo.present?
34
+ result = logo.thumb_fill
35
+ end
36
+ result
37
+ end
38
+
39
+ # выдать активного рекламодателя (он может быть только один)
40
+ # если активного нету - вернётся nil
41
+ def self.active
42
+ result = nil
43
+
44
+ s = "
45
+ SELECT
46
+ `c80_news_tz_r_advertisers`.*
47
+ FROM
48
+ `c80_news_tz_r_advertisers`
49
+ INNER JOIN
50
+ `c80_news_tz_advs_lives` ON `c80_news_tz_r_advertisers`.id = `c80_news_tz_advs_lives`.r_advertiser_id;
51
+ "
52
+
53
+ array_of_advertisers = self.find_by_sql(s)
54
+
55
+ if array_of_advertisers.count == 1
56
+ result = array_of_advertisers[0]
57
+ end
58
+
59
+ result
60
+
61
+ end
62
+
29
63
  end
30
64
  end
@@ -29,12 +29,9 @@ module C80NewsTz
29
29
  [:title] + Array.new(6) {|index| [:title, index+2]}
30
30
  end
31
31
 
32
- # TODO_MY:: используется ли метод short_meta_description?
33
32
  def short_meta_description
34
33
 
35
- if description.present? && description.length > 200
36
- result = description
37
- elsif full.present? && full.length > 0
34
+ if full.present? && full.length > 0
38
35
  result = strip_tags(full[0..200]+"...")
39
36
  else
40
37
  result = nil
@@ -46,8 +43,30 @@ module C80NewsTz
46
43
  # выдать публикации, принадлежащие указанной рубрике
47
44
  def self.where_rubric(rubric_slug)
48
45
  self.joins(:rubrics).where(:c80_news_tz_rubrics => {:slug => rubric_slug})
49
- end
50
-
46
+ end
47
+
48
+ # выдать массив с двумя последними публикациями указанного рекламодателя
49
+ # массив может содержать элементов: 0, 1, 2
50
+ def self.two_last_pubs_by_advr(advertiser_id)
51
+ s = "
52
+ SELECT
53
+ `c80_news_tz_r_blurbs`.*
54
+ FROM
55
+ `c80_news_tz_r_blurbs`
56
+ INNER JOIN
57
+ `c80_news_tz_advs_blurbs` ON `c80_news_tz_r_blurbs`.id = `c80_news_tz_advs_blurbs`.r_blurb_id
58
+ WHERE
59
+ `c80_news_tz_advs_blurbs`.r_advertiser_id = #{advertiser_id}
60
+ ORDER BY
61
+ `c80_news_tz_r_blurbs`.created_at DESC
62
+ LIMIT 2;
63
+ "
64
+
65
+ result = self.find_by_sql(s)
66
+ result
67
+
68
+ end
69
+
51
70
  # выдать картинку, которая пойдёт в блок преьвю
52
71
  def photo_preview
53
72
  result = nil
@@ -68,6 +87,36 @@ module C80NewsTz
68
87
  result
69
88
  end
70
89
 
90
+ # выдать id первой попавшейся рубрики
91
+ # если рубрики у публикации нету - выдать невероятное число 999999
92
+ def rubric_id
93
+ result = 999999
94
+ if rubrics.count > 0
95
+ result = rubrics.first.id
96
+ end
97
+ result
98
+ end
99
+
100
+ # выдать id первого попавшегося номера
101
+ # если номера у публикации нету - выдать невероятное число 999999
102
+ def issue_id
103
+ result = 999999
104
+ if issues.count > 0
105
+ result = issues.first.id
106
+ end
107
+ result
108
+ end
109
+
110
+ # выдать название номера, которому принадлежит новость
111
+ # если чего-то не хватает - выдаётся пустая строка
112
+ def issue_title
113
+ result = ""
114
+ if issues.count > 0
115
+ result = issues.first.number
116
+ end
117
+ result
118
+ end
119
+
71
120
  # выдать логотип первого попавшегося рекламодателя
72
121
  # если чего-то нету - выдаётся nil
73
122
  def company_logo
@@ -0,0 +1,44 @@
1
+ # грузит картинку для баннера, который находится в самом верху страницы
2
+ module C80NewsTz
3
+ class Bimage01Uploader < CarrierWave::Uploader::Base
4
+
5
+ include CarrierWave::MiniMagick
6
+
7
+ storage :file
8
+
9
+ process :resize_to_limit => [1200,1200]
10
+
11
+ version :thumb_preview do
12
+ process :resize_to_fill => [240,33]
13
+ end
14
+
15
+ version :thumb_fill do
16
+ process :resize_to_fill => [1200, 165]
17
+ end
18
+
19
+ version :thumb_fit do
20
+ process :resize_to_fit => [1200, 165]
21
+ end
22
+
23
+ def store_dir
24
+ "uploads/n_01/#{format("%02d", model.id)}"
25
+ end
26
+
27
+ def extension_white_list
28
+ %w(jpg jpeg gif png)
29
+ end
30
+
31
+ def filename
32
+ if original_filename
33
+ "photo_#{secure_token(4)}.#{file.extension}"
34
+ end
35
+ end
36
+
37
+ protected
38
+ def secure_token(length=16)
39
+ var = :"@#{mounted_as}_secure_token"
40
+ model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.hex(length/2))
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ # грузит картинку для баннера, который находится в рекламной области №2, перед содержимым страницы
2
+ module C80NewsTz
3
+ class Bimage02Uploader < CarrierWave::Uploader::Base
4
+
5
+ include CarrierWave::MiniMagick
6
+
7
+ storage :file
8
+
9
+ process :resize_to_limit => [812,812]
10
+
11
+ version :thumb_preview do
12
+ process :resize_to_fill => [406,65]
13
+ end
14
+
15
+ version :thumb_fill do
16
+ process :resize_to_fill => [812, 130]
17
+ end
18
+
19
+ version :thumb_fit do
20
+ process :resize_to_fit => [812, 130]
21
+ end
22
+
23
+ def store_dir
24
+ "uploads/n_02/#{format("%02d", model.id)}"
25
+ end
26
+
27
+ def extension_white_list
28
+ %w(jpg jpeg gif png)
29
+ end
30
+
31
+ def filename
32
+ if original_filename
33
+ "photo_#{secure_token(4)}.#{file.extension}"
34
+ end
35
+ end
36
+
37
+ protected
38
+ def secure_token(length=16)
39
+ var = :"@#{mounted_as}_secure_token"
40
+ model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.hex(length/2))
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ # грузит картинку для баннера, что справа от главной публикации
2
+ module C80NewsTz
3
+ class Bimage03Uploader < CarrierWave::Uploader::Base
4
+
5
+ include CarrierWave::MiniMagick
6
+
7
+ storage :file
8
+
9
+ process :resize_to_limit => [287,321]
10
+
11
+ version :thumb_preview do
12
+ process :resize_to_fill => [287,321]
13
+ end
14
+
15
+ version :thumb_fill do
16
+ process :resize_to_fill => [287,321]
17
+ end
18
+
19
+ version :thumb_fit do
20
+ process :resize_to_fit => [287,321]
21
+ end
22
+
23
+ def store_dir
24
+ "uploads/n_03/#{format("%02d", model.id)}"
25
+ end
26
+
27
+ def extension_white_list
28
+ %w(jpg jpeg gif png)
29
+ end
30
+
31
+ def filename
32
+ if original_filename
33
+ "photo_#{secure_token(4)}.#{file.extension}"
34
+ end
35
+ end
36
+
37
+ protected
38
+ def secure_token(length=16)
39
+ var = :"@#{mounted_as}_secure_token"
40
+ model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.hex(length/2))
41
+ end
42
+
43
+ end
44
+ end
@@ -8,14 +8,20 @@ module C80NewsTz
8
8
 
9
9
  process :resize_to_limit => [500,500]
10
10
 
11
+
12
+
13
+ # вставляются в блок "публикации рекламодателя"
11
14
  version :thumb_fit do
12
- process :resize_to_fit => [124,124]
15
+ process :resize_to_fit => [282,82]
13
16
  end
14
17
 
15
18
  version :thumb_fill do
16
- process :resize_to_fill => [124,74]
19
+ process :resize_to_fill => [282,82]
17
20
  end
18
21
 
22
+
23
+
24
+ # по идее, должны вставляться в preview блока новости
19
25
  version :thumb_preview_small do
20
26
  process :resize_to_fit => [80, 44]
21
27
  end
@@ -29,6 +35,9 @@ module C80NewsTz
29
35
  process :resize_to_fit => [124, 124]
30
36
  end
31
37
 
38
+
39
+
40
+
32
41
  def store_dir
33
42
  "uploads/rec/avs/_logos/#{format("%02d", model.id)}"
34
43
  end
@@ -0,0 +1,7 @@
1
+ <div class="container">
2
+ <div class="row">
3
+ <div class="b-site-masthead">
4
+ <%= render_image_link_lazy_holder(vp) %>
5
+ </div>
6
+ </div>
7
+ </div>
@@ -0,0 +1,3 @@
1
+ <div id="page_masthead">
2
+ <%= render_image_link_lazy_holder(vp) %>
3
+ </div>
@@ -0,0 +1,3 @@
1
+ <div>
2
+ <%= render_image_link_lazy_holder(vp) %>
3
+ </div>
data/config/routes.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  C80NewsTz::Engine.routes.draw do
2
2
  match 'news_guru', :to => 'application#guru', :via => :post
3
+ match 'rb', :to => 'banners#counter', :via => :post
3
4
  end
@@ -0,0 +1,14 @@
1
+ class CreateBanners01 < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_news_tz_banner01s, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :title
5
+ t.string :image
6
+ t.string :href
7
+ t.boolean :is_active
8
+ t.integer :shown, :default => 0
9
+ t.integer :clicks, :default => 0
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class CreateBanners02 < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_news_tz_banner02s, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :title
5
+ t.string :image
6
+ t.string :href
7
+ t.boolean :is_active
8
+ t.integer :shown, :default => 0
9
+ t.integer :clicks, :default => 0
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class CreateBanners03 < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_news_tz_banner03s, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :title
5
+ t.string :image
6
+ t.string :href
7
+ t.boolean :is_active
8
+ t.integer :shown, :default => 0
9
+ t.integer :clicks, :default => 0
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module C80NewsTz
2
- VERSION = "0.1.1.19"
2
+ VERSION = "0.1.1.21"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c80_news_tz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.19
4
+ version: 0.1.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-09 00:00:00.000000000 Z
11
+ date: 2016-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,9 @@ files:
94
94
  - LICENSE.txt
95
95
  - README.md
96
96
  - Rakefile
97
+ - app/admin/c80_news_tz/banners01.rb
98
+ - app/admin/c80_news_tz/banners02.rb
99
+ - app/admin/c80_news_tz/banners03.rb
97
100
  - app/admin/c80_news_tz/compaines.rb
98
101
  - app/admin/c80_news_tz/facts.rb
99
102
  - app/admin/c80_news_tz/issues.rb
@@ -114,6 +117,7 @@ files:
114
117
  - app/assets/javascripts/c80_news_tz/backend/r_blurbs.js
115
118
  - app/assets/javascripts/c80_news_tz/backend/rubrics.js
116
119
  - app/assets/javascripts/c80_news_tz/frontend/facts_ajax.js
120
+ - app/assets/javascripts/c80_news_tz/frontend/nabbers.js
117
121
  - app/assets/stylesheets/c80_news_tz/application.scss
118
122
  - app/assets/stylesheets/c80_news_tz/backend.scss
119
123
  - app/assets/stylesheets/c80_news_tz/backend/collapsed.scss
@@ -125,10 +129,18 @@ files:
125
129
  - app/assets/stylesheets/c80_news_tz/backend/spots.scss
126
130
  - app/assets/stylesheets/c80_news_tz/frontend/pubs_medium.scss
127
131
  - app/controllers/c80_news_tz/application_controller.rb
132
+ - app/controllers/c80_news_tz/banners_controller.rb
133
+ - app/helpers/c80_news_tz/advertisers_helper.rb
128
134
  - app/helpers/c80_news_tz/application_helper.rb
135
+ - app/helpers/c80_news_tz/banners_helper.rb
136
+ - app/helpers/c80_news_tz/blurbs_helper.rb
129
137
  - app/helpers/c80_news_tz/publications_helper.rb
130
138
  - app/helpers/c80_news_tz/subj_helper.rb
131
139
  - app/models/c80_news_tz/adress.rb
140
+ - app/models/c80_news_tz/banner01.rb
141
+ - app/models/c80_news_tz/banner02.rb
142
+ - app/models/c80_news_tz/banner03.rb
143
+ - app/models/c80_news_tz/banner_validator.rb
132
144
  - app/models/c80_news_tz/company.rb
133
145
  - app/models/c80_news_tz/cphoto.rb
134
146
  - app/models/c80_news_tz/fact.rb
@@ -149,6 +161,9 @@ files:
149
161
  - app/models/c80_news_tz/rubric.rb
150
162
  - app/models/c80_news_tz/rubric_validator.rb
151
163
  - app/models/c80_news_tz/spot.rb
164
+ - app/uploaders/c80_news_tz/bimage01_uploader.rb
165
+ - app/uploaders/c80_news_tz/bimage02_uploader.rb
166
+ - app/uploaders/c80_news_tz/bimage03_uploader.rb
152
167
  - app/uploaders/c80_news_tz/clogo_uploader.rb
153
168
  - app/uploaders/c80_news_tz/cphoto_uploader.rb
154
169
  - app/uploaders/c80_news_tz/fphoto_uploader.rb
@@ -158,7 +173,11 @@ files:
158
173
  - app/uploaders/c80_news_tz/r_alogo_uploader.rb
159
174
  - app/uploaders/c80_news_tz/r_bphoto_uploader.rb
160
175
  - app/views/c80_news_tz/application/guru.js.erb
176
+ - app/views/c80_news_tz/banners/counter.html.erb
161
177
  - app/views/layouts/c80_news_tz/application.html.erb
178
+ - app/views/shared/_banner_01.html.erb
179
+ - app/views/shared/_banner_02.html.erb
180
+ - app/views/shared/_banner_03.html.erb
162
181
  - app/views/shared/_fact.html.erb
163
182
  - app/views/shared/_news_block.html.erb
164
183
  - app/views/shared/_news_list.html.erb
@@ -196,6 +215,9 @@ files:
196
215
  - db/migrate/20160309151313_create_join_table_advertisers_blurbs.rb
197
216
  - db/migrate/20160309154848_create_bphotos.rb
198
217
  - db/migrate/20160309165151_create_join_table_blurbs_issues.rb
218
+ - db/migrate/20160309194444_create_banners01.rb
219
+ - db/migrate/20160310110000_create_banners02.rb
220
+ - db/migrate/20160310114242_create_banners03.rb
199
221
  - db/seeds/19_fill_news_props.rb.example
200
222
  - db/seeds/20_fill_rubrics.rb.example
201
223
  - db/seeds/21_fill_facts.rb.example