c80_news_tz 0.1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.travis.yml +3 -0
  4. data/CODE_OF_CONDUCT.md +13 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +81 -0
  8. data/Rakefile +1 -0
  9. data/app/admin/c80_news_tz/compaines.rb +131 -0
  10. data/app/admin/c80_news_tz/facts.rb +110 -0
  11. data/app/admin/c80_news_tz/issues.rb +60 -0
  12. data/app/admin/c80_news_tz/notices.rb +115 -0
  13. data/app/admin/c80_news_tz/rubrics.rb +45 -0
  14. data/app/assets/images/c80_news_tz/.keep +0 -0
  15. data/app/assets/javascripts/c80_news_tz/application.js.coffee +1 -0
  16. data/app/assets/javascripts/c80_news_tz/backend/collapsable-groups.js +22 -0
  17. data/app/assets/javascripts/c80_news_tz/backend.js.coffee +1 -0
  18. data/app/assets/javascripts/c80_news_tz/frontend/facts_ajax.js +68 -0
  19. data/app/assets/javascripts/c80_news_tz/frontend/facts_wookmark.js +10 -0
  20. data/app/assets/stylesheets/c80_news_tz/application.scss +5 -0
  21. data/app/assets/stylesheets/c80_news_tz/backend/collapsed.scss +49 -0
  22. data/app/assets/stylesheets/c80_news_tz/backend/companies.scss +98 -0
  23. data/app/assets/stylesheets/c80_news_tz/backend/notices.scss +68 -0
  24. data/app/assets/stylesheets/c80_news_tz/backend.scss +1 -0
  25. data/app/assets/stylesheets/c80_news_tz/facts_wookmark.scss +27 -0
  26. data/app/controllers/c80_news_tz/application_controller.rb +10 -0
  27. data/app/helpers/c80_news_tz/application_helper.rb +41 -0
  28. data/app/models/c80_news_tz/adress.rb +5 -0
  29. data/app/models/c80_news_tz/company.rb +42 -0
  30. data/app/models/c80_news_tz/cphoto.rb +38 -0
  31. data/app/models/c80_news_tz/fact.rb +44 -0
  32. data/app/models/c80_news_tz/fact_validator.rb +19 -0
  33. data/app/models/c80_news_tz/fphoto.rb +44 -0
  34. data/app/models/c80_news_tz/gallery.rb +12 -0
  35. data/app/models/c80_news_tz/gphoto.rb +6 -0
  36. data/app/models/c80_news_tz/issue.rb +11 -0
  37. data/app/models/c80_news_tz/notice.rb +41 -0
  38. data/app/models/c80_news_tz/nphoto.rb +38 -0
  39. data/app/models/c80_news_tz/pdf.rb +6 -0
  40. data/app/models/c80_news_tz/prop.rb +5 -0
  41. data/app/models/c80_news_tz/rubric.rb +25 -0
  42. data/app/models/c80_news_tz/rubric_validator.rb +18 -0
  43. data/app/uploaders/c80_news_tz/cphoto_uploader.rb +88 -0
  44. data/app/uploaders/c80_news_tz/fphoto_uploader.rb +93 -0
  45. data/app/uploaders/c80_news_tz/gphoto_uploader.rb +61 -0
  46. data/app/uploaders/c80_news_tz/nphoto_uploader.rb +88 -0
  47. data/app/uploaders/c80_news_tz/pdf_uploader.rb +27 -0
  48. data/app/views/c80_news_tz/application/guru.js.erb +10 -0
  49. data/app/views/layouts/c80_news_tz/application.html.erb +14 -0
  50. data/app/views/shared/_fact.html.erb +13 -0
  51. data/app/views/shared/_news_block.html.erb +8 -0
  52. data/app/views/shared/_news_list.html.erb +12 -0
  53. data/bin/console +14 -0
  54. data/bin/setup +7 -0
  55. data/c80_news_tz.gemspec +27 -0
  56. data/config/locales/ru.yml +70 -0
  57. data/config/routes.rb +4 -0
  58. data/db/migrate/20151129000045_create_rubrics.rb +11 -0
  59. data/db/migrate/20151213202020_create_facts.rb +16 -0
  60. data/db/migrate/20151213202021_create_join_table_facts_rubrics.rb +12 -0
  61. data/db/migrate/20151213203030_create_fphotos.rb +11 -0
  62. data/db/migrate/20151214133030_create_props.rb +9 -0
  63. data/db/migrate/20160226131111_create_issues.rb +9 -0
  64. data/db/migrate/20160226131112_create_join_table_facts_issues.rb +12 -0
  65. data/db/migrate/20160226131313_create_pdfs.rb +11 -0
  66. data/db/migrate/20160226142022_create_companies.rb +12 -0
  67. data/db/migrate/20160226142023_create_join_table_companies_facts.rb +12 -0
  68. data/db/migrate/20160226143300_create_cphotos.rb +10 -0
  69. data/db/migrate/20160227113411_create_notices.rb +13 -0
  70. data/db/migrate/20160227113412_create_join_table_companies_notices.rb +12 -0
  71. data/db/migrate/20160227114040_create_adresses.rb +21 -0
  72. data/db/migrate/20160227121414_create_galleries.rb +12 -0
  73. data/db/migrate/20160227121415_create_gphotos.rb +12 -0
  74. data/db/migrate/20160227121416_create_nphotos.rb +10 -0
  75. data/db/seeds/19_fill_news_props.rb.example +6 -0
  76. data/db/seeds/20_fill_rubrics.rb.example +10 -0
  77. data/db/seeds/21_fill_facts.rb.example +17 -0
  78. data/db/seeds/22_fill_companies.rb.example +49 -0
  79. data/db/seeds/23_fill_issues.rb.example +19 -0
  80. data/db/seeds/24_fill_notices.rb.example +46 -0
  81. data/lib/c80_news_tz/engine.rb +23 -0
  82. data/lib/c80_news_tz/version.rb +3 -0
  83. data/lib/c80_news_tz.rb +5 -0
  84. data/seeds.sh.example +2 -0
  85. metadata +197 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e03dd08c0feeb0acb20c298a3e84a18e2fee68fa
