c80_news_tz 0.1.1.18 → 0.1.1.19

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/app/admin/c80_news_tz/locations.rb +1 -1
  3. data/app/admin/c80_news_tz/r_advertisers.rb +60 -0
  4. data/app/admin/c80_news_tz/r_blurbs.rb +100 -0
  5. data/app/admin/c80_news_tz/r_lives.rb +36 -0
  6. data/app/admin/c80_news_tz/spots.rb +3 -2
  7. data/app/assets/javascripts/c80_news_tz/backend/companies.js +3 -0
  8. data/app/assets/javascripts/c80_news_tz/backend/facts.js +3 -0
  9. data/app/assets/javascripts/c80_news_tz/backend/r_advertisers.js +3 -0
  10. data/app/assets/javascripts/c80_news_tz/backend/r_blurbs.js +3 -0
  11. data/app/assets/javascripts/c80_news_tz/backend/rubrics.js +3 -0
  12. data/app/assets/stylesheets/c80_news_tz/backend/locations.scss +26 -0
  13. data/app/assets/stylesheets/c80_news_tz/backend/r_advertisers.scss +5 -0
  14. data/app/assets/stylesheets/c80_news_tz/backend/r_lives.scss +26 -0
  15. data/app/assets/stylesheets/c80_news_tz/backend/spots.scss +26 -0
  16. data/app/models/c80_news_tz/issue.rb +1 -0
  17. data/app/models/c80_news_tz/r_advertiser.rb +30 -0
  18. data/app/models/c80_news_tz/r_blurb.rb +84 -0
  19. data/app/models/c80_news_tz/r_bphoto.rb +39 -0
  20. data/app/models/c80_news_tz/r_live.rb +6 -0
  21. data/app/models/c80_news_tz/rubric.rb +2 -2
  22. data/app/uploaders/c80_news_tz/r_alogo_uploader.rb +55 -0
  23. data/app/uploaders/c80_news_tz/r_bphoto_uploader.rb +98 -0
  24. data/config/locales/ru.yml +34 -1
  25. data/db/migrate/20160309130000_create_lives.rb +11 -0
  26. data/db/migrate/20160309132020_create_advertisers.rb +12 -0
  27. data/db/migrate/20160309134444_create_join_table_advertisers_lives.rb +12 -0
  28. data/db/migrate/20160309145050_create_blurbs.rb +14 -0
  29. data/db/migrate/20160309150808_create_join_table_blurbs_rubrics.rb +12 -0
  30. data/db/migrate/20160309151313_create_join_table_advertisers_blurbs.rb +12 -0
  31. data/db/migrate/20160309154848_create_bphotos.rb +10 -0
  32. data/db/migrate/20160309165151_create_join_table_blurbs_issues.rb +12 -0
  33. data/lib/c80_news_tz/version.rb +1 -1
  34. metadata +28 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49c1b9b1d8a903b6fb209179f36690f5645404cc
4
- data.tar.gz: 58ab6e3a21b235b9258aaf85e6350109ec0d92ed
3
+ metadata.gz: 8a0f668c3dc59e8d30d94346ccf26593481b0849
4
+ data.tar.gz: 795d636d35a71bcc89bd7c8acdd8883288d68eac
5
5
  SHA512:
6
- metadata.gz: 201fc0c685907eb8142c075cefcccd10312e1ccac354dd14a4801d692c305eabd246853e7a3721002a3a1daa5a7e171a0b8c4f6f9db363279b74603124a434bb
7
- data.tar.gz: 72cc3f9218de587aeb78bf7ea450b9c884e8b9db3b3b37be3ed203f53d634c9caf0367b04c868456c5182f40f48c8b4c7935ddd964028f0b0a466f1bc54c2140
6
+ metadata.gz: bf27bbad97a44b79f4fff931f2afa6f2a6712716ec3e8d8b1586d54dade8f99897e13f6a0dfda93808d97a839c0991849e5e398cfbea43c95914e61c59ec4845
7
+ data.tar.gz: 5c9b791dd6374432cfd3eb4ac6fadc86ff96cea5b8eff92df1b8db079dca371f46a293c7d2d2f128e9fb892dc85f8cb0b9c30f51b595ab628600b9292c589778
@@ -1,6 +1,6 @@
1
1
  ActiveAdmin.register C80NewsTz::Location, :as => 'Location' do
2
2
 
3
- menu :label => "Места на главной", :parent => 'Содержимое сайта'
3
+ menu :label => "Публикации на главной", :parent => 'Содержимое сайта'
4
4
 
5
5
  before_filter :skip_sidebar!, :only => :index
6
6
 
