c80_yax 0.1.0.8 → 0.1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/engines/ti/README.md +20 -0
  4. data/engines/ti/app/admin/ti/categories.rb +69 -0
  5. data/engines/ti/app/admin/ti/docs.rb +70 -0
  6. data/engines/ti/app/admin/ti/x_ti.rb +5 -0
  7. data/engines/ti/app/assets/javascripts/ti/facts_ajax.js +76 -0
  8. data/engines/ti/app/assets/javascripts/ti.coffee +1 -0
  9. data/engines/ti/app/assets/stylesheets/ti/news_block.scss +49 -0
  10. data/engines/ti/app/assets/stylesheets/ti/will_paginate.scss +65 -0
  11. data/engines/ti/app/assets/stylesheets/ti.scss +5 -0
  12. data/engines/ti/app/controllers/ti/application_controller.rb +14 -0
  13. data/engines/ti/app/helpers/ti/application_helper.rb +96 -0
  14. data/engines/ti/app/models/ti/category.rb +11 -0
  15. data/engines/ti/app/models/ti/doc.rb +72 -0
  16. data/engines/ti/app/models/ti/doc_validator.rb +11 -0
  17. data/engines/ti/app/models/ti/dphoto.rb +59 -0
  18. data/engines/ti/app/models/ti/prop.rb +5 -0
  19. data/engines/ti/app/uploaders/ti/dphoto_uploader.rb +152 -0
  20. data/engines/ti/app/views/layouts/c80_news/application.html.erb +14 -0
  21. data/engines/ti/app/views/shared/_fact.html.erb +13 -0
  22. data/engines/ti/app/views/shared/_fact_inverted.html.erb +20 -0
  23. data/engines/ti/app/views/shared/_news_block.html.erb +18 -0
  24. data/engines/ti/app/views/shared/_news_list.html.erb +16 -0
  25. data/engines/ti/app/views/ti/application/guru.js.erb +16 -0
  26. data/engines/ti/bin/console +14 -0
  27. data/engines/ti/bin/setup +7 -0
  28. data/engines/ti/config/locales/ru.yml +4 -0
  29. data/engines/ti/config/routes.rb +3 -0
  30. data/engines/ti/db/migrate/20170706050000_create_ti_props.rb +13 -0
  31. data/engines/ti/db/migrate/20170706050505_create_ti_docs.rb +11 -0
  32. data/engines/ti/db/migrate/20170706050507_create_ti_categories.rb +11 -0
  33. data/engines/ti/db/migrate/20170706050606_create_ti_dphotos.rb +11 -0
  34. data/engines/ti/db/migrate/20170706083939_create_ti_join_table_categories_docs.rb +12 -0
  35. data/engines/ti/db/seeds/ti_02_fill_test_data.rb +23 -0
  36. data/engines/ti/lib/ti/engine.rb +23 -0
  37. data/engines/ti/lib/ti/version.rb +3 -0
  38. data/engines/ti/lib/ti.rb +5 -0
  39. data/lib/c80_yax/version.rb +1 -1
  40. data/lib/c80_yax.rb +1 -0
  41. metadata +38 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '0804e766b1342dc657468f4b7fb8057bc44d5c50'
4
- data.tar.gz: ad39ee25f7c4272fede3cf14e745b61c8bc639cb
3
+ metadata.gz: 2c34639f47cd3c6f011ee349011b3ae0b708eb2c
4
+ data.tar.gz: 97f56c76766c09b8fe053d05efa905efe9c2afbc
5
5
  SHA512:
6
- metadata.gz: b30de510b7481ef42394f42cc4caf3f8bec341af295991207b2a831d05481e4df083ee7e189fbb418b4b43008c9fa7038875108af8c4fa5fa4400df30aaf1cdf
7
- data.tar.gz: 7537c2bf4139138a3ee54be202a6cdca0d7030e4933cebab8e13894575a8fa5422a5198acc1c0790866246917183b46ec75a91e6ba5945bb17db3f478eea356b
6
+ metadata.gz: 71979c804018ef28d6877b884a25b659aa6bb4f2c61f7da02aa792ffc890af7a0fa20cf2d8462804587127dd5c5fc3b470045ba2e3cde4d972f01bc115c00133
7
+ data.tar.gz: 63c1c4155250fccbb9eb47c18c5675c8d7561ee5c895f969e2eba657f7790aaf7c4e236b7a282b9cb0ccba500a06f505850246bd4b8270c6f128bc41a2201301
data/Gemfile CHANGED
@@ -3,4 +3,5 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in c80_yax.gemspec
4
4
  gemspec
5
5
 
