muck-contents 0.1.12 → 0.2.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.
- data/README.rdoc +122 -15
- data/VERSION +1 -1
- data/app/controllers/muck/tiny_mce_controller.rb +47 -0
- data/app/helpers/tinymce_helper.rb +23 -8
- data/app/views/contents/_form.html.erb +1 -2
- data/app/views/contents/new.html.erb +1 -0
- data/app/views/layouts/tiny_mce.html.erb +25 -0
- data/app/views/tiny_mce/files.html.erb +136 -0
- data/app/views/tiny_mce/images.html.erb +312 -0
- data/{public/javascripts/tiny_mce/plugins/advlinktoo/link.htm → app/views/tiny_mce/links.html.erb} +328 -344
- data/config/muck_contents_routes.rb +6 -0
- data/lib/action_controller/acts/muck_content_handler.rb +1 -1
- data/locales/en.yml +2 -0
- data/muck-contents.gemspec +153 -25
- data/public/{javascripts/tiny_mce/plugins/advimagetoo/img → images/tinymce}/sample.gif +0 -0
- data/public/{javascripts/tiny_mce/plugins/advfiletoo/img → images/tinymce}/upload.gif +0 -0
- data/public/javascripts/tiny_mce/plugins/advfiletoo/editor_plugin.js +9 -22
- data/public/javascripts/tiny_mce/plugins/advfiletoo/editor_plugin_src.js +41 -54
- data/public/javascripts/tiny_mce/plugins/advfiletoo/js/functions.js +0 -139
- data/public/javascripts/tiny_mce/plugins/advimagetoo/editor_plugin.js +9 -17
- data/public/javascripts/tiny_mce/plugins/advimagetoo/editor_plugin_src.js +40 -50
- data/public/javascripts/tiny_mce/plugins/advimagetoo/js/functions.js +0 -152
- data/public/javascripts/tiny_mce/plugins/advlinktoo/editor_plugin.js +3 -14
- data/public/javascripts/tiny_mce/plugins/advlinktoo/editor_plugin_src.js +3 -14
- data/public/{javascripts/tiny_mce/plugins/advfiletoo/css/advfile.css → stylesheets/tinymce.css} +33 -12
- data/test/rails_root/Rakefile +2 -1
- data/test/rails_root/app/controllers/uploads_controller.rb +57 -0
- data/test/rails_root/app/models/upload.rb +94 -0
- data/test/rails_root/app/models/user.rb +5 -0
- data/test/rails_root/config/environment.rb +2 -0
- data/test/rails_root/config/initializers/mce_options.rb +12 -8
- data/test/rails_root/config/initializers/s3_credentials.rb +9 -0
- data/test/rails_root/db/migrate/{20090602041838_create_users.rb → 20090327231918_create_users.rb} +11 -10
- data/test/rails_root/db/migrate/20090402234137_create_languages.rb +18 -0
- data/test/rails_root/db/migrate/20090426041056_create_countries.rb +15 -0
- data/test/rails_root/db/migrate/20090426041103_create_states.rb +18 -0
- data/test/rails_root/db/migrate/{20090704220120_acts_as_taggable_on_migration.rb → 20090506000404_acts_as_taggable_on_migration.rb} +31 -29
- data/test/rails_root/db/migrate/20090517040220_create_uploads.rb +38 -0
- data/test/rails_root/db/migrate/20090730044139_add_comment_cache.rb +9 -0
- data/test/rails_root/db/migrate/20090818204527_add_activity_indexes.rb +9 -0
- data/test/rails_root/db/migrate/20090819030523_add_attachable_to_activities.rb +13 -0
- data/test/rails_root/lib/daemons/amazonaws.rb +36 -0
- data/test/rails_root/lib/tasks/muck.rake +7 -0
- data/test/rails_root/public/images/SWFUploadButton.png +0 -0
- data/test/rails_root/public/images/arrow_down.gif +0 -0
- data/test/rails_root/public/images/arrow_up.gif +0 -0
- data/test/rails_root/public/images/cancelbutton.gif +0 -0
- data/test/rails_root/public/images/fancybox/fancy_closebox.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_left.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_progress.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_right.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_e.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_n.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_ne.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_nw.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_s.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_se.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_sw.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_shadow_w.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_title_left.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_title_main.png +0 -0
- data/test/rails_root/public/images/fancybox/fancy_title_right.png +0 -0
- data/test/rails_root/public/images/file_icons/excel.gif +0 -0
- data/test/rails_root/public/images/file_icons/file.gif +0 -0
- data/test/rails_root/public/images/file_icons/file.png +0 -0
- data/test/rails_root/public/images/file_icons/file_aac.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_ai.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_avi.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_bin.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_bmp.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_cue.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_divx.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_doc.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_eps.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_flac.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_flv.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_gif.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_html.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_ical.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_indd.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_inx.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_iso.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_jpg.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_mov.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_mp3.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_mpg.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_pdf.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_php.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_png.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_pps.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_ppt.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_psd.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_qxd.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_qxp.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_raw.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_rtf.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_svg.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_tif.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_txt.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_vcf.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_wav.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_wma.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_xls.gif +0 -0
- data/test/rails_root/public/images/file_icons/file_xml.gif +0 -0
- data/test/rails_root/public/images/file_icons/mp3.gif +0 -0
- data/test/rails_root/public/images/file_icons/pdf.gif +0 -0
- data/test/rails_root/public/images/file_icons/pdf.png +0 -0
- data/test/rails_root/public/images/file_icons/text.gif +0 -0
- data/test/rails_root/public/images/file_icons/text.png +0 -0
- data/test/rails_root/public/images/file_icons/word.gif +0 -0
- data/test/rails_root/public/images/icons/blue_guy.png +0 -0
- data/test/rails_root/public/images/icons/button_background.png +0 -0
- data/test/rails_root/public/images/icons/cancel.png +0 -0
- data/test/rails_root/public/images/icons/close.png +0 -0
- data/test/rails_root/public/images/icons/comment.png +0 -0
- data/test/rails_root/public/images/icons/exclaim.png +0 -0
- data/test/rails_root/public/images/icons/external.png +0 -0
- data/test/rails_root/public/images/icons/feed.png +0 -0
- data/test/rails_root/public/images/icons/grey_guy.png +0 -0
- data/test/rails_root/public/images/icons/hide.png +0 -0
- data/test/rails_root/public/images/icons/information.png +0 -0
- data/test/rails_root/public/images/icons/minus.png +0 -0
- data/test/rails_root/public/images/icons/pending.png +0 -0
- data/test/rails_root/public/images/icons/question.png +0 -0
- data/test/rails_root/public/images/icons/search_box.png +0 -0
- data/test/rails_root/public/images/icons/star.png +0 -0
- data/test/rails_root/public/images/icons/stop.png +0 -0
- data/test/rails_root/public/images/icons/thumb_down.png +0 -0
- data/test/rails_root/public/images/icons/thumb_up.png +0 -0
- data/test/rails_root/public/images/nothing.png +0 -0
- data/test/rails_root/public/{javascripts/tiny_mce/plugins/advimagetoo/img → images/tinymce}/sample.gif +0 -0
- data/test/rails_root/public/{javascripts/tiny_mce/plugins/advfiletoo/img → images/tinymce}/upload.gif +0 -0
- data/test/rails_root/public/javascripts/jquery/colorpicker.js +450 -0
- data/test/rails_root/public/javascripts/jquery/jquery.autocomplete.js.readme +6 -0
- data/test/rails_root/public/javascripts/jquery/jquery.autocomplete.min.js +15 -0
- data/test/rails_root/public/javascripts/jquery/jquery.autocomplete.pack.js +767 -0
- data/test/rails_root/public/javascripts/jquery/jquery.easing.js +1 -0
- data/test/rails_root/public/javascripts/jquery/jquery.fancybox.js +9 -0
- data/test/rails_root/public/javascripts/jquery/jquery.metadata.min.js +13 -0
- data/test/rails_root/public/javascripts/jquery/jquery.queryString.js +33 -0
- data/test/rails_root/public/javascripts/jquery/jquery.swapimage.js +66 -0
- data/test/rails_root/public/javascripts/jquery/jquery.swapimage.min.js +11 -0
- data/test/rails_root/public/javascripts/jquery/jrails.js +1 -0
- data/test/rails_root/public/javascripts/muck.js +11 -6
- data/test/rails_root/public/javascripts/muck_activities.js +5 -6
- data/test/rails_root/public/javascripts/muck_time/en.js +53 -0
- data/test/rails_root/public/javascripts/swfupload/fileprogress.js +151 -0
- data/test/rails_root/public/javascripts/swfupload/handlers.js +201 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.cookies.js +53 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.js +980 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.queue.js +98 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.speed.js +342 -0
- data/test/rails_root/public/javascripts/swfupload/swfupload.swfobject.js +111 -0
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advfiletoo/editor_plugin.js +9 -22
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advfiletoo/editor_plugin_src.js +41 -54
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advfiletoo/js/functions.js +0 -139
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/editor_plugin.js +9 -17
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/editor_plugin_src.js +40 -50
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/image.htm +10 -9
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/js/functions.js +0 -152
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advlinktoo/editor_plugin.js +3 -14
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advlinktoo/editor_plugin_src.js +3 -14
- data/test/rails_root/public/javascripts/tiny_mce/templates/example.htm +14 -0
- data/test/rails_root/public/javascripts/tree.js +107 -0
- data/test/rails_root/public/stylesheets/jquery/jquery.autocomplete.css +15 -0
- data/test/rails_root/public/stylesheets/jquery/jquery.fancybox.css +44 -0
- data/test/rails_root/public/stylesheets/muck-activities.css +39 -0
- data/test/rails_root/public/stylesheets/styles.css +10 -3
- data/test/rails_root/public/stylesheets/swfupload.css +26 -0
- data/test/rails_root/public/{javascripts/tiny_mce/plugins/advfiletoo/css/advfile.css → stylesheets/tinymce.css} +33 -12
- data/test/rails_root/public/system/locals/000/000/026/original/deploy-1.rb +75 -0
- metadata +153 -25
- data/public/javascripts/tiny_mce/plugins/advfiletoo/file.htm +0 -139
- data/public/javascripts/tiny_mce/plugins/advimagetoo/css/advimage.css +0 -32
- data/public/javascripts/tiny_mce/plugins/advimagetoo/image.htm +0 -303
- data/public/javascripts/tiny_mce/plugins/advlinktoo/css/advlink.css +0 -8
- data/test/rails_root/db/migrate/20090608073052_create_friends.rb +0 -16
- data/test/rails_root/db/migrate/20090808005918_add_scope_index_to_slugs.rb +0 -9
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advfiletoo/file.htm +0 -139
- data/test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/css/advimage.css +0 -32
- data/test/rails_root/public/javascripts/tiny_mce/templates/bio.htm +0 -31
- data/test/rails_root/public/javascripts/tiny_mce/templates/country.htm +0 -59
data/README.rdoc
CHANGED
|
@@ -5,25 +5,27 @@ it easy to add this content to your website.
|
|
|
5
5
|
|
|
6
6
|
=== Gems
|
|
7
7
|
Note that all gems below should be installed automatically as a muck-contents has them set as a dependency.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
sudo gem install muck-acts_as_git # Versioning. Requires a git installation.
|
|
12
|
-
sudo gem install collectiveidea-awesome_nested_set # Nested pages. Used to setup navigation hierarchy (http://github.com/collectiveidea/awesome_nested_set/tree/master)
|
|
13
|
-
sudo gem install rgrove-sanitize # Remove harmful html. (http://github.com/rgrove/sanitize/tree/master.)
|
|
14
|
-
sudo gem install mbleigh-acts-as-taggable-on # Tagging. (http://github.com/mbleigh/acts-as-taggable-on/tree/master)
|
|
15
|
-
sudo gem install friendly_id # Pretty urls (http://github.com/norman/friendly_id/tree/master)
|
|
16
|
-
sudo gem install babelphish # Translations
|
|
17
|
-
sudo gem install muck-solr # Search Install muck_solr (or another version of acts_as_solr)
|
|
18
|
-
|
|
8
|
+
sudo gem install muck-contents
|
|
9
|
+
|
|
19
10
|
=== Configure environment.rb
|
|
20
11
|
Paste in the following:
|
|
21
|
-
config.gem "
|
|
22
|
-
config.gem "
|
|
23
|
-
config.gem "
|
|
12
|
+
config.gem "will_paginate"
|
|
13
|
+
config.gem "authlogic"
|
|
14
|
+
config.gem "searchlogic"
|
|
15
|
+
config.gem "bcrypt-ruby", :lib => "bcrypt", :version => ">=2.0.5"
|
|
16
|
+
config.gem "acts-as-taggable-on"
|
|
17
|
+
config.gem "awesome_nested_set"
|
|
24
18
|
config.gem "friendly_id"
|
|
19
|
+
config.gem "sanitize"
|
|
20
|
+
config.gem 'paperclip'
|
|
21
|
+
config.gem 'tiny_mce'
|
|
22
|
+
config.gem "uploader"
|
|
25
23
|
config.gem "babelphish"
|
|
26
|
-
|
|
24
|
+
config.gem 'muck-engine', :lib => 'muck_engine'
|
|
25
|
+
config.gem 'muck-users', :lib => 'muck_users'
|
|
26
|
+
config.gem 'muck-activities', :lib => 'muck_activities'
|
|
27
|
+
config.gem 'muck-solr', :lib => 'acts_as_solr'
|
|
28
|
+
config.gem 'muck-comments', :lib => 'muck_comments'
|
|
27
29
|
|
|
28
30
|
=== Gem configuration and setup
|
|
29
31
|
In your app do
|
|
@@ -33,6 +35,11 @@ In your app do
|
|
|
33
35
|
|
|
34
36
|
== Setup
|
|
35
37
|
|
|
38
|
+
=== Initializer
|
|
39
|
+
Running rake muck:contents:sync will copy all the needed javascript, image and css files into your project. It will also create an initializer called mce_options.rb. That file
|
|
40
|
+
contains two basic configurations for tinymce as well as examples on how to create templates. It is recommended that you don't modify that file as it will be overwritten the
|
|
41
|
+
next time you run rake muck:contents:sync. Instead use it as an example and create the desired tinymce setup.
|
|
42
|
+
|
|
36
43
|
=== User model
|
|
37
44
|
Add the following method to your user model and modify it according to your specific needs:
|
|
38
45
|
|
|
@@ -106,5 +113,105 @@ Override the contents controller to change the the security model. For example:
|
|
|
106
113
|
|
|
107
114
|
end
|
|
108
115
|
|
|
116
|
+
=== Uploader
|
|
117
|
+
muck-contents uses the uploader gem and thus requires all the configuration to make that gem function. This includes the addition of
|
|
118
|
+
and uploads controller and upload model. See that gem for more information. If you have generated your project using the rails template generator
|
|
119
|
+
(http://github.com/jbasdf/rails-templates) then it should be setup for you. The actual uploading of files and images will be handled by
|
|
120
|
+
the uploads controller. The security for uploads to your site should be handled in that controller.
|
|
121
|
+
|
|
122
|
+
==== Example uploads controller:
|
|
123
|
+
|
|
124
|
+
class UploadsController < Uploader::UploadsController
|
|
125
|
+
|
|
126
|
+
before_filter :login_required
|
|
127
|
+
before_filter :setup_parent, :only => [:index, :create, :swfupload, :photos, :files]
|
|
128
|
+
|
|
129
|
+
def index
|
|
130
|
+
@upload = Upload.new
|
|
131
|
+
@uploads = @parent.uploads.paginate(:page => @page, :per_page => @per_page, :order => 'created_at desc')
|
|
132
|
+
respond_to do |format|
|
|
133
|
+
format.html { render }
|
|
134
|
+
format.rss { render :layout => false }
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def photos
|
|
139
|
+
@images = @parent.uploads.images.paginate(:page => @page, :per_page => @per_page, :order => 'created_at desc')
|
|
140
|
+
respond_to do |format|
|
|
141
|
+
format.html { render }
|
|
142
|
+
format.rss { render :layout => false }
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def files
|
|
147
|
+
@files = @parent.uploads.files.paginate(:page => @page, :per_page => @per_page, :order => 'created_at desc')
|
|
148
|
+
respond_to do |format|
|
|
149
|
+
format.js { render :json => basic_uploads_json(@files) }
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
protected
|
|
154
|
+
|
|
155
|
+
def get_upload_text(upload)
|
|
156
|
+
render_to_string( :partial => 'uploads/upload_row', :object => upload, :locals => { :style => 'style="display:none;"', :parent => @parent } )
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def get_redirect
|
|
160
|
+
@parent
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def has_permission_to_upload(user, upload_parent)
|
|
164
|
+
return true if upload_parent.blank?
|
|
165
|
+
upload_parent.can_edit?(user)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def permission_denied
|
|
169
|
+
message = t("uploader.permission_denied")
|
|
170
|
+
respond_to do |format|
|
|
171
|
+
format.html do
|
|
172
|
+
flash[:notice] = message
|
|
173
|
+
redirect_to get_redirect
|
|
174
|
+
end
|
|
175
|
+
format.js { render :text => message }
|
|
176
|
+
format.json { render :json => { :success => false, :message => message } }
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
==== Example upload model:
|
|
183
|
+
NOTE: you must define icon, thumb, small, medium and large as styles. They can be any size you like.
|
|
184
|
+
|
|
185
|
+
class Upload < ActiveRecord::Base
|
|
186
|
+
|
|
187
|
+
acts_as_uploader :enable_s3 => false,
|
|
188
|
+
:has_attached_file => {
|
|
189
|
+
:url => "/system/:attachment/:id_partition/:style/:basename.:extension",
|
|
190
|
+
:path => ":rails_root/public/system/:attachment/:id_partition/:style/:basename.:extension",
|
|
191
|
+
:styles => { :icon => "30x30!",
|
|
192
|
+
:thumb => "100>",
|
|
193
|
+
:small => "150>",
|
|
194
|
+
:medium => "300>",
|
|
195
|
+
:large => "660>" },
|
|
196
|
+
:default_url => "/images/profile_default.jpg",
|
|
197
|
+
:storage => :s3,
|
|
198
|
+
:s3_credentials => AMAZON_S3_CREDENTIALS,
|
|
199
|
+
:bucket => "assets.#{GlobalConfig.application_url}",
|
|
200
|
+
:s3_host_alias => "assets.#{GlobalConfig.application_url}",
|
|
201
|
+
:convert_options => {
|
|
202
|
+
:all => '-quality 80'
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
:s3_path => ':id_partition/:style/:basename.:extension'
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
acts_as_taggable
|
|
209
|
+
|
|
210
|
+
named_scope :public, :conditions => "is_public = true"
|
|
211
|
+
named_scope :tagged_with, lambda {|tag_name| {:conditions => ["tags.name = ?", tag_name], :include => :tags} }
|
|
212
|
+
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
|
|
109
216
|
|
|
110
217
|
Copyright (c) 2009 Tatemae, released under the MIT license
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.2.0
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
class Muck::TinyMceController < ApplicationController
|
|
2
|
+
|
|
3
|
+
layout 'tiny_mce'
|
|
4
|
+
|
|
5
|
+
before_filter :get_parent
|
|
6
|
+
|
|
7
|
+
def tiny_mce_files
|
|
8
|
+
@body_tag = 'advfile'
|
|
9
|
+
@load_files_path = files_for_content_url(make_parent_params(@parent).merge(:format => 'json'))
|
|
10
|
+
respond_to do |format|
|
|
11
|
+
format.html { render :template => 'tiny_mce/files'}
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def tiny_mce_images
|
|
16
|
+
@body_tag = 'advimage'
|
|
17
|
+
@load_files_path = images_for_content_url(make_parent_params(@parent).merge(:format => 'json'))
|
|
18
|
+
respond_to do |format|
|
|
19
|
+
format.html { render :template => 'tiny_mce/images'}
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def tiny_mce_links
|
|
24
|
+
@body_tag = 'advlink'
|
|
25
|
+
@load_files_path = files_for_content_url(make_parent_params(@parent).merge(:format => 'json'))
|
|
26
|
+
respond_to do |format|
|
|
27
|
+
format.html { render :template => 'tiny_mce/links'}
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def images_for_content
|
|
32
|
+
@parent = current_user if @parent.blank?
|
|
33
|
+
@images = @parent.uploads.images.paginate(:page => @page, :per_page => @per_page, :order => 'created_at desc')
|
|
34
|
+
respond_to do |format|
|
|
35
|
+
format.json { render :json => @images.to_json(:only => [:id], :methods => [:thumb, :file_name]) }
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def files_for_content
|
|
40
|
+
@parent = current_user if @parent.blank?
|
|
41
|
+
@files = @parent.uploads.files.paginate(:page => @page, :per_page => @per_page, :order => 'created_at desc')
|
|
42
|
+
respond_to do |format|
|
|
43
|
+
format.json { render :json => @files.to_json(:only => [:id], :methods => [:icon, :file_name]) }
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
module TinymceHelper
|
|
2
2
|
|
|
3
|
-
# Pass paths into the tiny mce image and file dialog via hidden fields
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
# Pass paths into the tiny mce image, link and file dialog via hidden fields
|
|
4
|
+
# options:
|
|
5
|
+
# tiny_mce_files_width: width of file dialog. Default is 675
|
|
6
|
+
# tiny_mce_files_height: height of file dialog. Default is 540
|
|
7
|
+
# tiny_mce_images_width: width of image dialog. Default is 675
|
|
8
|
+
# tiny_mce_images_height height of image dialog. Default is 540
|
|
9
|
+
def mce_fields(parent, options = {})
|
|
10
|
+
parent_params = make_muck_parent_fields(parent) || {}
|
|
11
|
+
tiny_mce_files_path = tiny_mce_files_url(parent_params)
|
|
12
|
+
tiny_mce_images_path = tiny_mce_images_url(parent_params)
|
|
13
|
+
tiny_mce_links_path = tiny_mce_links_url(parent_params)
|
|
14
|
+
|
|
15
|
+
%Q{<input id="tiny_mce_files_path" type="hidden" value="#{tiny_mce_files_path}">
|
|
16
|
+
<input id="tiny_mce_files_width" type="hidden" value="#{options[:tiny_mce_files_width] || 675}">
|
|
17
|
+
<input id="tiny_mce_files_height" type="hidden" value="#{options[:tiny_mce_files_height] || 540}">
|
|
18
|
+
<input id="tiny_mce_images_path" type="hidden" value="#{tiny_mce_images_path}">
|
|
19
|
+
<input id="tiny_mce_images_width" type="hidden" value="#{options[:tiny_mce_images_width] || 675}">
|
|
20
|
+
<input id="tiny_mce_images_height" type="hidden" value="#{options[:tiny_mce_images_height] || 560}">
|
|
21
|
+
<input id="tiny_mce_links_path" type="hidden" value="#{tiny_mce_links_path}">}
|
|
11
22
|
end
|
|
12
23
|
|
|
24
|
+
def tiny_mce_upload_form(parent)
|
|
25
|
+
upload_form(parent, true, '', :upload_url =>new_upload_path_with_session_information(parent, 'json'))
|
|
26
|
+
end
|
|
27
|
+
|
|
13
28
|
end
|
|
@@ -23,13 +23,12 @@ message_id = "#{content.dom_id}_message"
|
|
|
23
23
|
<%= f.hidden_field :uri_path unless content.uri_path.blank? %>
|
|
24
24
|
<%= f.hidden_field :custom_scope unless content.custom_scope.blank? %>
|
|
25
25
|
</div>
|
|
26
|
-
<%= mce_fields(
|
|
26
|
+
<%= mce_fields(@parent) -%>
|
|
27
27
|
<% end %>
|
|
28
28
|
</div>
|
|
29
29
|
|
|
30
30
|
<% content_for :head do -%>
|
|
31
31
|
<%= include_tiny_mce_if_needed %>
|
|
32
|
-
<%= javascript_include_tag 'tiny_mce_helper' %>
|
|
33
32
|
<% end -%>
|
|
34
33
|
|
|
35
34
|
<script language="javascript" type="text/javascript">
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="<%= I18n.locale %>" xml:lang="<%= I18n.locale %>">
|
|
3
|
+
<head>
|
|
4
|
+
<title><%= @page_title || GlobalConfig.application_name %></title>
|
|
5
|
+
<%= javascript_include_tag %w{
|
|
6
|
+
jquery/jquery.js
|
|
7
|
+
jquery/jquery.queryString.js
|
|
8
|
+
jquery/jquery.autocomplete.min.js
|
|
9
|
+
tiny_mce/tiny_mce_popup.js
|
|
10
|
+
tiny_mce/utils/mctabs.js
|
|
11
|
+
tiny_mce/utils/form_utils.js
|
|
12
|
+
tiny_mce/utils/validate.js
|
|
13
|
+
application.js }, :cache => 'tinymce_js_cached' %>
|
|
14
|
+
<%= javascript_tag %[const AUTH_TOKEN = #{form_authenticity_token.inspect};] if protect_against_forgery? %>
|
|
15
|
+
<%= stylesheet_link_tag %W{ tinymce jquery/jquery.autocomplete }, :cache => true %>
|
|
16
|
+
<%= yield :head -%>
|
|
17
|
+
<base target="_self" />
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<%= yield :layout %>
|
|
21
|
+
<script type="text/javascript" language="JavaScript">
|
|
22
|
+
<%= yield :javascript %>
|
|
23
|
+
</script>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<div id="file-upload">
|
|
2
|
+
<fieldset>
|
|
3
|
+
<legend>Upload New File</legend>
|
|
4
|
+
<%= tiny_mce_upload_form(@parent) %>
|
|
5
|
+
</fieldset>
|
|
6
|
+
</div>
|
|
7
|
+
<br />
|
|
8
|
+
|
|
9
|
+
<form name="insert_file" id="insert_file" onsubmit="insertAction();return false;" action="#">
|
|
10
|
+
<div class="tabs">
|
|
11
|
+
<ul>
|
|
12
|
+
<li id="dynamic_select_tab" class="current"><span><a href="javascript:mcTabs.displayTab('dynamic_select_tab','dynamic_select_panel');" onmousedown="return false;">Files</a></span></li>
|
|
13
|
+
<li id="general_tab"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{#advfile_dlg.tab_general}</a></span></li>
|
|
14
|
+
</ul>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<div class="panel_wrapper">
|
|
18
|
+
|
|
19
|
+
<div id="dynamic_select_panel" class="panel current" style='overflow:auto'>
|
|
20
|
+
<fieldset>
|
|
21
|
+
<legend>Available Files - Click to Add</legend>
|
|
22
|
+
<div id="upload-list-message">
|
|
23
|
+
Loading Files...<br />
|
|
24
|
+
<img src="/images/spinner.gif">
|
|
25
|
+
</div>
|
|
26
|
+
<ul id="upload-list" class="file-list">
|
|
27
|
+
</ul>
|
|
28
|
+
</fieldset>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div id="general_panel" class="panel">
|
|
32
|
+
<fieldset>
|
|
33
|
+
<legend>{#advfile_dlg.general_props}</legend>
|
|
34
|
+
<table border="0" cellpadding="4" cellspacing="0">
|
|
35
|
+
<tr>
|
|
36
|
+
<td nowrap="nowrap"><label id="hreflabel" for="href">{#advfile_dlg.url}</label></td>
|
|
37
|
+
<td><table border="0" cellspacing="0" cellpadding="0">
|
|
38
|
+
<tr>
|
|
39
|
+
<td><input id="href" name="href" type="text" class="mceFocus" value="" onchange="selectByValue(this.form,'linklisthref',this.value);" /></td>
|
|
40
|
+
<td id="hrefbrowsercontainer"> </td>
|
|
41
|
+
</tr>
|
|
42
|
+
</table></td>
|
|
43
|
+
</tr>
|
|
44
|
+
<tr>
|
|
45
|
+
<td nowrap="nowrap"><label id="titlelabel" for="title">{#advfile_dlg.titlefield}</label></td>
|
|
46
|
+
<td><input id="title" name="title" type="text" value="" /></td>
|
|
47
|
+
</tr>
|
|
48
|
+
<tr>
|
|
49
|
+
<td><label id="classlabel" for="classlist">{#class_name}</label></td>
|
|
50
|
+
<td>
|
|
51
|
+
<select id="classlist" name="classlist" onchange="changeClass();">
|
|
52
|
+
<option value="" selected>{#not_set}</option>
|
|
53
|
+
</select>
|
|
54
|
+
</td>
|
|
55
|
+
</tr>
|
|
56
|
+
<tr>
|
|
57
|
+
<td><label id="stylelabel" for="style">{#advfile_dlg.style}</label></td>
|
|
58
|
+
<td><input type="text" id="style" name="style" value="" /></td>
|
|
59
|
+
</tr>
|
|
60
|
+
<tr>
|
|
61
|
+
<td class="column1"><label id="idlabel" for="id">{#advfile_dlg.id}</label></td>
|
|
62
|
+
<td><input id="id" name="id" type="text" value="" /></td>
|
|
63
|
+
</tr>
|
|
64
|
+
</table>
|
|
65
|
+
</fieldset>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div class="mceActionPanel">
|
|
71
|
+
<div style="float: left">
|
|
72
|
+
<input type="button" id="insert" name="insert" value="{#insert}" onclick="insertAction();" />
|
|
73
|
+
</div>
|
|
74
|
+
<div style="float: right">
|
|
75
|
+
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
</form>
|
|
80
|
+
|
|
81
|
+
<% content_for :head do -%>
|
|
82
|
+
<%= javascript_include_tag 'tiny_mce/plugins/advfiletoo/js/functions.js' -%>
|
|
83
|
+
<% end -%>
|
|
84
|
+
<script language="javascript" type="text/javascript">
|
|
85
|
+
jQuery(document).ready(function()
|
|
86
|
+
{
|
|
87
|
+
jQuery.getJSON('<%=@load_files_path%>', function(json){
|
|
88
|
+
if (json.length <= 0){
|
|
89
|
+
jQuery("#upload-list-message").html('<%= t('muck.contents.no_files') %>');
|
|
90
|
+
} else {
|
|
91
|
+
jQuery('#upload-list-message').html('');
|
|
92
|
+
for(i=0;i<json.length;i++){
|
|
93
|
+
add_file(json[i], 'append');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
function upload_completed_callback(data){
|
|
99
|
+
jQuery('#upload-list-message').html('');
|
|
100
|
+
var json = eval('(' + data + ')');
|
|
101
|
+
add_file(json, 'prepend');
|
|
102
|
+
}
|
|
103
|
+
function add_file(file, location){
|
|
104
|
+
var file_html = '<li id="file-' + file.id + '">' +
|
|
105
|
+
'<img class="icon" src="' + file.icon + '" alt="" />' +
|
|
106
|
+
'<a onclick="select_file(this);return false;" href="#">' + file.file_name + '</a>' +
|
|
107
|
+
'<a onclick="delete_file(this, ' + file.id + ');return false;" href="#"><img src="/images/icons/delete.png" /></a>' +
|
|
108
|
+
'<input type="hidden" value="' + file.file_name + '" /></li>';
|
|
109
|
+
if ('prepend' == location){
|
|
110
|
+
jQuery('#upload-list').prepend(file_html);
|
|
111
|
+
} else {
|
|
112
|
+
jQuery('#upload-list').append(file_html);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function delete_file(element, id){
|
|
116
|
+
jQuery(element).parents('li').removeClass('selected');
|
|
117
|
+
jQuery(element).parents('li').fadeOut();
|
|
118
|
+
jQuery.post('/uploads/' + id + '.js', {action: 'destroy', _method: 'delete' },
|
|
119
|
+
function(data){
|
|
120
|
+
// just chuck the message
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function select_file(element){
|
|
124
|
+
var anchor = jQuery(element);
|
|
125
|
+
var url = anchor.parents('li').children('input').val();
|
|
126
|
+
var name = anchor.html();
|
|
127
|
+
insert_file_too(url, name);
|
|
128
|
+
}
|
|
129
|
+
function insert_file_too(url, name){
|
|
130
|
+
jQuery('input#href').val(url);
|
|
131
|
+
if(jQuery('input#title').val().length <= 0){
|
|
132
|
+
jQuery('input#title').val(name);
|
|
133
|
+
}
|
|
134
|
+
mcTabs.displayTab('general_tab','general_panel');
|
|
135
|
+
}
|
|
136
|
+
</script>
|