@@ -0,0 +1,60 @@
1
+ ActiveAdmin.register C80NewsTz::RAdvertiser, :as => 'RAdvertiser' do
2
+
3
+ menu :label => "Рекламодатели", :parent => 'Содержимое сайта'
4
+
5
+ # before_filter :skip_sidebar!, :only => :index
6
+
7
+ permit_params :title,
8
+ :logo,
9
+ :r_blurb_ids => []
10
+
11
+ config.sort_order = 'title_asc'
12
+
13
+ filter :title
14
+
15
+ # controller do
16
+ # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
17
+ # end
18
+
19
+ index do
20
+ selectable_column
21
+ id_column
22
+ column :title
23
+ column :logo do |a|
24
+ if a.logo.present?
25
+ "#{image_tag("#{a.logo.thumb_preview_big.url}")}".html_safe
26
+ end
27
+ end
28
+
29
+ column :r_blurbs do |issue|
30
+ # нарисуем список
31
+ list_items = ((issue.r_blurbs.map { |p|
32
+ "<li>• #{ p.title } <a href='/news/#{p.slug}' target='_blank'>[view]</a> <a href='/admin/r_blurbs/#{p.slug}/edit'>[edit]</a> </li>"
33
+ }).join("")).html_safe
34
+
35
+ "<ul>#{list_items}</ul>".html_safe
36
+ end
37
+
38
+ actions
39
+ end
40
+
41
+ form(:html => {:multipart => true}) do |f|
42
+
43
+ f.inputs "Свойства" do
44
+
45
+ f.input :title
46
+ f.input :logo, :hint => "#{image_tag("#{f.object.logo.thumb_preview_big.url}")}".html_safe
47
+ end
48
+
49
+ f.inputs 'Публикации рекламодателя', :class => 'collapsed' do
50
+ f.input :r_blurbs,
51
+ :as => :check_boxes,
52
+ :member_label => Proc.new { |p|
53
+ "#{p.title} <a href='/news/#{p.slug}' target='_blank'>[view]</a> <a href='/admin/r_blurbs/#{p.slug}/edit'>[edit]</a>".html_safe
54
+ }
55
+ end
56
+
57
+ f.actions
58
+ end
59
+
60
+ end
@@ -0,0 +1,100 @@
1
+ ActiveAdmin.register C80NewsTz::RBlurb, :as => 'RBlurb' do
2
+
3
+ #before_filter :skip_sidebar!, :only => :index
4
+
5
+ menu :label => 'Публикации рекламодателей', :parent => 'Содержимое сайта'
6
+
7
+ permit_params :short,
8
+ :title,
9
+ :leader_abz,
10
+ :full,
11
+ :r_bphotos_attributes => [:id, :image, :_destroy],
12
+ :r_advertiser_ids => [],
13
+ :rubric_ids => [],
14
+ :issue_ids => []
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 :created_at do |fact|
25
+ local_time(fact[:created_at], format: '%e.%m.%Y')
26
+ end
27
+
28
+ column '' do |fact|
29
+ if fact.r_bphotos.count > 0
30
+ image_tag(fact.r_bphotos.first.image.thumb_preview_small)
31
+ end
32
+ end
33
+
34
+ column :short
35
+ column :rubrics do |fact|
36
+ # нарисуем список
37
+ list_items = ((fact.rubrics.map { |p|
38
+ "<li>#{ p.title }</li>"
39
+ }).join("")).html_safe
40
+
41
+ "<ul>#{list_items}</ul>".html_safe
42
+ end
43
+ column :issue do |fact|
44
+ # нарисуем список
45
+ list_items = ((fact.issues.map { |p|
46
+ "<li>• #{ p.number } <a href='/issues/#{p.id}' target='_blank'>[view]</a> <a href='/admin/issues/#{p.id}/edit'>[edit]</a> </li>"
47
+ }).join("")).html_safe
48
+
49
+ "<ul>#{list_items}</ul>".html_safe
50
+ end
51
+ # column :full
52
+
53
+ actions
54
+ end
55
+
56
+ form(:html => {:multipart => true}) do |f|
57
+ f.inputs 'Свойства' do
58
+ f.input :title
59
+
60
+ f.input :rubrics,
61
+ :as => :check_boxes,
62
+ :member_label => Proc.new { |p|
63
+ p.title
64
+ }
65
+
66
+ f.input :issues,
67
+ :as => :check_boxes,
68
+ :member_label => Proc.new { |p|
69
+ p.number
70
+ }
71
+
72
+ f.input :short, :input_html => {:rows => 3, :class => 'code_area'}
73
+ f.input :leader_abz, :input_html => {:rows => 3, :class => 'code_area'}
74
+
75
+ f.inputs 'Картинки, вставляемые в текст публикации (первая картинка идёт в предпросмотр публикации)', :class => 'collapsed' do
76
+ f.has_many :r_bphotos, :allow_destroy => true do |p|
77
+ p.input :image,
78
+ :as => :file,
79
+ :hint => image_tag(p.object.image.thumb_preview_medium)
80
+ end
81
+ end
82
+
83
+ f.inputs 'Текст публикации' do
84
+ f.input :full, :as => :ckeditor
85
+ end
86
+
87
+
88
+ f.inputs 'Рекламодатели, связанные с публикацией' do
89
+ f.input :r_advertisers,
90
+ :as => :check_boxes,
91
+ :member_label => Proc.new { |p|
92
+ "#{p.title} <a href='/rcompanies/#{p.slug}' target='_blank'>[view]</a> <a href='/admin/r_advertisers/#{p.slug}/edit'>[edit]</a>".html_safe
93
+ }
94
+ end
95
+
96
+ end
97
+ f.actions
98
+ end
99
+
100
+ end
@@ -0,0 +1,36 @@
1
+ ActiveAdmin.register C80NewsTz::RLive, :as => 'RLive' do
2
+
3
+ menu :label => "Рекламодатель активный", :parent => 'Содержимое сайта'
4
+
5
+ before_filter :skip_sidebar!, :only => :index
6
+
7
+ permit_params :r_advertiser_ids => []
8
+
9
+ index do
10
+ column :r_advertisers do |loc|
11
+ # нарисуем список
12
+ list_items = ((loc.r_advertisers.map { |p|
13
+ "<li>#{ p.title }</li>"
14
+ }).join("")).html_safe
15
+
16
+ "<ul>#{list_items}</ul>".html_safe
17
+ end
18
+ actions
19
+ end
20
+
21
+ form(:html => {:multipart => true}) do |f|
22
+ f.inputs "Свойства" do
23
+
24
+ f.input :r_advertisers,
25
+ :as => :select,
26
+ :input_html => {:multiple => false},
27
+ :include_blank => true,
28
+ :member_label => Proc.new { |p|
29
+ p.title
30
+ }
31
+
32
+ end
33
+ f.actions
34
+ end
35
+
36
+ end
@@ -10,7 +10,7 @@ ActiveAdmin.register C80NewsTz::Spot, :as => 'Spot' do
10
10
 
