image_input 0.0.2
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 +50 -0
- data/Rakefile +31 -0
- data/app/views/image_input/_input.html.erb +28 -0
- data/lib/image_input.rb +7 -0
- data/lib/image_input/engine.rb +7 -0
- data/lib/image_input/helpers.rb +7 -0
- data/lib/image_input/version.rb +5 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ab692730e6e757a30ca820411b9ff8bd3244b830b9fed37cb0cf2a9c60befaf4
|
4
|
+
data.tar.gz: 47a996956d900526f67a151aae095efe9f6203e17cff950e077715968284509b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1512ffee551389be86c22e21a57adae1a1bf8b8c74441babd3979302c23e035a48531e33ff399497904e76cfaa8f38fb243c1cda8ffd269a9e699a00b3985c98
|
7
|
+
data.tar.gz: 03f77b3abb31f14f8b4ccae63ac34c133624baec35d285235219939d5cb49bf0beb89547349d18ce0e8d9551869963f1bde8a82f98792a2e3a2fb542cf645ff8
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2020 Andrew Katz
|
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,50 @@
|
|
1
|
+
# Image Input
|
2
|
+
|
3
|
+
A Rails helper for a simple, clean image input for use with Active Storage.
|
4
|
+
|
5
|
+
```erb
|
6
|
+
<%= form_with(model: User.new) do |form| %>
|
7
|
+
<%= image_input form, :profile_picture %>
|
8
|
+
<% end %>
|
9
|
+
```
|
10
|
+
|
11
|
+
NOTE: The styles of this project are constructed using Tailwind CSS.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add to your Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'image_input'
|
19
|
+
```
|
20
|
+
|
21
|
+
```sh
|
22
|
+
bundle install
|
23
|
+
yarn add @mainkatz/image-input
|
24
|
+
```
|
25
|
+
|
26
|
+
## Development
|
27
|
+
|
28
|
+
To develop this locally you can update your Gemfile:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
gem 'image_input', path: 'PATH_TO_PROJECT'
|
32
|
+
```
|
33
|
+
|
34
|
+
In this project run:
|
35
|
+
|
36
|
+
```sh
|
37
|
+
yarn link
|
38
|
+
```
|
39
|
+
|
40
|
+
In your app project run:
|
41
|
+
|
42
|
+
```sh
|
43
|
+
yarn link @mainkatz/image-input
|
44
|
+
```
|
45
|
+
|
46
|
+
To auto-recompile this project, run:
|
47
|
+
|
48
|
+
```sh
|
49
|
+
yarn run dev
|
50
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rdoc/task'
|
10
|
+
|
11
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
12
|
+
rdoc.rdoc_dir = 'rdoc'
|
13
|
+
rdoc.title = 'RailsPing'
|
14
|
+
rdoc.options << '--line-numbers'
|
15
|
+
rdoc.rdoc_files.include('README.md')
|
16
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
17
|
+
end
|
18
|
+
|
19
|
+
load 'rails/tasks/statistics.rake'
|
20
|
+
|
21
|
+
require 'bundler/gem_tasks'
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
|
25
|
+
Rake::TestTask.new(:test) do |t|
|
26
|
+
t.libs << 'test'
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
28
|
+
t.verbose = false
|
29
|
+
end
|
30
|
+
|
31
|
+
task default: :test
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<div data-controller="image-input">
|
2
|
+
<%= form.file_field(
|
3
|
+
field,
|
4
|
+
class: 'hidden',
|
5
|
+
data: {
|
6
|
+
target: 'image-input.field',
|
7
|
+
action: 'change->image-input#onFileChosen'
|
8
|
+
}
|
9
|
+
) %>
|
10
|
+
|
11
|
+
<% if form.object.public_send(field).attached? %>
|
12
|
+
<%= image_tag(
|
13
|
+
form.object.public_send(field).variant(resize_to_limit: [300, 300]),
|
14
|
+
data: { target: 'image-input.image' },
|
15
|
+
class: 'rounded-md mb-4'
|
16
|
+
) %>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<a
|
20
|
+
href="#"
|
21
|
+
class="border border-transparent cursor-pointer duration-150 ease-in-out focus:outline-none font-bold inline-block leading-5 px-4 py-2 rounded-md text-sm transition active:bg-gray-50 active:text-gray-800 bg-white border-gray-300 hover:bg-gray-100 hover:text-gray-600 text-gray-800 mr-4"
|
22
|
+
data-action="click->image-input#chooseFile"
|
23
|
+
data-target="image-input.button"
|
24
|
+
>
|
25
|
+
<%= form.object.public_send(field).attached? ? 'Change' : 'Choose file' %>
|
26
|
+
</a>
|
27
|
+
<span class="hidden font-mono text-sm" data-target="image-input.fileNameLabel"></span>
|
28
|
+
</div>
|
data/lib/image_input.rb
ADDED
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: image_input
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Katz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-11-01 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: '6'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '6'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7'
|
33
|
+
description: A simple image input for Rails and Active Storage.
|
34
|
+
email:
|
35
|
+
- andrew.katz@hey.com
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- MIT-LICENSE
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- app/views/image_input/_input.html.erb
|
44
|
+
- lib/image_input.rb
|
45
|
+
- lib/image_input/engine.rb
|
46
|
+
- lib/image_input/helpers.rb
|
47
|
+
- lib/image_input/version.rb
|
48
|
+
homepage: https://github.com/andrewkatz/image_input
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata: {}
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2.4'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubygems_version: 3.1.4
|
68
|
+
signing_key:
|
69
|
+
specification_version: 4
|
70
|
+
summary: A simple image input for Rails and Active Storage.
|
71
|
+
test_files: []
|