banner_lite 0.0.1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +41 -0
- data/Rakefile +23 -0
- data/app/assets/javascripts/banner_lite/application.js +15 -0
- data/app/assets/stylesheets/banner_lite/application.css +15 -0
- data/app/controllers/banner_lite/application_controller.rb +4 -0
- data/app/controllers/banner_lite/banners_controller.rb +53 -0
- data/app/helpers/banner_lite/application_helper.rb +4 -0
- data/app/helpers/banner_lite/banners_helper.rb +12 -0
- data/app/models/banner_lite/banner.rb +33 -0
- data/app/views/banner_lite/banners/_form.html.erb +37 -0
- data/app/views/banner_lite/banners/edit.html.erb +6 -0
- data/app/views/banner_lite/banners/index.html.erb +31 -0
- data/app/views/banner_lite/banners/new.html.erb +5 -0
- data/app/views/banner_lite/banners/preview.html.erb +1 -0
- data/app/views/banner_lite/banners/show.html.erb +25 -0
- data/app/views/layouts/banner_lite/application.html.erb +14 -0
- data/config/routes.rb +7 -0
- data/db/migrate/20140221065958_create_banner_lite_banners.rb +10 -0
- data/lib/banner_lite/engine.rb +9 -0
- data/lib/banner_lite/version.rb +3 -0
- data/lib/banner_lite.rb +4 -0
- data/lib/tasks/banner_lite_tasks.rake +4 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5a578afa6e0b33823e19ab08019d75780eb8071d
|
4
|
+
data.tar.gz: 19403ed0e62b21b72cfb70c077c0b5774ffd1e14
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: acea8c77c5a8057baac23732ecc7c0ced3dfa25ce40ec0db325ac8d75ff991a2d4f214f5efc4e32f72219d5ed3ffca768c49caecc5e06f21723f17e8ca27c427
|
7
|
+
data.tar.gz: 29046471038d38ff42dff99cdd9d572a60e0761e1b107895a2ea6d35e34c69b81d98aa3d400505f7a84e2e26df5cab88e2c7aa9fba1443a3ce5dcb6e22a745b8
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 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.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# BannerLite
|
2
|
+
|
3
|
+
A Rails engine which enables the minimum banner management.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- BannerLite::Banner model and migration
|
8
|
+
- BannerLite::BannersController for CRUD banners
|
9
|
+
- A helper to show active banners
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add a line below to your Gemfile and `bundle`.
|
14
|
+
|
15
|
+
`gem 'banner_lite'`
|
16
|
+
|
17
|
+
## Migration
|
18
|
+
|
19
|
+
(TBD)
|
20
|
+
|
21
|
+
## Make your own admin views
|
22
|
+
|
23
|
+
(TBD)
|
24
|
+
|
25
|
+
## Helpers
|
26
|
+
|
27
|
+
- `banners(banners = nil)`
|
28
|
+
|
29
|
+
e.g.
|
30
|
+
|
31
|
+
<%= banners %>
|
32
|
+
|
33
|
+
emits something like:
|
34
|
+
|
35
|
+
<a href="http://your.host/page"><img src="banner/image.png" /></a>
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
This software is licensed under the MIT license.
|
40
|
+
|
41
|
+
Copyright 2014 KRAY Inc.
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'BannerLite'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/test_app/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_dependency "banner_lite/application_controller"
|
2
|
+
|
3
|
+
module BannerLite
|
4
|
+
class BannersController < ApplicationController
|
5
|
+
before_action :set_banner, only: [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
def index
|
8
|
+
@banners = Banner.all
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@banner = Banner.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def edit
|
19
|
+
end
|
20
|
+
|
21
|
+
def create
|
22
|
+
@banner = Banner.new(banner_params)
|
23
|
+
|
24
|
+
if @banner.save
|
25
|
+
redirect_to @banner, notice: 'Banner was successfully created.'
|
26
|
+
else
|
27
|
+
render action: 'new'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def update
|
32
|
+
if @banner.update(banner_params)
|
33
|
+
redirect_to @banner, notice: 'Banner was successfully updated.'
|
34
|
+
else
|
35
|
+
render action: 'edit'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
@banner.destroy
|
41
|
+
redirect_to banners_url, notice: 'Banner was successfully destroyed.'
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def set_banner
|
46
|
+
@banner = Banner.find(params[:id])
|
47
|
+
end
|
48
|
+
|
49
|
+
def banner_params
|
50
|
+
params.require(:banner).permit(:url, :file, :active_from, :active_until)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module BannerLite
|
2
|
+
class Banner < ActiveRecord::Base
|
3
|
+
attr_accessor :file
|
4
|
+
|
5
|
+
before_save :fill_file_name, if: :file
|
6
|
+
after_save :save_file, if: :file
|
7
|
+
after_destroy :remove_file
|
8
|
+
|
9
|
+
scope :active, ->{ now = Time.zone.now; where(arel_table[:active_from].lteq(now).and(arel_table[:active_until].gt(now))) }
|
10
|
+
|
11
|
+
def src
|
12
|
+
"/system/#{id}/#{file_name}"
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def base_dir
|
17
|
+
@base_dir ||= Rails.root.join('public', 'system', id.to_s)
|
18
|
+
end
|
19
|
+
|
20
|
+
def fill_file_name
|
21
|
+
self.file_name = file.original_filename
|
22
|
+
end
|
23
|
+
|
24
|
+
def remove_file
|
25
|
+
FileUtils.rm_rf(base_dir)
|
26
|
+
end
|
27
|
+
|
28
|
+
def save_file
|
29
|
+
FileUtils.mkdir(base_dir)
|
30
|
+
File.open(base_dir + file_name, 'wb'){|f| f.write(file.read) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<%= form_for(@banner) do |f| %>
|
2
|
+
<% if @banner.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@banner.errors.count, "error") %> prohibited this banner from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @banner.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :url %><br>
|
16
|
+
<%= f.text_field :url %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :file %><br>
|
20
|
+
<%- if f.object.file_name -%>
|
21
|
+
<%= image_tag f.object.src %><br>
|
22
|
+
<%= f.object.file_name %><br>
|
23
|
+
<%- end -%>
|
24
|
+
<%= f.file_field :file %>
|
25
|
+
</div>
|
26
|
+
<div class="field">
|
27
|
+
<%= f.label :active_from %><br>
|
28
|
+
<%= f.datetime_select :active_from %>
|
29
|
+
</div>
|
30
|
+
<div class="field">
|
31
|
+
<%= f.label :active_until %><br>
|
32
|
+
<%= f.datetime_select :active_until %>
|
33
|
+
</div>
|
34
|
+
<div class="actions">
|
35
|
+
<%= f.submit %>
|
36
|
+
</div>
|
37
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<h1>Listing banners</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<th>Url</th>
|
7
|
+
<th>File name</th>
|
8
|
+
<th>Active from</th>
|
9
|
+
<th>Active until</th>
|
10
|
+
<th colspan="3"></th>
|
11
|
+
</tr>
|
12
|
+
</thead>
|
13
|
+
|
14
|
+
<tbody>
|
15
|
+
<% @banners.each do |banner| %>
|
16
|
+
<tr>
|
17
|
+
<td><%= banner.url %></td>
|
18
|
+
<td><%= banner.file_name %></td>
|
19
|
+
<td><%= banner.active_from %></td>
|
20
|
+
<td><%= banner.active_until %></td>
|
21
|
+
<td><%= link_to 'Show', banner %></td>
|
22
|
+
<td><%= link_to 'Edit', edit_banner_path(banner) %></td>
|
23
|
+
<td><%= link_to 'Destroy', banner, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
</tbody>
|
27
|
+
</table>
|
28
|
+
|
29
|
+
<br>
|
30
|
+
|
31
|
+
<%= link_to 'New Banner', new_banner_path %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= banners %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<strong>Url:</strong>
|
5
|
+
<%= link_to @banner.url, @banner.url %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<strong>File name:</strong>
|
10
|
+
<%= @banner.file_name %><br>
|
11
|
+
<%= image_tag @banner.src %>
|
12
|
+
</p>
|
13
|
+
|
14
|
+
<p>
|
15
|
+
<strong>Active from:</strong>
|
16
|
+
<%= @banner.active_from %>
|
17
|
+
</p>
|
18
|
+
|
19
|
+
<p>
|
20
|
+
<strong>Active until:</strong>
|
21
|
+
<%= @banner.active_until %>
|
22
|
+
</p>
|
23
|
+
|
24
|
+
<%= link_to 'Edit', edit_banner_path(@banner) %> |
|
25
|
+
<%= link_to 'Back', banners_path %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>BannerLite</title>
|
5
|
+
<%= stylesheet_link_tag "banner_lite/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "banner_lite/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
data/lib/banner_lite.rb
ADDED
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: banner_lite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hiroki Yoshioka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.0.beta1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.0.beta1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: capybara
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A Rails engine for minimum banner management
|
70
|
+
email:
|
71
|
+
- irohiroki@kray.jp
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- MIT-LICENSE
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- app/assets/javascripts/banner_lite/application.js
|
80
|
+
- app/assets/stylesheets/banner_lite/application.css
|
81
|
+
- app/controllers/banner_lite/application_controller.rb
|
82
|
+
- app/controllers/banner_lite/banners_controller.rb
|
83
|
+
- app/helpers/banner_lite/application_helper.rb
|
84
|
+
- app/helpers/banner_lite/banners_helper.rb
|
85
|
+
- app/models/banner_lite/banner.rb
|
86
|
+
- app/views/banner_lite/banners/_form.html.erb
|
87
|
+
- app/views/banner_lite/banners/edit.html.erb
|
88
|
+
- app/views/banner_lite/banners/index.html.erb
|
89
|
+
- app/views/banner_lite/banners/new.html.erb
|
90
|
+
- app/views/banner_lite/banners/preview.html.erb
|
91
|
+
- app/views/banner_lite/banners/show.html.erb
|
92
|
+
- app/views/layouts/banner_lite/application.html.erb
|
93
|
+
- config/routes.rb
|
94
|
+
- db/migrate/20140221065958_create_banner_lite_banners.rb
|
95
|
+
- lib/banner_lite.rb
|
96
|
+
- lib/banner_lite/engine.rb
|
97
|
+
- lib/banner_lite/version.rb
|
98
|
+
- lib/tasks/banner_lite_tasks.rake
|
99
|
+
homepage: https://github.com/krayinc/banner_lite
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.2.0
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: A Rails engine for minimum banner management
|
123
|
+
test_files: []
|