11
11
  index do
12
12
  id_column
13
- column :title
13
+ # column :title
14
14
 
15
15
  column :rubrics do |loc|
16
16
  # нарисуем список
@@ -26,7 +26,8 @@ ActiveAdmin.register C80NewsTz::Spot, :as => 'Spot' do
26
26
 
27
27
  form(:html => {:multipart => true}) do |f|
28
28
  f.inputs "Свойства" do
29
- f.input :title
29
+ # f.input :title
30
+ f.input :id, :input_html => {:readonly => true }
30
31
 
31
32
  f.input :rubrics,
32
33
  :as => :select,
@@ -0,0 +1,3 @@
1
+ $(document).ready(function() {
2
+ $('body.show.admin_companies #main_content > div > h3').text('Компания');
3
+ });
@@ -0,0 +1,3 @@
1
+ $(document).ready(function() {
2
+ $('body.show.admin_facts #main_content > div > h3').text('Публикация');
3
+ });
@@ -0,0 +1,3 @@
1
+ $(document).ready(function() {
2
+ $('body.show.admin_r_advertisers #main_content > div > h3').text('Рекламодатель');
3
+ });
@@ -0,0 +1,3 @@
1
+ $(document).ready(function() {
2
+ $('body.show.admin_r_blurbs #main_content > div > h3').text('Публикация рекламодателя');
3
+ });
@@ -0,0 +1,3 @@
1
+ $(document).ready(function() {
2
+ $('body.show.admin_rubrics #main_content > div > h3').text('Рубрика');
3
+ });
@@ -0,0 +1,26 @@
1
+ body.admin_locations {
2
+
3
+ &.index {
4
+ #titlebar_right {
5
+ display: none !important;
6
+ }
7
+ .table_tools {
8
+ display: none !important;
9
+ }
10
+ a.view_link {
11
+ display: none !important;
12
+ }
13
+ a.delete_link {
14
+ display: none !important;
15
+ }
16
+ }
17
+
18
+ &.show {
19
+ #titlebar_right {
20
+ display: none !important;
21
+ }
22
+ #main_content > div > h3 {
23
+ display: none;
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,5 @@
1
+ body.new.admin_r_advertisers, body.edit.admin_r_advertisers {
2
+ li#r_advertiser_r_blurbs_input > fieldset > legend.label {
3
+ display: none;
4
+ }
5
+ }
@@ -0,0 +1,26 @@
1
+ body.admin_r_lives {
2
+
3
+ &.index {
4
+ #titlebar_right {
5
+ display: none !important;
6
+ }
7
+ .table_tools {
8
+ display: none !important;
9
+ }
10
+ a.view_link {
11
+ display: none !important;
12
+ }
13
+ a.delete_link {
14
+ display: none !important;
15
+ }
16
+ }
17
+
18
+ &.show {
19
+ #titlebar_right {
20
+ display: none !important;
21
+ }
22
+ #main_content > div > h3 {
23
+ display: none;
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,26 @@
1
+ body.admin_spots {
2
+
3
+ &.index {
4
+ #titlebar_right {
5
+ display: none !important;
6
+ }
7
+ .table_tools {
8
+ display: none !important;
9
+ }
10
+ a.view_link {
11
+ display: none !important;
12
+ }
13
+ a.delete_link {
14
+ display: none !important;
15
+ }
16
+ }
17
+
18
+ &.show {
19
+ #titlebar_right {
20
+ display: none !important;
21
+ }
22
+ #main_content > div > h3 {
23
+ display: none;
24
+ }
25
+ }
26
+ }
@@ -1,6 +1,7 @@
1
1
  module C80NewsTz
