├── test └── dummy │ ├── log │ └── .keep │ ├── app │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── concerns │ │ │ └── .keep │ │ └── image.rb │ ├── assets │ │ ├── images │ │ │ └── .keep │ │ ├── stylesheets │ │ │ └── application.css │ │ └── javascripts │ │ │ └── application.js │ ├── controllers │ │ ├── concerns │ │ │ └── .keep │ │ ├── application_controller.rb │ │ └── tinymce_assets_controller.rb │ ├── helpers │ │ └── application_helper.rb │ └── views │ │ ├── application │ │ └── editor.html.erb │ │ └── layouts │ │ └── application.html.erb │ ├── lib │ ├── assets │ │ └── .keep │ └── tasks │ │ └── .keep │ ├── test │ ├── models │ │ └── .keep │ ├── controllers │ │ └── .keep │ ├── fixtures │ │ └── .keep │ ├── helpers │ │ └── .keep │ ├── integration │ │ └── .keep │ ├── mailers │ │ └── .keep │ └── test_helper.rb │ ├── public │ ├── favicon.ico │ ├── robots.txt │ ├── 500.html │ ├── 422.html │ └── 404.html │ ├── vendor │ └── assets │ │ ├── javascripts │ │ └── .keep │ │ └── stylesheets │ │ └── .keep │ ├── bin │ ├── rake │ ├── bundle │ └── rails │ ├── config │ ├── routes.rb │ ├── initializers │ │ ├── session_store.rb │ │ ├── filter_parameter_logging.rb │ │ ├── mime_types.rb │ │ ├── backtrace_silencers.rb │ │ ├── wrap_parameters.rb │ │ ├── secret_token.rb │ │ └── inflections.rb │ ├── environment.rb │ ├── boot.rb │ ├── database.yml │ ├── locales │ │ └── en.yml │ ├── application.rb │ └── environments │ │ ├── development.rb │ │ ├── test.rb │ │ └── production.rb │ ├── config.ru │ ├── Rakefile │ ├── db │ ├── migrate │ │ └── 20140220155401_create_images.rb │ ├── seeds.rb │ └── schema.rb │ ├── .gitignore │ ├── README.rdoc │ └── Gemfile ├── Rakefile ├── .gitignore ├── Gemfile ├── lib ├── tinymce-rails-imageupload.rb ├── tinymce-rails-imageupload │ ├── version.rb │ └── rails.rb └── tasks │ └── tinymce-uploadimage-assets.rake ├── app └── assets │ └── javascripts │ └── tinymce │ └── plugins │ └── uploadimage │ ├── langs │ ├── zh_TW.js │ ├── pl.js │ ├── de.js │ ├── en.js │ ├── nb.js │ ├── ru.js │ ├── es.js │ ├── pt.js │ ├── pt_BR.js │ ├── pt_PT.js │ ├── fr.js │ ├── fr_FR.js │ ├── zh-cn.js │ └── da.js │ └── plugin.js ├── LICENSE ├── tinymce-rails-imageupload.gemspec ├── CHANGELOG.md └── README.md /test/dummy/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | -------------------------------------------------------------------------------- /test/dummy/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | .bundle 3 | Gemfile.lock 4 | pkg/* 5 | -------------------------------------------------------------------------------- /test/dummy/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /test/dummy/app/models/image.rb: -------------------------------------------------------------------------------- 1 | class Image < ActiveRecord::Base 2 | has_attached_file :file 3 | end -------------------------------------------------------------------------------- /test/dummy/app/views/application/editor.html.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/dummy/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "http://rubygems.org" 2 | 3 | # Specify your gem's dependencies in tinymce-rails-imageupload.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /lib/tinymce-rails-imageupload.rb: -------------------------------------------------------------------------------- 1 | require "tinymce-rails" 2 | require "tinymce-rails-imageupload/version" 3 | require "tinymce-rails-imageupload/rails" -------------------------------------------------------------------------------- /test/dummy/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /lib/tinymce-rails-imageupload/version.rb: -------------------------------------------------------------------------------- 1 | module Tinymce 2 | module Rails 3 | module Imageupload 4 | VERSION = "4.0.17.beta.3" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/dummy/config/routes.rb: -------------------------------------------------------------------------------- 1 | Dummy::Application.routes.draw do 2 | post '/tinymce_assets' => 'tinymce_assets#create' 3 | 4 | root to: 'application#editor' 5 | end 6 | -------------------------------------------------------------------------------- /test/dummy/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /test/dummy/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /test/dummy/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Dummy::Application.config.session_store :cookie_store, key: '_dummy_session' 4 | -------------------------------------------------------------------------------- /test/dummy/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Dummy::Application.initialize! 6 | -------------------------------------------------------------------------------- /test/dummy/config/boot.rb: -------------------------------------------------------------------------------- 1 | # Set up gems listed in the Gemfile. 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | 4 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) 5 | -------------------------------------------------------------------------------- /test/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /test/dummy/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /test/dummy/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | # Mime::Type.register_alias "text/html", :iphone 6 | -------------------------------------------------------------------------------- /test/dummy/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Dummy::Application.load_tasks 7 | -------------------------------------------------------------------------------- /test/dummy/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | 6 | def editor 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /test/dummy/db/migrate/20140220155401_create_images.rb: -------------------------------------------------------------------------------- 1 | class CreateImages < ActiveRecord::Migration 2 | def change 3 | create_table :images do |t| 4 | t.string :alt, default: "" 5 | t.string :hint, default: "" 6 | t.attachment :file 7 | t.timestamps 8 | end 9 | end 10 | end -------------------------------------------------------------------------------- /lib/tinymce-rails-imageupload/rails.rb: -------------------------------------------------------------------------------- 1 | module Tinymce 2 | module Rails 3 | module Imageupload 4 | class Engine < ::Rails::Engine 5 | initializer 'TinymceRailsImageupload.assets_pipeline' do |app| 6 | app.config.assets.precompile << "tinymce/plugins/uploadimage/*" 7 | end 8 | end 9 | end 10 | end 11 | end -------------------------------------------------------------------------------- /test/dummy/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /test/dummy/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |", 24 | plugins: ["uploadimage"], 25 | relative_urls: false, 26 | remove_script_host: false, 27 | document_base_url: (!window.location.origin ? window.location.protocol + "//" + window.location.host : window.location.origin) + "/", 28 | }) 29 | }); -------------------------------------------------------------------------------- /tinymce-rails-imageupload.gemspec: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | $:.push File.expand_path("../lib", __FILE__) 3 | require "tinymce-rails-imageupload/version" 4 | 5 | Gem::Specification.new do |s| 6 | s.name = "tinymce-rails-imageupload" 7 | s.version = Tinymce::Rails::Imageupload::VERSION 8 | s.authors = ["Per Christian B. Viken"] 9 | s.email = ["perchr@northblue.org"] 10 | s.homepage = "http://eastblue.org/oss" 11 | s.summary = %q{TinyMCE plugin for taking image uploads in Rails >= 3.2} 12 | s.description = %q{TinyMCE plugin for taking image uploads in Rails >= 3.2. Image storage is handled manually, so works with everything.} 13 | 14 | s.files = [Dir["app/assets/javascripts/tinymce/plugins/uploadimage/**/*.js"], 15 | Dir["lib/**/*.rb"], 16 | "lib/tasks/tinymce-uploadimage-assets.rake", 17 | "CHANGELOG.md", 18 | "LICENSE", 19 | "README.md", 20 | ].flatten 21 | s.test_files = [] 22 | s.require_paths = ["lib"] 23 | 24 | s.license = "MIT" 25 | 26 | s.add_runtime_dependency "railties", ">= 3.2" 27 | s.add_runtime_dependency "tinymce-rails", "~> 4.0" 28 | s.add_development_dependency "bundler", "~> 1.0" 29 | s.add_development_dependency "rails", ">= 3.1" 30 | end 31 | -------------------------------------------------------------------------------- /test/dummy/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 4 | gem 'rails', '4.0.2' 5 | 6 | # Use sqlite3 as the database for Active Record 7 | gem 'sqlite3' 8 | 9 | # Use SCSS for stylesheets 10 | gem 'sass-rails', '~> 4.0.0' 11 | 12 | # Use Uglifier as compressor for JavaScript assets 13 | gem 'uglifier', '>= 1.3.0' 14 | 15 | # Use CoffeeScript for .js.coffee assets and views 16 | gem 'coffee-rails', '~> 4.0.0' 17 | 18 | # See https://github.com/sstephenson/execjs#readme for more supported runtimes 19 | # gem 'therubyracer', platforms: :ruby 20 | 21 | # Use jquery as the JavaScript library 22 | gem 'jquery-rails' 23 | 24 | # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 25 | gem 'turbolinks' 26 | 27 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 28 | gem 'jbuilder', '~> 1.2' 29 | 30 | group :doc do 31 | # bundle exec rake doc:rails generates the API under doc/api. 32 | gem 'sdoc', require: false 33 | end 34 | 35 | # Use ActiveModel has_secure_password 36 | # gem 'bcrypt-ruby', '~> 3.1.2' 37 | 38 | # Use unicorn as the app server 39 | # gem 'unicorn' 40 | 41 | # Use Capistrano for deployment 42 | # gem 'capistrano', group: :development 43 | 44 | # Use debugger 45 | # gem 'debugger', group: [:development, :test] 46 | 47 | gem 'tinymce-rails-imageupload', path: '../../' 48 | gem 'paperclip' -------------------------------------------------------------------------------- /test/dummy/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
If you are the application owner check the logs for more information.
56 | 57 | 58 | -------------------------------------------------------------------------------- /test/dummy/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Maybe you tried to change something you didn't have access to.
55 |If you are the application owner check the logs for more information.
57 | 58 | 59 | -------------------------------------------------------------------------------- /test/dummy/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |You may have mistyped the address or the page may have moved.
55 |If you are the application owner check the logs for more information.
57 | 58 | 59 | -------------------------------------------------------------------------------- /test/dummy/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Dummy::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static asset server for tests with Cache-Control for performance. 16 | config.serve_static_assets = true 17 | config.static_cache_control = "public, max-age=3600" 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Print deprecation notices to the stderr. 35 | config.active_support.deprecation = :stderr 36 | end 37 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 4.0.0 / unreleased 2 | 3 | * Rewrite the plugin to work with TinyMCE 4. TinyMCE 3.x is supported in the 4 | tinymce3-branch. 5 | 6 | # 3.5.8.5 / 2013-05-07 7 | 8 | * Depend on tinymce-rails ~> 3.5.8.1 for the asset tasks. Thanks to joshcrews (Josh Crews) 9 | This should solve the issue with asset precompilation (#15). 10 | * Add Simplified Chinese (zh-cn) translations. Thanks to inntran (Yinchuan Song) 11 | 12 | # 3.5.8.4 / 2013-04-23 13 | 14 | * Make the plugin work in IE8 and IE9 again. Thanks to pomartel (Pierre Olivier Martel) 15 | * Add German translations. Thanks to pomartel (Pierre Olivier Martel) 16 | * Add Spanish translations. Thanks to pomartel (Pierre Olivier Martel) 17 | 18 | # 3.5.8.3 / 2013-03-18 19 | 20 | * Add option for assigning class to img tag. Thanks to nathanshox (Nathan Shaughnessy) 21 | * Add alt attribute to img tag and input for user to set it. Thanks to nathanshox (Nathan Shaughnessy) 22 | 23 | # 3.5.8.2 / 2013-03-11 24 | 25 | * Added fr-FR translations. Thanks to pompombidou (Harold Simpson) 26 | 27 | # 3.5.8.1 / 2013-02-08 28 | 29 | * Added pt-BR translations. Thanks to klebervirgilio (Kleber Correia) 30 | * Start signing the gem with rubygems-openpgp (https://github.com/grant-olson/rubygems-openpgp) 31 | * My signing key is available at https://eastblue.org/blag/contact/ 32 | 33 | # 3.5.8.0 / 2013-02-01 34 | 35 | * Tested with tinymce-rails 3.5.8 36 | * Handle errors from the server, both in the JSON, and from the server (HTTP 5xx and so on) 37 | * Don't submit the form without a file selected (fixes #1) 38 | * Display a spinner when uploading (fixes #2) 39 | 40 | # 3.5.6.4 / 2012-12-10 41 | 42 | * Convert CoffeeScript to JavaScript to avoid depending on CoffeeScript (#19). Thanks to sobrinho (Gabriel Sobrinho) 43 | 44 | # 3.5.6.3 / 2012-08-27 45 | 46 | * Make the POST URL configurable (#3). Thanks to minaguib (Mina Naguib) 47 | * Make it possible to send extra parameters to the controller (#10). Thanks to minaguib (Mina Naguib) 48 | 49 | # 3.5.6.2 / 2012-08-20 50 | 51 | * Portugese translation. Thanks to Hefesto 52 | * Fix for asset compilation. Thanks to ffloyd (Roman Kolesnev) 53 | 54 | # 3.5.6.1 / 2012-08-09 55 | 56 | * Russian translation. Thanks to ffloyd (Roman Kolesnev) 57 | * `window.opener` is not always available, so fall back to `window.parent` if needed. Thanks to ffloyd (Roman Kolesnev) 58 | 59 | # 3.5.6 / 2012-08-02 60 | 61 | * Relaxed dependency to work with newer tinymce-rails. Thanks to tjoneseng (Tim Jones) 62 | * Fix accessing opener window. Thanks to dpc (Dawid Ciężarkiewicz) 63 | 64 | # 3.4.9.1 / 2012-04-24 65 | 66 | * Work with Rails' CSRF protection by copying the token into our form before submitting it 67 | 68 | # 3.4.9 / 2012-04-05 69 | 70 | * Document how to use I18n with the gem 71 | * Explicitly require tinymce-rails so tinymce-rails-imageupload can be alone in the gemfile 72 | * Update dependency to tinymce-rails 3.4.9 73 | 74 | # 3.4.8.1 / 2012-03-07 75 | 76 | * Added support for setting height and width for the inserted image 77 | 78 | # 3.4.8 / 2012-02-29 79 | 80 | * Initial release 81 | -------------------------------------------------------------------------------- /test/dummy/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Dummy::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both thread web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 18 | # Add `rack-cache` to your Gemfile before enabling this. 19 | # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. 20 | # config.action_dispatch.rack_cache = true 21 | 22 | # Disable Rails's static asset server (Apache or nginx will already do this). 23 | config.serve_static_assets = false 24 | 25 | # Compress JavaScripts and CSS. 26 | config.assets.js_compressor = :uglifier 27 | # config.assets.css_compressor = :sass 28 | 29 | # Do not fallback to assets pipeline if a precompiled asset is missed. 30 | config.assets.compile = false 31 | 32 | # Generate digests for assets URLs. 33 | config.assets.digest = true 34 | 35 | # Version of your assets, change this if you want to expire all your assets. 36 | config.assets.version = '1.0' 37 | 38 | # Specifies the header that your server uses for sending files. 39 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 40 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 41 | 42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 43 | # config.force_ssl = true 44 | 45 | # Set to :debug to see everything in the log. 46 | config.log_level = :info 47 | 48 | # Prepend all log lines with the following tags. 49 | # config.log_tags = [ :subdomain, :uuid ] 50 | 51 | # Use a different logger for distributed setups. 52 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 53 | 54 | # Use a different cache store in production. 55 | # config.cache_store = :mem_cache_store 56 | 57 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 58 | # config.action_controller.asset_host = "http://assets.example.com" 59 | 60 | # Precompile additional assets. 61 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 62 | # config.assets.precompile += %w( search.js ) 63 | 64 | # Ignore bad email addresses and do not raise email delivery errors. 65 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 66 | # config.action_mailer.raise_delivery_errors = false 67 | 68 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 69 | # the I18n.default_locale when a translation can not be found). 70 | config.i18n.fallbacks = true 71 | 72 | # Send deprecation notices to registered listeners. 73 | config.active_support.deprecation = :notify 74 | 75 | # Disable automatic flushing of the log to improve performance. 76 | # config.autoflush_log = false 77 | 78 | # Use default logging formatter so that PID and timestamp are not suppressed. 79 | config.log_formatter = ::Logger::Formatter.new 80 | end 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IMPORTANT NOTE: 2 | This repository is no longer maintained, as I do not use TinyMCE for anything any more. 3 | I also understand that TinyMCE 4 is quite old. Luckily, [Frank Groeneveld](https://frankgroeneveld.nl) has written [a blog post detailing how to get image uploads working with TinyMCE 6 and Rails](https://frankgroeneveld.nl/2022/07/14/replace-tinymce-rails-imageupload/) that I recommend checking out. 4 | 5 | ~~This version is being rewritten to work with TinyMCE 4.x, and is 6 | currently not very tested. Use at your own risk, feedback welcome. For the stable version targetting TinyMCE 3, see 7 | the [tinymce3 branch](https://github.com/PerfectlyNormal/tinymce-rails-imageupload/tree/tinymce3)~~ 8 | 9 | # tinymce-rails-imageupload 10 | 11 | Simple plugin for TinyMCE that allows uploading images and inserting. 12 | It makes no assumptions about how you store the images, it simply POSTs to a 13 | URL and expects JSON back (see the Setup section). 14 | 15 | This plugin started as a copy of work done by [Peter Shoukry](http://77effects.com/), 16 | but has since mutated into something entirely different. 17 | 18 | Support for TinyMCE 3 is currently available in the [tinymce3 branch](https://github.com/PerfectlyNormal/tinymce-rails-imageupload/tree/tinymce3). 19 | The master branch is targetting TinyMCE 4.x. 20 | 21 | ## Demo 22 | 23 | A small demo app demonstrating a working setup for Rails 3.2 ([demo](http://murmuring-lowlands-1342.herokuapp.com/), [source](https://github.com/PerfectlyNormal/tinymce-rails-imageupload-demo3)), and for Rails 4 ([demo](http://murmuring-lowlands-7502.herokuapp.com/), [source](https://github.com/PerfectlyNormal/tinymce-rails-imageupload-demo)) is available for study. 24 | 25 | ## Requirements 26 | 27 | * Rails >= 3.1 28 | * TinyMCE4 using the advanced theme 29 | 30 | ## Setup 31 | 32 | ### Add the gem to your Gemfile 33 | 34 | gem 'tinymce-rails-imageupload', '~> 4.0.0.beta' 35 | 36 | # or use git 37 | 38 | gem 'tinymce-rails-imageupload', github: 'PerfectlyNormal/tinymce-rails-imageupload' 39 | 40 | ### Set up TinyMCE as you would normally, but in the call to `.tinymce()`, add 41 | 42 | plugins: "uploadimage" 43 | # toolbar option must include "uploadimage" somewhere to have the button appear 44 | 45 | and the rest should happen automatically. 46 | 47 | You can also globally have imageupload globally disabled but enabled on specific instances. 48 | 49 | ~~~yml 50 | # tinymce.yml 51 | toolbar: bold italic underline | uploadimage 52 | plugins: 53 | - uploadimage 54 | uploadimage: false 55 | ~~~ 56 | 57 | ~~~erb 58 | <%= tinymce uploadimage: true %> 59 | ~~~ 60 | 61 | ### Set up upload URL and handler 62 | 63 | The plugin defaults to POSTing to `/tinymce_assets`. You may modify it by 64 | supplying the option `uploadimage_form_url` in the call to `.tinymce()` 65 | 66 | Routing to your controller must be done manually. 67 | Set it up using something similar in `routes.rb`: 68 | 69 | post '/tinymce_assets' => 'tinymce_assets#create' 70 | 71 | This action gets called with a file parameter creatively called `file`, 72 | and must respond with JSON, containing the URL to the image. 73 | 74 | The JSON has to be returned with a content type of "text/html" to work, which 75 | is hopefully going to be fixed ([issue #7](https://github.com/PerfectlyNormal/tinymce-rails-imageupload/issues/7)). 76 | 77 | Example: 78 | 79 | class TinymceAssetsController < ApplicationController 80 | def create 81 | # Take upload from params[:file] and store it somehow... 82 | # Optionally also accept params[:hint] and consume if needed 83 | 84 | render json: { 85 | image: { 86 | url: view_context.image_url(image) 87 | } 88 | }, content_type: "text/html" 89 | end 90 | end 91 | 92 | 93 | If the JSON response contains a `width` and/or `height` key, 94 | those will be used in the inserted HTML (`.js` in
197 | `app/assets/javascripts/tinymce/plugins/uploadimage/langs` in your
198 | application, or fork the gem and add your own translations there.
199 |
200 | The format and available strings are listed below:
201 |
202 | ### nb.js
203 |
204 | tinyMCE.addI18n('nb', {
205 | 'Insert an image from your computer': 'Sett inn et bilde fra datamaskinen',
206 | 'Insert image': "Sett inn bilde",
207 | 'Choose an image': "Velg et bilde",
208 | 'You must choose a file': "Du m\u00e5 velge en fil",
209 | 'Got a bad response from the server': "Fikk et ugyldig svar fra serveren",
210 | "Didn't get a response from the server": "Fikk ikke svar fra serveren",
211 | 'Insert': "Sett inn",
212 | 'Cancel': "Avbryt",
213 | 'Image description': "Alternativ tekst for bilde",
214 | });
215 |
216 | ## Versioning
217 |
218 | The major, minor and patch version of this gem will be mirroring the
219 | release of `tinymce-rails` it is tested against.
220 |
221 | ## Signing
222 |
223 | This gem is signed using [rubygems-openpgp](https://github.com/grant-olson/rubygems-openpgp) using [my personal key](https://eastblue.org/blag/contact/), and the fingerprint is also included below.
224 |
225 | pub 4096R/CCFBB9EF 2013-02-01 [expires: 2017-02-01]
226 | Key fingerprint = 6077 34FC 32B6 6041 BF06 43F2 205D 9784 CCFB B9EF
227 | uid Per Christian Bechström Viken
228 | uid [jpeg image of size 6240]
229 | sub 4096R/13C6EED7 2013-02-01 [expires: 2017-02-01]
230 |
231 | ## Licensing
232 |
233 | The plugin is released under the MIT license.
234 |
235 | TinyMCE is released under the LGPL Version 2.1.
236 |
237 | The icon used for the button comes from the icon set Silk from famfamfam,
238 | released under the [Creative Commons Attribution 3.0 License](http://creativecommons.org/licenses/by/3.0/)
239 |
--------------------------------------------------------------------------------
/app/assets/javascripts/tinymce/plugins/uploadimage/plugin.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | tinymce.PluginManager.requireLangPack('uploadimage');
3 |
4 | tinymce.create('tinymce.plugins.UploadImage', {
5 | UploadImage: function(ed, url) {
6 | var form,
7 | iframe,
8 | win,
9 | throbber,
10 | selectedClass = '',
11 | editor = ed;
12 |
13 | function showDialog() {
14 | var classList = getClassList();
15 | var body = [
16 | { type: 'iframe', url: 'javascript:void(0)' },
17 | { type: 'textbox', name: 'file', label: ed.translate('Choose an image'), subtype: 'file' },
18 | { type: 'textbox', name: 'alt', label: ed.translate('Image description') }
19 | ];
20 |
21 | if (classList.length > 0) {
22 | selectedClass = classList[0].value;
23 | body = body.concat([
24 | {
25 | type: 'listbox',
26 | name: 'class',
27 | label: ed.translate('Class'),
28 | values: classList,
29 | onSelect: function(e) {
30 | selectedClass = this.value();
31 | }
32 | }
33 | ]);
34 | }
35 |
36 | body = body.concat([
37 | { type: 'container', classes: 'error', html: "
" },
38 |
39 | // Trick TinyMCE to add a empty div that "preloads" the throbber image
40 | { type: 'container', classes: 'throbber' }
41 | ]);
42 |
43 | win = editor.windowManager.open(
44 | {
45 | title: ed.translate('Insert an image from your computer'),
46 | width: 520 + parseInt(editor.getLang('uploadimage.delta_width', 0), 10),
47 | height: 180 + parseInt(editor.getLang('uploadimage.delta_height', 0), 10),
48 | body: body,
49 | buttons: [
50 | {
51 | text: ed.translate('Insert'),
52 | onclick: insertImage,
53 | subtype: 'primary'
54 | },
55 | {
56 | text: ed.translate('Cancel'),
57 | onclick: ed.windowManager.close
58 | }
59 | ]
60 | },
61 | {
62 | plugin_url: url
63 | }
64 | );
65 |
66 | /* WHY DO YOU HATE