6
- gem 'pack', path: 'engines/pack'
6
+ gem 'pack', path: 'engines/pack'
7
+ gem 'ti', path: 'engines/ti'
@@ -0,0 +1,20 @@
1
+ # техническая информация
2
+
3
+ Данный раздел предназначен для публикации материалов о тонкостях работы
4
+ с продукцией компании ORIMA, технической документации и инструкций
5
+ Функционал раздела предполагает, что из панели управления сайтом можно
6
+ создавать категории, в которые входят те или иные публикации.
7
+
8
+ * [ ] Так же для категорий могут быть созданы подкатегории. Таким образом
9
+ можно разместить большое количество инструкций.
10
+
11
+ * [X] Каждый совет или идея создается как отдельная публикация, которой
12
+ можно присвоить заголовок, текст и изображения.
13
+
14
+ * [ ] При этом каждой публикации необходимо присвоить категорию к которой она относится.
15
+
16
+ * [ ] Также можно опубликовать совет или идею как видео, задав ссылку
17
+ на соответствующее видео с youtube.com
18
+
19
+ C помощью функционала создания категорий и подкатегорий раздела
20
+ «Техническая информация» также можно размещать любые документы, например сертификаты.
@@ -0,0 +1,69 @@
1
+ ActiveAdmin.register Ti::Category, as: 'Category' do
2
+
3
+ menu :label => 'Категории',
4
+ :parent => 'x_ti',
5
+ :priority => 2
6
+
7
+ permit_params :title,
8
+ :full,
9
+ :ord,
10
+ :parent_category_id
11
+
12
+ config.sort_order = 'id_asc'
13
+ # config.clear_action_items!
14
+ config.batch_actions = false
15
+
16
+ # filter :title
17
+ # filter :strsubcats
18
+ # filter :is_excluded_from_filtering
19
+ # filter :is_normal_price
20
+
21
+ before_filter :skip_sidebar!, :only => :index
22
+
23
+ # controller do
24
+ # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
25
+ # end
26
+
27
+ index do
28
+ # selectable_column
29
+ id_column
30
+
31
+ column :title
32
+ column :ord
33
+ column :parent_category do |pn|
34
+ if pn.parent_category_id.present?
35
+ rpn = Ti::Category.find_by(id:pn.parent_category_id)
36
+ rpn.title unless rpn.nil?
37
+ end
38
+ end
39
+
40
+ actions
41
+ end
42
+
43
+ form(:html => {:multipart => true}) do |f|
44
+
45
+ f.inputs 'Свойства' do
46
+ f.input :title
47
+ f.input :ord
48
+
49
+ f.input :parent_category,
50
+ as: :select,
51
+ collection: Ti::Category.all,
52
+ input_html: {
53
+ :class => 'selectpicker',
54
+ :title => '',
55
+ :data => {
56
+ :size => 10,
57
+ :width => '400px'
58
+ },
59
+ :multiple => false
60
+ },
61
+ :include_blank => true
62
+
63
+ end
64
+
65
+ f.actions
66
+
67
+ end
68
+
69
+ end
@@ -0,0 +1,70 @@
1
+ ActiveAdmin.register Ti::Doc, :as => 'Docs' do
2
+
3
+ before_filter :skip_sidebar!, :only => :index
4
+
5
+ menu :label => 'Документы',
6
+ :parent => 'x_ti',
7
+ :priority => 1
8
+
9
+ permit_params :title,
10
+ :full,
11
+ :category_ids => [],
12
+ :dphotos_attributes => [:id,:image,:_destroy]
13
+
14
+ index do
15
+ selectable_column
16
+ id_column
17
+ column :title
18
+ column :created_at do |fact|
19
+ local_time(fact[:created_at], format: '%e.%m.%Y')
20
+ end
21
+
22
+ column '' do |fact|
23
+ if fact.dphotos.count > 0
24
+ image_tag(fact.dphotos.first.image.thumb_sm)
25
+ end
26
+ end
27
+
28
+ column :full do |doc|
29
+ res = '-'
30
+ if doc.full.present?
31
+ res = "#{doc.full[0..30]}..."
32
+ end
33
+ res
34
+ end
35
+
36
+ actions
37
+ end
38
+
39
+ form(:html => {:multipart => true}) do |f|
40
+ f.inputs 'Свойства' do
41
+ f.input :title
42
+
43
+ f.input :categories,
44
+ :as => :select,
45
+ :input_html => {
46
+ :title => '',
47
+ :class => 'selectpicker',
48
+ :data => {
49
+ :size => 10
50
+ },
51
+ :multiple => false
52
+ },
53
+ :include_blank => true
54
+
55
+ f.inputs 'Фото' do
56
+ f.has_many :dphotos, :allow_destroy => true do |dphoto|
57
+ dphoto.input :image,
58
+ :as => :file,
59
+ :hint => image_tag(dphoto.object.image.thumb_sm)
60
+ end
61
+ end
62
+
63
+ f.input :full, :as => :ckeditor,
64
+ :input_html => {:style => 'height:500px', rows: 20}
65
+
66
+ end
67
+ f.actions
68
+ end
69
+
70
+ end
@@ -0,0 +1,5 @@
1
+ ActiveAdmin.register_page 'x_ti' do
2
+ menu :label => 'Техническая информация',
3
+ :priority => 21,
4
+ :url => '#'
5
+ end
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ // Код, реализующий ajax функционал на странице "новости"
4
+
5
+ var fNewsBindHistoryAdapter;
6
+ var fNewsdoAjaxRequest;
7
+ var fNewsProccessPaginateLinks;
8
+ var fNewsStartWillPaginateAjax;
9
+ var fNewsProcessBlocks; // при клике по preview-картинке новости будет происходить переход на просмотр новости
10
+
11
+ $(function () {
12
+ if ($('.news_block[data-is_render_paginator="true"]').length) {
13
+
14
+ fNewsBindHistoryAdapter = function () {
15
+ History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
16
+
17
+ // Log the State
18
+ var State = History.getState(); // Note: We are using History.getState() instead of event.state
19
+ var p;
20
+
21
+ //History.log('statechange:', State.data, State.title, State.url);
22
+ if (State.title == "") {
23
+ p = 1;
24
+ } else {
25
+ p = State.data.page;
26
+ }
27
+
28
+ fNewsdoAjaxRequest(p);
29
+ });
30
+ };
31
+
32
+ fNewsdoAjaxRequest = function (page/*integer*/,callback/*function*/) {
33
+
34
+ var $ajax_div = $('.ajax_div'); // к этому контейнеру изначально прикреплены кое-какие данные
35
+
36
+ $.ajax({
37
+ url: "/news_guru",
38
+ type: "POST",
39
+ data: {
40
+ page: page,
41
+ is_render_paginator: $ajax_div.data('is_render_paginator'), // эти переменные
42
+ partial_name: $ajax_div.data('partial_name'), // уходят транзитом
43
+ css_class_news_block: $ajax_div.data('css_class_news_block') // на render_news_block
44
+ },
45
+ dataType: "script"
46
+ }).done(callback);
47
+ };
48
+
49
+ fNewsProccessPaginateLinks = function () {
50
+ //console.log("fNewsProccessPaginateLinks");
51
+ $(".news_block .div_will_paginate a").click(function (e) {
52
+ e.preventDefault();
53
+ var page = $(this).attr('href').split("?page=")[1];
54
+ History.pushState({page:page},window.document.title,"?page="+page);
55
+ });
56
+ };
57
+
58
+ fNewsStartWillPaginateAjax = function () {
59
+ if ($(".news_block .div_will_paginate a").length > 0) {
60
+ fNewsProccessPaginateLinks();
61
+ fNewsBindHistoryAdapter();
62
+ }
63
+ };
64
+
65
+ fNewsProcessBlocks = function() {
66
+ $(".fact img").click(function (e) {
67
+ // NB:: parent().parent() хардкод: картинка лежит в ссылке, ссылка лежит в диве
68
+ window.location.href = $(this).parent().parent().data('url');
69
+ });
70
+ };
71
+
72
+ fNewsStartWillPaginateAjax();
73
+ fNewsProcessBlocks();
74
+
75
+ }
76
+ });
@@ -0,0 +1 @@
1
+ #= require_tree ./ti
@@ -0,0 +1,49 @@
1
+ div.news_block {
2
+
3
+ div.news_list {
4
+ position: relative; /** Needed to ensure items are laid out relative to this container **/
5
+ padding: 0;
6
+ margin: 0;
7
+
8
+ div.fact {
9
+ display: block;
10
+ float: left;
11
+ /*width: 229px;*/
12
+ /*max-height: 350px;*/
13
+ overflow: hidden;
14
+ margin-bottom: 25px;
15
+
16
+ img {
17
+ margin-bottom: 15px;
18
+ max-width: 100%;
19
+ }
20
+
21
+ &.clear_left {
22
+ clear: left;
23
+ }
24
+
25
+ }
26
+
27
+ &.per_row_3 {
28
+ .fact {
29
+ width: 33.33333%;
30
+ }
31
+ }
32
+
33
+ &.per_row_4 {
34
+ .fact {
35
+ width: 25%;
36
+ }
37
+ }
38
+
39
+ &.is_news_page {
40
+
41
+ div.fact {
42
+
43
+ }
44
+
45
+ }
46
+
47
+ }
48
+
49
+ }
@@ -0,0 +1,65 @@
1
+ div.ajax_div {
2
+
3
+ div.div_will_paginate {
4
+ width: 100%;
5
+ clear: both;
6
+ float: left;
7
+ padding: 0 46px;
8
+
9
+ .pagination {
10
+ margin: 0;
11
+
12
+ span {
13
+ &.previous_page {
14
+ display: none;
15
+ }
16
+ &.next_page {
17
+ display: none;
18
+ }
19
+ }
20
+
21
+ em {
22
+
23
+ display: inline-block;
24
+ line-height: 29px;
25
+ width: 30px;
26
+ height: 30px;
27
+
28
+ text-align: center;
29
+ font-weight: bold !important;
30
+ font-style: normal !important;
31
+
32
+ border: 1px solid #B6B6B6;
33
+ background-color: #E9353B;
34
+ color:#ffffff;
35
+
36
+ }
37
+
38
+ a {
39
+ display: inline-block;
40
+ line-height: 29px;
41
+ width: 30px;
42
+ height: 30px;
43
+
44
+ border: 1px solid #B6B6B6;
45
+ background-color: #ffffff;
46
+ color:#777777;
47
+ text-align: center;
48
+ font-weight: bold !important;
49
+
50
+ text-decoration: none;
51
+ &:hover, &:active, &:focus { text-decoration: none !important; color: black; }
52
+
53
+ &.previous_page {
54
+ display: none;
55
+ }
56
+ &.next_page {
57
+ display: none;
58
+ }
59
+
60
+ }
61
+ }
62
+
63
+ }
64
+
65
+ }
@@ -0,0 +1,5 @@
1
+ /*
2
+ *= require_self
3
+ */
4
+
5
+ @import "ti/**/*";
@@ -0,0 +1,14 @@
1
+ require 'c80_lazy_images'
2
+
3
+ module Ti
4
+ class ApplicationController < ActionController::Base
5
+
6
+ helper C80LazyImages::Engine.helpers
7
+
8
+ def guru
9
+ respond_to do |format|
10
+ format.js
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,96 @@
1
+ module Ti
2
+ module ApplicationHelper
3
+
4
+ include LocalTimeHelper
5
+
6
+ def render_news_block(is_news_page=false, page=1, options={})
7
+
8
+ # 1. на странице НОВОСТИ выводим per_page новостей, в виджете выводим per_widget новостей
9
+ # 2. на странице НОВОСТИ div.news_block имеет класс is_news_page
10
+ # 3. к div.news_block можно дописать стиль, типа style_photostudio
11
+
12
+ per_page = Prop.first.per_widget
13
+ css_class_news_block = ''
14
+ if is_news_page
15
+ css_class_news_block = 'is_news_page'
16
+ per_page = Prop.first.per_page
17
+ end
18
+ per_block_row = Prop.first.per_widget
19
+
20
+ #
21
+ if options[:css_class_news_block].present?
22
+ css_class_news_block += " #{options[:css_class_news_block]}"
23
+ end
24
+
25
+ news = Fact.paginate(:page => page, :per_page => per_page)
26
+
27
+ is_render_paginator = options[:is_render_paginator].present? \
28
+ ? options[:is_render_paginator] \
29
+ : is_news_page
30
+
31
+ render :partial => "shared/news_block",
32
+ :locals => {
33
+ :news_list => news,
34
+ :is_news_page => is_news_page,
35
+ :per_block_row => per_block_row,
36
+ :partial_name => options[:partial_name],
37
+ :is_render_paginator => is_render_paginator,
38
+ :thumb_size => options[:thumb_size],
39
+ :css_class_news_block => css_class_news_block,
40
+ :h3_title => options[:h3_title]
41
+ }
42
+ end
43
+
44
+ def render_one_fact(fact, partial_name='fact', thumb_size='thumb_md', additional_css_class=nil)
45
+
46
+
47
+ unless thumb_size.present?
48
+ thumb_size = 'thumb_md'
49
+ end
50
+
51
+ # Rails.logger.debug "[TRACE] <render_one_fact> thumb_size: #{thumb_size}"
52
+
53
+ # свойства модуля
54
+ p = Prop.first
55
+
56
+ # чтобы вёрстка не прыгала - зафиксируем размер картинки
57
+ w = p.send("#{thumb_size}_width")
58
+ h = p.send("#{thumb_size}_width")
59
+
60
+ render :partial => "shared/#{partial_name}",
61
+ :locals => {
62
+ fact: fact,
63
+ css_common_width_height: "width:#{w}px;height:#{h}px",
64
+ css_common_width: "width:#{w}px;",
65
+ thumb_size:thumb_size,
66
+ additional_css_class:additional_css_class
67
+ }
68
+ end
69
+
70
+ def url_for_fact(fact)
71
+ "/news/#{fact.slug}"
72
+ end
73
+
74
+ # метод добавлен, чтобы сократить количество символов в строке, которую надо вставить в
75
+ # 256-символьное структурное поле Страницы (Page) типа after_main (в админке), чтобы отрендерить новостной виджет
76
+ def render_news_widget(css_class_news_block='style_default',
77
+ partial_name='fact_inverted',
78
+ thumb_size='thumb_preview',
79
+ h3_title=' '
80
+ )
81
+
82
+ if h3_title == ' '
83
+ h3_title = I18n.t('c80_news.news_widget.h3_title')
84
+ end
85
+
86
+ render_news_block(false, params[:page], {
87
+ :partial_name => partial_name,
88
+ :thumb_size => thumb_size,
89
+ :css_class_news_block => css_class_news_block,
90
+ :h3_title => h3_title
91
+ }
92
+ )
93
+ end
94
+
95
+ end
96
+ end
@@ -0,0 +1,11 @@
1
+ module Ti
2
+ class Category < ActiveRecord::Base
3
+ has_many :child_categories,
4
+ class_name: 'Ti::Category',
5
+ foreign_key: 'parent_category_id',
6
+ dependent: :nullify
7
+ belongs_to :parent_category, class_name: 'Ti::Category'
8
+ has_and_belongs_to_many :docs
9
+ validates :title, presence: true
10
+ end
11
+ end
@@ -0,0 +1,72 @@
1
+ require 'babosa'
2
+ include ActionView::Helpers::SanitizeHelper
3
+
4
+ module Ti
5
+ class Doc < ActiveRecord::Base
6
+ has_many :dphotos, :dependent => :destroy
7
+ accepts_nested_attributes_for :dphotos,
8
+ :reject_if => lambda { |attributes|
9
+ !attributes.present?
10
+ },
11
+ :allow_destroy => true
12
+ has_and_belongs_to_many :categories
13
+ validates_with DocValidator
14
+ default_scope {order(:created_at => :desc)}
15
+
16
+ extend FriendlyId
17
+ friendly_id :title, use: :slugged
18
+ def normalize_friendly_id(input)
19
+ input.to_s.to_slug.normalize(transliterations: :russian).to_s
20
+ end
21
+
22
+ def slug_candidates
23
+ [:title] + Array.new(6) {|index| [:title, index+2]}
24
+ end
25
+
26
+ def short_meta_description
27
+
28
+ if description.present? && description.length > 200
29
+ result = description
30
+ elsif full.present? && full.length > 0
31
+ result = strip_tags(full[0..200]+'...')
32
+ else
33
+ result = nil
34
+ end
35
+ result
36
+
37
+ end
38
+
39
+ def thumb_sm
40
+ s = ''
41
+ if dphotos.count > 0
42
+ s = dphotos.first.image.thumb_sm
43
+ end
44
+ s
45
+ end
46
+
47
+ def thumb_md
48
+ s = ''
49
+ if dphotos.count > 0
50
+ s = dphotos.first.image.thumb_md
51
+ end
52
+ s
53
+ end
54
+
55
+ def thumb_lg
56
+ s = ''
57
+ if dphotos.count > 0
58
+ s = dphotos.first.image.thumb_lg
59
+ end
60
+ s
61
+ end
62
+
63
+ def thumb_preview
64
+ s = ''
65
+ if dphotos.count > 0
66
+ s = dphotos.first.image.thumb_preview
67
+ end
68
+ s
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,11 @@
1
+ module Ti
2
+ class DocValidator < ActiveModel::Validator
3
+ def validate(record)
4
+
5
+ unless record.title.present?
6
+ record.errors[:title] = 'Название не может быть пустым'
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,59 @@
1
+ module Ti
2
+ class Dphoto < ActiveRecord::Base
3
+ belongs_to :doc
4
+ mount_uploader :image, DphotoUploader
5
+
6
+ # в ~ от размеров thumb-ов и page_content_width - выдать соответствующую картинку
7
+ # • Если у картинки thumb_big шириной ≥ page_content_width - вставляем этот thumb_big.
8
+ # • Иначе: вставлем thumb_small.
9
+ def content_image(type='normal')
10
+
11
+ if type == 'normal'
12
+ img = MiniMagick::Image.open(image.thumb_big.path)
13
+ w = SiteProp.first.page_content_width
14
+ if img['width'] < w
15
+ image.thumb_small
16
+ else
17
+ image.thumb_big
18
+ end
19
+
20
+ elsif type == 'small'
21
+ image.thumb_small
22
+
23
+ elsif type == 'big'
24
+ image.thumb_big
25
+ end
26
+
27
+ end
28
+
29
+ # выдать размеры картинки, которая будет вставлена в текст страницы
30
+ def content_image_size(type='normal')
31
+
32
+ if type == 'normal'
33
+ img = MiniMagick::Image.open(image.thumb_big.path)
34
+ w = SiteProp.first.page_content_width
35
+ if img['width'] < w
36
+ img = MiniMagick::Image.open(image.thumb_small.path)
37
+ [img['width'], img['height']]
38
+ else
39
+ [img['width'], img['height']]
40
+ end
41
+
42
+ elsif type == 'small'
43
+ img = MiniMagick::Image.open(image.thumb_small.path)
44
+ [img['width'], img['height']]
45
+
46
+ elsif type == 'big'
47
+ img = MiniMagick::Image.open(image.thumb_big.path)
48
+ [img['width'], img['height']]
49
+ end
50
+ end
51
+
52
+ # выдать размеры картинки thumb_preview
53
+ def thumb_preview_size
54
+ img = MiniMagick::Image.open(image.thumb_preview.path)
55
+ [img['width'], img['height']]
56
+ end
57
+
58
+ end
59
+ end
@@ -0,0 +1,5 @@
1
+ module Ti
2
+ class Prop < ActiveRecord::Base
3
+
4
+ end
5
+ end
@@ -0,0 +1,152 @@
1
+ module Ti
2
+ class DphotoUploader < BaseFileUploader
3
+
4
+ # ограничение оригинальной картинки
5
+ process :resize_to_limit => [1600,1600]
6
+
7
+ def store_dir
8
+ "uploads/docs/#{format('%02d', model.fact_id)}"
9
+ end
10
+
11
+ # ---[ идут в контент новости ]---[ размер зависит от SiteProps.page_content_width ]--------------------------------------------------------------------------------------------------------------------
12
+
13
+ version :thumb_big do
14
+ process :resize_to_thumb_big
15
+ end
16
+
17
+ version :thumb_small do
18
+ process :resize_to_thumb_small
19
+ end
20
+
21
+ # ------------------------------------------------------------------------------------------------------------------------
22
+
23
+ version :thumb_preview do
24
+ begin
25
+ # Proc.new {
26
+ p = C80News::Prop.first
27
+ process :resize_to_fill => [p.thumb_preview_width, p.thumb_preview_height]
28
+ # }
29
+ rescue => e
30
+ Rails.logger.debug "[TRACE] <C80News.fphoto_uploader> thumb_preview ERROR: #{e}"
31
+ end
32
+ end
33
+
34
+ version :thumb_lg do
35
+ process :resize_to_lg
36
+ end
37
+
38
+ version :thumb_md do
39
+ process :resize_to_md
40
+ end
41
+
42
+ version :thumb_sm do
43
+ process :resize_to_sm
44
+ end
45
+
46
+ # --[ идут в контент новости ]--------------------------------------------------------------------------------------
47
+
48
+ def resize_to_thumb_big
49
+ # byebug
50
+
51
+ w = SiteProp.first.page_content_width
52
+ h = calc_height_of_image(w)
53
+
54
+ # puts "<PageArtUploader.resize_to_limit_big>"
55
+ manipulate! do |img|
56
+ img.resize "#{w}x#{h}>"
57
+ img = yield(img) if block_given?
58
+ img
59
+ end
60
+
61
+ end
62
+
63
+ def resize_to_thumb_small
64
+ # puts "<PageArtUploader.resize_to_limit_small>"
65
+ manipulate! do |img|
66
+
67
+ w = SiteProp.first.page_content_width/2
68
+ h = calc_height_of_image(w)
69
+
70
+ img.resize "#{w}x#{h}>"
71
+ img = yield(img) if block_given?
72
+ img
73
+
74
+ end
75
+ end
76
+
77
+ # ------------------------------------------------------------------------------------------------------------------------
78
+
79
+ def resize_to_lg
80
+ # byebug
81
+
82
+ w = C80News::Prop.first.thumb_lg_width
83
+ h = C80News::Prop.first.thumb_lg_height
84
+
85
+ manipulate! do |img|
86
+ img.resize "#{w}x#{h}^"
87
+ img.gravity 'center'
88
+ img.extent "#{w}x#{h}"
89
+ img = yield(img) if block_given?
90
+ img
91
+ end
92
+
93
+ end
94
+
95
+ def resize_to_md
96
+
97
+ manipulate! do |img|
98
+
99
+ w = C80News::Prop.first.thumb_md_width
100
+ h = C80News::Prop.first.thumb_md_height
101
+
102
+ img.resize "#{w}x#{h}^"
103
+ img.gravity 'center'
104
+ img.extent "#{w}x#{h}"
105
+ img = yield(img) if block_given?
106
+ img
107
+
108
+ end
109
+
110
+ end
111
+
112
+ def resize_to_sm
113
+
114
+ manipulate! do |img|
115
+
116
+ w = C80News::Prop.first.thumb_sm_width
117
+ h = C80News::Prop.first.thumb_sm_height
118
+
119
+ img.resize "#{w}x#{h}^"
120
+ img.gravity 'center'
121
+ img.extent "#{w}x#{h}"
122
+ img = yield(img) if block_given?
123
+ img
124
+
125
+ end
126
+
127
+ end
128
+
129
+ # ------------------------------------------------------------------------------------------------------------------------
130
+
131
+ protected
132
+ def secure_token(length=16)
133
+ var = :"@#{mounted_as}_secure_token"
134
+ model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.hex(length/2))
135
+ end
136
+
137
+ private
138
+
139
+ def calc_height_of_image(w)
140
+ model_image = ::MiniMagick::Image.open(current_path)
141
+ calc_height(w, model_image["width"], model_image["height"])
142
+ end
143
+
144
+ # подгоняем по ширине, рассчитываем высоту
145
+ def calc_height(width, original_w, original_h)
146
+ k = width.to_f/original_w
147
+ original_h * k
148
+ end
149
+
150
+
151
+ end
152
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>News</title>
5
+ <%= stylesheet_link_tag "news/application", media: "all" %>
6
+ <%= javascript_include_tag "news/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,13 @@
1
+ <div class="fact" data-url="<%= url_for_fact(fact) %>">
2
+ <p class="date">
3
+ <%= local_time(fact[:created_at], format: '%e.%m.%Y') %>
4
+ </p>
5
+ <%= link_to(url_for_fact(fact)) do %>
6
+ <h5><%= fact.title %></h5>
7
+ <% end %>
8
+ [[1]]
9
+ <p class="short">
10
+ <%= fact[:short].html_safe %>
11
+ </p>
12
+ <div class="white_shadow"></div>
13
+ </div>
@@ -0,0 +1,20 @@
1
+ <div class="fact <%=additional_css_class%>">
2
+ <%= render_image_link_lazy({
3
+ :alt_image => fact.title,
4
+ :image => fact.send(thumb_size),
5
+ :a_href => url_for_fact(fact),
6
+ :a_class => '',
7
+ :a_style => css_common_width_height,
8
+ :a_rel => 'nofollow'
9
+ }) %>
10
+ <%= link_to(url_for_fact(fact), class: 'h5') do %>
11
+ <h5 style="<%= css_common_width %>"><%= fact.title %></h5>
12
+ <% end %>
13
+ <p class="date" style="<%= css_common_width %>">
14
+ <%= local_time(fact[:created_at], format: '%e.%m.%Y') %>
15
+ </p>
16
+ <p class="short" style="<%= css_common_width %>">
17
+ <%= fact[:short].html_safe %>
18
+ </p>
19
+ <div class="white_shadow"></div>
20
+ </div>
@@ -0,0 +1,18 @@
1
+ <% if h3_title.present? %>
2
+ <h3 class="section_title h3_for_news_block"><%= h3_title %></h3>
3
+ <% end %>
4
+ <div class="ajax_div news_block <%= css_class_news_block %>"
5
+ data-partial_name="<%= partial_name %>"
6
+ data-css_class_news_block="<%= css_class_news_block %>"
7
+ data-is_render_paginator="<%= is_render_paginator %>">
8
+ <%= render :partial => "shared/news_list",
9
+ :locals => {
10
+ :news_list => news_list,
11
+ :is_news_page => is_news_page,
12
+ :per_row => per_block_row,
13
+ :partial_name => partial_name,
14
+ :is_render_paginator => is_render_paginator,
15
+ :thumb_size => thumb_size
16
+ }
17
+ %>
18
+ </div>
@@ -0,0 +1,16 @@
1
+ <div class="news_list clearfix per_row_<%=per_row%>">
2
+ <% news_list.each_with_index do |fact, index| %>
3
+
4
+ <%# чтобы не было такого https://dl.dropboxusercontent.com/u/1365807/work/sokol/tx/2016-11-05_165449_news_clear.jpg %>
5
+ <% clear_left_css_class = index % per_row == 0 ? 'clear_left':'' %>
6
+ <% clear_left_css_class += " index_#{index}" %>
7
+
8
+ <%= render_one_fact(fact, partial_name, thumb_size, clear_left_css_class.to_s).to_s %>
9
+
10
+ <% end %>
11
+ </div>
12
+ <% if is_news_page || is_render_paginator %>
13
+ <div class="div_will_paginate">
14
+ <%= will_paginate news_list %>
15
+ </div>
16
+ <% end %>
@@ -0,0 +1,16 @@
1
+
2
+ var html_str = "<%= j render_news_block(true,params[:page], {
3
+ :partial_name => params[:partial_name],
4
+ :is_render_paginator => params[:is_render_paginator],
5
+ :css_class_news_block => params[:css_class_news_block]
6
+ })
7
+ %>";
8
+
9
+ var $aa = $('.news_block[data-is_render_paginator="true"]');
10
+ $aa.replaceWith(html_str);
11
+
12
+ Holder.run($aa.find("img"));
13
+ fLazyStart();
14
+
15
+ fNewsProccessPaginateLinks();
16
+ fNewsProcessBlocks();
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "c80_news"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,4 @@
1
+ ru:
2
+ c80_news:
3
+ news_widget:
4
+ h3_title: 'Новости'
@@ -0,0 +1,3 @@
1
+ C80News::Engine.routes.draw do
2
+ # match 'news_guru', :to => 'application#guru', :via => :post
3
+ end
@@ -0,0 +1,13 @@
1
+ class CreateTiProps < ActiveRecord::Migration
2
+ def change
3
+ create_table :ti_props do |t|
4
+ t.integer :thumb_sm_width
5
+ t.integer :thumb_sm_height
6
+ t.integer :thumb_md_width
7
+ t.integer :thumb_md_height
8
+ t.integer :thumb_lg_width
9
+ t.integer :thumb_lg_height
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ class CreateTiDocs < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :ti_docs do |t|
4
+ t.string :title
5
+ t.text :full
6
+ t.string :slug
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateTiCategories < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :ti_categories do |t|
4
+ t.string :title
5
+ t.integer :ord
6
+ t.text :full
7
+ t.references :parent_category, index: true
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateTiDphotos < ActiveRecord::Migration
2
+ def change
3
+ create_table :ti_dphotos do |t|
4
+ t.string :image
5
+ t.references :doc, index: true
6
+
7
+ t.timestamps null: false
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class CreateTiJoinTableCategoriesDocs < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :ti_categories_docs, :id => false do |t|
4
+ t.integer :category_id, :null => false
5
+ t.integer :doc_id, :null => false
6
+ end
7
+
8
+ add_index :ti_categories_docs, [:category_id, :doc_id], :unique => true, :name => 'ti_index1'
9
+ add_index :ti_categories_docs, [:doc_id, :category_id], :unique => true, :name => 'ti_index2'
10
+
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ # rake db:seed:ti_02_fill_test_data
2
+
3
+ Ti::Category.delete_all
4
+ Ti::Category.create!([
5
+ { ord: 10, id: 1, title: 'Монтажные инструкции' }
6
+ ])
7
+
8
+ Ti::Category.create!([
9
+ { ord: 100, title: 'Водосточные системы', parent_category_id: 1},
10
+ { ord: 110, title: 'Снегозадержатели', parent_category_id: 1},
11
+ { ord: 120, title: 'Лестницы', parent_category_id: 1},
12
+ { ord: 130, title: 'Кровельные мостики и ограждения', parent_category_id: 1},
13
+ { ord: 140, title: 'Продукция из меди', parent_category_id: 1}
14
+ ])
15
+
16
+ Ti::Doc.delete_all
17
+ Ti::Doc.create!([
18
+ { title: 'Монтаж круглой водосточной системы P87', category_ids: [100] },
19
+ { title: 'Монтаж круглого водосточного желоба P13', category_ids: [100] },
20
+ { title: 'Монтаж прямоугольной водосточной системы K12', category_ids: [100] },
21
+ { title: 'Установка водосточной трубы P10 и K9x9', category_ids: [100] },
22
+ { title: 'Установка внутреннего кронштейна прямоугольной водосточной системы', category_ids: [100] }
23
+ ])
@@ -0,0 +1,23 @@
1
+ module Ti
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Ti
4
+
5
+ initializer :ti_engine do
6
+ if defined?(ActiveAdmin)
7
+ ActiveAdmin.application.load_paths += Dir["#{config.root}/app/models/**/"]
8
+ #ActiveAdmin.application.load_paths += Dir["#{config.root}/app/models/concerns/**/"]
9
+ ActiveAdmin.application.load_paths += Dir["#{config.root}/app/admin/ti/**/"]
10
+ # ActiveAdmin.application.load_paths += Dir["#{config.root}/app/jobs/**/"]
11
+ end
12
+ end
13
+
14
+ initializer :append_migrations do |app|
15
+ unless app.root.to_s.match root.to_s
16
+ config.paths['db/migrate'].expanded.each do |expanded_path|
17
+ app.config.paths['db/migrate'] << expanded_path
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module Ti
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,5 @@
1
+ require_relative "./ti/version"
2
+ require_relative "./ti/engine"
3
+
4
+ module Ti
5
+ end
@@ -1,3 +1,3 @@
1
1
  module C80Yax