2
2
  class Issue < ActiveRecord::Base
3
3
  has_and_belongs_to_many :facts, :join_table => 'c80_news_tz_facts_issues'
4
+ has_and_belongs_to_many :r_blurbs, :join_table => 'c80_news_tz_blurbs_issues'
4
5
  has_many :pdfs, :dependent => :destroy
5
6
  accepts_nested_attributes_for :pdfs,
6
7
  :reject_if => lambda { |attributes|
@@ -0,0 +1,30 @@
1
+ include ActionView::Helpers::SanitizeHelper
2
+ require "babosa"
3
+
4
+ # рекламодатель
5
+ module C80NewsTz
6
+ class RAdvertiser < ActiveRecord::Base
7
+
8
+ has_and_belongs_to_many :r_lives, :join_table => 'c80_news_tz_advs_lives'
9
+ has_and_belongs_to_many :r_blurbs, :join_table => 'c80_news_tz_advs_blurbs'
10
+
11
+ mount_uploader :logo, RAlogoUploader
12
+
13
+ extend FriendlyId
14
+ friendly_id :title, use: :slugged
15
+
16
+ def normalize_friendly_id(input)
17
+ input.to_s.to_slug.normalize(transliterations: :russian).to_s
18
+ end
19
+
20
+ def slug_candidates
21
+ [:title] + Array.new(6) { |index| [:title, index+2] }
22
+ end
23
+
24
+ def should_generate_new_friendly_id?
25
+ slug.blank?
26
+ # name_changed? || super
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,84 @@
1
+ require "babosa"
2
+ include ActionView::Helpers::SanitizeHelper
3
+
4
+ # публикация рекламодателя
5
+ module C80NewsTz
6
+ class RBlurb < ActiveRecord::Base
7
+ has_and_belongs_to_many :issues, :join_table => 'c80_news_tz_facts_issues'
8
+ has_many :r_bphotos, :dependent => :destroy
9
+ accepts_nested_attributes_for :r_bphotos,
10
+ :reject_if => lambda { |attributes|
11
+ !attributes.present?
12
+ },
13
+ :allow_destroy => true
14
+
15
+ has_and_belongs_to_many :issues, :join_table => 'c80_news_tz_blurbs_issues'
16
+ has_and_belongs_to_many :rubrics, :join_table => 'c80_news_tz_blurbs_rubrics'
17
+ has_and_belongs_to_many :r_advertisers, :join_table => 'c80_news_tz_advs_blurbs'
18
+
19
+ validates_with FactValidator
20
+ default_scope {order(:created_at => :desc)}
21
+
22
+ extend FriendlyId
23
+ friendly_id :title, use: :slugged
24
+ def normalize_friendly_id(input)
25
+ input.to_s.to_slug.normalize(transliterations: :russian).to_s
26
+ end
27
+
28
+ def slug_candidates
29
+ [:title] + Array.new(6) {|index| [:title, index+2]}
30
+ end
31
+
32
+ # TODO_MY:: используется ли метод short_meta_description?
33
+ def short_meta_description
34
+
35
+ if description.present? && description.length > 200
36
+ result = description
37
+ elsif full.present? && full.length > 0
38
+ result = strip_tags(full[0..200]+"...")
39
+ else
40
+ result = nil
41
+ end
42
+ result
43
+
44
+ end
45
+
46
+ # выдать публикации, принадлежащие указанной рубрике
47
+ def self.where_rubric(rubric_slug)
48
+ self.joins(:rubrics).where(:c80_news_tz_rubrics => {:slug => rubric_slug})
49
+ end
50
+
51
+ # выдать картинку, которая пойдёт в блок преьвю
52
+ def photo_preview
53
+ result = nil
54
+ if fphotos.count > 0
55
+ result = fphotos.first.image
56
+ else
57
+ end
58
+ result
59
+ end
60
+
61
+ # выдать строку: title первой попавшейся рубрики
62
+ # если таковой нету - выдаётся пустая строка
63
+ def rubric_title
64
+ result = ""
65
+ if rubrics.count > 0
66
+ result = rubrics.first.title
67
+ end
68
+ result
69
+ end
70
+
71
+ # выдать логотип первого попавшегося рекламодателя
72
+ # если чего-то нету - выдаётся nil
73
+ def company_logo
74
+ result = nil
75
+ if r_advertisers.count > 0
76
+ if r_advertisers.first.logo.present?
77
+ result = r_advertisers.first.logo
78
+ end
79
+ end
80
+ result
81
+ end
82
+
83
+ end
84
+ end
@@ -0,0 +1,39 @@
1
+ # фотография в тексте публикации рекламодателя
2
+ module C80NewsTz
3
+ class RBphoto < ActiveRecord::Base
4
+ belongs_to :r_blurbs
5
+ mount_uploader :image, RBphotoUploader
6
+
7
+ # в ~ от размеров thumb-ов и page_content_width - выдать соответствующую картинку
8
+ # • Если у картинки thumb_big шириной ≥ page_content_width - вставляем этот thumb_big.
9
+ # • Иначе: вставлем thumb_small.
10
+ def content_image
11
+ img = MiniMagick::Image.open(image.thumb_big.path)
12
+ w = SiteProp.first.page_content_width
13
+ if img["width"] < w
14
+ image.thumb_small
15
+ else
16
+ image.thumb_big
17
+ end
18
+ end
19
+
20
+ # выдать размеры картинки, которая будет вставлена в текст страницы
21
+ def content_image_size
22
+ img = MiniMagick::Image.open(image.thumb_big.path)
23
+ w = SiteProp.first.page_content_width
24
+ if img["width"] < w
25
+ img = MiniMagick::Image.open(image.thumb_small.path)
26
+ [img["width"],img["height"]]
27
+ else
28
+ [img["width"],img["height"]]
29
+ end
30
+ end
31
+
32
+ # выдать размеры картинки thumb_preview
33
+ # def thumb_preview_size
34
+ # img = MiniMagick::Image.open(image.thumb_preview.path)
35
+ # [img["width"],img["height"]]
36
+ # end
37
+
38
+ end
39
+ end
@@ -0,0 +1,6 @@
1
+ # Активный рекламодатель
2
+ module C80NewsTz
3
+ class RLive < ActiveRecord::Base
4
+ has_and_belongs_to_many :r_advertisers, :join_table => 'c80_news_tz_advs_lives'
5
+ end
6
+ end
@@ -2,6 +2,8 @@ require "babosa"
2
2
  module C80NewsTz
3
3
  class Rubric < ActiveRecord::Base
4
4
  has_and_belongs_to_many :spots, :join_table => 'c80_news_tz_rubrics_spots'
5
+ has_and_belongs_to_many :facts, :join_table => 'c80_news_tz_facts_rubrics'
6
+ has_and_belongs_to_many :r_blurbs, :join_table => 'c80_news_tz_blurbs_rubrics'
5
7
 
6
8
  validates_with RubricValidator
7
9
 
@@ -16,8 +18,6 @@ module C80NewsTz
16
18
  [:title] + Array.new(6) { |index| [:title, index+2] }
17
19
  end
18
20
 
19
- has_and_belongs_to_many :facts, :join_table => 'c80_news_tz_facts_rubrics'
20
-
21
21
  def should_generate_new_friendly_id?
22
22
  slug.blank?
23
23
  # name_changed? || super
@@ -0,0 +1,55 @@
1
+ # грузит лого рекламодателя
2
+ module C80NewsTz
3
+ class RAlogoUploader < CarrierWave::Uploader::Base
4
+
5
+ include CarrierWave::MiniMagick
6
+
7
+ storage :file
8
+
9
+ process :resize_to_limit => [500,500]
10
+
11
+ version :thumb_fit do
12
+ process :resize_to_fit => [124,124]
13
+ end
14
+
15
+ version :thumb_fill do
16
+ process :resize_to_fill => [124,74]
17
+ end
18
+
19
+ version :thumb_preview_small do
20
+ process :resize_to_fit => [80, 44]
21
+ end
22
+
23
+ version :thumb_preview_medium do
24
+ process :resize_to_fit => [80, 44]
25
+ end
26
+
27
+ # идёт в блок "главная публикация", что на главной
28
+ version :thumb_preview_big do
29
+ process :resize_to_fit => [124, 124]
30
+ end
31
+
32
+ def store_dir
33
+ "uploads/rec/avs/_logos/#{format("%02d", model.id)}"
34
+ end
35
+
36
+ def extension_white_list
37
+ %w(jpg jpeg gif png)
38
+ end
39
+
40
+ def filename
41
+ if original_filename
42
+ "logo_#{secure_token(4)}.#{file.extension}"
43
+ end
44
+ end
45
+
46
+ protected
47
+ def secure_token(length=16)
48
+ var = :"@#{mounted_as}_secure_token"
49
+ model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.hex(length/2))
50
+ end
51
+
52
+
53
+ end
54
+
55
+ end
@@ -0,0 +1,98 @@
1
+ # грузит картинки, вставляемые в текст публикаций рекламодателей
2
+ module C80NewsTz
3
+ class RBphotoUploader < CarrierWave::Uploader::Base
4
+
5
+ include CarrierWave::MiniMagick
6
+
7
+ storage :file
8
+
9
+ # При загрузке картинок генерим два thumb:
10
+ # - thumb_big (resize_to_limit),
11
+ # - thumb_small (resize_to_limit: w = page_content*1/3).
12
+
13
+ version :thumb_big do
14
+ process :resize_to_limit_big
15
+ end
16
+
17
+ version :thumb_small do
18
+ process :resize_to_limit_small
19
+ end
20
+
21
+ version :thumb_preview_small do
22
+ process :resize_to_fill => [126, 84]
23
+ end
24
+
25
+ version :thumb_preview_medium do
26
+ process :resize_to_fill => [223, 149]
27
+ end
28
+
29
+ # идёт в блок "главная публикация", что на главной
30
+ version :thumb_preview_big do
31
+ process :resize_to_fill => [500, 321]
32
+ end
33
+
34
+ def store_dir
35
+ "uploads/rec/blurbs/#{format("%02d", model.r_blurb_id)}"
36
+ end
37
+
38
+ def extension_white_list
39
+ %w(jpg jpeg gif png)
40
+ end
41
+
42
+ def filename
43
+ if original_filename
44
+ "photo_#{secure_token(4)}.#{file.extension}"
45
+ end
46
+ end
47
+
48
+ protected
49
+ def secure_token(length=16)
50
+ var = :"@#{mounted_as}_secure_token"
51
+ model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.hex(length/2))
52
+ end
53
+
54
+
55
+ def resize_to_limit_big
56
+ # puts "<PageArtUploader.resize_to_limit_big>"
57
+ manipulate! do |img|
58
+
59
+ w = SiteProp.first.page_content_width
60
+ h = calc_height_of_image(w)
61
+
62
+ img.resize "#{w}x#{h}>"
63
+ img = yield(img) if block_given?
64
+ img
65
+
66
+ end
67
+ end
68
+
69
+ def resize_to_limit_small
70
+ # puts "<PageArtUploader.resize_to_limit_small>"
71
+ manipulate! do |img|
72
+
73
+ w = SiteProp.first.page_content_width/3
74
+ h = calc_height_of_image(w)
75
+
76
+ img.resize "#{w}x#{h}>"
77
+ img = yield(img) if block_given?
78
+ img
79
+
80
+ end
81
+ end
82
+
83
+ private
84
+
85
+ def calc_height_of_image(w)
86
+ model_image = ::MiniMagick::Image.open(model.image.current_path)
87
+ calc_height(w, model_image["width"], model_image["height"])
88
+ end
89
+
90
+ # подгоняем по ширине, рассчитываем высоту
91
+ def calc_height(width, original_w, original_h)
92
+ k = width.to_f/original_w
93
+ original_h * k
94
+ end
95
+
96
+
97
+ end
98
+ end
@@ -25,6 +25,19 @@ ru:
25
25
  location:
