wysihat-engine 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/.gitignore +5 -0
  2. data/CHANGELOG +5 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +20 -0
  5. data/Rakefile +41 -0
  6. data/TODO +3 -0
  7. data/VERSION +1 -0
  8. data/app/controllers/wysihat_files_controller.rb +26 -0
  9. data/app/helpers/wysihat_files_helper.rb +2 -0
  10. data/app/models/wysihat_file.rb +3 -0
  11. data/app/views/wysihat_files/_form.html.erb +13 -0
  12. data/app/views/wysihat_files/_wysihat_file.html.erb +3 -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/generators/wysihat/templates/images/arrow_redo.png +0 -0
  16. data/generators/wysihat/templates/images/arrow_undo.png +0 -0
  17. data/generators/wysihat/templates/images/b.png +0 -0
  18. data/generators/wysihat/templates/images/bl.png +0 -0
  19. data/generators/wysihat/templates/images/br.png +0 -0
  20. data/generators/wysihat/templates/images/closelabel.gif +0 -0
  21. data/generators/wysihat/templates/images/exclamation.png +0 -0
  22. data/generators/wysihat/templates/images/film.png +0 -0
  23. data/generators/wysihat/templates/images/image.png +0 -0
  24. data/generators/wysihat/templates/images/link.png +0 -0
  25. data/generators/wysihat/templates/images/loading.gif +0 -0
  26. data/generators/wysihat/templates/images/page_code.png +0 -0
  27. data/generators/wysihat/templates/images/page_white_flash.png +0 -0
  28. data/generators/wysihat/templates/images/paste_plain.png +0 -0
  29. data/generators/wysihat/templates/images/text_align_center.png +0 -0
  30. data/generators/wysihat/templates/images/text_align_left.png +0 -0
  31. data/generators/wysihat/templates/images/text_align_right.png +0 -0
  32. data/generators/wysihat/templates/images/text_bold.png +0 -0
  33. data/generators/wysihat/templates/images/text_heading_1.png +0 -0
  34. data/generators/wysihat/templates/images/text_heading_2.png +0 -0
  35. data/generators/wysihat/templates/images/text_heading_3.png +0 -0
  36. data/generators/wysihat/templates/images/text_italic.png +0 -0
  37. data/generators/wysihat/templates/images/text_list_bullets.png +0 -0
  38. data/generators/wysihat/templates/images/text_list_numbers.png +0 -0
  39. data/generators/wysihat/templates/images/text_strikethrough.png +0 -0
  40. data/generators/wysihat/templates/images/text_underline.png +0 -0
  41. data/generators/wysihat/templates/images/tl.png +0 -0
  42. data/generators/wysihat/templates/images/tr.png +0 -0
  43. data/generators/wysihat/templates/javascripts/facebox.js +190 -0
  44. data/generators/wysihat/templates/javascripts/wysihat.js +2098 -0
  45. data/generators/wysihat/templates/migrations/create_wysihat_files.rb +15 -0
  46. data/generators/wysihat/templates/stylesheets/facebox.css +95 -0
  47. data/generators/wysihat/templates/stylesheets/wysihat.css +76 -0
  48. data/generators/wysihat/wysihat_generator.rb +50 -0
  49. data/lib/wysihat-engine.rb +132 -0
  50. data/vendor/plugins/responds_to_parent/MIT-LICENSE +20 -0
  51. data/vendor/plugins/responds_to_parent/README +42 -0
  52. data/vendor/plugins/responds_to_parent/Rakefile +22 -0
  53. data/vendor/plugins/responds_to_parent/init.rb +2 -0
  54. data/vendor/plugins/responds_to_parent/lib/parent_selector_assertion.rb +144 -0
  55. data/vendor/plugins/responds_to_parent/lib/responds_to_parent.rb +37 -0
  56. data/vendor/plugins/responds_to_parent/rails/init.rb +2 -0
  57. data/vendor/plugins/responds_to_parent/responds-to-parent.gemspec +15 -0
  58. data/vendor/plugins/responds_to_parent/test/assert_select_parent_test.rb +319 -0
  59. data/vendor/plugins/responds_to_parent/test/responds_to_parent_test.rb +116 -0
  60. data/wysihat-engine.gemspec +101 -0
  61. metadata +133 -0
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/CHANGELOG ADDED
@@ -0,0 +1,5 @@
1
+ 0.1.0 (October 3rd, 2009) - Jeff Kreeftmeijer
2
+
3
+ * Made it a gem.
4
+ * Created a generator to get rid of the ugly rake task.
5
+ * 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.rdoc ADDED
@@ -0,0 +1,20 @@
1
+ = WysihatEngine
2
+
3
+ A simple Engine to get everyone up and running with Wysihat ( http://github.com/josh/wysihat ) fast.
4
+
5
+ == Installation
6
+
7
+ http://wiki.github.com/80beans/wysihat-engine/installation
8
+
9
+ == Examples
10
+
11
+ http://wiki.github.com/80beans/wysihat-engine/examples
12
+
13
+ == Contributing
14
+
15
+ Found an issue? Have a great idea? Want to help? Great!
16
+ Issue reports and pull requests are always welcome. :)
17
+
18
+ == License
19
+
20
+ Copyright (c) 2009 80beans, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,41 @@
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 = 'WysihatEngine'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
24
+
25
+ begin
26
+ require 'jeweler'
27
+ Jeweler::Tasks.new do |gem|
28
+ gem.name = "wysihat-engine"
29
+ gem.summary = "A rails engine to allow users to use the WysiHat editors."
30
+ gem.description = "A rails engine to allow users to use the WysiHat editors."
31
+ gem.email = "jeff@80beans.com"
32
+ gem.homepage = "http://www.80beans.com/2009/10/01/wysihat-engine/"
33
+ gem.authors = ["Jeff Kreeftmeijer"]
34
+ gem.add_dependency('thoughtbot-paperclip')
35
+ gem.add_dependency('giraffesoft-resource_controller')
36
+ end
37
+ rescue LoadError
38
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
39
+ end
40
+
41
+ Jeweler::GemcutterTasks.new
data/TODO ADDED
@@ -0,0 +1,3 @@
1
+ * get it working as a plugin again ( some problem with ResourceController )
2
+ * remove ResourceController, it's useless and confusing
3
+ * rewrite the :paste button to use josh's solution ( http://www.80beans.com/2009/10/01/wysihat-engine/comment-page-1/#comment-1834 )
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,26 @@
1
+ class WysihatFilesController < ResourceController::Base
2
+ index.before do
3
+ @wysihat_file = WysihatFile.new
4
+ end
5
+
6
+ #create do
7
+ # responds_to_parent do
8
+ # render :update do |page|
9
+ # if(@wysihat_file.save)
10
+ # page.insert_html :bottom, :wysihat_files, :partial => 'wysihat_file', :object => @wysihat_file
11
+ # end
12
+ # end
13
+ # end
14
+ #end
15
+ def create
16
+ @wysihat_file = WysihatFile.new(params[:wysihat_file])
17
+
18
+ responds_to_parent do
19
+ render :update do |page|
20
+ if(@wysihat_file.save)
21
+ page.insert_html :bottom, :wysihat_files, :partial => 'wysihat_file', :object => @wysihat_file
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,2 @@
1
+ module WysihatFilesHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ class WysihatFile < ActiveRecord::Base
2
+ has_attached_file :file
3
+ 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,3 @@
1
+ <li id="wysihat_file_<%= wysihat_file.id %>">
2
+ <%= link_to_function(wysihat_file.file_file_name, "$$('iframe##{params[:editor]}')[0].insertImage(this.href); facebox.close();", :href => wysihat_file.file.url) %>
3
+ </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,190 @@
1
+ /* Facebox for Prototype, version 2.0
2
+ * By Robert Gaal - http://wakoopa.com
3
+ *
4
+ * Heavily based on Facebox by Chris Wanstrath - http://famspam.com/facebox
5
+ * First ported to Prototype by Phil Burrows - http://blog.philburrows.com
6
+ *
7
+ * Licensed under the MIT:
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ *
10
+ * Need help? Join the Google Groups mailing list:
11
+ * http://groups.google.com/group/facebox/
12
+ *
13
+ * Dependencies: prototype & script.aculo.us + images & CSS files from original facebox
14
+ * Usage: Append 'rel="facebox"' to an element to call it inside a so-called facebox
15
+ *
16
+ *--------------------------------------------------------------------------*/
17
+
18
+
19
+ var Facebox = Class.create({
20
+ initialize : function(extra_set){
21
+ this.settings = {
22
+ loading_image : '/images/loading.gif',
23
+ close_image : '/images/closelabel.gif',
24
+ image_types : new RegExp('\.' + ['png', 'jpg', 'jpeg', 'gif'].join('|') + '$', 'i'),
25
+ inited : true,
26
+ facebox_html : '\
27
+ <div id="facebox" style="display:none;"> \
28
+ <div class="popup"> \
29
+ <table id="facebox_table"> \
30
+ <tbody> \
31
+ <tr> \
32
+ <td class="tl"/><td class="b"/><td class="tr"/> \
33
+ </tr> \
34
+ <tr> \
35
+ <td class="b"/> \
36
+ <td class="body"> \
37
+ <div class="content"> \
38
+ </div> \
39
+ <div class="footer"> \
40
+ <a href="#" class="close"> \
41
+ <img src="/images/closelabel.gif" title="close" class="close_image" /> \
42
+ </a> \
43
+ </div> \
44
+ </td> \
45
+ <td class="b"/> \
46
+ </tr> \
47
+ <tr> \
48
+ <td class="bl"/><td class="b"/><td class="br"/> \
49
+ </tr> \
50
+ </tbody> \
51
+ </table> \
52
+ </div> \
53
+ </div>'
54
+ };
55
+ if (extra_set) Object.extend(this.settings, extra_set);
56
+ $(document.body).insert({bottom: this.settings.facebox_html});
57
+
58
+ this.preload = [ new Image(), new Image() ];
59
+ this.preload[0].src = this.settings.close_image;
60
+ this.preload[1].src = this.settings.loading_image;
61
+
62
+ f = this;
63
+ $$('#facebox .b:first, #facebox .bl, #facebox .br, #facebox .tl, #facebox .tr').each(function(elem){
64
+ f.preload.push(new Image());
65
+ f.preload.slice(-1).src = elem.getStyle('background-image').replace(/url\((.+)\)/, '$1');
66
+ });
67
+
68
+ this.facebox = $('facebox');
69
+ this.keyPressListener = this.watchKeyPress.bindAsEventListener(this);
70
+
71
+ this.watchClickEvents();
72
+ fb = this;
73
+ Event.observe($$('#facebox .close').first(), 'click', function(e){
74
+ Event.stop(e);
75
+ fb.close()
76
+ });
77
+ Event.observe($$('#facebox .close_image').first(), 'click', function(e){
78
+ Event.stop(e);
79
+ fb.close()
80
+ });
81
+ },
82
+
83
+ watchKeyPress : function(e){
84
+ // Close if espace is pressed or if there's a click outside of the facebox
85
+ if (e.keyCode == 27 || !Event.element(e).descendantOf(this.facebox)) this.close();
86
+ },
87
+
88
+ watchClickEvents : function(e){
89
+ var f = this;
90
+ $$('a[rel=facebox]').each(function(elem,i){
91
+ Event.observe(elem, 'click', function(e){
92
+ Event.stop(e);
93
+ f.click_handler(elem, e);
94
+ });
95
+ });
96
+ },
97
+
98
+ loading : function() {
99
+ if ($$('#facebox .loading').length == 1) return true;
100
+
101
+ contentWrapper = $$('#facebox .content').first();
102
+ contentWrapper.childElements().each(function(elem, i){
103
+ elem.remove();
104
+ });
105
+ contentWrapper.insert({bottom: '<div class="loading"><img src="'+this.settings.loading_image+'"/></div>'});
106
+
107
+ var pageScroll = document.viewport.getScrollOffsets();
108
+ this.facebox.setStyle({
109
+ 'top': pageScroll.top + (document.viewport.getHeight() / 10) + 'px',
110
+ 'left': document.viewport.getWidth() / 2 - (this.facebox.getWidth() / 2) + 'px'
111
+ });
112
+
113
+ Event.observe(document, 'keypress', this.keyPressListener);
114
+ Event.observe(document, 'click', this.keyPressListener);
115
+ },
116
+
117
+ reveal : function(data, klass){
118
+ this.loading();
119
+ load = $$('#facebox .loading').first();
120
+ if(load) load.remove();
121
+
122
+ contentWrapper = $$('#facebox .content').first();
123
+ if (klass) contentWrapper.addClassName(klass);
124
+ //contentWrapper.insert({bottom: data});
125
+ contentWrapper.update(data);
126
+
127
+ $$('#facebox .body').first().childElements().each(function(elem,i){
128
+ elem.show();
129
+ });
130
+
131
+ if(!this.facebox.visible()) new Effect.Appear(this.facebox, {duration: .3});
132
+ this.facebox.setStyle({
133
+ 'left': document.viewport.getWidth() / 2 - (this.facebox.getWidth() / 2) + 'px'
134
+ });
135
+
136
+ Event.observe(document, 'keypress', this.keyPressListener);
137
+ Event.observe(document, 'click', this.keyPressListener);
138
+ },
139
+
140
+ close : function(){
141
+ new Effect.Fade('facebox', {duration: .3});
142
+ },
143
+
144
+ click_handler : function(elem, e){
145
+ this.loading();
146
+ Event.stop(e);
147
+
148
+ // support for rel="facebox[.inline_popup]" syntax, to add a class
149
+ var klass = elem.rel.match(/facebox\[\.(\w+)\]/);
150
+ if (klass) klass = klass[1];
151
+
152
+ new Effect.Appear(this.facebox, {duration: .3});
153
+
154
+ if (elem.href.match(/#/)){
155
+ var url = window.location.href.split('#')[0];
156
+ var target = elem.href.replace(url+'#','');
157
+ // var data = $$(target).first();
158
+ var d = $(target);
159
+ // create a new element so as to not delete the original on close()
160
+ var data = new Element(d.tagName);
161
+ data.innerHTML = d.innerHTML;
162
+ this.reveal(data, klass);
163
+ } else if (elem.href.match(this.settings.image_types)) {
164
+ var image = new Image();
165
+ fb = this;
166
+ image.onload = function() {
167
+ fb.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass)
168
+ }
169
+ image.src = elem.href;
170
+ } else {
171
+ var fb = this;
172
+ var url = elem.href;
173
+ new Ajax.Request(url, {
174
+ method : 'get',
175
+ onFailure : function(transport){
176
+ fb.reveal(transport.responseText, klass);
177
+ },
178
+ onSuccess : function(transport){
179
+ fb.reveal(transport.responseText, klass);
180
+ }
181
+ });
182
+
183
+ }
184
+ }
185
+ });
186
+
187
+ var facebox;
188
+ document.observe('dom:loaded', function(){
189
+ facebox = new Facebox();
190
+ });