4
+ data.tar.gz: 319fc26efc7beb193b40c1eb2a67667be56a008e
5
+ SHA512:
6
+ metadata.gz: dfef6ff4b16fbef6bbcd0b1e9ad2ec94338c19f51e6e597b5ae8f32d29e5e4d79629b2160198619e99a4be0322d2b87b6d34716785e536773504f9a51d2667c8
7
+ data.tar.gz: 1f1e5f0dcd668b1187dd3ded85b64b2ac71620718b47dea904a0ff3cfb66a0fd1292272e7fdc88109501587bded7f41f86bc29c4b9ed478bd45ee4bfe31e2c67
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.idea/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.gem
12
+
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.4
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in c80_news_tz.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 C80609A
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # C80NewsTz
2
+
3
+ This gem adds News, Rubrics, Issues, Companies, Galleries, Notices to site.
4
+ News HABTM Rubrics. News HABTM Issues. News HABTM Companies. Companies has_many Galleries. Companies HABTM Notices.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'c80_news_tz'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install c80_news_tz
21
+
22
+ ## Usage
23
+
24
+ 1) `rake db:migrate`
25
+
26
+ 2) Скопировать example файлы из `db\seeds\`, убрать расширение example.
27
+
28
+ 3) `cp seeds.sh.example seeds.sh; sudo chmod +x seeds.sh; ./seeds.sh`.
29
+
30
+ 4) Add the line to application's routes file:
31
+
32
+ ```
33
+ mount C80NewsTz::Engine => '/'
34
+ ```
35
+
36
+ 5) Add this line to `application.js.coffee`:
37
+
38
+ ```
39
+ #= require c80_news_tz
40
+ ```
41
+
42
+ 6) Add this line to `application.scss`:
43
+
44
+ ```
45
+ @import "c80_news_tz/application";
46
+ ```
47
+
48
+ 7) Add this line to `application_controller.rb`:
49
+
50
+ ```
51
+ helper C80NewsTz::Engine.helpers
52
+ ```
53
+
54
+ This gem uses: ActiveAdmin, Fontawesome.
55
+
56
+ Add this to your `active_admin_custom.scss` file:
57
+
58
+ ```scss
59
+ @import "font-awesome";
60
+ ```
61
+
62
+ ## Available helper methods
63
+
64
+ ```
65
+ render_news_block
66
+ render_one_fact
67
+ ```
68
+
69
+ ## Development
70
+
71
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
72
+
73
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
74
+
75
+ ## Contributing
76
+
77
+ 1. Fork it ( https://github.com/[my-github-username]/c80_news_tz/fork )
78
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
79
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
80
+ 4. Push to the branch (`git push origin my-new-feature`)
81
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,131 @@
1
+ ActiveAdmin.register C80NewsTz::Company, :as => 'Company' do
2
+
3
+ menu :label => "Компании", :parent => 'Содержимое сайта'
4
+
5
+ before_filter :skip_sidebar!, :only => :index
6
+
7
+ permit_params :title,
8
+ :activity_type,
9
+ :desc,
10
+ :fact_ids => [],
11
+ :adress_attributes => [:id, :locality, :street, :telephone_1, :telephone_2, :telephone_3, :latitude, :longitude, :email_1, :email_2, :site_1, :site_2],
12
+ :cphotos_attributes => [:id, :image, :_destroy],
13
+ :galleries_attributes => [:id, :title, :gphotos_attributes => [:id, :image, :title, :_destroy]]
14
+
15
+ config.sort_order = 'title_asc'
16
+
17
+ # controller do
18
+ # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
19
+ # end
20
+
21
+ index do
22
+ selectable_column
23
+ id_column
24
+ column :title
25
+ column :activity_type
26
+ column :desc do |c|
27
+ c.desc.html_safe[0..100]
28
+ end
29
+
30
+ =begin
31
+ column '' do |company|
32
+ if company.cphotos.count > 0
33
+ image_tag(company.cphotos.first.image.thumb_preview)
34
+ end
35
+ end
36
+ =end
37
+
38
+ =begin
39
+
40
+ column :pdfs do |issue|
41
+ list_items = ((issue.pdfs.map { |pdf|
42
+ "<li>• <a href='#{pdf.file.url}' target='_blank'>#{pdf.file}</a> </li>"
43
+ }).join("").html_safe)
44
+ "<ul>#{list_items}</ul>".html_safe
45
+ end
46
+ =end
47
+
48
+ column :facts do |issue|
49
+ # нарисуем список
50
+ list_items = ((issue.facts.map { |p|
51
+ "<li>• #{ p.title } <a href='/news/#{p.slug}' target='_blank'>[view]</a> <a href='/admin/facts/#{p.slug}/edit'>[edit]</a> </li>"
52
+ }).join("")).html_safe
53
+
54
+ "<ul>#{list_items}</ul>".html_safe
55
+ end
56
+
57
+
58
+ actions
59
+ end
60
+
61
+ form(:html => {:multipart => true}) do |f|
62
+
63
+ f.inputs "Свойства" do
64
+
65
+ f.input :title
66
+ f.input :activity_type
67
+
68
+ end
69
+
70
+ f.inputs "Адрес", :class => 'collapsed', for: [:adress, f.object.adress || C80NewsTz::Adress.new] do |s|
71
+ s.input :locality
72
+ s.input :street
73
+ s.input :telephone_1
74
+ s.input :telephone_2
75
+ s.input :telephone_3
76
+ s.input :latitude
77
+ s.input :longitude
78
+ s.input :email_1
79
+ s.input :email_2
80
+ s.input :site_1
81
+ s.input :site_2
82
+ s.actions
83
+ end
84
+
85
+ f.inputs 'Картинки, вставляемые в описание', :class => 'collapsed' do
86
+ f.has_many :cphotos, :allow_destroy => true do |cphoto|
87
+ cphoto.input :image,
88
+ :as => :file,
89
+ :hint => image_tag(cphoto.object.image.thumb_preview)
90
+ end
91
+ end
92
+
93
+ f.inputs "Описание" do
94
+ f.input :desc, :as => :ckeditor
95
+ end
96
+
97
+ =begin
98
+
99
+ f.has_many :pdfs, :allow_destroy => true do |ff|
100
+ ff.input :file, :as => :file, :hint => ff.template.asset_url(ff.object.file)
101
+ end
102
+ =end
103
+ f.inputs 'Новости\публикации, связанные с компанией', :class => 'collapsed' do
104
+ f.input :facts,
105
+ :as => :check_boxes,
106
+ :member_label => Proc.new { |p|
107
+ "#{p.title} <a href='/news/#{p.slug}' target='_blank'>[view]</a> <a href='/admin/facts/#{p.slug}/edit'>[edit]</a>".html_safe
108
+ }
109
+ end
110
+
111
+ f.inputs "Галереи", :class => 'collapsed-with-bug' do
112
+
113
+ f.has_many :galleries, :class => 'no-collapsed', :allow_destroy => true do |ff|
114
+ ff.input :title
115
+ # f.input :tag
116
+
117
+ ff.has_many :gphotos, :allow_destroy => true do |gp|
118
+ gp.input :image,
119
+ :as => :file,
120
+ :hint => gp.template.image_tag(gp.object.image.thumb_99)
121
+ gp.input :title,
122
+ :hint => 'Название фото. Будет выводиться при наведении мыши и при просмотре фото.'
123
+ end
124
+ end
125
+
126
+ end
127
+
128
+ f.actions
129
+ end
130
+
131
+ end
@@ -0,0 +1,110 @@
1
+ ActiveAdmin.register C80NewsTz::Fact, :as => 'Fact' 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
+ # :keywords,
12
+ # :description,
13
+ :fphotos_attributes => [:id, :image, :_destroy],
14
+ :company_ids => [],
15
+ :rubric_ids => [],
16
+ :issue_ids => []
17
+
18
+ # controller do
19
+ # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
20
+ # end
21
+
22
+ index do
23
+ selectable_column
24
+ id_column
25
+ column :title
26
+ column :created_at do |fact|
27
+ local_time(fact[:created_at], format: '%e.%m.%Y')
28
+ end
29
+
30
+ column '' do |fact|
31
+ if fact.fphotos.count > 0
32
+ image_tag(fact.fphotos.first.image.thumb_preview)
33
+ end
34
+ end
35
+
36
+ column :short
37
+ column :rubrics do |fact|
38
+ # нарисуем список
39
+ list_items = ((fact.rubrics.map { |p|
40
+ "<li>#{ p.title }</li>"
41
+ }).join("")).html_safe
42
+
43
+ "<ul>#{list_items}</ul>".html_safe
44
+ end
45
+ column :issue do |fact|
46
+ # нарисуем список
47
+ list_items = ((fact.issues.map { |p|
48
+ "<li>• #{ p.number } <a href='/issues/#{p.id}' target='_blank'>[view]</a> <a href='/admin/issues/#{p.id}/edit'>[edit]</a> </li>"
49
+ }).join("")).html_safe
50
+
51
+ "<ul>#{list_items}</ul>".html_safe
52
+ end
53
+ # column :full
54
+
55
+ actions
56
+ end
57
+
58
+ form(:html => {:multipart => true}) do |f|
59
+ f.inputs 'Свойства' do
60
+ f.input :title
61
+
62
+ f.input :rubrics,
63
+ :as => :check_boxes,
64
+ :member_label => Proc.new { |p|
65
+ p.title
66
+ }
67
+
68
+ f.input :issues,
69
+ :as => :check_boxes,
70
+ :member_label => Proc.new { |p|
71
+ p.number
72
+ }
73
+
74
+ f.input :short, :input_html => {:rows => 3, :class => 'code_area'}
75
+ f.input :leader_abz, :input_html => {:rows => 3, :class => 'code_area'}
76
+
77
+ f.inputs 'Картинки, вставляемые в текст новости (первая картинка идёт в предпросмотр новости)', :class => 'collapsed' do
78
+ f.has_many :fphotos, :allow_destroy => true do |fphotos|
79
+ fphotos.input :image,
80
+ :as => :file,
81
+ :hint => image_tag(fphotos.object.image.thumb_preview)
82
+ end
83
+ end
84
+
85
+ f.inputs 'Текст новости' do
86
+ f.input :full, :as => :ckeditor
87
+ end
88
+
89
+
90
+ f.inputs 'Компании, связанные с публикацией' do
91
+ f.input :companies,
92
+ :as => :check_boxes,
93
+ :member_label => Proc.new { |p|
94
+ "#{p.title} <a href='/companies/#{p.slug}' target='_blank'>[view]</a> <a href='/admin/companies/#{p.slug}/edit'>[edit]</a>".html_safe
95
+ }
96
+ end
97
+
98
+ # f.input :keywords,
99
+ # :input_html => {
100
+ # :class => 'code_area',
101
+ # :rows => 2
102
+ # }#,
103
+ # :hint => "[SEO] meta Keywords; Поле можно оставить пустым, тогда будут использованы ключевые слова сайта:<br> #{SiteProps.first.keywords}".html_safe
104
+ #f.input :description, :hint => "[SEO] meta Description; Поле можно оставить пустым, тогда будут использованы 200 первых символов новости."
105
+
106
+ end
107
+ f.actions
108
+ end
109
+
110
+ end
@@ -0,0 +1,60 @@
1
+ ActiveAdmin.register C80NewsTz::Issue, :as => 'Issue' do
2
+
3
+ menu :label => "Номера", :parent => 'Содержимое сайта'
4
+
5
+ before_filter :skip_sidebar!, :only => :index
6
+
7
+ permit_params :number,
8
+ :fact_ids => [],
9
+ :pdfs_attributes => [:id,:file,:_destroy]
10
+
11
+ config.sort_order = 'number_asc'
12
+
13
+ # controller do
14
+ # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
15
+ # end
16
+
17
+ index do
18
+ selectable_column
19
+ id_column
20
+ column :number
21
+
22
+ column :pdfs do |issue|
23
+ list_items = ((issue.pdfs.map { |pdf|
24
+ "<li>• <a href='#{pdf.file.url}' target='_blank'>#{pdf.file}</a> </li>"
25
+ }).join("").html_safe)
26
+ "<ul>#{list_items}</ul>".html_safe
27
+ end
28
+
29
+ column :facts do |issue|
30
+ # нарисуем список
31
+ list_items = ((issue.facts.map { |p|
32
+ "<li>• #{ p.title } <a href='/news/#{p.slug}' target='_blank'>[view]</a> <a href='/admin/facts/#{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
+ f.inputs "Свойства" do
43
+
44
+ f.input :number
45
+
46
+ f.has_many :pdfs, :allow_destroy => true do |ff|
47
+ ff.input :file, :as => :file, :hint => ff.template.asset_url(ff.object.file)
48
+ end
49
+
50
+ f.input :facts,
51
+ :as => :check_boxes,
52
+ :member_label => Proc.new { |p|
53
+ p.title
54
+ }
55
+
56
+ end
57
+ f.actions
58
+ end
59
+
60
+ end