26
26
  one: 'место'
27
27
  other: 'Места на главной под публикации'
28
+ r_live:
29
+ one: 'активного рекламодателя'
30
+ other: 'Активный рекламодатель'
31
+ r_advertiser:
32
+ one: 'рекламодателя'
33
+ other: 'Рекламодатели'
34
+ r_blurb:
35
+ one: 'публикацию рекламодателя'
36
+ other: 'Публикации рекламодателей'
37
+ c80_news_tz/r_bphoto: ""
38
+ spot:
39
+ one: 'место под рубрику на главной'
40
+ other: 'Рубрики на главной'
28
41
  attributes:
29
42
  c80_news_tz/notice:
30
43
  title: "Название"
@@ -73,4 +86,24 @@ ru:
73
86
  facts: 'Публикации'
74
87
  c80_news_tz/location:
75
88
  title: 'Название'
76
- facts: 'Публикация'
89
+ facts: 'Публикация'
90
+ c80_news_tz/r_live:
91
+ title: 'Название'
92
+ r_advertisers: 'Рекламодатель'
93
+ c80_news_tz/r_advertiser:
94
+ title: 'Название'
95
+ logo: 'Лого'
96
+ r_blurbs: 'Публикации'
97
+ c80_news_tz/r_blurb:
98
+ title: 'Заголовок'
99
+ created_at: 'Дата создания'
100
+ short: 'Кратко'
101
+ rubrics: 'Рубрики'
102
+ issues: 'Номер'
103
+ issue: 'Номер'
104
+ leader_abz: 'Лидер абзац'
105
+ full: ''
106
+ r_advertisers: ''
107
+ c80_news_tz/spot:
108
+ title: 'Название'
109
+ rubrics: 'Рубрика'
@@ -0,0 +1,11 @@
1
+ # активный рекламодатель
2
+ class CreateLives < ActiveRecord::Migration
3
+ def change
4
+ create_table :c80_news_tz_r_lives, :options => 'COLLATE=utf8_unicode_ci' do |t|
5
+ t.string :title
6
+ t.string :tag
7
+
8
+ t.timestamps null: false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ # рекламодатель
2
+ class CreateAdvertisers < ActiveRecord::Migration
3
+ def change
4
+ create_table :c80_news_tz_r_advertisers, :options => 'COLLATE=utf8_unicode_ci' do |t|
5
+ t.string :title
6
+ t.string :slug
7
+ t.string :logo
8
+
9
+ t.timestamps null: false
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class CreateJoinTableAdvertisersLives < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_news_tz_advs_lives, :id => false do |t|
4
+ t.integer :r_advertiser_id, :null => false
5
+ t.integer :r_live_id, :null => false
6
+ end
7
+
8
+ # Add table index
9
+ add_index :c80_news_tz_advs_lives, [:r_advertiser_id, :r_live_id], :unique => true
10
+
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ class CreateBlurbs < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_news_tz_r_blurbs, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :title
5
+ t.string :sub_title
6
+ t.text :short
7
+ t.text :leader_abz
8
+ t.text :full
9
+ t.string :slug
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ class CreateJoinTableBlurbsRubrics < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_news_tz_blurbs_rubrics, :id => false do |t|
4
+ t.integer :r_blurb_id, :null => false
5
+ t.integer :rubric_id, :null => false
6
+ end
7
+
8
+ # Add table index
9
+ add_index :c80_news_tz_blurbs_rubrics, [:r_blurb_id, :rubric_id], :unique => true
10
+
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class CreateJoinTableAdvertisersBlurbs < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_news_tz_advs_blurbs, :id => false do |t|
4
+ t.integer :r_advertiser_id, :null => false
5
+ t.integer :r_blurb_id, :null => false
6
+ end
7
+
8
+ # Add table index
9
+ add_index :c80_news_tz_advs_blurbs, [:r_advertiser_id, :r_blurb_id], :unique => true
10
+
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ class CreateBphotos < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_news_tz_r_bphotos, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :image
5
+ t.references :r_blurb, :index => true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ class CreateJoinTableBlurbsIssues < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_news_tz_blurbs_issues, :id => false do |t|
4
+ t.integer :issue_id, :null => false
5
+ t.integer :r_blurb_id, :null => false
6
+ end
7
+
8
+ # Add table index
9
+ add_index :c80_news_tz_blurbs_issues, [:issue_id, :r_blurb_id], :unique => true
10
+
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module C80NewsTz
2
- VERSION = "0.1.1.18"
2
+ VERSION = "0.1.1.19"
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.18
4
+ version: 0.1.1.19
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-07 00:00:00.000000000 Z
11
+ date: 2016-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,18 +99,30 @@ files:
99
99
  - app/admin/c80_news_tz/issues.rb
