mix-rails-core 0.22.0 → 0.23.0
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.
- data/app/models/admix/categories_datagrid.rb +1 -2
- data/app/models/attachment.rb +4 -3
- data/app/models/categorization.rb +5 -0
- data/app/models/category.rb +3 -2
- data/app/models/concerns/attachment.rb +0 -3
- data/app/uploaders/core/file_uploader.rb +1 -3
- data/config/initializers/carrierwave.rb +1 -5
- data/config/initializers/defaults_rails.rb +1 -0
- data/config/locales/core.pt-BR.yml +2 -1
- data/config/routes.rb +0 -2
- data/db/migrate/20130206195145_create_attachments.rb +10 -0
- data/db/migrate/20130206195329_create_categories.rb +8 -0
- data/db/migrate/20130207132351_create_categorizations.rb +9 -0
- data/lib/mix-rails-core.rb +3 -22
- data/lib/mix-rails-core/engine.rb +2 -4
- data/lib/mix-rails-core/version.rb +1 -1
- metadata +10 -72
- data/app/controllers/gridfs_controller.rb +0 -31
- data/config/initializers/mongoid.rb +0 -1
- data/lib/mix-rails-core/gridfs.rb +0 -32
@@ -5,11 +5,10 @@ class Admix::CategoriesDatagrid
|
|
5
5
|
extend AdmixHelper
|
6
6
|
|
7
7
|
scope do
|
8
|
-
Category
|
8
|
+
Category
|
9
9
|
end
|
10
10
|
|
11
11
|
column :name, :header => input_label(:categories, :name)
|
12
|
-
column :_type, :header => input_label(:categories, :_type)
|
13
12
|
|
14
13
|
include Admix::TableActions
|
15
14
|
end
|
data/app/models/attachment.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
-
class Attachment
|
2
|
-
|
3
|
-
|
1
|
+
class Attachment < ActiveRecord::Base
|
2
|
+
attr_accessible :file, :name
|
3
|
+
mount_uploader :file, Core::FileUploader
|
4
|
+
end
|
data/app/models/category.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'carrierwave/processing/mini_magick'
|
3
|
-
require 'mix-rails-core/gridfs'
|
4
3
|
|
5
4
|
class Core::FileUploader < CarrierWave::Uploader::Base
|
6
5
|
|
@@ -13,13 +12,12 @@ class Core::FileUploader < CarrierWave::Uploader::Base
|
|
13
12
|
include Sprockets::Helpers::IsolatedHelper
|
14
13
|
|
15
14
|
# Choose what kind of storage to use for this uploader:
|
16
|
-
storage :grid_fs
|
17
15
|
# storage :fog
|
18
16
|
|
19
17
|
# Override the directory where uploaded files will be stored.
|
20
18
|
# This is a sensible default for uploaders that are meant to be mounted:
|
21
19
|
def store_dir
|
22
|
-
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
20
|
+
"system/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
23
21
|
end
|
24
22
|
|
25
23
|
def cache_dir
|
@@ -0,0 +1 @@
|
|
1
|
+
ActiveRecord::Base.include_root_in_json = false
|
@@ -20,10 +20,10 @@ pt-BR:
|
|
20
20
|
categories:
|
21
21
|
categories: 'Categorias'
|
22
22
|
category: 'Categoria'
|
23
|
-
|
24
23
|
simple_form:
|
25
24
|
labels:
|
26
25
|
defaults:
|
26
|
+
cell: 'Celular'
|
27
27
|
code: 'Código'
|
28
28
|
lamina_image: 'Imagem de lâmina'
|
29
29
|
featured_image: 'Imagem destaque'
|
@@ -69,3 +69,4 @@ pt-BR:
|
|
69
69
|
password: 'Sua senha'
|
70
70
|
errors:
|
71
71
|
invalid_url: 'O formato da url está incorreto'
|
72
|
+
dependent: 'Não é possível deletar este registro pois está associado a outros.'
|
data/config/routes.rb
CHANGED
data/lib/mix-rails-core.rb
CHANGED
@@ -1,45 +1,26 @@
|
|
1
|
-
require 'mix-rails-core/railtie'
|
2
|
-
|
3
|
-
|
1
|
+
require 'mix-rails-core/railtie'
|
4
2
|
require 'mix-rails-core/engine'
|
5
|
-
|
6
3
|
require 'enumerize'
|
7
|
-
|
8
4
|
require 'fancybox-rails'
|
9
|
-
|
10
5
|
require 'rails-i18n'
|
11
|
-
|
12
6
|
require 'activevalidators'
|
13
7
|
require 'i18n_routing'
|
14
|
-
|
15
8
|
require 'simple-navigation'
|
16
9
|
require 'simple-navigation-bootstrap'
|
17
10
|
require 'breadcrumbs'
|
18
11
|
require 'will_paginate'
|
19
|
-
|
20
12
|
require 'coffee-script'
|
21
13
|
require 'coffee-filter'
|
22
|
-
|
23
|
-
|
24
|
-
# TODO: Create two new to separate the mix-rails-core-core(class api) from the mix-rails-orm(database-access)
|
25
|
-
require 'mongoid'
|
26
|
-
require 'mongoid_slug'
|
27
|
-
|
28
|
-
#require 'bson_ext'
|
29
|
-
require 'mongo'
|
30
|
-
require 'carrierwave/mongoid'
|
14
|
+
require 'carrierwave'
|
31
15
|
require 'mini_magick'
|
32
16
|
require 'haml_coffee_assets'
|
33
|
-
|
34
17
|
require 'mail_form'
|
35
18
|
require 'simple_form'
|
36
|
-
|
37
19
|
require 'rails-backbone'
|
38
|
-
|
39
20
|
require 'bootstrap-sass'
|
40
21
|
require 'jquery-qtip2-rails'
|
41
|
-
|
42
22
|
require 'authority'
|
23
|
+
require 'default_value_for'
|
43
24
|
|
44
25
|
module MixRailsCore
|
45
26
|
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
module MixRailsCore
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
|
4
|
-
config.autoload_paths += Dir["#{config.root}/lib/**/"]
|
5
|
-
config.autoload_paths += Dir["#{config.root}/app/models/**/"]
|
6
|
-
|
7
|
-
|
4
|
+
# config.autoload_paths += Dir["#{config.root}/lib/**/"]
|
5
|
+
# config.autoload_paths += Dir["#{config.root}/app/models/**/"]
|
8
6
|
|
9
7
|
config.generators do |g|
|
10
8
|
g.test_framework :rspec
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mix-rails-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -124,71 +124,7 @@ dependencies:
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ! '>='
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '0'
|
134
|
-
type: :runtime
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ! '>='
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '0'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: mongoid_slug
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
150
|
-
type: :runtime
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
158
|
-
- !ruby/object:Gem::Dependency
|
159
|
-
name: bson_ext
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
|
-
requirements:
|
163
|
-
- - ! '>='
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '0'
|
166
|
-
type: :runtime
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
|
-
requirements:
|
171
|
-
- - ! '>='
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
174
|
-
- !ruby/object:Gem::Dependency
|
175
|
-
name: mongo
|
176
|
-
requirement: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
|
-
requirements:
|
179
|
-
- - ! '>='
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
version: '0'
|
182
|
-
type: :runtime
|
183
|
-
prerelease: false
|
184
|
-
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
|
-
requirements:
|
187
|
-
- - ! '>='
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
version: '0'
|
190
|
-
- !ruby/object:Gem::Dependency
|
191
|
-
name: carrierwave-mongoid
|
127
|
+
name: carrierwave
|
192
128
|
requirement: !ruby/object:Gem::Requirement
|
193
129
|
none: false
|
194
130
|
requirements:
|
@@ -441,7 +377,6 @@ files:
|
|
441
377
|
- app/inputs/datepicker_input.rb
|
442
378
|
- app/controllers/admix/categories_controller.rb
|
443
379
|
- app/controllers/mix_controller.rb
|
444
|
-
- app/controllers/gridfs_controller.rb
|
445
380
|
- app/assets/stylesheets/jplayer/jplayer.pink.flag.css
|
446
381
|
- app/assets/stylesheets/colorbox.css
|
447
382
|
- app/assets/stylesheets/colorbox/colorbox.css.erb
|
@@ -1189,17 +1124,20 @@ files:
|
|
1189
1124
|
- app/models/attachment.rb
|
1190
1125
|
- app/models/concerns/attachment.rb
|
1191
1126
|
- app/models/concerns/category.rb
|
1127
|
+
- app/models/categorization.rb
|
1192
1128
|
- app/models/category.rb
|
1193
1129
|
- app/views/mix/_title.html.haml
|
1194
1130
|
- app/views/admix/categories/_form_fields.haml
|
1195
1131
|
- app/views/admix/categories/_show.haml
|
1196
1132
|
- config/locales/core.pt-BR.yml
|
1197
1133
|
- config/initializers/authority.rb
|
1198
|
-
- config/initializers/
|
1134
|
+
- config/initializers/defaults_rails.rb
|
1199
1135
|
- config/initializers/carrierwave.rb
|
1200
1136
|
- config/routes.rb
|
1137
|
+
- db/migrate/20130207132351_create_categorizations.rb
|
1138
|
+
- db/migrate/20130206195145_create_attachments.rb
|
1139
|
+
- db/migrate/20130206195329_create_categories.rb
|
1201
1140
|
- lib/tasks/mix-rails_tasks.rake
|
1202
|
-
- lib/mix-rails-core/gridfs.rb
|
1203
1141
|
- lib/mix-rails-core/railtie.rb
|
1204
1142
|
- lib/mix-rails-core/concerns/engine.rb
|
1205
1143
|
- lib/mix-rails-core/version.rb
|
@@ -1222,7 +1160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1222
1160
|
version: '0'
|
1223
1161
|
segments:
|
1224
1162
|
- 0
|
1225
|
-
hash:
|
1163
|
+
hash: 4297422372143745569
|
1226
1164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1227
1165
|
none: false
|
1228
1166
|
requirements:
|
@@ -1231,7 +1169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1231
1169
|
version: '0'
|
1232
1170
|
segments:
|
1233
1171
|
- 0
|
1234
|
-
hash:
|
1172
|
+
hash: 4297422372143745569
|
1235
1173
|
requirements: []
|
1236
1174
|
rubyforge_project:
|
1237
1175
|
rubygems_version: 1.8.24
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'mongo'
|
2
|
-
require 'mix-rails-core/gridfs'
|
3
|
-
require 'fileutils'
|
4
|
-
|
5
|
-
class GridfsController < ActionController::Metal
|
6
|
-
def serve
|
7
|
-
|
8
|
-
file_dir = File.expand_path '../', "#{Rails.root.join('public')}#{env['PATH_INFO']}"
|
9
|
-
FileUtils.mkdir_p file_dir unless Dir.exists?(file_dir)
|
10
|
-
gridfs_file = MixRailsCore::Gridfs::read_file(env["PATH_INFO"])
|
11
|
-
tmp_file_name = "#{Rails.root.join('public')}#{env['PATH_INFO']}"
|
12
|
-
file_content = gridfs_file.read
|
13
|
-
File.open(tmp_file_name, 'wb') do |f|
|
14
|
-
f.write(file_content)
|
15
|
-
f.close
|
16
|
-
end
|
17
|
-
|
18
|
-
begin
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
self.response_body = file_content
|
23
|
-
|
24
|
-
self.content_type = gridfs_file.content_type
|
25
|
-
rescue
|
26
|
-
self.status = :not_found
|
27
|
-
self.content_type = 'text/plain'
|
28
|
-
self.response_body = ''
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
#Mongoid.include_root_in_json = false
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module MixRailsCore
|
2
|
-
module Gridfs
|
3
|
-
|
4
|
-
mattr_accessor :read_file
|
5
|
-
|
6
|
-
def self.read_file(filepath)
|
7
|
-
gridfs_path = filepath.gsub("/system/", "")
|
8
|
-
|
9
|
-
database_name = Mongoid::Config.sessions[:default][:database]
|
10
|
-
host_and_port = Mongoid::Config.sessions[:default][:hosts][0].split(':')
|
11
|
-
|
12
|
-
host = host_and_port[0]
|
13
|
-
port = host_and_port[1]
|
14
|
-
|
15
|
-
username = Mongoid::Config.sessions[:default][:username]
|
16
|
-
password = Mongoid::Config.sessions[:default][:password]
|
17
|
-
|
18
|
-
con = Mongo::MongoClient.new(host, port)
|
19
|
-
|
20
|
-
if username
|
21
|
-
con.add_auth(database_name, username, password)
|
22
|
-
end
|
23
|
-
|
24
|
-
db = con.db(database_name)
|
25
|
-
|
26
|
-
gridfs_file = Mongo::GridFileSystem.new(db).open(gridfs_path, 'r')
|
27
|
-
|
28
|
-
gridfs_file
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|