2
- VERSION = '0.1.0.8'
2
+ VERSION = '0.1.0.9'
3
3
  end
data/lib/c80_yax.rb CHANGED
@@ -6,6 +6,7 @@ require 'c80_yax/item_photos_sizes_cache'
6
6
  require 'rails-observers'
7
7
  require 'mini_magick'
8
8
  require_relative '../engines/pack/lib/pack'
9
+ require_relative '../engines/ti/lib/ti'
9
10
 
10
11
  module C80Yax
11
12
  def self.table_name_prefix
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c80_yax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.8
4
+ version: 0.1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-05 00:00:00.000000000 Z
11
+ date: 2017-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -244,6 +244,42 @@ files:
244
244
  - engines/pack/db/migrate/20170625215151_create_c80_yax_pack_srows.rb
245
245
  - engines/pack/lib/pack.rb
246
246
  - engines/pack/lib/pack/engine.rb
247
+ - engines/ti/README.md
248
+ - engines/ti/app/admin/ti/categories.rb
249
+ - engines/ti/app/admin/ti/docs.rb
250
+ - engines/ti/app/admin/ti/x_ti.rb
251
+ - engines/ti/app/assets/javascripts/ti.coffee
252
+ - engines/ti/app/assets/javascripts/ti/facts_ajax.js
253
+ - engines/ti/app/assets/stylesheets/ti.scss
254
+ - engines/ti/app/assets/stylesheets/ti/news_block.scss
255
+ - engines/ti/app/assets/stylesheets/ti/will_paginate.scss
256
+ - engines/ti/app/controllers/ti/application_controller.rb
257
+ - engines/ti/app/helpers/ti/application_helper.rb
258
+ - engines/ti/app/models/ti/category.rb
259
+ - engines/ti/app/models/ti/doc.rb
260
+ - engines/ti/app/models/ti/doc_validator.rb
261
+ - engines/ti/app/models/ti/dphoto.rb
262
+ - engines/ti/app/models/ti/prop.rb
263
+ - engines/ti/app/uploaders/ti/dphoto_uploader.rb
264
+ - engines/ti/app/views/layouts/c80_news/application.html.erb
265
+ - engines/ti/app/views/shared/_fact.html.erb
266
+ - engines/ti/app/views/shared/_fact_inverted.html.erb
267
+ - engines/ti/app/views/shared/_news_block.html.erb
268
+ - engines/ti/app/views/shared/_news_list.html.erb
269
+ - engines/ti/app/views/ti/application/guru.js.erb
270
+ - engines/ti/bin/console
271
+ - engines/ti/bin/setup
272
+ - engines/ti/config/locales/ru.yml
273
+ - engines/ti/config/routes.rb
274
+ - engines/ti/db/migrate/20170706050000_create_ti_props.rb
275
+ - engines/ti/db/migrate/20170706050505_create_ti_docs.rb
276
+ - engines/ti/db/migrate/20170706050507_create_ti_categories.rb
277
+ - engines/ti/db/migrate/20170706050606_create_ti_dphotos.rb
278
+ - engines/ti/db/migrate/20170706083939_create_ti_join_table_categories_docs.rb
279
+ - engines/ti/db/seeds/ti_02_fill_test_data.rb
280
+ - engines/ti/lib/ti.rb
281
+ - engines/ti/lib/ti/engine.rb
282
+ - engines/ti/lib/ti/version.rb
247
283
  - lib/c80_yax.rb
248
284
  - lib/c80_yax/engine.rb
249
285
  - lib/c80_yax/item_photos_sizes_cache.rb