100
100
  - app/admin/c80_news_tz/locations.rb
101
101
  - app/admin/c80_news_tz/notices.rb
102
+ - app/admin/c80_news_tz/r_advertisers.rb
103
+ - app/admin/c80_news_tz/r_blurbs.rb
104
+ - app/admin/c80_news_tz/r_lives.rb
102
105
  - app/admin/c80_news_tz/rubrics.rb
103
106
  - app/admin/c80_news_tz/spots.rb
104
107
  - app/assets/images/c80_news_tz/.keep
105
108
  - app/assets/javascripts/c80_news_tz/application.js.coffee
106
109
  - app/assets/javascripts/c80_news_tz/backend.js.coffee
107
110
  - app/assets/javascripts/c80_news_tz/backend/collapsable-groups.js
111
+ - app/assets/javascripts/c80_news_tz/backend/companies.js
112
+ - app/assets/javascripts/c80_news_tz/backend/facts.js
113
+ - app/assets/javascripts/c80_news_tz/backend/r_advertisers.js
114
+ - app/assets/javascripts/c80_news_tz/backend/r_blurbs.js
115
+ - app/assets/javascripts/c80_news_tz/backend/rubrics.js
108
116
  - app/assets/javascripts/c80_news_tz/frontend/facts_ajax.js
