alchemy_file_selector 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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +44 -0
- data/Rakefile +32 -0
- data/app/assets/javascripts/alchemy_file_selector/alchemy_admin_require.js +1 -0
- data/app/assets/javascripts/tinymce/plugins/alchemy_file_selector/plugin.min.js +52 -0
- data/app/views/alchemy/admin/pictures/show.json.jbuilder +5 -0
- data/lib/alchemy_file_selector.rb +5 -0
- data/lib/alchemy_file_selector/engine.rb +17 -0
- data/lib/alchemy_file_selector/version.rb +3 -0
- data/lib/tasks/alchemy_file_selector_tasks.rake +4 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4028a5535cd5efae9e24bfd7467f1952b3392701
|
4
|
+
data.tar.gz: 72611e1f3076605d73dc3b0c0e5fb0ebe9c0c6cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d4496deb4c0bc514d918e9e4821d1437af051351d0f77db9db889f738b39c62fa02dae7d12cb980cf852f43550f3b6eb6ce1ff64cef8322145a5a92ec126e48c
|
7
|
+
data.tar.gz: 78b6e04e9173306808449e2eae575b6a4fc62121dc62ccdb2d0034e47d26f8206f6d79c2af48c996cd58b5e18fa6aa571a023d1a36dce3104c01367bdd8ba40f
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2018 Jury Ghidinelli
|
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,44 @@
|
|
1
|
+
# AlchemyFileSelector
|
2
|
+
It's a Alchemy Plugin that enable TinyMCE editor to include images from Alchemy image gallery, directly into RichText Editor.
|
3
|
+
|
4
|
+
__N.B.: Use of this plugin must not be encouraged because collide with Alchemy CMS philosophy (that we fully agree)__
|
5
|
+
__because not separate the content from layout. So use it carefully!__
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Insert into file 'vendor/assets/javascripts/alchemy/admin/all.js'
|
10
|
+
|
11
|
+
```javascript
|
12
|
+
require 'alchemy_file_selector/alchemy_admin_require.js'
|
13
|
+
```
|
14
|
+
|
15
|
+
Plugin automatically add Tinymce toolbar button, if you want to change that, you have to change Tinymce toolbar
|
16
|
+
configurations as usually.
|
17
|
+
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'alchemy_file_selector'
|
24
|
+
```
|
25
|
+
|
26
|
+
And then execute:
|
27
|
+
```bash
|
28
|
+
$ bundle
|
29
|
+
```
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
```bash
|
33
|
+
$ gem install alchemy_file_selector
|
34
|
+
```
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
Contribute it if you want!
|
38
|
+
|
39
|
+
## License
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
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 = 'AlchemyFileSelector'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'test'
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
29
|
+
t.verbose = false
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require js-routes
|
@@ -0,0 +1,52 @@
|
|
1
|
+
tinymce.PluginManager.add('alchemy_file_selector', function (editor, url) {
|
2
|
+
|
3
|
+
var content_id = editor.targetElm.name.match(/contents\[([0-9]+)\]/)[1];
|
4
|
+
|
5
|
+
var close_editor_windows = function () {
|
6
|
+
tinymce.each(editor.windowManager.getWindows(), function (w) {
|
7
|
+
w.hide();
|
8
|
+
});
|
9
|
+
}
|
10
|
+
|
11
|
+
var show_editor_windows = function () {
|
12
|
+
tinymce.each(editor.windowManager.getWindows(), function (w) {
|
13
|
+
w.show();
|
14
|
+
});
|
15
|
+
}
|
16
|
+
|
17
|
+
editor.settings.file_picker_callback = function (callback, value, meta) {
|
18
|
+
|
19
|
+
close_editor_windows();
|
20
|
+
|
21
|
+
//url fasullo per avere immagini
|
22
|
+
var url = '/admin/pictures?content_id=' + content_id + '&element_id=0&options%5Bcrop%5D=true&options%5Bfixed_ratio%5D=false&swap=true';
|
23
|
+
dialog = new Alchemy.Dialog(url, {
|
24
|
+
title: "Insert image",
|
25
|
+
size: '780x580',
|
26
|
+
padding: false,
|
27
|
+
modal: true
|
28
|
+
})
|
29
|
+
|
30
|
+
dialog.open();
|
31
|
+
|
32
|
+
|
33
|
+
$(dialog.dialog_body).on('click', '.assign_image_list_detail a', function (e) {
|
34
|
+
e.preventDefault();
|
35
|
+
e.stopPropagation();
|
36
|
+
|
37
|
+
var image_id = this.href.match(/picture_id=([0-9]+)/)[1];
|
38
|
+
|
39
|
+
$.ajax({
|
40
|
+
url: Routes.alchemy_admin_picture_path(image_id, {format: 'json'}),
|
41
|
+
success: function (data) {
|
42
|
+
callback(data.url, {alt: data.alt, width: data.width, height: data.height});
|
43
|
+
show_editor_windows();
|
44
|
+
dialog.close();
|
45
|
+
}
|
46
|
+
})
|
47
|
+
|
48
|
+
});
|
49
|
+
|
50
|
+
}
|
51
|
+
|
52
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module AlchemyFileSelector
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace AlchemyFileSelector
|
4
|
+
|
5
|
+
|
6
|
+
initializer "alchemy_file_selector.append_tinymce_plugin" do
|
7
|
+
tb = Alchemy::Tinymce.init[:toolbar]
|
8
|
+
tb[tb.length-1] = tb.last + " | image"
|
9
|
+
|
10
|
+
Alchemy::Tinymce.init = {
|
11
|
+
plugins: Alchemy::Tinymce.plugins + ['image', 'alchemy_file_selector'],
|
12
|
+
toolbar: tb
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alchemy_file_selector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jury Ghidinelli
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-05 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: 5.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: alchemy_cms
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: js-routes
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: sqlite3
|
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: AlchemyFileSelector.
|
70
|
+
email:
|
71
|
+
- juryghidinelli@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- MIT-LICENSE
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- app/assets/javascripts/alchemy_file_selector/alchemy_admin_require.js
|
80
|
+
- app/assets/javascripts/tinymce/plugins/alchemy_file_selector/plugin.min.js
|
81
|
+
- app/views/alchemy/admin/pictures/show.json.jbuilder
|
82
|
+
- lib/alchemy_file_selector.rb
|
83
|
+
- lib/alchemy_file_selector/engine.rb
|
84
|
+
- lib/alchemy_file_selector/version.rb
|
85
|
+
- lib/tasks/alchemy_file_selector_tasks.rake
|
86
|
+
homepage: https://github.com/ArchimediaZerogroup/alchemy-file-selector
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.6.8
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: AlchemyFileSelector
|
110
|
+
test_files: []
|