background_module 0.1.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/CHANGELOG +0 -0
- data/MIT-LICENSE +20 -0
- data/Manifest +21 -0
- data/README +50 -0
- data/Rakefile +14 -0
- data/app/controllers/fundos_controller.rb +61 -0
- data/app/helpers/fundo_helper.rb +10 -0
- data/app/models/fundo.rb +6 -0
- data/app/views/fundos/_css.erb +43 -0
- data/app/views/fundos/_fundo.erb +22 -0
- data/app/views/fundos/_menu.erb +5 -0
- data/app/views/fundos/edit.html.erb +23 -0
- data/app/views/fundos/index.html.erb +22 -0
- data/app/views/fundos/new.html.erb +23 -0
- data/background_module.gemspec +30 -0
- data/config/routes.rb +3 -0
- data/generators/background_module/background_module_generator.rb +19 -0
- data/generators/background_module/templates/create_fundos.rb +19 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/background_module.rb +11 -0
- data/uninstall.rb +1 -0
- metadata +91 -0
data/CHANGELOG
ADDED
File without changes
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 [name of plugin creator]
|
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/Manifest
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
CHANGELOG
|
2
|
+
MIT-LICENSE
|
3
|
+
Manifest
|
4
|
+
README
|
5
|
+
Rakefile
|
6
|
+
app/controllers/fundos_controller.rb
|
7
|
+
app/helpers/fundo_helper.rb
|
8
|
+
app/models/fundo.rb
|
9
|
+
app/views/fundos/_css.erb
|
10
|
+
app/views/fundos/_fundo.erb
|
11
|
+
app/views/fundos/_menu.erb
|
12
|
+
app/views/fundos/edit.html.erb
|
13
|
+
app/views/fundos/index.html.erb
|
14
|
+
app/views/fundos/new.html.erb
|
15
|
+
config/routes.rb
|
16
|
+
generators/background_module/background_module_generator.rb
|
17
|
+
generators/background_module/templates/create_fundos.rb
|
18
|
+
init.rb
|
19
|
+
install.rb
|
20
|
+
lib/background_module.rb
|
21
|
+
uninstall.rb
|
data/README
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
Background
|
2
|
+
==========
|
3
|
+
|
4
|
+
Create a helpers/controller/views to control e show ramdom backgrounds.
|
5
|
+
|
6
|
+
Dependencies:
|
7
|
+
=============
|
8
|
+
paperclip
|
9
|
+
acl9
|
10
|
+
|
11
|
+
|
12
|
+
Install
|
13
|
+
=======
|
14
|
+
Run:
|
15
|
+
|
16
|
+
gem sources -a http://gemcutter.org
|
17
|
+
gem install background
|
18
|
+
|
19
|
+
put in your environment.rb :
|
20
|
+
config.gem "background"
|
21
|
+
config.reload_plugins = true
|
22
|
+
|
23
|
+
|
24
|
+
Run:
|
25
|
+
//create the migration of background tables
|
26
|
+
script/generate background migration
|
27
|
+
rake db:migrate
|
28
|
+
|
29
|
+
|
30
|
+
Use the gem
|
31
|
+
===========
|
32
|
+
|
33
|
+
Insert in your layout inside <head> tag
|
34
|
+
<%= random_background %>
|
35
|
+
|
36
|
+
Insert in your adm menu
|
37
|
+
<%= menu_background %>
|
38
|
+
|
39
|
+
IMPORTANT
|
40
|
+
=========
|
41
|
+
This gem is to be use with acl9
|
42
|
+
The menu is able just for user with :moderator role
|
43
|
+
|
44
|
+
The menu will use the layout "adm"
|
45
|
+
|
46
|
+
|
47
|
+
=========
|
48
|
+
|
49
|
+
|
50
|
+
Copyright (c) 2010 Eduardo Cauli, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('background_module', '0.1.0') do |p|
|
6
|
+
p.description = "Ramdom background"
|
7
|
+
p.url = "http://github.com/ecauli/background_module"
|
8
|
+
p.author = "Eduardo Cauli"
|
9
|
+
p.email = "ecauli@gmail.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = []
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class FundosController < ApplicationController
|
2
|
+
|
3
|
+
layout "adm"
|
4
|
+
|
5
|
+
access_control do
|
6
|
+
allow :moderator, :to => [:index, :show,:create, :new, :destroy, :update, :edit, :crop]
|
7
|
+
end
|
8
|
+
|
9
|
+
def index
|
10
|
+
@fundos = Fundo.all
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def new
|
15
|
+
@fundo = Fundo.new
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /banners/1/edit
|
20
|
+
def edit
|
21
|
+
@fundo = Fundo.find(params[:id])
|
22
|
+
end
|
23
|
+
|
24
|
+
# POST /banners
|
25
|
+
# POST /banners.xml
|
26
|
+
def create
|
27
|
+
@fundo = Fundo.new(params[:fundo])
|
28
|
+
|
29
|
+
respond_to do |format|
|
30
|
+
if @fundo.save
|
31
|
+
flash[:notice] = 'Fundo adicionado com sucesso.'
|
32
|
+
format.html { redirect_to(fundos_url)}
|
33
|
+
else
|
34
|
+
format.html { render :action => "new" }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def update
|
40
|
+
@fundo = Fundo.find(params[:id])
|
41
|
+
|
42
|
+
respond_to do |format|
|
43
|
+
if @fundo.update_attributes(params[:fundo])
|
44
|
+
flash[:notice] = 'Fundo adicionado com sucesso.'
|
45
|
+
format.html { redirect_to(fundos_url)}
|
46
|
+
else
|
47
|
+
format.html { render :action => "edit" }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def destroy
|
53
|
+
@fundo = Fundo.find(params[:id])
|
54
|
+
@fundo.destroy
|
55
|
+
|
56
|
+
respond_to do |format|
|
57
|
+
format.html { redirect_to(fundos_url) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
data/app/models/fundo.rb
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
class Fundo < ActiveRecord::Base
|
2
|
+
has_attached_file :arquivo
|
3
|
+
validates_attachment_presence :arquivo
|
4
|
+
validates_attachment_size :arquivo, :less_than => 5.megabytes
|
5
|
+
validates_attachment_content_type :arquivo, :content_type =>['image/jpeg', 'image/png','image/pjpeg', 'image/x-png']
|
6
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<% fundo = Fundo.find(:first,:order => "rand()", :conditions=>{:home=>true} ) %>
|
2
|
+
|
3
|
+
<% unless fundo.nil? %>
|
4
|
+
<style type="text/css">
|
5
|
+
body{
|
6
|
+
background:url("<%= fundo.arquivo.url %>") no-repeat fixed center top black;
|
7
|
+
margin:0 auto;
|
8
|
+
min-width:1000px;
|
9
|
+
width:100%;
|
10
|
+
}
|
11
|
+
.cor{
|
12
|
+
background-color:<%= fundo.cor %> !important;
|
13
|
+
}
|
14
|
+
.txt_cor{
|
15
|
+
color:<%= fundo.cor %> !important;
|
16
|
+
}
|
17
|
+
h2{
|
18
|
+
background-color:<%= fundo.cor %> !important;
|
19
|
+
padding: 5px;
|
20
|
+
color: white;
|
21
|
+
}
|
22
|
+
</style>
|
23
|
+
<% else %>
|
24
|
+
<style type="text/css">
|
25
|
+
body{
|
26
|
+
background-color: black;
|
27
|
+
margin:0 auto;
|
28
|
+
min-width:1000px;
|
29
|
+
width:100%;
|
30
|
+
}
|
31
|
+
.cor{
|
32
|
+
background-color: black !important;
|
33
|
+
}
|
34
|
+
.txt_cor{
|
35
|
+
color: black !important;
|
36
|
+
}
|
37
|
+
h2{
|
38
|
+
background-color:black !important;
|
39
|
+
padding: 5px;
|
40
|
+
color: white;
|
41
|
+
}
|
42
|
+
</style>
|
43
|
+
<% end %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<% form_for fundo, :html => { :multipart => true } do |f| %>
|
2
|
+
<%= f.error_messages %>
|
3
|
+
|
4
|
+
<p>
|
5
|
+
<%= f.label :titulo %><br />
|
6
|
+
<%= f.text_field :titulo %>
|
7
|
+
</p>
|
8
|
+
<p>
|
9
|
+
<%= f.label :arquivo, "Arquivo" %>
|
10
|
+
<%= f.file_field :arquivo %>
|
11
|
+
</p>
|
12
|
+
<%= f.label "Cor" %><br />
|
13
|
+
<div id="color"></div>
|
14
|
+
<%= f.hidden_field :cor %>
|
15
|
+
<p>
|
16
|
+
<p>
|
17
|
+
<%= f.label "HOME" %><br />
|
18
|
+
<%= f.check_box :home %>
|
19
|
+
</p>
|
20
|
+
<%= f.submit 'Enviar' %>
|
21
|
+
</p>
|
22
|
+
<% end %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% title "Novo Fundo" %>
|
2
|
+
<% content_for (:head) do %>
|
3
|
+
<%= javascript_include_tag 'jquery' %>
|
4
|
+
<%= stylesheet_link_tag "colorpicker" %>
|
5
|
+
<%= javascript_include_tag "colorpicker" %>
|
6
|
+
<script type="text/javascript">
|
7
|
+
jQuery.noConflict();
|
8
|
+
jQuery(document).ready(function() {
|
9
|
+
jQuery('#color').ColorPicker({
|
10
|
+
flat: true,
|
11
|
+
color: '<%=@fundo.cor%>',
|
12
|
+
onChange: function (hsb, hex, rgb) {
|
13
|
+
jQuery("#fundo_cor").val("#"+hex);
|
14
|
+
}
|
15
|
+
});
|
16
|
+
});
|
17
|
+
</script>
|
18
|
+
<% end %>
|
19
|
+
<h1>Editar Fundo</h1>
|
20
|
+
|
21
|
+
<%= render :partial => @fundo %>
|
22
|
+
|
23
|
+
<%= link_to 'Voltar', fundos_path %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<h1>Lista de fundos</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<th>Titulo</th>
|
6
|
+
<th>Cor</th>
|
7
|
+
<th>HOME</th>
|
8
|
+
</tr>
|
9
|
+
|
10
|
+
<% @fundos.each do |fundo| %>
|
11
|
+
<tr>
|
12
|
+
<td><%=h fundo.titulo %></td>
|
13
|
+
<td style="background-color:<%= fundo.cor%>"><%= fundo.cor %></td>
|
14
|
+
<td><%=h simnao(fundo.home) %></td>
|
15
|
+
<td><%= link_to 'Editar', edit_fundo_path(fundo) %></td>
|
16
|
+
<td><%= link_to 'Deletar', fundo, :confirm => 'tem certeza?', :method => :delete %></td>
|
17
|
+
</tr>
|
18
|
+
<% end %>
|
19
|
+
</table>
|
20
|
+
<br />
|
21
|
+
|
22
|
+
<%= link_to 'Novo Fundo', new_fundo_path %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% title "Novo Fundo" %>
|
2
|
+
<% content_for (:head) do %>
|
3
|
+
<%= javascript_include_tag 'jquery' %>
|
4
|
+
<%= stylesheet_link_tag "colorpicker" %>
|
5
|
+
<%= javascript_include_tag "colorpicker" %>
|
6
|
+
<script type="text/javascript">
|
7
|
+
jQuery.noConflict();
|
8
|
+
jQuery(document).ready(function() {
|
9
|
+
jQuery('#color').ColorPicker({
|
10
|
+
flat: true,
|
11
|
+
color: '#990000',
|
12
|
+
onChange: function (hsb, hex, rgb) {
|
13
|
+
jQuery("#fundo_cor").val("#"+hex);
|
14
|
+
}
|
15
|
+
});
|
16
|
+
});
|
17
|
+
</script>
|
18
|
+
<% end %>
|
19
|
+
<h1>Novo Fundo</h1>
|
20
|
+
|
21
|
+
<%= render :partial => @fundo %>
|
22
|
+
|
23
|
+
<%= link_to 'Voltar', fundos_path %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{background_module}
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Eduardo Cauli"]
|
9
|
+
s.date = %q{2010-04-27}
|
10
|
+
s.description = %q{Ramdom background}
|
11
|
+
s.email = %q{ecauli@gmail.com}
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "README", "lib/background_module.rb"]
|
13
|
+
s.files = ["CHANGELOG", "MIT-LICENSE", "Manifest", "README", "Rakefile", "app/controllers/fundos_controller.rb", "app/helpers/fundo_helper.rb", "app/models/fundo.rb", "app/views/fundos/_css.erb", "app/views/fundos/_fundo.erb", "app/views/fundos/_menu.erb", "app/views/fundos/edit.html.erb", "app/views/fundos/index.html.erb", "app/views/fundos/new.html.erb", "config/routes.rb", "generators/background_module/background_module_generator.rb", "generators/background_module/templates/create_fundos.rb", "init.rb", "install.rb", "lib/background_module.rb", "uninstall.rb", "background_module.gemspec"]
|
14
|
+
s.homepage = %q{http://github.com/ecauli/background_module}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Background_module", "--main", "README"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{background_module}
|
18
|
+
s.rubygems_version = %q{1.3.6}
|
19
|
+
s.summary = %q{Ramdom background}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class BackgroundGenerator < Rails::Generator::NamedBase
|
2
|
+
def migration
|
3
|
+
record do |m|
|
4
|
+
unless options[:skip_migration]
|
5
|
+
m.migration_template('create_fundos.rb', 'db/migrate', :migration_file_name => 'create_background')
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def add_options!(opt)
|
13
|
+
opt.separator ''
|
14
|
+
opt.separator 'Options:'
|
15
|
+
opt.on("--skip-migration", "Don't generate a migration for the background table") do |value|
|
16
|
+
options[:skip_migration] = value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateFundos < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :fundos do |t|
|
4
|
+
t.string :cor
|
5
|
+
t.string :titulo
|
6
|
+
t.string :arquivo_file_name
|
7
|
+
t.string :arquivo_content_type, :string
|
8
|
+
t.integer :arquivo_file_size, :integer
|
9
|
+
t.datetime :banners, :arquivo_updated_at, :datetime
|
10
|
+
t.boolean :home , :default=> false
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.down
|
17
|
+
drop_table :fundos
|
18
|
+
end
|
19
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "lib", "background_module")
|
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: background_module
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Eduardo Cauli
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-27 00:00:00 -03:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Ramdom background
|
22
|
+
email: ecauli@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- CHANGELOG
|
29
|
+
- README
|
30
|
+
- lib/background_module.rb
|
31
|
+
files:
|
32
|
+
- CHANGELOG
|
33
|
+
- MIT-LICENSE
|
34
|
+
- Manifest
|
35
|
+
- README
|
36
|
+
- Rakefile
|
37
|
+
- app/controllers/fundos_controller.rb
|
38
|
+
- app/helpers/fundo_helper.rb
|
39
|
+
- app/models/fundo.rb
|
40
|
+
- app/views/fundos/_css.erb
|
41
|
+
- app/views/fundos/_fundo.erb
|
42
|
+
- app/views/fundos/_menu.erb
|
43
|
+
- app/views/fundos/edit.html.erb
|
44
|
+
- app/views/fundos/index.html.erb
|
45
|
+
- app/views/fundos/new.html.erb
|
46
|
+
- config/routes.rb
|
47
|
+
- generators/background_module/background_module_generator.rb
|
48
|
+
- generators/background_module/templates/create_fundos.rb
|
49
|
+
- init.rb
|
50
|
+
- install.rb
|
51
|
+
- lib/background_module.rb
|
52
|
+
- uninstall.rb
|
53
|
+
- background_module.gemspec
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://github.com/ecauli/background_module
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options:
|
60
|
+
- --line-numbers
|
61
|
+
- --inline-source
|
62
|
+
- --title
|
63
|
+
- Background_module
|
64
|
+
- --main
|
65
|
+
- README
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
segments:
|
80
|
+
- 1
|
81
|
+
- 2
|
82
|
+
version: "1.2"
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project: background_module
|
86
|
+
rubygems_version: 1.3.6
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Ramdom background
|
90
|
+
test_files: []
|
91
|
+
|