109
117
  - app/assets/stylesheets/c80_news_tz/application.scss
110
118
  - app/assets/stylesheets/c80_news_tz/backend.scss
111
119
  - app/assets/stylesheets/c80_news_tz/backend/collapsed.scss
112
120
  - app/assets/stylesheets/c80_news_tz/backend/companies.scss
121
+ - app/assets/stylesheets/c80_news_tz/backend/locations.scss
113
122
  - app/assets/stylesheets/c80_news_tz/backend/notices.scss
123
+ - app/assets/stylesheets/c80_news_tz/backend/r_advertisers.scss
124
+ - app/assets/stylesheets/c80_news_tz/backend/r_lives.scss
125
+ - app/assets/stylesheets/c80_news_tz/backend/spots.scss
114
126
  - app/assets/stylesheets/c80_news_tz/frontend/pubs_medium.scss
115
127
  - app/controllers/c80_news_tz/application_controller.rb
116
128
  - app/helpers/c80_news_tz/application_helper.rb
@@ -130,6 +142,10 @@ files:
130
142
  - app/models/c80_news_tz/nphoto.rb
131
143
  - app/models/c80_news_tz/pdf.rb
132
144
  - app/models/c80_news_tz/prop.rb
145
+ - app/models/c80_news_tz/r_advertiser.rb
146
+ - app/models/c80_news_tz/r_blurb.rb
147
+ - app/models/c80_news_tz/r_bphoto.rb
148
+ - app/models/c80_news_tz/r_live.rb
133
149
  - app/models/c80_news_tz/rubric.rb
