cas-cms 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +43 -0
- data/Rakefile +37 -0
- data/app/assets/config/cas_manifest.js +2 -0
- data/app/assets/images/cas/black-star.svg +4 -0
- data/app/assets/images/cas/check.svg +4 -0
- data/app/assets/images/cas/dropzone-in.svg +4 -0
- data/app/assets/images/cas/loading.gif +0 -0
- data/app/assets/images/cas/white-star.svg +4 -0
- data/app/assets/javascripts/cas/application.js +51 -0
- data/app/assets/javascripts/cas/fileupload_manifest.js +269 -0
- data/app/assets/javascripts/cas/plugins/cas_image_gallery.js +353 -0
- data/app/assets/javascripts/cas/vendor/file_upload/canvas-to-blob.min.js +2 -0
- data/app/assets/javascripts/cas/vendor/file_upload/jquery.fileupload-image.js +326 -0
- data/app/assets/javascripts/cas/vendor/file_upload/jquery.fileupload-process.js +178 -0
- data/app/assets/javascripts/cas/vendor/file_upload/jquery.fileupload.js +1482 -0
- data/app/assets/javascripts/cas/vendor/file_upload/jquery.iframe-transport.js +224 -0
- data/app/assets/javascripts/cas/vendor/file_upload/jquery.ui.widget.js +572 -0
- data/app/assets/javascripts/cas/vendor/file_upload/load-image.all.min.js +2 -0
- data/app/assets/javascripts/cas/vendor/jquery.ui.touch-punch.min.js +11 -0
- data/app/assets/javascripts/cas/vendor/selectize.min.js +3 -0
- data/app/assets/stylesheets/cas/application.sass +17 -0
- data/app/assets/stylesheets/cas/colors.sass +6 -0
- data/app/assets/stylesheets/cas/form.sass +99 -0
- data/app/assets/stylesheets/cas/layout.sass +68 -0
- data/app/assets/stylesheets/cas/mixins.sass +34 -0
- data/app/assets/stylesheets/cas/plugins/attachments_form.sass +16 -0
- data/app/assets/stylesheets/cas/plugins/image_gallery.sass +128 -0
- data/app/assets/stylesheets/cas/tables.sass +13 -0
- data/app/assets/stylesheets/cas/typography.sass +27 -0
- data/app/assets/stylesheets/cas/vendors/selectize.default.css +394 -0
- data/app/assets/stylesheets/cas/vendors/simplegrid.css +298 -0
- data/app/controllers/cas/api/files_controller.rb +88 -0
- data/app/controllers/cas/application_controller.rb +17 -0
- data/app/controllers/cas/devise/sessions_controller.rb +9 -0
- data/app/controllers/cas/file_uploads_controller.rb +14 -0
- data/app/controllers/cas/sections/application_controller.rb +23 -0
- data/app/controllers/cas/sections/categories_controller.rb +47 -0
- data/app/controllers/cas/sections/contents_controller.rb +144 -0
- data/app/controllers/cas/sections_controller.rb +7 -0
- data/app/controllers/cas/users_controller.rb +61 -0
- data/app/helpers/cas/application_helper.rb +4 -0
- data/app/helpers/cas/form_helper.rb +11 -0
- data/app/jobs/cas/application_job.rb +4 -0
- data/app/jobs/cas/images/delete_job.rb +11 -0
- data/app/jobs/cas/images/promote_job.rb +11 -0
- data/app/jobs/cas/increment_pageviews_job.rb +11 -0
- data/app/models/cas/application_record.rb +5 -0
- data/app/models/cas/category.rb +6 -0
- data/app/models/cas/content.rb +59 -0
- data/app/models/cas/media_file.rb +77 -0
- data/app/models/cas/section.rb +10 -0
- data/app/models/cas/site.rb +5 -0
- data/app/models/cas/user.rb +39 -0
- data/app/uploaders/file_uploader.rb +26 -0
- data/app/views/cas/devise/sessions/new.html.erb +24 -0
- data/app/views/cas/sections/categories/_form.html.erb +19 -0
- data/app/views/cas/sections/categories/edit.html.erb +5 -0
- data/app/views/cas/sections/categories/index.html.erb +28 -0
- data/app/views/cas/sections/categories/new.html.erb +5 -0
- data/app/views/cas/sections/contents/_form_attachments.html.erb +42 -0
- data/app/views/cas/sections/contents/_form_attachments_template.html.erb +11 -0
- data/app/views/cas/sections/contents/_form_for_content.html.erb +85 -0
- data/app/views/cas/sections/contents/_form_for_survey.html.erb +36 -0
- data/app/views/cas/sections/contents/_form_images.html.erb +86 -0
- data/app/views/cas/sections/contents/edit.html.erb +6 -0
- data/app/views/cas/sections/contents/index.html.erb +71 -0
- data/app/views/cas/sections/contents/new.html.erb +5 -0
- data/app/views/cas/sections/index.html.erb +21 -0
- data/app/views/cas/shared/_error_messages.html.erb +12 -0
- data/app/views/cas/users/_form.html.erb +11 -0
- data/app/views/cas/users/edit.html.erb +2 -0
- data/app/views/cas/users/index.html.erb +34 -0
- data/app/views/cas/users/new.html.erb +2 -0
- data/app/views/layouts/cas/application.html.erb +71 -0
- data/config/initializers/acts_as_taggable.rb +1 -0
- data/config/initializers/devise.rb +277 -0
- data/config/initializers/shrine.rb +50 -0
- data/config/initializers/simple_form.rb +169 -0
- data/config/locales/devise.en.yml +64 -0
- data/config/locales/pt-BR.yml +242 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/routes.rb +31 -0
- data/db/migrate/20170129212144_create_cas_sites.rb +15 -0
- data/db/migrate/20170219172958_create_cas_sections.rb +12 -0
- data/db/migrate/20170219175007_create_cas_contents.rb +17 -0
- data/db/migrate/20170612204500_create_cas_users.rb +14 -0
- data/db/migrate/20170613174724_create_cas_media_files.rb +20 -0
- data/db/migrate/20170613175912_create_cas_categories.rb +14 -0
- data/db/migrate/20170614171928_add_columns_to_cas_contents.rb +12 -0
- data/db/migrate/20170614172904_add_column_to_cas_sections.rb +6 -0
- data/db/migrate/20170615235532_add_devise_to_cas_users.rb +49 -0
- data/db/migrate/20170616011202_remove_password_from_cas_users.rb +5 -0
- data/db/migrate/20170618014204_v3_migration_fields.rb +30 -0
- data/db/migrate/20170623182702_add_column_category_id_to_cas_content.rb +6 -0
- data/db/migrate/20170624024648_rename_url_to_path_in_files.rb +7 -0
- data/db/migrate/20170625192119_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +36 -0
- data/db/migrate/20170625192120_add_missing_unique_indices.acts_as_taggable_on_engine.rb +26 -0
- data/db/migrate/20170625192121_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +20 -0
- data/db/migrate/20170625192122_add_missing_taggable_index.acts_as_taggable_on_engine.rb +15 -0
- data/db/migrate/20170625192123_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +15 -0
- data/db/migrate/20170625192124_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb +23 -0
- data/db/migrate/20170713210101_add_location_to_cas_content.rb +5 -0
- data/db/migrate/20170714043036_add_url_to_content.rb +5 -0
- data/db/migrate/20170718201535_add_embedded_to_content.rb +5 -0
- data/db/migrate/20170801171952_categories_with_jsonb_metadata.rb +6 -0
- data/db/migrate/20170801173256_add_published_at_to_cas_contents.rb +6 -0
- data/db/migrate/20170801175407_add_description_to_cas_categories.rb +5 -0
- data/db/migrate/20170830000000_add_data_search_extensions.rb +17 -0
- data/db/migrate/20170830000001_add_search_index_to_cas_contents.rb +20 -0
- data/db/migrate/20170830000002_use_uuid_with_acts_as_taggable_references.rb +17 -0
- data/db/migrate/20170919181809_pageviews_default_to_zero.rb +9 -0
- data/db/migrate/20171201191059_add_domains_to_cas_site.rb +6 -0
- data/lib/cas.rb +22 -0
- data/lib/cas/config.rb +42 -0
- data/lib/cas/engine.rb +33 -0
- data/lib/cas/form_field.rb +54 -0
- data/lib/cas/remote_callbacks.rb +36 -0
- data/lib/cas/section_config.rb +84 -0
- data/lib/cas/setup.rb +43 -0
- data/lib/cas/version.rb +3 -0
- data/lib/devise/custom_failure.rb +16 -0
- data/lib/tasks/cas_tasks.rake +4 -0
- data/lib/templates/erb/scaffold/_form.html.erb +13 -0
- metadata +560 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9b88802ff9371e54ee620c776c90e53077379d80
|
4
|
+
data.tar.gz: c5df9bfa6966724c9c87fcff5d44116a60d95910
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e75b570c8b02a11c99a2239cdb0024107498169ff1fe1152f7c296837c72409a0453d09aaec614b52ad1934e86559af06389ae68311f084ce19a51e2102a7ed4
|
7
|
+
data.tar.gz: 920b28f837047f0539179e7a3bb0f0e512bae04975a9f8ac3ff69d3ec94ec0b0f48f40da9317627d9ea92396a9a876c48fc83de2dd4834343a9809175a2ce81a
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Thayná de Oliveira
|
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,43 @@
|
|
1
|
+
# Cas
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'cas'
|
13
|
+
```
|
14
|
+
|
15
|
+
### Setup
|
16
|
+
|
17
|
+
**Engine:** Cas is mounted in your main Rails application. Say your application
|
18
|
+
is called MyBlog, you make can make it accessible at `myblog.com/admin`
|
19
|
+
by setting the following in the `config/routes.rb` file in your main
|
20
|
+
application:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
Rails.application.routes.draw do
|
24
|
+
mount Cas::Engine, at: "/admin"
|
25
|
+
|
26
|
+
# ... other routes
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
**S3:** you need S3 credentials to use Cas (for file uploads). Set the
|
31
|
+
following ENV vars (e.g paste in your `~/.bash_profile` or use the `dotenv`
|
32
|
+
gem in your main Rails application):
|
33
|
+
|
34
|
+
export S3_ACCESS_KEY_ID="value"
|
35
|
+
export S3_SECRET_ACCESS_KEY="value"
|
36
|
+
export S3_REGION="value"
|
37
|
+
export S3_BUCKET="value"
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
Contribution directions go here.
|
41
|
+
|
42
|
+
## License
|
43
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
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 = 'Cas'
|
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("../spec/test_app/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<svg width="100pt" height="100pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
3
|
+
<path d="m50 25l8.1133 16.348 17.887 2.75-12.871 12.855 2.9375 18.047-16.07-8.4023-16.07 8.4023 2.9375-18.047-12.871-12.855 17.887-2.75z"/>
|
4
|
+
</svg>
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<svg fill="#FFFFFF" width="100pt" height="100pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
3
|
+
<path d="m69.535 95.832h-4.1016c-1.1484 0-2.082 0.93359-2.082 2.082 0 1.1484 0.93359 2.082 2.082 2.082h4.1016c1.1484 0 2.082-0.93359 2.082-2.082 0-1.1484-0.92969-2.082-2.082-2.082zm21.352-54.027c1 0.21094 1.9453 0.67969 2.7266 1.3398 0.39453 0.33203 0.875 0.49609 1.3516 0.49609 0.58984 0 1.1758-0.25 1.5859-0.73438 0.74609-0.875 0.63672-2.1914-0.23828-2.9375-1.3086-1.1133-2.8828-1.8906-4.5586-2.2461-1.0977-0.23047-2.2344 0.48047-2.4766 1.6055-0.23047 1.1289 0.48828 2.2383 1.6094 2.4766zm-33.656 54.027h-4.1016c-1.1484 0-2.082 0.93359-2.082 2.082 0 1.1484 0.93359 2.082 2.082 2.082h4.1016c1.1484 0 2.082-0.93359 2.082-2.082 0-1.1484-0.92969-2.082-2.082-2.082zm-15.562-8.4531v-4.1055c0-1.1484-0.93359-2.082-2.082-2.082-1.1523 0-2.0859 0.93359-2.0859 2.082v4.1055c0 1.1484 0.93359 2.082 2.082 2.082 1.1523 0 2.0859-0.92578 2.0859-2.082zm4.0547 8.0586c-0.95703-0.35938-1.8242-0.95703-2.5039-1.7344-0.75781-0.86719-2.0742-0.94922-2.9375-0.19141-0.86719 0.75781-0.95312 2.0742-0.19531 2.9414 1.1289 1.293 2.5703 2.2891 4.1719 2.8867 0.24609 0.085937 0.48828 0.13281 0.73438 0.13281 0.83984 0 1.6367-0.51562 1.9492-1.3555 0.39844-1.0742-0.14844-2.2812-1.2188-2.6797zm52.195-24.02c-1.1484 0-2.082 0.93359-2.082 2.082v4.1016c0 1.1484 0.93359 2.082 2.082 2.082 1.1484 0 2.082-0.93359 2.082-2.082v-4.1016c0-1.1484-0.93359-2.082-2.082-2.082zm0-12.305c-1.1484 0-2.082 0.93359-2.082 2.082v4.1016c0 1.1484 0.93359 2.082 2.082 2.082 1.1484 0 2.082-0.93359 2.082-2.082v-4.1016c0-1.1523-0.93359-2.082-2.082-2.082zm0-12.309c-1.1484 0-2.082 0.93359-2.082 2.082v4.1016c0 1.1484 0.93359 2.082 2.082 2.082 1.1484 0 2.082-0.93359 2.082-2.082v-4.1016c0-1.1484-0.93359-2.082-2.082-2.082zm0 36.918c-1.1484 0-2.082 0.93359-2.082 2.082l-0.007813 4.0195 2.082 0.078125 2.0898-0.32031v-3.7773c0-1.1523-0.93359-2.082-2.082-2.082zm-5.0859 11.203c-0.875 0.53516-1.875 0.84766-2.8984 0.89844-1.1484 0.0625-2.0273 1.043-1.9727 2.1914 0.058593 1.1133 0.97656 1.9766 2.0781 1.9766h0.10938c1.7109-0.089844 3.3906-0.61328 4.8555-1.5078 0.98438-0.60156 1.293-1.8828 0.69141-2.8672-0.59766-0.98828-1.8906-1.2891-2.8633-0.69141zm-10.984 0.90625h-4.1016c-1.1484 0-2.082 0.93359-2.082 2.082 0 1.1484 0.93359 2.082 2.082 2.082h4.1016c1.1484 0 2.082-0.93359 2.082-2.082 0-1.1484-0.93359-2.082-2.082-2.082zm-8.9297-56.25c0-1.1484-0.93359-2.082-2.0859-2.082h-1.4453c-0.35938-0.41406-0.64844-0.87109-1.0391-1.2617l-5.8477-5.8516v-19.969c0-5.7422-4.6719-10.418-10.418-10.418h-41.668c-5.7422 0-10.414 4.6758-10.414 10.418v41.668c0 5.7383 4.6719 10.414 10.418 10.414h20.832c1.1484 0 2.082-0.93359 2.082-2.082 0-1.1523-0.93359-2.0859-2.082-2.0859h-20.832c-3.4453 0-6.25-2.8047-6.25-6.25v-31.25h54.168v7.2969c-2.0156-0.3125-4.1484 0.16406-5.6406 1.6484-0.74609 0.74609-1.293 1.6406-1.6016 2.6172-2.2891-0.78516-4.9844-0.20312-6.7344 1.5508-0.93359 0.93359-1.5469 2.0977-1.793 3.3672-1.9961-0.28906-4.0586 0.39453-5.5 1.8398-1.2305 1.2266-1.9023 2.8633-1.9023 4.6016 0 0.15234 0.003907 0.30469 0.015626 0.45312-1.4023 0.1875-2.6953 0.82812-3.7148 1.8477-2.5352 2.5352-2.5352 6.6641 0 9.1953l1.8672 1.8633v7.4727c0 3.3945 1.6523 6.3828 4.1758 8.2891 0 0.011719-0.007812 0.023438-0.007812 0.042969v2.082c0 1.1484 0.93359 2.082 2.082 2.082 1.1523 0 2.0859-0.93359 2.0859-2.082v-0.21094c0.67188 0.13672 1.3711 0.21094 2.082 0.21094h8.543c12.52 0 22.707-10.188 22.707-22.707 0-3.9492-1.0977-7.6953-2.9766-11.047 0.52734-0.375 0.89453-0.96094 0.89453-1.6641zm-62.5-27.082c-1.1523 0-2.0859-0.93359-2.0859-2.082 0-1.1523 0.93359-2.0859 2.0859-2.0859 1.1484 0 2.082 0.93359 2.082 2.0859 0 1.1484-0.93359 2.082-2.082 2.082zm8.332 0c-1.1484 0-2.082-0.93359-2.082-2.082 0-1.1523 0.93359-2.0859 2.082-2.0859s2.082 0.93359 2.082 2.0859c0 1.1484-0.93359 2.082-2.082 2.082zm8.332 0c-1.1484 0-2.082-0.93359-2.082-2.082 0-1.1523 0.93359-2.0859 2.082-2.0859 1.1523 0 2.0859 0.93359 2.0859 2.0859 0 1.1484-0.93359 2.082-2.0859 2.082zm56.055 25h-4.1016c-1.1484 0-2.082 0.93359-2.082 2.082 0 1.1484 0.93359 2.082 2.082 2.082h4.1016c1.1484 0 2.082-0.93359 2.082-2.082 0.003906-1.1484-0.92969-2.082-2.082-2.082z"/>
|
4
|
+
</svg>
|
Binary file
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<svg fill="#FFFFFF" width="100pt" height="100pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
3
|
+
<path d="m50 25l8.1133 16.348 17.887 2.75-12.871 12.855 2.9375 18.047-16.07-8.4023-16.07 8.4023 2.9375-18.047-12.871-12.855 17.887-2.75z"/>
|
4
|
+
</svg>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
//= require jquery
|
2
|
+
//= require jquery_ujs
|
3
|
+
//= require tinymce-jquery
|
4
|
+
//= require cas/vendor/selectize.min
|
5
|
+
//= require_self
|
6
|
+
|
7
|
+
$(document).ready(function() {
|
8
|
+
$(".js-tags").selectize({
|
9
|
+
plugins: ['restore_on_backspace', 'remove_button'],
|
10
|
+
delimiter: ',',
|
11
|
+
persist: true,
|
12
|
+
preload: false,
|
13
|
+
render: {
|
14
|
+
option_create: function(item, escape) {
|
15
|
+
var input = item.input;
|
16
|
+
return '<div class="create">' +
|
17
|
+
(input ? '<span class="caption">Criar <b>' + escape(input) + '</b></span>' : '') +
|
18
|
+
'</div>';
|
19
|
+
},
|
20
|
+
},
|
21
|
+
create: function(input) {
|
22
|
+
return {
|
23
|
+
value: input,
|
24
|
+
text: input
|
25
|
+
}
|
26
|
+
},
|
27
|
+
onInitialize: function(){
|
28
|
+
var selectize = this;
|
29
|
+
var data = this.$input.data('autocomplete');
|
30
|
+
selectize.addOption(data);
|
31
|
+
}
|
32
|
+
});
|
33
|
+
|
34
|
+
tinyMCE.init({
|
35
|
+
selector: 'textarea.editor',
|
36
|
+
mode : "exact",
|
37
|
+
relative_urls : false,
|
38
|
+
convert_urls : 0, // default 1
|
39
|
+
pagebreak_separator : '<br clear="all" class="pagebreak" />',
|
40
|
+
height : '350',
|
41
|
+
convert_fonts_to_spans : true,
|
42
|
+
font_size_style_values : "8pt,10pt,12pt,14pt,18pt,24pt,36pt",
|
43
|
+
inline_styles: false,
|
44
|
+
extended_valid_elements: "embed,param,object,iframe[src|title|width|height|allowfullscreen|frameborder]",
|
45
|
+
language : "pt_BR",
|
46
|
+
plugins : 'image,imagetools,code,paste,pagebreak,table,wordcount,link',
|
47
|
+
default_link_target: "_blank",
|
48
|
+
images_upload_url: paths.fileUpload.path,
|
49
|
+
images_upload_credentials: true
|
50
|
+
});
|
51
|
+
});
|
@@ -0,0 +1,269 @@
|
|
1
|
+
// jquery already loaded
|
2
|
+
//= require jquery-ui/widgets/sortable
|
3
|
+
//= require cas/vendor/jquery.ui.touch-punch.min.js
|
4
|
+
//
|
5
|
+
// widget needs only when jquery ui is not included
|
6
|
+
// require cas/vendor/file_upload/jquery.ui.widget
|
7
|
+
//= require cas/vendor/file_upload/load-image.all.min
|
8
|
+
//= require cas/vendor/file_upload/canvas-to-blob.min
|
9
|
+
//= require cas/vendor/file_upload/jquery.iframe-transport
|
10
|
+
//= require cas/vendor/file_upload/jquery.fileupload
|
11
|
+
//= require cas/vendor/file_upload/jquery.fileupload-process
|
12
|
+
//= require cas/vendor/file_upload/jquery.fileupload-image
|
13
|
+
//= require cas/plugins/cas_image_gallery
|
14
|
+
//= require_self
|
15
|
+
var gallery;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Shared functions
|
19
|
+
*
|
20
|
+
* These are functions that are used for both images and generic attachments.
|
21
|
+
*/
|
22
|
+
var UploadSharedFunctions = {
|
23
|
+
progress: function(e, data) {
|
24
|
+
var progress = parseInt(data.loaded / data.total * 100, 10);
|
25
|
+
var percentage = progress.toString() + '%'
|
26
|
+
data.progressBar.find(".progress-bar").css("width", percentage);
|
27
|
+
data.progressBar.find(".name").html(percentage);
|
28
|
+
},
|
29
|
+
fail: function(e, data) {
|
30
|
+
console.log("error", e);
|
31
|
+
console.log("data", data);
|
32
|
+
data.progressBar.remove();
|
33
|
+
alert('Falha ao enviar arquivo: '+data.files[0].name);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Image gallery upload functions
|
39
|
+
*
|
40
|
+
* These functions are only used by the upload mechanism intented for the upload
|
41
|
+
* of images for the gallery, not general attachments.
|
42
|
+
*/
|
43
|
+
var ImageGalleryUploadFunctions = {
|
44
|
+
add: function(e, data) {
|
45
|
+
var acceptFileTypes = /^image\/(gif|jpe?g|png|tiff)$/i;
|
46
|
+
|
47
|
+
for (var index in data.originalFiles) {
|
48
|
+
var file = data.originalFiles[index];
|
49
|
+
if(file['type'].length && !acceptFileTypes.test(file['type'])) {
|
50
|
+
alert('O arquivo enviado não é uma imagem.');
|
51
|
+
return false;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
var that = this;
|
56
|
+
|
57
|
+
data.progressBar = $('<div class="progress-status"><span class="name"> </span><div class="progress-bar"></div></div>');
|
58
|
+
$(this).after(data.progressBar);
|
59
|
+
|
60
|
+
var options = {
|
61
|
+
extension: data.files[0].name.match(/(\.\w+)?$/)[0], // set extension
|
62
|
+
_: Date.now(), // prevent caching
|
63
|
+
}
|
64
|
+
|
65
|
+
$.getJSON('/admin/files/cache/presign', options, function(result) {
|
66
|
+
console.log("image: presign result", result);
|
67
|
+
console.log("image: now will submit file to S3 URL: ", result["url"]);
|
68
|
+
data.formData = result['fields'];
|
69
|
+
data.url = result['url'];
|
70
|
+
data.paramName = 'file';
|
71
|
+
$.blueimp.fileupload.prototype.options.add.call(that, e, data);
|
72
|
+
data.submit();
|
73
|
+
});
|
74
|
+
},
|
75
|
+
done: function(e, data) {
|
76
|
+
console.log("Image: upload done! Now posting to /admin/api/files", data.formData);
|
77
|
+
data.progressBar.remove();
|
78
|
+
|
79
|
+
var file = {
|
80
|
+
original: {
|
81
|
+
id: data.formData.key.match(/cache\/(.+)/)[1], // we have to remove the prefix part
|
82
|
+
storage: 'cache',
|
83
|
+
metadata: {
|
84
|
+
size: data.files[0].size,
|
85
|
+
filename: data.files[0].name.match(/[^\/\\]*$/)[0], // IE returns full path
|
86
|
+
mime_type: data.files[0].type
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
var fileInput = $(this);
|
92
|
+
var fileInputName = $(this).attr("name");
|
93
|
+
var fileImagesGallery = $(fileInput.data("images"));
|
94
|
+
|
95
|
+
console.log("image: posting to /admin/api/files");
|
96
|
+
$.ajax("/admin/api/files", {
|
97
|
+
method: 'POST',
|
98
|
+
data: {
|
99
|
+
data: {
|
100
|
+
attributes: {
|
101
|
+
metadata: file,
|
102
|
+
media_type: 'image'
|
103
|
+
},
|
104
|
+
relationships: {
|
105
|
+
attachable: {
|
106
|
+
data: {
|
107
|
+
type: gallery.attachable().type,
|
108
|
+
id: gallery.attachable().id
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}).done(function(response) {
|
115
|
+
var id = response.data.id;
|
116
|
+
var url = response.data.attributes.url;
|
117
|
+
var filename = response.data.attributes["original-name"];
|
118
|
+
gallery.addImage({
|
119
|
+
url: url,
|
120
|
+
id: id,
|
121
|
+
filename: filename,
|
122
|
+
orderBy: "filename"
|
123
|
+
});
|
124
|
+
});
|
125
|
+
}
|
126
|
+
};
|
127
|
+
|
128
|
+
var AttachmentUploadFunctions = {
|
129
|
+
add: function(e, data) {
|
130
|
+
data.progressBar = $('<div class="progress-status"><span class="name"> </span><div class="progress-bar"></div></div>');
|
131
|
+
$(this).after(data.progressBar);
|
132
|
+
|
133
|
+
var options = {
|
134
|
+
extension: data.files[0].name.match(/(\.\w+)?$/)[0], // set extension
|
135
|
+
_: Date.now(), // prevent caching
|
136
|
+
}
|
137
|
+
|
138
|
+
$.getJSON('/admin/files/cache/presign', options, function(result) {
|
139
|
+
console.log("Attachment presign result", result);
|
140
|
+
data.formData = result['fields'];
|
141
|
+
data.url = result['url'];
|
142
|
+
data.paramName = 'file';
|
143
|
+
data.submit();
|
144
|
+
});
|
145
|
+
},
|
146
|
+
done: function(e, data) {
|
147
|
+
console.log("Attachment upload done! Now posting to /admin/api/files");
|
148
|
+
data.progressBar.remove();
|
149
|
+
|
150
|
+
var file = {
|
151
|
+
original: {
|
152
|
+
id: data.formData.key.match(/cache\/(.+)/)[1], // we have to remove the prefix part
|
153
|
+
storage: 'cache',
|
154
|
+
metadata: {
|
155
|
+
size: data.files[0].size,
|
156
|
+
filename: data.files[0].name.match(/[^\/\\]*$/)[0], // IE returns full path
|
157
|
+
mime_type: data.files[0].type
|
158
|
+
}
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
var fileInput = $(this);
|
163
|
+
var fileInputName = $(this).attr("name");
|
164
|
+
var fileImagesGallery = $(fileInput.data("images"));
|
165
|
+
|
166
|
+
console.log("Attachment: posting to /admin/api/files");
|
167
|
+
$.ajax("/admin/api/files", {
|
168
|
+
method: 'POST',
|
169
|
+
data: {
|
170
|
+
data: {
|
171
|
+
attributes: {
|
172
|
+
metadata: file,
|
173
|
+
media_type: 'attachment'
|
174
|
+
},
|
175
|
+
relationships: {
|
176
|
+
attachable: {
|
177
|
+
data: {
|
178
|
+
type: gallery.attachable().type,
|
179
|
+
id: gallery.attachable().id
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}).done(function(response) {
|
186
|
+
var id = response.data.id;
|
187
|
+
var url = response.data.attributes.url;
|
188
|
+
var filename = response.data.attributes["original-name"];
|
189
|
+
var itemTemplate = $("#cas-attachments-template").html();
|
190
|
+
var finalHtml = $(itemTemplate);
|
191
|
+
|
192
|
+
finalHtml.attr("data-id", id);
|
193
|
+
finalHtml.find(".filename").html(filename);
|
194
|
+
|
195
|
+
$("#attachments-list").append(finalHtml);
|
196
|
+
/**
|
197
|
+
* order is set to 0 all for now
|
198
|
+
*/
|
199
|
+
$("#attachments-list").append("<input type='hidden' name='attachments[files][0][id]' class='js-attachment-input' value='"+id+"' />");
|
200
|
+
});
|
201
|
+
}
|
202
|
+
};
|
203
|
+
|
204
|
+
function deleteFiles(ids) {
|
205
|
+
if (confirm("Tem certeza disso?")) {
|
206
|
+
return $.ajax("" + paths.deleteFile.path + "/" + ids.join(), {
|
207
|
+
method: paths.deleteFile.method
|
208
|
+
});
|
209
|
+
} else {
|
210
|
+
return false;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
$(function() {
|
215
|
+
gallery = new CasImageGallery({
|
216
|
+
element: $(".cas-image-gallery"),
|
217
|
+
selectionEnabled: false,
|
218
|
+
preloadedImagesElements: $(".cas-image-gallery .cas-gallery-preloaded"),
|
219
|
+
onDelete: deleteFiles
|
220
|
+
});
|
221
|
+
gallery.init();
|
222
|
+
|
223
|
+
$(".cas-image-gallery .images").sortable({
|
224
|
+
stop: function() {
|
225
|
+
gallery.resetImagesOrder();
|
226
|
+
}
|
227
|
+
});
|
228
|
+
|
229
|
+
$('.cas-image-gallery [type=file]').fileupload({
|
230
|
+
maxChunkSize: 10000000, // 10000000 = 10mb
|
231
|
+
dropZone: $('.cas-image-gallery.dropzone'),
|
232
|
+
dataType: 'json',
|
233
|
+
disableImageResize: /Android(?!.*Chrome)|Opera/.test(window.navigator && navigator.userAgent),
|
234
|
+
imageMaxWidth: 1920,
|
235
|
+
imageMaxHeight: 1920,
|
236
|
+
imageOrientation: true,
|
237
|
+
prependFiles: true,
|
238
|
+
|
239
|
+
// callbacks
|
240
|
+
add: ImageGalleryUploadFunctions.add,
|
241
|
+
progress: UploadSharedFunctions.progress,
|
242
|
+
fail: UploadSharedFunctions.fail,
|
243
|
+
done: ImageGalleryUploadFunctions.done
|
244
|
+
});
|
245
|
+
|
246
|
+
$('.cas-attachments [type=file]').fileupload({
|
247
|
+
maxChunkSize: 10000000, // 10000000 = 10mb
|
248
|
+
dropZone: $('.cas-attachments.dropzone'),
|
249
|
+
dataType: 'json',
|
250
|
+
|
251
|
+
// callbacks
|
252
|
+
add: AttachmentUploadFunctions.add,
|
253
|
+
progress: UploadSharedFunctions.progress,
|
254
|
+
fail: UploadSharedFunctions.fail,
|
255
|
+
done: AttachmentUploadFunctions.done
|
256
|
+
});
|
257
|
+
|
258
|
+
// DELETING ATTACHMENTS
|
259
|
+
$('.cas-attachments').on('click', '.js-delete-file', function(el) {
|
260
|
+
var fileEl = $(this).parents("[data-id]");
|
261
|
+
var id = [fileEl.attr('data-id')];
|
262
|
+
var response = deleteFiles(id);
|
263
|
+
if (response) {
|
264
|
+
response.done(function() {
|
265
|
+
fileEl.remove();
|
266
|
+
});
|
267
|
+
}
|
268
|
+
});
|
269
|
+
});
|