mix-rails-settings 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/settings.js +2 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/assets/stylesheets/settings.css +4 -0
- data/app/controllers/admix/settings_controller.rb +5 -0
- data/app/models/admix/settings_datagrid.rb +27 -0
- data/app/models/setting.rb +54 -0
- data/app/uploaders/settings/image_uploader.rb +68 -0
- data/app/views/admix/settings/_form_fields.html.haml +5 -0
- data/app/views/admix/settings/_show.html.haml +9 -0
- data/config/locales/settings.en.yml +3 -0
- data/config/locales/settings.pt-BR.yml +10 -0
- data/config/routes.rb +5 -0
- data/lib/mix-rails-settings.rb +4 -0
- data/lib/mix-rails-settings/engine.rb +52 -0
- data/lib/mix-rails-settings/version.rb +10 -0
- data/lib/tasks/settings_tasks.rake +4 -0
- metadata +88 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Settings'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
div.field, div.actions {
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#notice {
|
24
|
+
color: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
.field_with_errors {
|
28
|
+
padding: 2px;
|
29
|
+
background-color: red;
|
30
|
+
display: table;
|
31
|
+
}
|
32
|
+
|
33
|
+
#error_explanation {
|
34
|
+
width: 450px;
|
35
|
+
border: 2px solid red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 0;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#error_explanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
margin-bottom: 0px;
|
49
|
+
background-color: #c00;
|
50
|
+
color: #fff;
|
51
|
+
}
|
52
|
+
|
53
|
+
#error_explanation ul li {
|
54
|
+
font-size: 12px;
|
55
|
+
list-style: square;
|
56
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Admix::SettingsDatagrid
|
2
|
+
|
3
|
+
include Datagrid
|
4
|
+
|
5
|
+
scope do
|
6
|
+
Setting.desc(:name)
|
7
|
+
end
|
8
|
+
|
9
|
+
filter :name, :string
|
10
|
+
|
11
|
+
column :name, header: I18n.t('settings.fields.name')
|
12
|
+
column :key, header: I18n.t('settings.fields.key')
|
13
|
+
column :value, header: I18n.t('settings.fields.value')
|
14
|
+
|
15
|
+
column :image, header: I18n.t('settings.fields.image'), html: true do |post|
|
16
|
+
if post.image?
|
17
|
+
image_tag post.image.url
|
18
|
+
else
|
19
|
+
"--"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
column :activated, header: I18n.t('settings.fields.activated')
|
24
|
+
|
25
|
+
include Admix::TableActions
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class Setting
|
2
|
+
include Mongoid::Document
|
3
|
+
|
4
|
+
field :name, type: String
|
5
|
+
field :key, type: String
|
6
|
+
field :value
|
7
|
+
field :activated, type: Boolean
|
8
|
+
field :system, type: Boolean, default: false
|
9
|
+
|
10
|
+
validates_uniqueness_of :key
|
11
|
+
|
12
|
+
mount_uploader :image, Settings::ImageUploader
|
13
|
+
|
14
|
+
def self.app_title
|
15
|
+
begin
|
16
|
+
Setting.find_by(key: 'app_title').value
|
17
|
+
rescue
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.app_email
|
23
|
+
begin
|
24
|
+
Setting.find_by(key: 'app_email').value
|
25
|
+
rescue
|
26
|
+
false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.admix_logo
|
31
|
+
begin
|
32
|
+
Setting.find_by(key: 'admix_logo')
|
33
|
+
rescue
|
34
|
+
false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.link_twitter
|
39
|
+
begin
|
40
|
+
Setting.find_by(key: 'link_twitter').value
|
41
|
+
rescue
|
42
|
+
false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.link_facebook
|
47
|
+
begin
|
48
|
+
Setting.find_by(key: 'link_facebook').value
|
49
|
+
rescue
|
50
|
+
false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'carrierwave/processing/mini_magick'
|
3
|
+
|
4
|
+
class Settings::ImageUploader < CarrierWave::Uploader::Base
|
5
|
+
|
6
|
+
# Include RMagick or MiniMagick support:
|
7
|
+
# include CarrierWave::RMagick
|
8
|
+
include CarrierWave::MiniMagick
|
9
|
+
|
10
|
+
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
|
11
|
+
include Sprockets::Helpers::RailsHelper
|
12
|
+
include Sprockets::Helpers::IsolatedHelper
|
13
|
+
|
14
|
+
# Choose what kind of storage to use for this uploader:
|
15
|
+
storage :grid_fs
|
16
|
+
# storage :fog
|
17
|
+
|
18
|
+
# Override the directory where uploaded files will be stored.
|
19
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
20
|
+
def store_dir
|
21
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
22
|
+
end
|
23
|
+
|
24
|
+
# Provide a default URL as a default if there hasn't been a file uploaded:
|
25
|
+
# def default_url
|
26
|
+
# # For Rails 3.1+ asset pipeline compatibility:
|
27
|
+
# # asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
28
|
+
#
|
29
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
30
|
+
# end
|
31
|
+
|
32
|
+
# Process files as they are uploaded:
|
33
|
+
# process :scale => [200, 300]
|
34
|
+
#
|
35
|
+
# def scale(width, height)
|
36
|
+
# # do something
|
37
|
+
# end
|
38
|
+
|
39
|
+
# Create different versions of your uploaded files:
|
40
|
+
# version :thumb do
|
41
|
+
# process :resize_to_fit => [80, 80]
|
42
|
+
# end
|
43
|
+
|
44
|
+
# version :medium do
|
45
|
+
# process :resize_to_fill => [640,420]
|
46
|
+
# end
|
47
|
+
|
48
|
+
# version :thumb do
|
49
|
+
# process :resize_to_fill => [190,143]
|
50
|
+
# end
|
51
|
+
|
52
|
+
# version :small_thumb do
|
53
|
+
# process :resize_to_fill => [82,62]
|
54
|
+
# end
|
55
|
+
|
56
|
+
# Add a white list of extensions which are allowed to be uploaded.
|
57
|
+
# For images you might use something like this:
|
58
|
+
# def extension_white_list
|
59
|
+
# %w(jpg jpeg gif png)
|
60
|
+
# end
|
61
|
+
|
62
|
+
# Override the filename of the uploaded files:
|
63
|
+
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
64
|
+
# def filename
|
65
|
+
# "something.jpg" if original_filename
|
66
|
+
# end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
= f.input :name, label: t('settings.fields.name'), as: 'string'
|
2
|
+
= f.input :key, label: t('settings.fields.key'), as: 'string'
|
3
|
+
= f.input :value, label: t('settings.fields.value'), as: 'text'
|
4
|
+
= f.input :image, label: t('settings.fields.image'), as: :file
|
5
|
+
= f.input :activated, label: t('settings.fields.activated'), as: 'boolean'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
module MixRailsSettings
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
|
4
|
+
initializer "settings.default_settings" do |app|
|
5
|
+
|
6
|
+
config = app.config
|
7
|
+
#config.action_dispatch.x_frame_options = 'SAMEORIGIN, GOFORIT'
|
8
|
+
|
9
|
+
|
10
|
+
config.time_zone = 'Brasilia'
|
11
|
+
config.i18n.available_locales = ['pt-BR', :en]
|
12
|
+
|
13
|
+
config.action_mailer.delivery_method = :smtp
|
14
|
+
|
15
|
+
config.action_mailer.smtp_settings = {
|
16
|
+
:address => "smtp.gmail.com",
|
17
|
+
:port => 587,
|
18
|
+
:domain => "mixinternet.com.br",
|
19
|
+
:user_name => "noreply@mixinternet.com.br",
|
20
|
+
:password => "15963211",
|
21
|
+
:authentication => 'plain',
|
22
|
+
:enable_starttls_auto => true
|
23
|
+
}
|
24
|
+
|
25
|
+
config.action_mailer.perform_deliveries = true
|
26
|
+
config.action_mailer.raise_delivery_errors = true
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def navigation
|
31
|
+
if defined? Admix
|
32
|
+
Admix::Navigation::NavBar.post_menu do
|
33
|
+
Admix::Navigation::NavBar.find(:general) do |menu|
|
34
|
+
menu.submenu do |submenu|
|
35
|
+
submenu.key = :settings
|
36
|
+
submenu.title = I18n.t 'settings.settings'
|
37
|
+
submenu.url = 'admix_settings_url'
|
38
|
+
|
39
|
+
submenu.instance_eval do
|
40
|
+
def can_render?(current_user)
|
41
|
+
current_user.is?(:admin)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mix-rails-settings
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.10.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sadjow Leão
|
9
|
+
- Rafael Garcia
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-01-22 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rails
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.2.9
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 3.2.9
|
31
|
+
description: Settings module
|
32
|
+
email:
|
33
|
+
- sadjow@gmail.com
|
34
|
+
- rafbgarcia@gmail.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- app/uploaders/settings/image_uploader.rb
|
40
|
+
- app/controllers/admix/settings_controller.rb
|
41
|
+
- app/assets/stylesheets/settings.css
|
42
|
+
- app/assets/stylesheets/scaffold.css
|
43
|
+
- app/assets/javascripts/settings.js
|
44
|
+
- app/models/admix/settings_datagrid.rb
|
45
|
+
- app/models/setting.rb
|
46
|
+
- app/views/admix/settings/_show.html.haml
|
47
|
+
- app/views/admix/settings/_form_fields.html.haml
|
48
|
+
- config/locales/settings.pt-BR.yml
|
49
|
+
- config/locales/settings.en.yml
|
50
|
+
- config/routes.rb
|
51
|
+
- lib/tasks/settings_tasks.rake
|
52
|
+
- lib/mix-rails-settings/version.rb
|
53
|
+
- lib/mix-rails-settings/engine.rb
|
54
|
+
- lib/mix-rails-settings.rb
|
55
|
+
- MIT-LICENSE
|
56
|
+
- Rakefile
|
57
|
+
- README.rdoc
|
58
|
+
homepage: https://github.com/mixinternet/mix-rails
|
59
|
+
licenses: []
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
hash: -2800120376113667874
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
hash: -2800120376113667874
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.8.24
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: Settings module
|
88
|
+
test_files: []
|