134
150
  - app/models/c80_news_tz/rubric_validator.rb
135
151
  - app/models/c80_news_tz/spot.rb
@@ -139,6 +155,8 @@ files:
139
155
  - app/uploaders/c80_news_tz/gphoto_uploader.rb
140
156
  - app/uploaders/c80_news_tz/nphoto_uploader.rb
141
157
  - app/uploaders/c80_news_tz/pdf_uploader.rb
158
+ - app/uploaders/c80_news_tz/r_alogo_uploader.rb
159
+ - app/uploaders/c80_news_tz/r_bphoto_uploader.rb
142
160
  - app/views/c80_news_tz/application/guru.js.erb
143
161
  - app/views/layouts/c80_news_tz/application.html.erb
144
162
  - app/views/shared/_fact.html.erb
@@ -170,6 +188,14 @@ files:
170
188
  - db/migrate/20160304145555_create_join_table_facts_locations.rb
171
189
  - db/migrate/20160307075757_create_spots.rb
172
190
  - db/migrate/20160307075858_create_join_table_rubrics_spots.rb
191
+ - db/migrate/20160309130000_create_lives.rb
192
+ - db/migrate/20160309132020_create_advertisers.rb
193
+ - db/migrate/20160309134444_create_join_table_advertisers_lives.rb
194
+ - db/migrate/20160309145050_create_blurbs.rb
195
+ - db/migrate/20160309150808_create_join_table_blurbs_rubrics.rb
196
+ - db/migrate/20160309151313_create_join_table_advertisers_blurbs.rb
197
+ - db/migrate/20160309154848_create_bphotos.rb
198
+ - db/migrate/20160309165151_create_join_table_blurbs_issues.rb
173
199
  - db/seeds/19_fill_news_props.rb.example
174
200
  - db/seeds/20_fill_rubrics.rb.example
175
201
  - db/seeds/21_fill_facts.rb.example