c80_news_tz 0.1.1.1 → 0.1.1.15
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.
- checksums.yaml +4 -4
- data/README.md +65 -32
- data/app/admin/c80_news_tz/compaines.rb +3 -2
- data/app/admin/c80_news_tz/facts.rb +5 -5
- data/app/admin/c80_news_tz/locations.rb +43 -0
- data/app/helpers/c80_news_tz/application_helper.rb +13 -28
- data/app/helpers/c80_news_tz/subj_helper.rb +32 -0
- data/app/models/c80_news_tz/company.rb +18 -0
- data/app/models/c80_news_tz/cphoto.rb +0 -6
- data/app/models/c80_news_tz/fact.rb +54 -0
- data/app/models/c80_news_tz/fact_validator.rb +5 -5
- data/app/models/c80_news_tz/fphoto.rb +4 -4
- data/app/models/c80_news_tz/location.rb +5 -0
- data/app/models/c80_news_tz/nphoto.rb +0 -6
- data/app/uploaders/c80_news_tz/clogo_uploader.rb +55 -0
- data/app/uploaders/c80_news_tz/fphoto_uploader.rb +11 -2
- data/config/locales/ru.yml +11 -5
- data/config/routes.rb +0 -1
- data/db/migrate/20160226142022_create_companies.rb +1 -0
- data/db/migrate/20160304145554_create_locations.rb +10 -0
- data/db/migrate/20160304145555_create_join_table_facts_locations.rb +12 -0
- data/lib/c80_news_tz/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2c20f9594fbbe051876b9634c02ffea4b09d41aa
|
|
4
|
+
data.tar.gz: bdfd17888df61ac487a59f9d7a38d3ff4f493cc7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 74897617e0613cc2b5ca6dc5c0fa87170e3bc18947fe54c9193f584c0383b85a5db322a683e552bad687292dea2d2139199e099126b448479e48e85700514d69
|
|
7
|
+
data.tar.gz: bd5f68976b44438e69c1b9c6aa70dabdcd7cf0c81485883ab353cfcff45752e9d6b793c40f42a162da7e234ea231a86974cfcb4151f7e6c59656341da7cc6471
|
data/README.md
CHANGED
|
@@ -7,9 +7,7 @@ News HABTM Rubrics. News HABTM Issues. News HABTM Companies. Companies has_many
|
|
|
7
7
|
|
|
8
8
|
Add this line to your application's Gemfile:
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
gem 'c80_news_tz'
|
|
12
|
-
```
|
|
10
|
+
gem 'c80_news_tz'
|
|
13
11
|
|
|
14
12
|
And then execute:
|
|
15
13
|
|
|
@@ -19,52 +17,87 @@ Or install it yourself as:
|
|
|
19
17
|
|
|
20
18
|
$ gem install c80_news_tz
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
Perform migrations:
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
$ rake db:migrate
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
Copy example seed files from `<GEM_FOLDER>\db\seeds\` to `<HOST_PROJECT_FOLDER>\db\seeds\`,
|
|
25
|
+
remove `.example` extensions.
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
Copy seeds.sh.example file:
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
cp <GEM_FOLDER>\seeds.sh.example <HOST_PROJECT_FOLDER>\seeds.sh; sudo chmod +x seeds.sh; ./seeds.sh
|
|
30
|
+
|
|
31
|
+
Add the line to application's routes file:
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
mount C80NewsTz::Engine => '/'
|
|
34
|
-
```
|
|
33
|
+
mount C80NewsTz::Engine => '/'
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
Add this line to `application.js.coffee`:
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
#= require c80_news_tz
|
|
40
|
-
```
|
|
37
|
+
#= require c80_news_tz
|
|
41
38
|
|
|
42
|
-
|
|
39
|
+
Add this line to `application.scss`:
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
@import "c80_news_tz/application";
|
|
46
|
-
```
|
|
41
|
+
@import "c80_news_tz/application";
|
|
47
42
|
|
|
48
|
-
|
|
43
|
+
Add this line to `application_controller.rb`:
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
helper C80NewsTz::Engine.helpers
|
|
52
|
-
```
|
|
45
|
+
helper C80NewsTz::Engine.helpers
|
|
53
46
|
|
|
54
|
-
This gem uses: ActiveAdmin, Fontawesome.
|
|
47
|
+
This gem uses: ActiveAdmin, Fontawesome. Add this to your `active_admin_custom.scss` file:
|
|
55
48
|
|
|
56
|
-
|
|
49
|
+
@import "font-awesome";
|
|
57
50
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
Add these lines to `routes.rb` (optional):
|
|
52
|
+
|
|
53
|
+
get '/companies/:company_slug' => 'site#company'
|
|
54
|
+
get '/news/:fact_slug' => 'site#fact'
|
|
55
|
+
get '/issues/:issue_slug' => 'site#issue'
|
|
56
|
+
get '/notices/:notice_slug' => 'site#notice'
|
|
57
|
+
get '/rubrics/:rubric_slug' => 'site#rubric'
|
|
58
|
+
|
|
59
|
+
Implement these methods in `site_controller.rb` (optional):
|
|
60
|
+
|
|
61
|
+
def company
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# просмотр новости на отдельной странице
|
|
65
|
+
def fact
|
|
66
|
+
@fact = C80NewsTz::Fact.where(:slug => params[:fact_slug]).first
|
|
67
|
+
@vparams[:page_content] = @fact.full if @fact.full.present?
|
|
68
|
+
@vparams[:body_id] = 'fact'
|
|
69
|
+
add_title @fact.title
|
|
70
|
+
# add_breadcrumb @page.title
|
|
71
|
+
@vparams[:description] = @fact.short_meta_description if @fact.short_meta_description.present?
|
|
72
|
+
override_with_seo
|
|
73
|
+
# найти и подсветить родительский пункт меню
|
|
74
|
+
@vparams[:active_menus] << MenuItem.where(:title => 'Новости').first.id
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def issue
|
|
78
|
+
# ...
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def notice
|
|
82
|
+
# ...
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# просмотр рубрики на отдельной странице
|
|
86
|
+
def rubric
|
|
87
|
+
@rubric = C80NewsTz::Rubric.where(:slug => params[:rubric_slug]).first
|
|
88
|
+
add_title(@rubric.title)
|
|
89
|
+
override_with_seo
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
Implement corresponding views (optional). For example `views/site/fact.html.erb`:
|
|
93
|
+
|
|
94
|
+
<h1><%= @fact.title %></h1>
|
|
95
|
+
<%= check_page_art(@vparams[:page_content], @fact.fphotos, @fact.title).html_safe %>
|
|
61
96
|
|
|
62
97
|
## Available helper methods
|
|
63
98
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
render_one_fact
|
|
67
|
-
```
|
|
99
|
+
render_news_block
|
|
100
|
+
render_one_fact
|
|
68
101
|
|
|
69
102
|
## Development
|
|
70
103
|
|
|
@@ -7,6 +7,7 @@ ActiveAdmin.register C80NewsTz::Company, :as => 'Company' do
|
|
|
7
7
|
permit_params :title,
|
|
8
8
|
:activity_type,
|
|
9
9
|
:desc,
|
|
10
|
+
:logo,
|
|
10
11
|
:fact_ids => [],
|
|
11
12
|
:adress_attributes => [:id, :locality, :street, :telephone_1, :telephone_2, :telephone_3, :latitude, :longitude, :email_1, :email_2, :site_1, :site_2],
|
|
12
13
|
:cphotos_attributes => [:id, :image, :_destroy],
|
|
@@ -64,7 +65,7 @@ ActiveAdmin.register C80NewsTz::Company, :as => 'Company' do
|
|
|
64
65
|
|
|
65
66
|
f.input :title
|
|
66
67
|
f.input :activity_type
|
|
67
|
-
|
|
68
|
+
f.input :logo, :hint => "#{image_tag("#{f.object.logo.url}")}".html_safe
|
|
68
69
|
end
|
|
69
70
|
|
|
70
71
|
f.inputs "Адрес", :class => 'collapsed', for: [:adress, f.object.adress || C80NewsTz::Adress.new] do |s|
|
|
@@ -100,7 +101,7 @@ ActiveAdmin.register C80NewsTz::Company, :as => 'Company' do
|
|
|
100
101
|
ff.input :file, :as => :file, :hint => ff.template.asset_url(ff.object.file)
|
|
101
102
|
end
|
|
102
103
|
=end
|
|
103
|
-
f.inputs '
|
|
104
|
+
f.inputs 'Публикации, связанные с компанией', :class => 'collapsed' do
|
|
104
105
|
f.input :facts,
|
|
105
106
|
:as => :check_boxes,
|
|
106
107
|
:member_label => Proc.new { |p|
|
|
@@ -2,7 +2,7 @@ ActiveAdmin.register C80NewsTz::Fact, :as => 'Fact' do
|
|
|
2
2
|
|
|
3
3
|
before_filter :skip_sidebar!, :only => :index
|
|
4
4
|
|
|
5
|
-
menu :label => '
|
|
5
|
+
menu :label => 'Публикации', :parent => 'Содержимое сайта'
|
|
6
6
|
|
|
7
7
|
permit_params :short,
|
|
8
8
|
:title,
|
|
@@ -29,7 +29,7 @@ ActiveAdmin.register C80NewsTz::Fact, :as => 'Fact' do
|
|
|
29
29
|
|
|
30
30
|
column '' do |fact|
|
|
31
31
|
if fact.fphotos.count > 0
|
|
32
|
-
image_tag(fact.fphotos.first.image.
|
|
32
|
+
image_tag(fact.fphotos.first.image.thumb_preview_medium)
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
@@ -74,15 +74,15 @@ ActiveAdmin.register C80NewsTz::Fact, :as => 'Fact' do
|
|
|
74
74
|
f.input :short, :input_html => {:rows => 3, :class => 'code_area'}
|
|
75
75
|
f.input :leader_abz, :input_html => {:rows => 3, :class => 'code_area'}
|
|
76
76
|
|
|
77
|
-
f.inputs 'Картинки, вставляемые в текст
|
|
77
|
+
f.inputs 'Картинки, вставляемые в текст публикации (первая картинка идёт в предпросмотр публикации)', :class => 'collapsed' do
|
|
78
78
|
f.has_many :fphotos, :allow_destroy => true do |fphotos|
|
|
79
79
|
fphotos.input :image,
|
|
80
80
|
:as => :file,
|
|
81
|
-
:hint => image_tag(fphotos.object.image.
|
|
81
|
+
:hint => image_tag(fphotos.object.image.thumb_preview_medium)
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
f.inputs 'Текст
|
|
85
|
+
f.inputs 'Текст публикации' do
|
|
86
86
|
f.input :full, :as => :ckeditor
|
|
87
87
|
end
|
|
88
88
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
ActiveAdmin.register C80NewsTz::Location, :as => 'Location' do
|
|
2
|
+
|
|
3
|
+
menu :label => "Места на главной", :parent => 'Содержимое сайта'
|
|
4
|
+
|
|
5
|
+
before_filter :skip_sidebar!, :only => :index
|
|
6
|
+
|
|
7
|
+
permit_params :fact_ids => []
|
|
8
|
+
|
|
9
|
+
config.sort_order = 'id_asc'
|
|
10
|
+
|
|
11
|
+
index do
|
|
12
|
+
id_column
|
|
13
|
+
column :title
|
|
14
|
+
|
|
15
|
+
column :facts do |loc|
|
|
16
|
+
# нарисуем список
|
|
17
|
+
list_items = ((loc.facts.map { |p|
|
|
18
|
+
"<li>• #{ p.title } <a href='/news/#{p.slug}' target='_blank'>[view]</a> <a href='/admin/facts/#{p.slug}/edit'>[edit]</a> </li>"
|
|
19
|
+
}).join("")).html_safe
|
|
20
|
+
|
|
21
|
+
"<ul>#{list_items}</ul>".html_safe
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
actions
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
form(:html => {:multipart => true}) do |f|
|
|
28
|
+
f.inputs "Свойства" do
|
|
29
|
+
f.input :title
|
|
30
|
+
|
|
31
|
+
f.input :facts,
|
|
32
|
+
:as => :select,
|
|
33
|
+
:input_html => {:multiple => false},
|
|
34
|
+
:include_blank => true,
|
|
35
|
+
:member_label => Proc.new { |p|
|
|
36
|
+
p.title
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
f.actions
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
@@ -2,39 +2,24 @@
|
|
|
2
2
|
module C80NewsTz
|
|
3
3
|
module ApplicationHelper
|
|
4
4
|
|
|
5
|
-
include LocalTimeHelper
|
|
6
|
-
|
|
7
|
-
def render_news_block(is_news_page=false,page=1)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if is_news_page
|
|
11
|
-
per_page = C80NewsTz::Prop.first.per_page
|
|
12
|
-
news = Fact.paginate(:page => page,:per_page => per_page)
|
|
13
|
-
else
|
|
14
|
-
per_widget = C80NewsTz::Prop.first.per_widget
|
|
15
|
-
news = Fact.limit(per_widget)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
render :partial => "shared/news_block",
|
|
19
|
-
:locals => {
|
|
20
|
-
:news_list => news,
|
|
21
|
-
:is_news_page => is_news_page
|
|
22
|
-
}
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def render_one_fact(fact)
|
|
26
|
-
render :partial => "shared/fact",
|
|
27
|
-
:locals => {
|
|
28
|
-
fact: fact
|
|
29
|
-
}
|
|
30
|
-
end
|
|
31
|
-
|
|
32
5
|
def url_for_fact(fact)
|
|
33
6
|
"news/#{fact.slug}"
|
|
34
7
|
end
|
|
35
8
|
|
|
36
9
|
def apph_url_for_rubric(rubric_slug)
|
|
37
|
-
"rubrics/#{rubric_slug}"
|
|
10
|
+
"#{root_url}rubrics/#{rubric_slug}"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def apph_url_for_company(company_slug)
|
|
14
|
+
"companies/#{company_slug}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def apph_url_for_notice(notice_slug)
|
|
18
|
+
"notices/#{notice_slug}"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def apph_url_for_issue(issue_id)
|
|
22
|
+
"issues/#{issue_id}"
|
|
38
23
|
end
|
|
39
24
|
|
|
40
25
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module C80NewsTz
|
|
2
|
+
module SubjHelper
|
|
3
|
+
|
|
4
|
+
include LocalTimeHelper
|
|
5
|
+
|
|
6
|
+
def render_news_block(is_news_page=false,page=1)
|
|
7
|
+
|
|
8
|
+
if is_news_page
|
|
9
|
+
per_page = C80NewsTz::Prop.first.per_page
|
|
10
|
+
news = Fact.paginate(:page => page,:per_page => per_page)
|
|
11
|
+
else
|
|
12
|
+
per_widget = C80NewsTz::Prop.first.per_widget
|
|
13
|
+
news = Fact.limit(per_widget)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
render :partial => "shared/news_block",
|
|
17
|
+
:locals => {
|
|
18
|
+
:news_list => news,
|
|
19
|
+
:is_news_page => is_news_page
|
|
20
|
+
}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def render_one_fact(fact)
|
|
24
|
+
render :partial => "shared/fact",
|
|
25
|
+
:locals => {
|
|
26
|
+
fact: fact
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
include ActionView::Helpers::SanitizeHelper
|
|
1
2
|
require "babosa"
|
|
3
|
+
|
|
2
4
|
module C80NewsTz
|
|
3
5
|
class Company < ActiveRecord::Base
|
|
4
6
|
has_many :galleries, :dependent => :destroy
|
|
@@ -22,6 +24,8 @@ module C80NewsTz
|
|
|
22
24
|
has_and_belongs_to_many :facts, :join_table => 'c80_news_tz_companies_facts'
|
|
23
25
|
has_and_belongs_to_many :notices, :join_table => 'c80_news_tz_companies_notices'
|
|
24
26
|
|
|
27
|
+
mount_uploader :logo, ClogoUploader
|
|
28
|
+
|
|
25
29
|
extend FriendlyId
|
|
26
30
|
friendly_id :title, use: :slugged
|
|
27
31
|
|
|
@@ -38,5 +42,19 @@ module C80NewsTz
|
|
|
38
42
|
# name_changed? || super
|
|
39
43
|
end
|
|
40
44
|
|
|
45
|
+
def desc_short
|
|
46
|
+
result = ''
|
|
47
|
+
|
|
48
|
+
if desc.present?
|
|
49
|
+
d = desc.gsub!(/\[\[\d\]\]/, '')
|
|
50
|
+
if d.nil?
|
|
51
|
+
d = desc
|
|
52
|
+
end
|
|
53
|
+
result = strip_tags(d)[0..100]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
result
|
|
57
|
+
end
|
|
58
|
+
|
|
41
59
|
end
|
|
42
60
|
end
|
|
@@ -13,6 +13,7 @@ module C80NewsTz
|
|
|
13
13
|
|
|
14
14
|
has_and_belongs_to_many :rubrics, :join_table => 'c80_news_tz_facts_rubrics'
|
|
15
15
|
has_and_belongs_to_many :companies, :join_table => 'c80_news_tz_companies_facts'
|
|
16
|
+
has_and_belongs_to_many :locations, :join_table => 'c80_news_tz_facts_locations'
|
|
16
17
|
|
|
17
18
|
validates_with FactValidator
|
|
18
19
|
default_scope {order(:created_at => :desc)}
|
|
@@ -40,5 +41,58 @@ module C80NewsTz
|
|
|
40
41
|
|
|
41
42
|
end
|
|
42
43
|
|
|
44
|
+
# выдать картинку, которая пойдёт в блок преьвю
|
|
45
|
+
def photo_preview
|
|
46
|
+
result = nil
|
|
47
|
+
if fphotos.count > 0
|
|
48
|
+
result = fphotos.first.image
|
|
49
|
+
else
|
|
50
|
+
end
|
|
51
|
+
result
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# выдать строку: title первой попавшейся рубрики
|
|
55
|
+
# если таковой нету - выдаётся пустая строка
|
|
56
|
+
def rubric_title
|
|
57
|
+
result = ""
|
|
58
|
+
if rubrics.count > 0
|
|
59
|
+
result = rubrics.first.title
|
|
60
|
+
end
|
|
61
|
+
result
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# выдать логотип первой попавшейся компании
|
|
65
|
+
# если чего-то нету - выдаётся nil
|
|
66
|
+
def company_logo
|
|
67
|
+
result = nil
|
|
68
|
+
if companies.count > 0
|
|
69
|
+
if companies.first.logo.present?
|
|
70
|
+
result = companies.first.logo
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
result
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# выдать массив хэшей: список фактов, находящихся в указанных позициях, отсортированный по location_id
|
|
77
|
+
def self.where_locations(arr_locs_ids)
|
|
78
|
+
# f = C80NewsTz::Fact.joins(:locations).where(:c80_news_tz_locations => {:id => [1,2]})
|
|
79
|
+
|
|
80
|
+
s = "
|
|
81
|
+
SELECT
|
|
82
|
+
`c80_news_tz_facts`.*,
|
|
83
|
+
`c80_news_tz_locations`.`id` AS `location_id`
|
|
84
|
+
FROM `c80_news_tz_facts`
|
|
85
|
+
INNER JOIN `c80_news_tz_facts_locations` ON `c80_news_tz_facts_locations`.`fact_id` = `c80_news_tz_facts`.`id`
|
|
86
|
+
INNER JOIN `c80_news_tz_locations` ON `c80_news_tz_locations`.`id` = `c80_news_tz_facts_locations`.`location_id`
|
|
87
|
+
WHERE `c80_news_tz_locations`.`id` IN (#{arr_locs_ids.join(",")})
|
|
88
|
+
ORDER BY `location_id`;
|
|
89
|
+
"
|
|
90
|
+
|
|
91
|
+
# result = self.connection.select_all(s)
|
|
92
|
+
result = self.find_by_sql(s)
|
|
93
|
+
|
|
94
|
+
result
|
|
95
|
+
end
|
|
96
|
+
|
|
43
97
|
end
|
|
44
98
|
end
|
|
@@ -3,15 +3,15 @@ module C80NewsTz
|
|
|
3
3
|
def validate(record)
|
|
4
4
|
|
|
5
5
|
unless record.title.present?
|
|
6
|
-
record.errors[:title] = 'Название
|
|
6
|
+
record.errors[:title] = 'Название публикации не может быть пустым'
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
unless record.short.present?
|
|
10
|
-
|
|
11
|
-
end
|
|
9
|
+
# unless record.short.present?
|
|
10
|
+
# record.errors[:short] = 'Заполните краткое описание публикации'
|
|
11
|
+
# end
|
|
12
12
|
|
|
13
13
|
unless record.full.present?
|
|
14
|
-
record.errors[:full] = 'Текст
|
|
14
|
+
record.errors[:full] = 'Текст публикации не может быть пустым'
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
end
|
|
@@ -35,10 +35,10 @@ module C80NewsTz
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# выдать размеры картинки thumb_preview
|
|
38
|
-
def thumb_preview_size
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
end
|
|
38
|
+
# def thumb_preview_size
|
|
39
|
+
# img = MiniMagick::Image.open(image.thumb_preview.path)
|
|
40
|
+
# [img["width"],img["height"]]
|
|
41
|
+
# end
|
|
42
42
|
|
|
43
43
|
end
|
|
44
44
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# грузит лого компании
|
|
2
|
+
module C80NewsTz
|
|
3
|
+
class ClogoUploader < 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/companies/_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
|
|
@@ -22,8 +22,17 @@ module C80NewsTz
|
|
|
22
22
|
process :resize_to_limit_small
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
version :
|
|
26
|
-
process :resize_to_fill => [
|
|
25
|
+
version :thumb_preview_small do
|
|
26
|
+
process :resize_to_fill => [126, 84]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
version :thumb_preview_medium do
|
|
30
|
+
process :resize_to_fill => [223, 149]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# идёт в блок "главная публикация", что на главной
|
|
34
|
+
version :thumb_preview_big do
|
|
35
|
+
process :resize_to_fill => [500, 321]
|
|
27
36
|
end
|
|
28
37
|
|
|
29
38
|
def store_dir
|
data/config/locales/ru.yml
CHANGED
|
@@ -14,14 +14,17 @@ ru:
|
|
|
14
14
|
one: "компанию"
|
|
15
15
|
other: "Компании"
|
|
16
16
|
fact:
|
|
17
|
-
one: '
|
|
18
|
-
other: '
|
|
17
|
+
one: 'публикацию'
|
|
18
|
+
other: 'Публикации'
|
|
19
19
|
issue:
|
|
20
20
|
one: 'номер журнала'
|
|
21
21
|
other: 'Номера журнала'
|
|
22
22
|
rubric:
|
|
23
23
|
one: 'рубрику'
|
|
24
24
|
other: 'Рубрики'
|
|
25
|
+
location:
|
|
26
|
+
one: 'место'
|
|
27
|
+
other: 'Места на главной под публикации'
|
|
25
28
|
attributes:
|
|
26
29
|
c80_news_tz/notice:
|
|
27
30
|
title: "Название"
|
|
@@ -47,7 +50,7 @@ ru:
|
|
|
47
50
|
title: 'Название'
|
|
48
51
|
activity_type: 'Род деятельности'
|
|
49
52
|
desc: 'Описание'
|
|
50
|
-
facts: '
|
|
53
|
+
facts: 'Публикации'
|
|
51
54
|
c80_news_tz/gallery:
|
|
52
55
|
title: 'Название галереи'
|
|
53
56
|
c80_news_tz/fact:
|
|
@@ -64,7 +67,10 @@ ru:
|
|
|
64
67
|
number: 'Номер'
|
|
65
68
|
pdf: 'PDF'
|
|
66
69
|
pdfs: 'PDF'
|
|
67
|
-
facts: '
|
|
70
|
+
facts: 'Публикации'
|
|
68
71
|
c80_news_tz/rubric:
|
|
69
72
|
title: 'Название'
|
|
70
|
-
facts: '
|
|
73
|
+
facts: 'Публикации'
|
|
74
|
+
c80_news_tz/location:
|
|
75
|
+
title: 'Название'
|
|
76
|
+
facts: 'Публикация'
|
data/config/routes.rb
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class CreateJoinTableFactsLocations < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :c80_news_tz_facts_locations, :id => false do |t|
|
|
4
|
+
t.integer :fact_id, :null => false
|
|
5
|
+
t.integer :location_id, :null => false
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Add table index
|
|
9
|
+
add_index :c80_news_tz_facts_locations, [:fact_id, :location_id], :unique => true
|
|
10
|
+
|
|
11
|
+
end
|
|
12
|
+
end
|
data/lib/c80_news_tz/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.1.1.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- C80609A
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-03-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -97,6 +97,7 @@ files:
|
|
|
97
97
|
- app/admin/c80_news_tz/compaines.rb
|
|
98
98
|
- app/admin/c80_news_tz/facts.rb
|
|
99
99
|
- app/admin/c80_news_tz/issues.rb
|
|
100
|
+
- app/admin/c80_news_tz/locations.rb
|
|
100
101
|
- app/admin/c80_news_tz/notices.rb
|
|
101
102
|
- app/admin/c80_news_tz/rubrics.rb
|
|
102
103
|
- app/assets/images/c80_news_tz/.keep
|
|
@@ -113,6 +114,7 @@ files:
|
|
|
113
114
|
- app/assets/stylesheets/c80_news_tz/facts_wookmark.scss
|
|
114
115
|
- app/controllers/c80_news_tz/application_controller.rb
|
|
115
116
|
- app/helpers/c80_news_tz/application_helper.rb
|
|
117
|
+
- app/helpers/c80_news_tz/subj_helper.rb
|
|
116
118
|
- app/models/c80_news_tz/adress.rb
|
|
117
119
|
- app/models/c80_news_tz/company.rb
|
|
118
120
|
- app/models/c80_news_tz/cphoto.rb
|
|
@@ -122,12 +124,14 @@ files:
|
|
|
122
124
|
- app/models/c80_news_tz/gallery.rb
|
|
123
125
|
- app/models/c80_news_tz/gphoto.rb
|
|
124
126
|
- app/models/c80_news_tz/issue.rb
|
|
127
|
+
- app/models/c80_news_tz/location.rb
|
|
125
128
|
- app/models/c80_news_tz/notice.rb
|
|
126
129
|
- app/models/c80_news_tz/nphoto.rb
|
|
127
130
|
- app/models/c80_news_tz/pdf.rb
|
|
128
131
|
- app/models/c80_news_tz/prop.rb
|
|
129
132
|
- app/models/c80_news_tz/rubric.rb
|
|
130
133
|
- app/models/c80_news_tz/rubric_validator.rb
|
|
134
|
+
- app/uploaders/c80_news_tz/clogo_uploader.rb
|
|
131
135
|
- app/uploaders/c80_news_tz/cphoto_uploader.rb
|
|
132
136
|
- app/uploaders/c80_news_tz/fphoto_uploader.rb
|
|
133
137
|
- app/uploaders/c80_news_tz/gphoto_uploader.rb
|
|
@@ -160,6 +164,8 @@ files:
|
|
|
160
164
|
- db/migrate/20160227121414_create_galleries.rb
|
|
161
165
|
- db/migrate/20160227121415_create_gphotos.rb
|
|
162
166
|
- db/migrate/20160227121416_create_nphotos.rb
|
|
167
|
+
- db/migrate/20160304145554_create_locations.rb
|
|
168
|
+
- db/migrate/20160304145555_create_join_table_facts_locations.rb
|
|
163
169
|
- db/seeds/19_fill_news_props.rb.example
|
|
164
170
|
- db/seeds/20_fill_rubrics.rb.example
|
|
165
171
|
- db/seeds/21_fill_facts.rb.example
|