solidus_product_attachments 0.0.4 → 0.0.5
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 +4 -4
- data/README.md +45 -13
- data/app/models/spree/attachment.rb +3 -1
- data/lib/solidus_product_attachments/testing_support/factories.rb +5 -0
- data/lib/solidus_product_attachments/testing_support/factories/attachments.rb +7 -0
- data/lib/solidus_product_attachments/testing_support/fixtures/test_file.pdf +0 -0
- data/lib/solidus_product_attachments/testing_support/support/assets.rb +3 -0
- data/lib/solidus_product_attachments/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80cc02a5360a349128560bfc8a7fb742e3f18051
|
4
|
+
data.tar.gz: 36ba3e7e2e45ff76dad104f33f9152896b27637c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13dc6e736815335271c75da5513cf1d8a061ff7b72d77ece199f15c18b0225fb3dbe311c29cffee6c11e52d4ff70532bf964f4b6ff645fb8d06c6e4ad01f6fd8
|
7
|
+
data.tar.gz: 6f40d2cb9a434aeb58d1aa5cbfd408e002b1d4ae0e9336940370fe0bf06d3b3093e1a1ced4c514852e736b1abba587ee64fbfda07d60ff899e7f0f096eedb6e5
|
data/README.md
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
|
2
|
-
=========================
|
1
|
+
# Solidus Product Attachments
|
3
2
|
|
4
|
-
|
3
|
+
This Solidus extension allows the administrator to upload PDF files to a product or to a variant.
|
5
4
|
|
6
5
|
[](https://semaphoreci.com/renuo/solidus_product_attachments)
|
6
|
+
[](https://badge.fury.io/rb/solidus_product_attachments)
|
7
7
|
|
8
|
+
## Installation
|
8
9
|
|
9
|
-
|
10
|
-
------------
|
11
|
-
|
12
|
-
Add solidus_product_attachments to your Gemfile:
|
10
|
+
Add `solidus_product_attachments` to your `Gemfile`:
|
13
11
|
|
14
12
|
```ruby
|
15
13
|
gem 'solidus_product_attachments'
|
@@ -22,21 +20,55 @@ bundle
|
|
22
20
|
bundle exec rails g solidus_product_attachments:install
|
23
21
|
```
|
24
22
|
|
25
|
-
|
26
|
-
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### Backend
|
26
|
+
|
27
|
+
The usage of this extension is made very easy. All you have to do is to include it in your `Gemfile` and run the installer. After doing this, you can go to a product's page in the admin view and you'll notice a new `Documents` tab.
|
28
|
+
|
29
|
+
<img width="1205" alt="Product documents tab" src="https://user-images.githubusercontent.com/31915276/53641672-f26efc00-3c2f-11e9-841d-687e7c849957.png">
|
30
|
+
|
31
|
+
The functionality of the documents upload is very similar to the images upload. You can upload a document per drag and drop or you can choose a file manually.
|
32
|
+
|
33
|
+
### Frontend
|
34
|
+
|
35
|
+
This extension does not come with a frontend implementation of a download option for the users. It's completely up to you
|
36
|
+
to add it, but you can inspire yourself from the following example:
|
27
37
|
|
28
|
-
|
38
|
+
<img width="205" alt="Download option example" src="https://user-images.githubusercontent.com/31915276/53641960-c738dc80-3c30-11e9-82ef-df730bd0e357.png">
|
39
|
+
|
40
|
+
And the code (only for the product downloads, without css):
|
41
|
+
|
42
|
+
```erb
|
43
|
+
<% if @product.attachments.any? %>
|
44
|
+
<div class="product-downloads">
|
45
|
+
<h2>I18n.t('spree.product_download_title')</h2>
|
46
|
+
<ul class="unstyled">
|
47
|
+
<% @product.attachments.each do |attachment| %>
|
48
|
+
<li>
|
49
|
+
<%= link_to attachment.alt.presence || attachment.attachment_file_name, attachment.attachment.url, target: '_blank' %>
|
50
|
+
</li>
|
51
|
+
<% end %>
|
52
|
+
</ul>
|
53
|
+
</div>
|
54
|
+
<% end %>
|
55
|
+
```
|
56
|
+
|
57
|
+
## Testing
|
58
|
+
|
59
|
+
First bundle your dependencies, then run `bundle exec rake`. This command will default to building the dummy app if it does not exist, then it will run the specs and [Rubocop](https://github.com/bbatsov/rubocop) static code analysis. The dummy app can be regenerated by using `bundle exec rake test_app`.
|
29
60
|
|
30
61
|
```shell
|
31
62
|
bundle
|
32
63
|
bundle exec rake
|
33
64
|
```
|
34
65
|
|
35
|
-
When testing your
|
36
|
-
Simply add this require statement to your spec_helper:
|
66
|
+
When testing your application's integration with this extension, you may use its factories. In order to do this, simply add this require statement to your spec_helper:
|
37
67
|
|
38
68
|
```ruby
|
39
69
|
require 'solidus_product_attachments/factories'
|
40
70
|
```
|
41
71
|
|
42
|
-
Copyright
|
72
|
+
## Copyright
|
73
|
+
|
74
|
+
Copyright (c) 2019 [Renuo AG](https://www.renuo.ch/en), released under the New BSD License.
|
@@ -4,7 +4,9 @@ module Spree
|
|
4
4
|
attachment_updated_at id position type].freeze
|
5
5
|
PERMITTED_ATTACHMENT_ATTRIBUTES = %i[alt attachment position viewable_id viewable_type].freeze
|
6
6
|
|
7
|
-
has_attached_file :attachment
|
7
|
+
has_attached_file :attachment,
|
8
|
+
url: '/spree/attachments/:id/:basename.:extension',
|
9
|
+
path: ':rails_root/public/spree/attachments/:id/:basename.:extension'
|
8
10
|
|
9
11
|
validate :no_attachment_errors
|
10
12
|
validates_attachment :attachment, content_type: { content_type: 'application/pdf' }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_product_attachments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renuo AG
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -247,6 +247,10 @@ files:
|
|
247
247
|
- lib/generators/solidus_product_attachments/install/install_generator.rb
|
248
248
|
- lib/solidus_product_attachments.rb
|
249
249
|
- lib/solidus_product_attachments/engine.rb
|
250
|
+
- lib/solidus_product_attachments/testing_support/factories.rb
|
251
|
+
- lib/solidus_product_attachments/testing_support/factories/attachments.rb
|
252
|
+
- lib/solidus_product_attachments/testing_support/fixtures/test_file.pdf
|
253
|
+
- lib/solidus_product_attachments/testing_support/support/assets.rb
|
250
254
|
- lib/solidus_product_attachments/version.rb
|
251
255
|
homepage: https://www.renuo.ch
|
252
256
|
licenses:
|