bcalloway-wysihat-engine 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.gitignore +6 -0
  2. data/CHANGELOG +51 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.textile +24 -0
  5. data/Rakefile +78 -0
  6. data/TODO +4 -0
  7. data/VERSION +1 -0
  8. data/app/controllers/wysihat_files_controller.rb +35 -0
  9. data/app/helpers/wysihat_files_helper.rb +2 -0
  10. data/app/models/wysihat_file.rb +9 -0
  11. data/app/views/wysihat_files/_form.html.erb +13 -0
  12. data/app/views/wysihat_files/_wysihat_file.html.erb +11 -0
  13. data/app/views/wysihat_files/index.html.erb +5 -0
  14. data/app/views/wysihat_files/new.html.erb +1 -0
  15. data/config/locales/en.yml +5 -0
  16. data/generators/wysihat/templates/css/facebox.css +60 -0
  17. data/generators/wysihat/templates/css/wysihat.css +44 -0
  18. data/generators/wysihat/templates/images/facebox/b.png +0 -0
  19. data/generators/wysihat/templates/images/facebox/bl.png +0 -0
  20. data/generators/wysihat/templates/images/facebox/br.png +0 -0
  21. data/generators/wysihat/templates/images/facebox/closelabel.gif +0 -0
  22. data/generators/wysihat/templates/images/facebox/loading.gif +0 -0
  23. data/generators/wysihat/templates/images/facebox/tl.png +0 -0
  24. data/generators/wysihat/templates/images/facebox/tr.png +0 -0
  25. data/generators/wysihat/templates/images/icons/arrow_redo.png +0 -0
  26. data/generators/wysihat/templates/images/icons/arrow_undo.png +0 -0
  27. data/generators/wysihat/templates/images/icons/exclamation.png +0 -0
  28. data/generators/wysihat/templates/images/icons/image.png +0 -0
  29. data/generators/wysihat/templates/images/icons/link.png +0 -0
  30. data/generators/wysihat/templates/images/icons/page_code.png +0 -0
  31. data/generators/wysihat/templates/images/icons/text_align_center.png +0 -0
  32. data/generators/wysihat/templates/images/icons/text_align_left.png +0 -0
  33. data/generators/wysihat/templates/images/icons/text_align_right.png +0 -0
  34. data/generators/wysihat/templates/images/icons/text_bold.png +0 -0
  35. data/generators/wysihat/templates/images/icons/text_italic.png +0 -0
  36. data/generators/wysihat/templates/images/icons/text_list_bullets.png +0 -0
  37. data/generators/wysihat/templates/images/icons/text_list_numbers.png +0 -0
  38. data/generators/wysihat/templates/images/icons/text_strikethrough.png +0 -0
  39. data/generators/wysihat/templates/images/icons/text_underline.png +0 -0
  40. data/generators/wysihat/templates/javascripts/facebox.js +180 -0
  41. data/generators/wysihat/templates/javascripts/wysihat.js +2073 -0
  42. data/generators/wysihat/templates/javascripts/wysihat_engine.js +101 -0
  43. data/generators/wysihat/templates/javascripts/wysihat_engine_pack.js +1 -0
  44. data/generators/wysihat/templates/migrations/create_wysihat_files.rb +15 -0
  45. data/generators/wysihat/templates/sass/facebox.sass +108 -0
  46. data/generators/wysihat/templates/sass/wysihat.sass +66 -0
  47. data/generators/wysihat/wysihat_generator.rb +83 -0
  48. data/lib/wysihat-engine.rb +38 -0
  49. data/wysihat-engine.gemspec +90 -0
  50. metadata +123 -0
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ .sass-cache
4
+ coverage
5
+ rdoc
6
+ pkg
data/CHANGELOG ADDED
@@ -0,0 +1,51 @@
1
+ 0.1.8 (November 30, 2009) - Brandon Calloway
2
+ * Added thumbnail creation for uploaded images
3
+ * Added file upload with "copy-url-to-clipboard" functionality
4
+
5
+ 0.1.7 (November 6th, 2009) - Jeff Kreeftmeijer
6
+ * Toolbar didn't show up in IE. Fixed :)
7
+
8
+ 0.1.7 (November 1st, 2009) - Jeff Kreeftmeijer
9
+ * added the exclamation.png icon back in the generator.
10
+
11
+ 0.1.7 (October 28th, 2009) - Jeff Kreeftmeijer
12
+ * fixed a bug in the generator; it copied "loading.gif" to "loading.png". Thanks Eric!
13
+ * two functions in the rakefile were called cssify. One should've been called sassify. fixed :)
14
+ * added "render :layout => false" to WysihatFilesController#index
15
+ * put the "exclamation.png" icon back. Was pretty useful after all.
16
+
17
+ 0.1.7 (October 27th, 2009) - Jeff Kreeftmeijer
18
+ * put the facebox images & icons in a subdir
19
+ * created sassify & cssify rake tasks (like the minify one)
20
+ * removed the .sass_cache dir and added it to the .gitignore file.
21
+
22
+ 0.1.6 (October 21st, 2009) - Jeff Kreeftmeijer
23
+ * fixed a bug that sanitized the output (onsumbit) rather than the input (on paste).
24
+
25
+ 0.1.5 (October 11th, 2009) - Jeff Kreeftmeijer
26
+ * fixed a bug that occurred while submitting the form.
27
+
28
+ 0.1.4 (October 5th, 2009) - Jeff Kreeftmeijer
29
+ * removed the :paste button, you can now just paste it in the editor. It will work ;)
30
+ * added a destroy function for the wysihat_files
31
+ * added a locales file to support i18n
32
+
33
+ 0.1.3 (October 5th, 2009) - Jeff Kreeftmeijer
34
+ * added sass support
35
+
36
+ 0.1.2 (October 4th, 2009) - Jeff Kreeftmeijer
37
+
38
+ * added a --no-stylesheet option to the generator
39
+ * removed ResourceController as a dependency. Normal controller now :)
40
+ * moved more javascript to wysihat_engine.js
41
+ * added wysihat_engine_pack.js (all javascripts minfied & concatenated)
42
+
43
+ 0.1.1 (October 3rd, 2009) - Jeff Kreeftmeijer
44
+
45
+ * Moved most of the javascript to the javascript folder (javascripts/wysihat_engine.js) instead of doing it inline.
46
+
47
+ 0.1.0 (October 3rd, 2009) - Jeff Kreeftmeijer
48
+
49
+ * Made it a gem.
50
+ * Created a generator to get rid of the ugly rake task.
51
+ * Removed lots of files (like /public and /config). Everything is in a generator template now.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 80beans
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.textile ADDED
@@ -0,0 +1,24 @@
1
+ h1. WysiHat Engine
2
+
3
+ A Rails engine to help integrate the "37signals WysiHat rich text editor":http://github.com/josh/wysihat/ to your application.
4
+
5
+ h2. What's New in the Fork
6
+
7
+ * Added thumbnail creation for uploaded images via Paperclip/ImageMagick
8
+ * Added separate file upload with "copy-url-to-clipboard" functionality
9
+
10
+ h2. Using the WysiHat Engine
11
+
12
+ We've written an "Installation Guide":http://wiki.github.com/80beans/wysihat-engine/installation and some "Examples":http://wiki.github.com/80beans/wysihat-engine/examples to get you started. Any questions? Don't hesitate to "ask":http://github.com/inbox/new/jeffkreeftmeijer.
13
+
14
+ h2. Demo
15
+
16
+ There's a "demo rails app":http://github.com/80beans/wysihat-engine-demo so you can have a quick look around.
17
+
18
+ h2. Contributing
19
+
20
+ Found an issue? Have a great idea? Want to help? Great! Please take a second to read the "Contributing Guide":http://wiki.github.com/80beans/wysihat-engine/contributing.
21
+
22
+ h2. License
23
+
24
+ Copyright (c) 2009 80beans, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,78 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the wysihat_engine plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the wysihat_engine plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'WysiHat Engine'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
24
+
25
+ desc 'minify and concatenate the javascript files to make a pack'
26
+ task :minify do
27
+ require "yui/compressor"
28
+
29
+ compressor = YUI::JavaScriptCompressor.new(:munge => true)
30
+ dir = 'generators/wysihat/templates/javascripts'
31
+ pack = File.new("#{dir}/wysihat_engine_pack.js", "w")
32
+
33
+ string = ''
34
+ files = ['facebox', 'wysihat', 'wysihat_engine']
35
+ files.each do |file|
36
+ file = open("#{dir}/#{file}.js")
37
+ string << file.read
38
+ file.close
39
+ end
40
+
41
+ pack.write(compressor.compress(string))
42
+ pack.close
43
+ end
44
+
45
+ desc 'create css files from the sass files. It will overwrite files if they already exist.'
46
+ task :cssify do
47
+ files = ['facebox', 'wysihat']
48
+ files.each do |file|
49
+ system "sass generators/wysihat/templates/sass/#{file}.sass generators/wysihat/templates/css/#{file}.css"
50
+ end
51
+ end
52
+
53
+ desc 'create sass files from the css files. It will overwrite files if they already exist.'
54
+ task :sassify do
55
+ files = ['facebox', 'wysihat']
56
+ files.each do |file|
57
+ system "css2sass generators/wysihat/templates/css/#{file}.css generators/wysihat/templates/sass/#{file}.sass"
58
+ end
59
+ end
60
+
61
+
62
+ begin
63
+ require 'jeweler'
64
+ Jeweler::Tasks.new do |gem|
65
+ gem.name = "wysihat-engine"
66
+ gem.summary = "A Rails engine to help integrate the 37signals WysiHat rich text editor to your application."
67
+ gem.description = "A Rails engine to help integrate the 37signals WysiHat rich text editor to your application."
68
+ gem.email = "jeff@80beans.com"
69
+ gem.homepage = "http://www.80beans.com/2009/10/01/wysihat-engine/"
70
+ gem.authors = ["Jeff Kreeftmeijer"]
71
+ gem.add_development_dependency "yui-compressor", ">= 0.9.1"
72
+ gem.add_dependency 'paperclip', ">= 2.3.1"
73
+ end
74
+ rescue LoadError
75
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
76
+ end
77
+
78
+ Jeweler::GemcutterTasks.new
data/TODO ADDED
@@ -0,0 +1,4 @@
1
+ * add a config.yml file and put some of the settings in there
2
+ * use sprockets for javascripts, stylesheets and images
3
+ * add font selection
4
+ * figure out a way to do a "clean paste". (paste without any markup or styling)
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.7
@@ -0,0 +1,35 @@
1
+ class WysihatFilesController < ApplicationController
2
+ def index
3
+ @wysihat_file = WysihatFile.new
4
+ if params[:type] && params[:type] == "file"
5
+ @wysihat_files = WysihatFile.file_content_type_not_like("image").all
6
+ else
7
+ @wysihat_files = WysihatFile.file_content_type_like("image").all
8
+ end
9
+ render :layout => false
10
+ end
11
+
12
+ def create
13
+ @wysihat_file = WysihatFile.new(params[:wysihat_file])
14
+
15
+ responds_to_parent do
16
+ render :update do |page|
17
+ if(@wysihat_file.save)
18
+ page.insert_html :bottom, :wysihat_files, :partial => 'wysihat_file', :object => @wysihat_file
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ def destroy
25
+ @wysihat_file = WysihatFile.find(params[:id])
26
+ respond_to do |wants|
27
+ wants.js {
28
+ render :update do |page|
29
+ page.remove "wysihat_file_#{@wysihat_file.id}"
30
+ end
31
+ }
32
+ end
33
+ @wysihat_file.destroy
34
+ end
35
+ end
@@ -0,0 +1,2 @@
1
+ module WysihatFilesHelper
2
+ end
@@ -0,0 +1,9 @@
1
+ class WysihatFile < ActiveRecord::Base
2
+ has_attached_file :file, :styles => { :medium => "300x300>", :thumb => "100x100>" }
3
+ before_post_process :image?
4
+
5
+ def image?
6
+ !(file_content_type =~ /^image.*/).nil?
7
+ end
8
+
9
+ end
@@ -0,0 +1,13 @@
1
+ <% form_for @wysihat_file, :html => { :multipart => true, :target => 'file_upload' } do |f| %>
2
+
3
+ <p>
4
+ <%= f.label :file %><br/>
5
+ <%= f.file_field :file %>
6
+ </p>
7
+ <p>
8
+ <%= f.submit %>
9
+ </p>
10
+
11
+ <% end %>
12
+
13
+ <iframe id='file_upload' name="file_upload" style="width:1px;height:1px;border:0px" src="about:blank"></iframe>
@@ -0,0 +1,11 @@
1
+ <li id="wysihat_file_<%= wysihat_file.id %>" class="<%= params[:type] %>">
2
+ <div id="asset">
3
+ <%= link_to_function((image_tag wysihat_file.file.url(:thumb)), "$$('iframe##{params[:editor]}')[0].insertImage(this.href); facebox.close();", :href => wysihat_file.file.url) %>
4
+ </div>
5
+ <% if params[:type] && params[:type] == "file" %>
6
+ <%= render :partial => '/wysihat_files/clipboard', :locals => { :file => "#{wysihat_file.id}", :url => "http://#{SITE_URL}#{wysihat_file.file.url}" } %>
7
+ <% end %>
8
+ <div id="delete">
9
+ <%= link_to_remote t('wysihat_files.destroy.name'), :url => wysihat_file, :method => :delete, :confirm => t('wysihat_files.destroy.sure') %>
10
+ </div>
11
+ </li>
@@ -0,0 +1,5 @@
1
+ <ul id="wysihat_files" class="files">
2
+ <%= render @wysihat_files %>
3
+ </ul>
4
+
5
+ <%= render 'form' %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,5 @@
1
+ en:
2
+ wysihat_files:
3
+ destroy:
4
+ name: delete
5
+ sure: Are you sure you want to delete this file?
@@ -0,0 +1,60 @@
1
+ #facebox {
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ z-index: 100;
6
+ text-align: left; }
7
+ #facebox .b {
8
+ background: url(../images/facebox/b.png); }
9
+ #facebox .tl {
10
+ background: url(../images/facebox/tl.png); }
11
+ #facebox .tr {
12
+ background: url(../images/facebox/tr.png); }
13
+ #facebox .bl {
14
+ background: url(../images/facebox/bl.png); }
15
+ #facebox .br {
16
+ background: url(../images/facebox/br.png); }
17
+ #facebox .popup {
18
+ position: relative; }
19
+ #facebox table {
20
+ border-collapse: collapse; }
21
+ #facebox td {
22
+ border-bottom: 0;
23
+ padding: 0; }
24
+ #facebox .body {
25
+ padding: 10px;
26
+ background: #fff;
27
+ width: 370px; }
28
+ #facebox .loading, #facebox .image {
29
+ text-align: center; }
30
+ #facebox img {
31
+ border: 0;
32
+ margin: 0; }
33
+ #facebox .footer {
34
+ border-top: 1px solid #DDDDDD;
35
+ padding-top: 5px;
36
+ margin-top: 10px;
37
+ text-align: right; }
38
+ #facebox .tl, #facebox .tr, #facebox .bl, #facebox .br {
39
+ height: 10px;
40
+ width: 10px;
41
+ overflow: hidden;
42
+ padding: 0; }
43
+
44
+ #facebox_overlay {
45
+ position: fixed;
46
+ top: 0px;
47
+ left: 0px;
48
+ height: 100%;
49
+ width: 100%; }
50
+
51
+ .facebox_hide {
52
+ z-index: -100; }
53
+
54
+ .facebox_overlayBG {
55
+ background-color: #000;
56
+ z-index: 99; }
57
+
58
+ * html #facebox_overlay {
59
+ position: absolute;
60
+ height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); }
@@ -0,0 +1,44 @@
1
+ div.editor_toolbar a {
2
+ float: left;
3
+ width: 16px;
4
+ height: 16px;
5
+ margin: 5px;
6
+ background-repeat: no-repeat; }
7
+ div.editor_toolbar span {
8
+ display: none; }
9
+
10
+ .editor_toolbar .button {
11
+ background-image: url('../images/icons/exclamation.png'); }
12
+ .editor_toolbar .bold {
13
+ background-image: url('../images/icons/text_bold.png'); }
14
+ .editor_toolbar .italic {
15
+ background-image: url('../images/icons/text_italic.png'); }
16
+ .editor_toolbar .underline {
17
+ background-image: url('../images/icons/text_underline.png'); }
18
+ .editor_toolbar .strikethrough {
19
+ background-image: url('../images/icons/text_strikethrough.png'); }
20
+ .editor_toolbar .justifyleft {
21
+ background-image: url('../images/icons/text_align_left.png'); }
22
+ .editor_toolbar .justifycenter {
23
+ background-image: url('../images/icons/text_align_center.png'); }
24
+ .editor_toolbar .justifyright {
25
+ background-image: url('../images/icons/text_align_right.png'); }
26
+ .editor_toolbar .undo {
27
+ background-image: url('../images/icons/arrow_undo.png'); }
28
+ .editor_toolbar .redo {
29
+ background-image: url('../images/icons/arrow_redo.png'); }
30
+ .editor_toolbar .insertorderedlist {
31
+ background-image: url('../images/icons/text_list_numbers.png'); }
32
+ .editor_toolbar .insertunorderedlist {
33
+ background-image: url('../images/icons/text_list_bullets.png'); }
34
+ .editor_toolbar .link {
35
+ background-image: url('../images/icons/link.png'); }
36
+ .editor_toolbar .image {
37
+ background-image: url('../images/icons/image.png'); }
38
+ .editor_toolbar .html {
39
+ background-image: url('../images/icons/page_code.png'); }
40
+
41
+ iframe.editor {
42
+ border: 1px solid #999;
43
+ height: 400px;
44
+ width: 100%; }