c80_features 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 807124975e97db4c339158b93b08fe2e67f7f9b9
4
+ data.tar.gz: 9cbf0fee7c5e48990974d5fb0ee2f3c654a702c2
5
+ SHA512:
6
+ metadata.gz: 801cca2134c1ea04acb651e81e079d18c9bdaad68afdca36a3ea3bc728d8513b937b642befba89b5f12767bb04e579c19d94c6c179dcfa0d2c0af2159792182c
7
+ data.tar.gz: 95b10cdc2d3401820229b3f7bce4eef5dbe74bf1fe7507c79a187aad50b28acaf14747e305f70a458f0f13b43843b5527cee41a03bcb1f811af74ce45d7c6133
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.idea/
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.gem
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_features.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 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,45 @@
1
+ # C80Features
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/c80_features.svg)](http://badge.fury.io/rb/c80_features)
4
+ [![Build Status](https://travis-ci.org/c080609a/c80_features.svg?branch=master)](https://travis-ci.org/c080609a/c80_feedback_form)
5
+
6
+
7
+ Adds model Features::Para (paragraph) to site,
8
+ which are usually enumerated as text blocks one by one in a single row
9
+ (e.g.: testimonials, features, trust symbols etc.).
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'c80_features'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install c80_features
26
+
27
+ Available helper's methods:
28
+ ```ruby
29
+ <%= features_block_with_images %>
30
+ <%= features_block %>
31
+ ```
32
+
33
+ ## Development
34
+
35
+ 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.
36
+
37
+ 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).
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it ( https://github.com/[my-github-username]/c80_features/fork )
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,36 @@
1
+ ActiveAdmin.register C80Features::Para, :as => 'Para' do
2
+
3
+ before_filter :skip_sidebar!, :only => :index
4
+
5
+ menu :label => 'Преимущества'
6
+
7
+ config.sort_order = 'id_asc'
8
+
9
+ permit_params :title,
10
+ :content,
11
+ :image
12
+
13
+ index do
14
+ selectable_column
15
+ column :image do |ab|
16
+ image_tag("#{ab.image.thumb_fill.url}")
17
+ end
18
+ column :title
19
+ column :content do |about|
20
+ about.content.html_safe
21
+ end
22
+ actions
23
+ end
24
+
25
+ form(:html => {:multipart => true}) do |f|
26
+
27
+ f.inputs 'Свойства' do
28
+ f.input :image, :hint => image_tag("#{f.object.image}")
29
+ f.input :title
30
+ f.input :content, :as => :ckeditor
31
+ end
32
+
33
+ f.actions
34
+ end
35
+
36
+ end
@@ -0,0 +1,21 @@
1
+ module C80Features
2
+ module ApplicationHelper
3
+
4
+ def render_features_block_with_images
5
+ para_all = C80Features::Para.all
6
+ render :partial => 'c80_features/features_block_with_images',
7
+ :locals => {
8
+ :para_all => para_all
9
+ }
10
+ end
11
+
12
+ def render_features_block
13
+ para_all = C80Features::Para.all
14
+ render :partial => 'c80_features/features_block',
15
+ :locals => {
16
+ :para_all => para_all
17
+ }
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,6 @@
1
+ module C80Features
2
+ class Para < ActiveRecord::Base
3
+ validates_with ParaValidator
4
+ mount_uploader :image, ParaUploader
5
+ end
6
+ end
@@ -0,0 +1,16 @@
1
+ module C80Features
2
+ class ParaValidator < ActiveModel::Validator
3
+ def validate(record)
4
+ puts "<ParaValidator.validate> record = #{record}"
5
+
6
+ # unless record.title.present?
7
+ # record.errors[:title] = 'Укажите заголовок'
8
+ # end
9
+
10
+ unless record.content.present?
11
+ record.errors[:content] = 'Заполните текст'
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ # загрузка иконок в блоки "о нас"
2
+ class C80Features::ParaUploader < CarrierWave::Uploader::Base
3
+
4
+ include CarrierWave::MiniMagick
5
+
6
+ storage :file
7
+
8
+ def store_dir
9
+ "uploads/features"
10
+ end
11
+
12
+ def filename
13
+ if original_filename
14
+ "photo_#{model.id}.#{file.extension}"
15
+ end
16
+ end
17
+
18
+ # TODO:: размеры картинок вынести в отдельную модель Props
19
+
20
+ process :resize_to_limit => [121,107]
21
+
22
+ version :thumb_fill do
23
+ process :resize_to_fill => [121,107]
24
+ end
25
+
26
+ version :thumb_fit do
27
+ process :resize_to_fit => [121,107]
28
+ end
29
+
30
+ end
@@ -0,0 +1,9 @@
1
+ <% para_all.each_with_index do |paragraph,index| %>
2
+ <div id="<%= "feature_#{index}"%>">
3
+ <div class="ind"><%= index %></div>
4
+ <% if paragraph.title.present? %>
5
+ <h3><%= paragraph.title %></h3>
6
+ <% end %>
7
+ <div class="cnt"><%= paragraph.content.html_safe %></div>
8
+ </div>
9
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <% para_all.each do |paragraph| %>
2
+ <div style="background: transparent url(<%= image_path(paragraph.image.thumb_fill.url) %>) no-repeat 50% 0;">
3
+ <h3><%= paragraph.title %></h3>
4
+ <div><%= paragraph.content.html_safe %></div>
5
+ </div>
6
+ <% end %>
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "c80_features"
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
data/bin/setup ADDED
@@ -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,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'c80_features/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "c80_features"
8
+ spec.version = C80Features::VERSION
9
+ spec.authors = ["C80609A"]
10
+ spec.email = ["c080609a@gmail.com"]
11
+
12
+ spec.summary = 'Features'
13
+ spec.description = 'Adds model Features::Para (paragraph) to site,
14
+ which are usually enumerated as text blocks one by one in a single row
15
+ (e.g.: testimonials, features, trust symbols etc.). '
16
+ spec.homepage = ""
17
+ spec.license = "MIT"
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.9"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_dependency 'rails', '~> 4.1', '>= 4.1.4'
27
+ spec.add_dependency 'activeadmin'
28
+ spec.add_dependency 'carrierwave'
29
+
30
+ end
@@ -0,0 +1,12 @@
1
+ ru:
2
+ activerecord:
3
+ models:
4
+ para:
5
+ one: "текстовый блок"
6
+ other: "Преимущества"
7
+ attributes:
8
+ para:
9
+ id: "№"
10
+ title: "Заголовок"
11
+ image: "Картинка"
12
+ content: "Содержимое"
@@ -0,0 +1,9 @@
1
+ class CreateC80FeaturesParas < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_features_paras, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :title
5
+ t.text :content
6
+ t.string :image
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,30 @@
1
+ require_relative '../../app/helpers/c80_features/application_helper'
2
+
3
+ module C80Features
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace C80Features
6
+
7
+ initializer :c80_features_engine do
8
+ if defined?(ActiveAdmin)
9
+ ActiveAdmin.application.load_paths += Dir["#{config.root}/app/models/**/"]
10
+ #ActiveAdmin.application.load_paths += Dir["#{config.root}/app/models/concerns/**/"]
11
+ ActiveAdmin.application.load_paths += Dir["#{config.root}/app/admin/c80_features/**/"]
12
+ # ActiveAdmin.application.load_paths += Dir["#{config.root}/app/jobs/**/"]
13
+ end
14
+
15
+ ActiveSupport.on_load(:action_view) do
16
+ include C80Features::ApplicationHelper
17
+ end
18
+
19
+ end
20
+
21
+ initializer :append_migrations do |app|
22
+ unless app.root.to_s.match root.to_s
23
+ config.paths['db/migrate'].expanded.each do |expanded_path|
24
+ app.config.paths['db/migrate'] << expanded_path
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module C80Features
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,8 @@
1
+ require 'c80_features/version'
2
+ require 'c80_features/engine'
3
+
4
+ module C80Features
5
+ def self.table_name_prefix
6
+ 'c80_features_'
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: c80_features
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - C80609A
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.1'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 4.1.4
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '4.1'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 4.1.4
61
+ - !ruby/object:Gem::Dependency
62
+ name: activeadmin
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: carrierwave
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ description: "Adds model Features::Para (paragraph) to site,\nwhich are usually enumerated
90
+ as text blocks one by one in a single row\n(e.g.: testimonials, features, trust
91
+ symbols etc.). "
92
+ email:
93
+ - c080609a@gmail.com
94
+ executables: []
95
+ extensions: []
96
+ extra_rdoc_files: []
97
+ files:
98
+ - ".gitignore"
99
+ - ".travis.yml"
100
+ - CODE_OF_CONDUCT.md
101
+ - Gemfile
102
+ - LICENSE.txt
103
+ - README.md
104
+ - Rakefile
105
+ - app/admin/c80_features/paras.rb
106
+ - app/helpers/c80_features/application_helper.rb
107
+ - app/models/c80_features/para.rb
108
+ - app/models/c80_features/para_validator.rb
109
+ - app/uploaders/c80_features/para_uploader.rb
110
+ - app/views/c80_features/_features_block.html.erb
111
+ - app/views/c80_features/_features_block_with_images.html.erb
112
+ - bin/console
113
+ - bin/setup
114
+ - c80_features.gemspec
115
+ - config/locales/ru.yml
116
+ - db/migrate/20151216132727_create_c80_features_paras.rb
117
+ - lib/c80_features.rb
118
+ - lib/c80_features/engine.rb
119
+ - lib/c80_features/version.rb
120
+ homepage: ''
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.4.7
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: Features
144
+ test_files: []