push_type_core 0.1.1 → 0.2.0.beta2
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/app/controllers/front_end_controller.rb +5 -1
- data/app/fields/push_type/array_field.rb +15 -0
- data/app/fields/push_type/tag_list_field.rb +29 -0
- data/app/models/concerns/push_type/customizable.rb +10 -4
- data/app/models/concerns/push_type/nestable.rb +29 -5
- data/app/models/concerns/push_type/publishable.rb +3 -2
- data/app/models/concerns/push_type/unexposable.rb +29 -0
- data/app/models/push_type/asset.rb +19 -13
- data/app/models/push_type/node.rb +1 -0
- data/db/migrate/20141117170533_create_push_type_users.rb +1 -1
- data/db/migrate/20141117204630_create_push_type_nodes.rb +1 -1
- data/lib/generators/push_type/dummy/dummy_generator.rb +1 -1
- data/lib/generators/push_type/dummy/templates/page.rb +1 -1
- data/lib/generators/push_type/install/install_generator.rb +4 -4
- data/lib/generators/push_type/install/templates/push_type.rb +11 -1
- data/lib/push_type/core/engine.rb +4 -2
- data/lib/push_type/core.rb +6 -4
- data/lib/push_type/field_type.rb +13 -2
- data/lib/push_type/rails/routes.rb +1 -1
- data/lib/push_type/tag_list_query.rb +38 -0
- data/lib/push_type/testing/common_rake.rb +2 -2
- data/lib/push_type/testing/setup.rb +6 -2
- data/test/dummy/app/assets/stylesheets/application.css +1 -1
- data/test/dummy/bin/rails +1 -1
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/environments/development.rb +4 -0
- data/test/dummy/config/environments/production.rb +13 -12
- data/test/dummy/config/environments/test.rb +5 -2
- data/test/dummy/config/initializers/assets.rb +3 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +1 -1
- data/test/dummy/config/initializers/push_type.rb +11 -1
- data/test/dummy/config/secrets.yml +2 -2
- data/test/dummy/config.ru +1 -1
- data/test/dummy/db/migrate/{20150108182218_create_push_type_users.push_type.rb → 20150208150305_create_push_type_users.push_type.rb} +1 -1
- data/test/dummy/db/migrate/{20150108182219_create_push_type_nodes.push_type.rb → 20150208150306_create_push_type_nodes.push_type.rb} +1 -1
- data/test/dummy/db/migrate/{20150108182220_create_push_type_node_hierarchies.push_type.rb → 20150208150307_create_push_type_node_hierarchies.push_type.rb} +0 -0
- data/test/dummy/db/migrate/{20150108182221_create_push_type_assets.push_type.rb → 20150208150308_create_push_type_assets.push_type.rb} +0 -0
- data/test/dummy/db/schema.rb +7 -7
- data/test/dummy/log/test.log +1311 -990
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/generators/config/initializers/push_type.rb +11 -1
- data/test/lib/push_type/core_test.rb +24 -7
- data/test/lib/push_type/field_type_test.rb +25 -4
- data/test/lib/push_type/tag_list_query_test.rb +36 -0
- data/test/models/concerns/push_type/customizable_test.rb +20 -3
- data/test/models/concerns/push_type/nestable_test.rb +41 -15
- data/test/models/concerns/push_type/publishable_test.rb +0 -1
- data/test/models/concerns/push_type/unexposable_test.rb +33 -0
- data/test/models/push_type/asset_test.rb +5 -4
- data/test/test_helper.rb +2 -0
- metadata +26 -17
- data/app/fields/push_type/rich_text_field.rb +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 913da9e49a877e4f10781017676afbf8f87356a9
|
|
4
|
+
data.tar.gz: 5d277256f7eb5ca7b6f744dbfb203b6169f39f23
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9dede54e2d4e68d5ffe2a552abe6d9f6e0066c754d260a9af0055afc50128ea212fecee691fc748e4d43305655a41be47122ba3dd6d278b5ea251daef56d4fa
|
|
7
|
+
data.tar.gz: e204e54912e6538c9350c6aad38cc8522b55d7bf341cf88679c78427380126f790e6bc7ebfccffdfca4dc4979689ef34eee928bea99df140918a964ceb44be47
|
|
@@ -9,9 +9,13 @@ class FrontEndController < ApplicationController
|
|
|
9
9
|
private
|
|
10
10
|
|
|
11
11
|
def load_node
|
|
12
|
-
@node = PushType::Node.published.find_by_path
|
|
12
|
+
@node = PushType::Node.published.find_by_path permalink_parts
|
|
13
13
|
raise ActiveRecord::RecordNotFound unless @node
|
|
14
14
|
instance_variable_set "@#{ @node.type.underscore }", @node
|
|
15
15
|
end
|
|
16
|
+
|
|
17
|
+
def permalink_parts
|
|
18
|
+
params[:permalink].split('/')
|
|
19
|
+
end
|
|
16
20
|
|
|
17
21
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'push_type/tag_list_query'
|
|
2
|
+
|
|
3
|
+
module PushType
|
|
4
|
+
class TagListField < ArrayField
|
|
5
|
+
|
|
6
|
+
def template
|
|
7
|
+
@opts[:template] || 'tag_list'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def html_options
|
|
11
|
+
{ multiple: true, placeholder: 'Tags...' }.merge(super).merge(class: 'tagsinput')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_json(val)
|
|
15
|
+
super.reject(&:blank?)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def from_json(val)
|
|
19
|
+
super.reject(&:blank?)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
initialized_on_node do |object, field|
|
|
23
|
+
object.define_singleton_method "all_#{ field.name }".to_sym do |*args|
|
|
24
|
+
TagListQuery.new(field.name, object.name.underscore.to_sym).all *args
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -6,6 +6,10 @@ module PushType
|
|
|
6
6
|
self.class.fields
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
+
def field_params
|
|
10
|
+
fields.map { |k, field| field.param }
|
|
11
|
+
end
|
|
12
|
+
|
|
9
13
|
module ClassMethods
|
|
10
14
|
|
|
11
15
|
attr_reader :fields
|
|
@@ -26,8 +30,12 @@ module PushType
|
|
|
26
30
|
store_accessor :field_store, name
|
|
27
31
|
|
|
28
32
|
validates name, opts[:validates] if opts[:validates]
|
|
29
|
-
|
|
33
|
+
|
|
30
34
|
override_accessor fields[name]
|
|
35
|
+
|
|
36
|
+
if block = field_factory(kind).initialized_blk
|
|
37
|
+
block.call(self, fields[name])
|
|
38
|
+
end
|
|
31
39
|
end
|
|
32
40
|
|
|
33
41
|
protected
|
|
@@ -42,12 +50,10 @@ module PushType
|
|
|
42
50
|
|
|
43
51
|
def override_accessor(f)
|
|
44
52
|
define_method "#{f.name}=".to_sym do |val|
|
|
45
|
-
return unless val
|
|
46
53
|
super f.to_json(val)
|
|
47
54
|
end
|
|
48
55
|
define_method f.name do
|
|
49
|
-
|
|
50
|
-
f.from_json val
|
|
56
|
+
f.from_json super()
|
|
51
57
|
end
|
|
52
58
|
end
|
|
53
59
|
|
|
@@ -2,19 +2,43 @@ module PushType
|
|
|
2
2
|
module Nestable
|
|
3
3
|
extend ActiveSupport::Concern
|
|
4
4
|
|
|
5
|
-
def
|
|
6
|
-
self.class.
|
|
5
|
+
def child_nodes
|
|
6
|
+
self.class.child_nodes
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def custom_child_order?
|
|
10
|
+
self.class.child_order.present?
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def sortable?
|
|
14
|
+
!custom_child_order?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def children
|
|
18
|
+
return super() unless custom_child_order?
|
|
19
|
+
super.reorder(self.class.child_order)
|
|
7
20
|
end
|
|
8
21
|
|
|
9
22
|
module ClassMethods
|
|
10
23
|
|
|
11
|
-
|
|
12
|
-
|
|
24
|
+
attr_reader :child_order
|
|
25
|
+
|
|
26
|
+
def child_nodes
|
|
27
|
+
types = @child_nodes || PushType.config.root_nodes
|
|
13
28
|
PushType.node_types_from_list(types)
|
|
14
29
|
end
|
|
15
30
|
|
|
16
31
|
def has_child_nodes(*args)
|
|
17
|
-
|
|
32
|
+
if args.last.is_a? Hash
|
|
33
|
+
opts = args.pop
|
|
34
|
+
@child_order = case opts[:order]
|
|
35
|
+
when :blog then ['published_at DESC', 'created_at DESC']
|
|
36
|
+
else opts[:order]
|
|
37
|
+
end
|
|
38
|
+
else
|
|
39
|
+
@child_order = nil
|
|
40
|
+
end
|
|
41
|
+
@child_nodes = args
|
|
18
42
|
end
|
|
19
43
|
|
|
20
44
|
end
|
|
@@ -6,7 +6,8 @@ module PushType
|
|
|
6
6
|
enum status: [ :draft, :published ]
|
|
7
7
|
|
|
8
8
|
scope :published, -> {
|
|
9
|
-
not_trash.
|
|
9
|
+
not_trash.exposed.
|
|
10
|
+
where(['push_type_nodes.status = ? AND push_type_nodes.published_at <= ?', self.statuses[:published], Time.zone.now]).
|
|
10
11
|
where(['push_type_nodes.published_to IS NULL OR push_type_nodes.published_to > ?', Time.zone.now])
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -36,7 +37,7 @@ module PushType
|
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
def set_default_status
|
|
39
|
-
self.status
|
|
40
|
+
self.status ||= self.class.statuses[:draft]
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module PushType
|
|
2
|
+
module Unexposable
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
included do
|
|
6
|
+
scope :exposed, -> {
|
|
7
|
+
node_types = PushType.unexposed_nodes
|
|
8
|
+
node_types.present? ? where(['push_type_nodes.type NOT IN (?)', node_types]) : all
|
|
9
|
+
}
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def exposed?
|
|
13
|
+
self.class.exposed?
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
module ClassMethods
|
|
17
|
+
|
|
18
|
+
def unexpose!
|
|
19
|
+
PushType.config.unexposed_nodes.push(self.name.underscore.to_sym).uniq!
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def exposed?
|
|
23
|
+
!PushType.unexposed_nodes.include?(self.name)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -11,6 +11,9 @@ module PushType
|
|
|
11
11
|
|
|
12
12
|
default_scope { order(created_at: :desc) }
|
|
13
13
|
|
|
14
|
+
scope :image, -> { where(['mime_type LIKE ?', 'image/%']) }
|
|
15
|
+
scope :not_image, -> { where(['mime_type NOT LIKE ?', 'image/%']) }
|
|
16
|
+
|
|
14
17
|
before_create :set_mime_type
|
|
15
18
|
after_destroy :destroy_file!
|
|
16
19
|
|
|
@@ -33,26 +36,29 @@ module PushType
|
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
def media(style = nil)
|
|
36
|
-
if image?
|
|
37
|
-
|
|
39
|
+
return file if !image? || style.blank?
|
|
40
|
+
|
|
41
|
+
case style.to_sym
|
|
42
|
+
when :original then file
|
|
43
|
+
when :push_type_thumb then preview_thumb
|
|
44
|
+
else
|
|
45
|
+
size = PushType.config.media_styles[style.to_sym] || style
|
|
46
|
+
file.thumb(size)
|
|
38
47
|
end
|
|
39
|
-
size ? file.thumb(size) : file
|
|
40
48
|
end
|
|
41
49
|
|
|
42
|
-
def
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
def preview_thumb(size = '300x300')
|
|
51
|
+
return unless image?
|
|
52
|
+
|
|
53
|
+
width, height = size.split('x').map(&:to_i)
|
|
54
|
+
|
|
55
|
+
if file.width >= width && file.height >= height
|
|
56
|
+
file.thumb("#{ size }#")
|
|
46
57
|
else
|
|
47
|
-
"
|
|
58
|
+
file.convert("-background white -gravity center -extent #{ size }")
|
|
48
59
|
end
|
|
49
60
|
end
|
|
50
61
|
|
|
51
|
-
def as_json(options = nil)
|
|
52
|
-
options = { only: [:id, :file_name, :file_size, :mime_type, :created_at], methods: [:new_record?, :image?, :description_or_file_name, :preview_thumb_url] } if options.empty?
|
|
53
|
-
super(options)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
62
|
private
|
|
57
63
|
|
|
58
64
|
def set_mime_type
|
|
@@ -23,7 +23,7 @@ module PushType
|
|
|
23
23
|
opts[:skip_gemfile] = true
|
|
24
24
|
opts[:skip_bundle] = true
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
say "Generating dummy Rails application... (#{options[:lib_name]})"
|
|
27
27
|
invoke Rails::Generators::AppGenerator, [ File.expand_path(dummy_path, destination_root) ], opts
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -15,14 +15,14 @@ module PushType
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def install_migrations
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
say '- Copying migrations'
|
|
19
|
+
rake 'railties:install:migrations'
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def run_migrations
|
|
23
23
|
if options[:migrate]
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
say '- Running migrations'
|
|
25
|
+
rake 'db:migrate'
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
PushType.setup do |config|
|
|
2
2
|
|
|
3
|
-
config.
|
|
3
|
+
#config.root_nodes = :all
|
|
4
|
+
|
|
5
|
+
#config.home_slug = 'home'
|
|
6
|
+
|
|
7
|
+
#config.unexposed_nodes = []
|
|
8
|
+
|
|
9
|
+
#config.media_styles = {
|
|
10
|
+
# large: '1024x1024>',
|
|
11
|
+
# medium: '512x512>',
|
|
12
|
+
# small: '256x256>'
|
|
13
|
+
#}
|
|
4
14
|
|
|
5
15
|
end
|
|
@@ -4,9 +4,11 @@ module PushType
|
|
|
4
4
|
isolate_namespace PushType
|
|
5
5
|
engine_name 'push_type'
|
|
6
6
|
|
|
7
|
-
config.
|
|
7
|
+
config.root_nodes = :all
|
|
8
8
|
|
|
9
|
-
config.
|
|
9
|
+
config.home_slug = 'home'
|
|
10
|
+
|
|
11
|
+
config.unexposed_nodes = []
|
|
10
12
|
|
|
11
13
|
config.media_styles = {
|
|
12
14
|
large: '1024x1024>',
|
data/lib/push_type/core.rb
CHANGED
|
@@ -13,8 +13,12 @@ module PushType
|
|
|
13
13
|
yield config if block
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def
|
|
17
|
-
node_types_from_list(config.
|
|
16
|
+
def root_nodes
|
|
17
|
+
node_types_from_list(config.root_nodes)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def unexposed_nodes
|
|
21
|
+
node_types_from_list(config.unexposed_nodes).map(&:camelcase)
|
|
18
22
|
end
|
|
19
23
|
|
|
20
24
|
def node_types_from_list(types = nil)
|
|
@@ -41,5 +45,3 @@ end
|
|
|
41
45
|
require 'push_type/core/engine'
|
|
42
46
|
require 'push_type/rails/routes'
|
|
43
47
|
require 'push_type/field_type'
|
|
44
|
-
|
|
45
|
-
|
data/lib/push_type/field_type.rb
CHANGED
|
@@ -3,11 +3,22 @@ module PushType
|
|
|
3
3
|
|
|
4
4
|
attr_reader :name
|
|
5
5
|
|
|
6
|
+
class << self
|
|
7
|
+
attr_reader :initialized_blk
|
|
8
|
+
def initialized_on_node(&block)
|
|
9
|
+
@initialized_blk = block
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
6
13
|
def initialize(name, opts = {})
|
|
7
14
|
@name = name.to_s
|
|
8
15
|
@opts = opts
|
|
9
16
|
end
|
|
10
17
|
|
|
18
|
+
def param
|
|
19
|
+
name.to_sym
|
|
20
|
+
end
|
|
21
|
+
|
|
11
22
|
def kind
|
|
12
23
|
self.class.name.demodulize.underscore.gsub(/_(field|type)$/, '')
|
|
13
24
|
end
|
|
@@ -38,11 +49,11 @@ module PushType
|
|
|
38
49
|
end
|
|
39
50
|
|
|
40
51
|
def to_json(val)
|
|
41
|
-
val
|
|
52
|
+
val
|
|
42
53
|
end
|
|
43
54
|
|
|
44
55
|
def from_json(val)
|
|
45
|
-
val
|
|
56
|
+
val
|
|
46
57
|
end
|
|
47
58
|
|
|
48
59
|
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module PushType
|
|
2
|
+
class TagListQuery
|
|
3
|
+
|
|
4
|
+
def initialize(name, type)
|
|
5
|
+
@name = name
|
|
6
|
+
@type = type
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def all(opts = {})
|
|
10
|
+
@opts = { type: @type }.merge(opts)
|
|
11
|
+
connection.select_all(query).rows.flatten
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def node_types
|
|
15
|
+
PushType.node_types_from_list(@opts[:type]).map { |n| "'#{ n.camelcase }'" }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def connection
|
|
21
|
+
PushType::Node.connection
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def query
|
|
25
|
+
[
|
|
26
|
+
"SELECT DISTINCT jsonb_array_elements_text(field_store->'#{ @name }') AS _tag",
|
|
27
|
+
"FROM push_type_nodes",
|
|
28
|
+
where_sql,
|
|
29
|
+
"ORDER BY _tag"
|
|
30
|
+
].compact.join(' ')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def where_sql
|
|
34
|
+
"WHERE push_type_nodes.type IN (#{ node_types.join(', ') })" unless @opts[:type] == :all || node_types.blank?
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -13,9 +13,9 @@ namespace :common do
|
|
|
13
13
|
PushType::DummyGenerator.start opts
|
|
14
14
|
|
|
15
15
|
Dir.chdir File.join(args[:base_path], args[:dummy_path]) do
|
|
16
|
-
|
|
16
|
+
system 'bundle exec rake db:drop db:create'
|
|
17
|
+
PushType::InstallGenerator.start ['--quiet']
|
|
17
18
|
PushType::NodeGenerator.start ['page', '--quiet']
|
|
18
|
-
system 'bundle exec rake db:drop db:create db:migrate'
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
require 'database_cleaner'
|
|
2
2
|
|
|
3
|
+
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
|
4
|
+
# to be shown.
|
|
5
|
+
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
|
6
|
+
|
|
3
7
|
# Load support files
|
|
4
8
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
5
9
|
|
|
@@ -8,10 +12,10 @@ DatabaseCleaner.clean_with :truncation
|
|
|
8
12
|
Dragonfly.app.use_datastore :memory
|
|
9
13
|
|
|
10
14
|
class ActiveSupport::TestCase
|
|
11
|
-
ActiveRecord::Migration.check_pending!
|
|
12
|
-
|
|
13
15
|
before :each do
|
|
14
16
|
DatabaseCleaner.start
|
|
17
|
+
PushType.config.root_nodes = :all
|
|
18
|
+
PushType.config.unexposed_nodes = []
|
|
15
19
|
end
|
|
16
20
|
|
|
17
21
|
after :each do
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* listed below.
|
|
4
4
|
*
|
|
5
5
|
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
-
* or vendor/assets/stylesheets
|
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
|
7
7
|
*
|
|
8
8
|
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
9
|
* compiled file so the styles you add here take precedence over styles defined in any styles
|
data/test/dummy/bin/rails
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'pathname'
|
|
3
|
+
|
|
4
|
+
# path to your application root.
|
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
|
6
|
+
|
|
7
|
+
Dir.chdir APP_ROOT do
|
|
8
|
+
# This script is a starting point to setup your application.
|
|
9
|
+
# Add necessary setup steps to this file:
|
|
10
|
+
|
|
11
|
+
puts "== Installing dependencies =="
|
|
12
|
+
system "gem install bundler --conservative"
|
|
13
|
+
system "bundle check || bundle install"
|
|
14
|
+
|
|
15
|
+
# puts "\n== Copying sample files =="
|
|
16
|
+
# unless File.exist?("config/database.yml")
|
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
|
18
|
+
# end
|
|
19
|
+
|
|
20
|
+
puts "\n== Preparing database =="
|
|
21
|
+
system "bin/rake db:setup"
|
|
22
|
+
|
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
|
24
|
+
system "rm -f log/*"
|
|
25
|
+
system "rm -rf tmp/cache"
|
|
26
|
+
|
|
27
|
+
puts "\n== Restarting application server =="
|
|
28
|
+
system "touch tmp/restart.txt"
|
|
29
|
+
end
|
|
@@ -27,6 +27,10 @@ Rails.application.configure do
|
|
|
27
27
|
# number of complex assets.
|
|
28
28
|
config.assets.debug = true
|
|
29
29
|
|
|
30
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
|
31
|
+
# yet still be able to expire them through the digest params.
|
|
32
|
+
config.assets.digest = true
|
|
33
|
+
|
|
30
34
|
# Adds additional error checking when serving assets at runtime.
|
|
31
35
|
# Checks for improperly declared sprockets dependencies.
|
|
32
36
|
# Raises helpful error messages.
|
|
@@ -16,11 +16,13 @@ Rails.application.configure do
|
|
|
16
16
|
|
|
17
17
|
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
|
18
18
|
# Add `rack-cache` to your Gemfile before enabling this.
|
|
19
|
-
# For large-scale production use, consider using a caching reverse proxy like
|
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like
|
|
20
|
+
# NGINX, varnish or squid.
|
|
20
21
|
# config.action_dispatch.rack_cache = true
|
|
21
22
|
|
|
22
|
-
# Disable
|
|
23
|
-
|
|
23
|
+
# Disable serving static files from the `/public` folder by default since
|
|
24
|
+
# Apache or NGINX already handles this.
|
|
25
|
+
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
|
24
26
|
|
|
25
27
|
# Compress JavaScripts and CSS.
|
|
26
28
|
config.assets.js_compressor = :uglifier
|
|
@@ -29,20 +31,22 @@ Rails.application.configure do
|
|
|
29
31
|
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
|
30
32
|
config.assets.compile = false
|
|
31
33
|
|
|
32
|
-
#
|
|
34
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
|
35
|
+
# yet still be able to expire them through the digest params.
|
|
33
36
|
config.assets.digest = true
|
|
34
37
|
|
|
35
38
|
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
|
36
39
|
|
|
37
40
|
# Specifies the header that your server uses for sending files.
|
|
38
|
-
# config.action_dispatch.x_sendfile_header =
|
|
39
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for
|
|
41
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
|
42
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
|
40
43
|
|
|
41
44
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
|
42
45
|
# config.force_ssl = true
|
|
43
46
|
|
|
44
|
-
#
|
|
45
|
-
|
|
47
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
|
48
|
+
# when problems arise.
|
|
49
|
+
config.log_level = :debug
|
|
46
50
|
|
|
47
51
|
# Prepend all log lines with the following tags.
|
|
48
52
|
# config.log_tags = [ :subdomain, :uuid ]
|
|
@@ -54,7 +58,7 @@ Rails.application.configure do
|
|
|
54
58
|
# config.cache_store = :mem_cache_store
|
|
55
59
|
|
|
56
60
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
|
57
|
-
# config.action_controller.asset_host =
|
|
61
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
|
58
62
|
|
|
59
63
|
# Ignore bad email addresses and do not raise email delivery errors.
|
|
60
64
|
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
|
@@ -67,9 +71,6 @@ Rails.application.configure do
|
|
|
67
71
|
# Send deprecation notices to registered listeners.
|
|
68
72
|
config.active_support.deprecation = :notify
|
|
69
73
|
|
|
70
|
-
# Disable automatic flushing of the log to improve performance.
|
|
71
|
-
# config.autoflush_log = false
|
|
72
|
-
|
|
73
74
|
# Use default logging formatter so that PID and timestamp are not suppressed.
|
|
74
75
|
config.log_formatter = ::Logger::Formatter.new
|
|
75
76
|
|
|
@@ -12,8 +12,8 @@ Rails.application.configure do
|
|
|
12
12
|
# preloads Rails for running tests, you may have to set it to true.
|
|
13
13
|
config.eager_load = false
|
|
14
14
|
|
|
15
|
-
# Configure static
|
|
16
|
-
config.
|
|
15
|
+
# Configure static file server for tests with Cache-Control for performance.
|
|
16
|
+
config.serve_static_files = true
|
|
17
17
|
config.static_cache_control = 'public, max-age=3600'
|
|
18
18
|
|
|
19
19
|
# Show full error reports and disable caching.
|
|
@@ -31,6 +31,9 @@ Rails.application.configure do
|
|
|
31
31
|
# ActionMailer::Base.deliveries array.
|
|
32
32
|
config.action_mailer.delivery_method = :test
|
|
33
33
|
|
|
34
|
+
# Randomize the order test cases are executed.
|
|
35
|
+
config.active_support.test_order = :random
|
|
36
|
+
|
|
34
37
|
# Print deprecation notices to the stderr.
|
|
35
38
|
config.active_support.deprecation = :stderr
|
|
36
39
|
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
# Version of your assets, change this if you want to expire all your assets.
|
|
4
4
|
Rails.application.config.assets.version = '1.0'
|
|
5
5
|
|
|
6
|
+
# Add additional assets to the asset load path
|
|
7
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
|
8
|
+
|
|
6
9
|
# Precompile additional assets.
|
|
7
10
|
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
|
8
11
|
# Rails.application.config.assets.precompile += %w( search.js )
|