enju_barcode 0.0.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 +45 -0
- data/app/assets/javascripts/barcodes.js +2 -0
- data/app/assets/stylesheets/barcodes.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/barcodes_controller.rb +89 -0
- data/app/helpers/barcodes_helper.rb +2 -0
- data/app/models/barcode.rb +24 -0
- data/app/views/barcodes/_form.html.erb +14 -0
- data/app/views/barcodes/barcode.html.erb +32 -0
- data/app/views/barcodes/edit.html.erb +13 -0
- data/app/views/barcodes/index.html.erb +32 -0
- data/app/views/barcodes/new.html.erb +12 -0
- data/app/views/barcodes/show.html.erb +27 -0
- data/app/views/barcodes/show.png.erb +1 -0
- data/config/locales/translation_en.yml +9 -0
- data/config/locales/translation_ja.yml +9 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20081108112016_create_barcodes.rb +14 -0
- data/lib/enju_barcode.rb +4 -0
- data/lib/enju_barcode/engine.rb +8 -0
- data/lib/enju_barcode/version.rb +3 -0
- data/lib/tasks/enju_barcode_tasks.rake +4 -0
- data/spec/controllers/barcodes_controller_spec.rb +479 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +62 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/ability.rb +18 -0
- data/spec/dummy/app/models/role.rb +5 -0
- data/spec/dummy/app/models/user.rb +28 -0
- data/spec/dummy/app/models/user_has_role.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/page/403.html.erb +9 -0
- data/spec/dummy/app/views/page/403.xml.erb +4 -0
- data/spec/dummy/app/views/page/404.html.erb +9 -0
- data/spec/dummy/app/views/page/404.xml.erb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +209 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +6 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +60 -0
- data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +13 -0
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +31 -0
- data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
- data/spec/dummy/db/schema.rb +62 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +6623 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/barcode.rb +5 -0
- data/spec/factories/user.rb +31 -0
- data/spec/fixtures/roles.yml +21 -0
- data/spec/fixtures/user_has_roles.yml +41 -0
- data/spec/fixtures/users.yml +69 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/controller_macros.rb +48 -0
- data/spec/support/devise.rb +4 -0
- metadata +263 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 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,45 @@
|
|
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 = 'EnjuPurchaseRequest'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
Bundler::GemHelper.install_tasks
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
|
31
|
+
Rake::TestTask.new(:test) do |t|
|
32
|
+
t.libs << 'lib'
|
33
|
+
t.libs << 'test'
|
34
|
+
t.pattern = 'test/**/*_test.rb'
|
35
|
+
t.verbose = false
|
36
|
+
end
|
37
|
+
|
38
|
+
require 'rspec/core'
|
39
|
+
require 'rspec/core/rake_task'
|
40
|
+
|
41
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
42
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
43
|
+
end
|
44
|
+
|
45
|
+
task :default => :spec
|
@@ -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,89 @@
|
|
1
|
+
class BarcodesController < ApplicationController
|
2
|
+
load_and_authorize_resource
|
3
|
+
|
4
|
+
# GET /barcodes
|
5
|
+
# GET /barcodes.json
|
6
|
+
def index
|
7
|
+
@barcodes = Barcode.page(params[:page])
|
8
|
+
@start_rows = params[:start_rows]
|
9
|
+
@start_cols = params[:start_cols]
|
10
|
+
|
11
|
+
if params[:mode] == 'barcode'
|
12
|
+
render :action => 'barcode', :layout => false
|
13
|
+
return
|
14
|
+
end
|
15
|
+
|
16
|
+
respond_to do |format|
|
17
|
+
format.html # index.html.erb
|
18
|
+
format.json { render :json => @barcodes }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# GET /barcodes/1
|
23
|
+
# GET /barcodes/1.json
|
24
|
+
def show
|
25
|
+
respond_to do |format|
|
26
|
+
format.html # show.html.erb
|
27
|
+
format.json { render :json => @barcode }
|
28
|
+
format.svg { send_data @barcode.data, :type => 'image/svg+json', :disposition => 'inline' }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# GET /barcodes/new
|
33
|
+
# GET /barcodes/new.json
|
34
|
+
def new
|
35
|
+
@barcode = Barcode.new
|
36
|
+
|
37
|
+
respond_to do |format|
|
38
|
+
format.html # new.html.erb
|
39
|
+
format.json { render :json => @barcode }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# GET /barcodes/1/edit
|
44
|
+
def edit
|
45
|
+
end
|
46
|
+
|
47
|
+
# POST /barcodes
|
48
|
+
# POST /barcodes.json
|
49
|
+
def create
|
50
|
+
@barcode = Barcode.new(params[:barcode])
|
51
|
+
|
52
|
+
respond_to do |format|
|
53
|
+
if @barcode.save
|
54
|
+
flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.barcode'))
|
55
|
+
format.html { redirect_to(@barcode) }
|
56
|
+
format.json { render :json => @barcode, :status => :created, :location => @barcode }
|
57
|
+
else
|
58
|
+
format.html { render :action => "new" }
|
59
|
+
format.json { render :json => @barcode.errors, :status => :unprocessable_entity }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# PUT /barcodes/1
|
65
|
+
# PUT /barcodes/1.json
|
66
|
+
def update
|
67
|
+
respond_to do |format|
|
68
|
+
if @barcode.update_attributes(params[:barcode])
|
69
|
+
flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.barcode'))
|
70
|
+
format.html { redirect_to(@barcode) }
|
71
|
+
format.json { head :ok }
|
72
|
+
else
|
73
|
+
format.html { render :action => "edit" }
|
74
|
+
format.json { render :json => @barcode.errors, :status => :unprocessable_entity }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# DELETE /barcodes/1
|
80
|
+
# DELETE /barcodes/1.json
|
81
|
+
def destroy
|
82
|
+
@barcode.destroy
|
83
|
+
|
84
|
+
respond_to do |format|
|
85
|
+
format.html { redirect_to(barcodes_url) }
|
86
|
+
format.json { head :ok }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# TODO: Codarbar support
|
2
|
+
require 'barby/barcode/code_39'
|
3
|
+
require 'barby/outputter/svg_outputter'
|
4
|
+
|
5
|
+
class Barcode < ActiveRecord::Base
|
6
|
+
belongs_to :barcodable, :polymorphic => true
|
7
|
+
|
8
|
+
validates_presence_of :code_word
|
9
|
+
before_save :generate_barcode
|
10
|
+
|
11
|
+
attr_accessor :start_rows, :start_cols
|
12
|
+
|
13
|
+
def self.per_page
|
14
|
+
10
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_barcode
|
18
|
+
self.data = Barby::Code39.new(code_word).to_svg(:width => 150, :height => 70)
|
19
|
+
end
|
20
|
+
|
21
|
+
def is_readable_by(user, parent = nil)
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%- form_for(@barcode) do |f| -%>
|
2
|
+
<%= f.error_messages -%>
|
3
|
+
|
4
|
+
<p>
|
5
|
+
<%= f.label t('activerecord.attributes.barcode.code_word') -%><br />
|
6
|
+
<%= f.text_field :code_word -%>
|
7
|
+
<%= javascript_tag("$('#barcode_code_word').focus()") -%>
|
8
|
+
</p>
|
9
|
+
<p>
|
10
|
+
<%= f.submit -%>
|
11
|
+
</p>
|
12
|
+
<%- end -%>
|
13
|
+
|
14
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<title><%= t('activerecord.models.barcode') -%> - <%= @library_group.display_name.localize -%></title>
|
6
|
+
</head>
|
7
|
+
|
8
|
+
<body style="width: 210mm; padding-left: 5mm; padding-right: 5mm">
|
9
|
+
<table>
|
10
|
+
<%- @barcodes.each_with_index do |barcode, i| -%>
|
11
|
+
<%- if i == 0 or i % 4 == 0 -%>
|
12
|
+
<tr>
|
13
|
+
<%- end -%>
|
14
|
+
<td style="text-align: center; width: 50mm; height: 30mm">
|
15
|
+
<div style="font-size: 10pt; line-height: 0" -%>
|
16
|
+
<%- unless barcode.code_word.blank? -%>
|
17
|
+
<%= image_tag(barcode_path(barcode, :format => :png), :alt => barcode.code_word) -%>
|
18
|
+
<%- end -%>
|
19
|
+
<br />
|
20
|
+
<%= barcode.code_word -%>
|
21
|
+
</div>
|
22
|
+
<div style="font-size: 10pt" -%>
|
23
|
+
<%= @library_group.display_name.localize -%>
|
24
|
+
</div>
|
25
|
+
</td>
|
26
|
+
<%- if i != 0 and (i + 1) % 4 == 0 -%>
|
27
|
+
</tr>
|
28
|
+
<%- end -%>
|
29
|
+
<%- end -%>
|
30
|
+
</table>
|
31
|
+
</body>
|
32
|
+
</html>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div id="content_detail" class="ui-corner-all">
|
2
|
+
<h1 class="title"><%= t('page.editing', :model => t('activerecord.models.barcode')) -%></h1>
|
3
|
+
<div id="content_list">
|
4
|
+
<%= render 'form' %>
|
5
|
+
</div>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div id="submenu" class="ui-corner-all">
|
9
|
+
<ul>
|
10
|
+
<li><%= link_to t('page.show'), @barcode -%></li>
|
11
|
+
<li><%= link_to t('page.back'), barcodes_path -%></li>
|
12
|
+
</ul>
|
13
|
+
</div>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<div id="content_detail" class="ui-corner-all">
|
2
|
+
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.barcode')) -%></h1>
|
3
|
+
<div id="content_list">
|
4
|
+
|
5
|
+
<table class="index">
|
6
|
+
<tr>
|
7
|
+
<th><%= t('activerecord.attributes.barcode.code_word') -%></th>
|
8
|
+
<th><%= t('activerecord.attributes.barcode.barcode_type') -%></th>
|
9
|
+
<th></th>
|
10
|
+
</tr>
|
11
|
+
|
12
|
+
<%- for barcode in @barcodes -%>
|
13
|
+
<tr class="line<%= cycle("0", "1") -%>">
|
14
|
+
<td><%= link_to barcode.code_word, barcode -%></td>
|
15
|
+
<td><%= barcode.barcode_type -%></td>
|
16
|
+
<td>
|
17
|
+
<%= link_to t('page.edit'), edit_barcode_path(barcode) -%>
|
18
|
+
<%= link_to t('page.destroy'), barcode, :confirm => t('page.are_you_sure'), :method => :delete -%>
|
19
|
+
</td>
|
20
|
+
</tr>
|
21
|
+
<%- end -%>
|
22
|
+
</table>
|
23
|
+
|
24
|
+
<%= will_paginate(@barcodes) -%>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div id="submenu" class="ui-corner-all">
|
29
|
+
<ul>
|
30
|
+
<li><%= link_to t('page.new', :model => t('activerecord.models.barcode')), new_barcode_path -%></li>
|
31
|
+
</ul>
|
32
|
+
</div>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div id="content_detail" class="ui-corner-all">
|
2
|
+
<h1 class="title"><%= t('page.new', :model => t('activerecord.models.barcode')) -%></h1>
|
3
|
+
<div id="content_list">
|
4
|
+
<%= render 'form' %>
|
5
|
+
</div>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div id="submenu" class="ui-corner-all">
|
9
|
+
<ul>
|
10
|
+
<li><%= link_to t('page.back'), barcodes_path -%></li>
|
11
|
+
</ul>
|
12
|
+
</div>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<div id="content_detail" class="ui-corner-all">
|
2
|
+
<h1 class="title"><%= t('page.showing', :model => t('activerecord.models.barcode')) -%></h1>
|
3
|
+
<div id="content_list">
|
4
|
+
<p>
|
5
|
+
<strong><%= t('activerecord.attributes.barcode.barcode_type') -%>:</strong>
|
6
|
+
<%= @barcode.barcode_type -%>
|
7
|
+
</p>
|
8
|
+
|
9
|
+
<p>
|
10
|
+
<strong><%= t('activerecord.attributes.barcode.barcodable') -%>:</strong>
|
11
|
+
<%= link_to h("#{@barcode.barcodable_type} / #{@barcode.barcodable_id}"), @barcode.barcodable if @barcode.barcodable -%>
|
12
|
+
</p>
|
13
|
+
|
14
|
+
<p>
|
15
|
+
<strong><%= t('activerecord.attributes.barcode.data') -%>:</strong>
|
16
|
+
<%= image_tag(barcode_path(@barcode, :format => :svg), :alt => @barcode.code_word) -%>
|
17
|
+
</p>
|
18
|
+
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<div id="submenu" class="ui-corner-all">
|
23
|
+
<ul>
|
24
|
+
<li><%= link_to t('page.edit'), edit_barcode_path(@barcode) -%></li>
|
25
|
+
<li><%= link_to t('page.back'), barcodes_path -%></li>
|
26
|
+
</ul>
|
27
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @barcode.data -%>
|
data/config/routes.rb
ADDED