midas 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/.bundle/config +2 -0
  2. data/.document +5 -0
  3. data/.gitignore +32 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE +20 -0
  6. data/README.textile +21 -0
  7. data/Rakefile +84 -0
  8. data/VERSION +1 -0
  9. data/features/step_definitions/editor_steps.rb +16 -0
  10. data/features/step_definitions/web_steps.rb +205 -0
  11. data/features/support/env.rb +39 -0
  12. data/features/support/paths.rb +29 -0
  13. data/features/view_editor.feature +8 -0
  14. data/generators/midas/midas_generator.rb +1 -0
  15. data/lib/midas.rb +1 -0
  16. data/midas.gemspec +131 -0
  17. data/public/images/midas/toolbars/actions/_background.png +0 -0
  18. data/public/images/midas/toolbars/actions/_background_radio.png +0 -0
  19. data/public/images/midas/toolbars/actions/_separator.png +0 -0
  20. data/public/images/midas/toolbars/actions/extra/prefspane.png +0 -0
  21. data/public/images/midas/toolbars/actions/extra/todospane.png +0 -0
  22. data/public/images/midas/toolbars/actions/historypanel.png +0 -0
  23. data/public/images/midas/toolbars/actions/insertcharacter.png +0 -0
  24. data/public/images/midas/toolbars/actions/insertlink.png +0 -0
  25. data/public/images/midas/toolbars/actions/insertmedia.png +0 -0
  26. data/public/images/midas/toolbars/actions/insertobject.png +0 -0
  27. data/public/images/midas/toolbars/actions/inserttable.png +0 -0
  28. data/public/images/midas/toolbars/actions/inspectorpanel.png +0 -0
  29. data/public/images/midas/toolbars/actions/notespanel.png +0 -0
  30. data/public/images/midas/toolbars/actions/preview.png +0 -0
  31. data/public/images/midas/toolbars/actions/redo.png +0 -0
  32. data/public/images/midas/toolbars/actions/save.png +0 -0
  33. data/public/images/midas/toolbars/actions/undo.png +0 -0
  34. data/public/images/midas/toolbars/htmleditor/_background.png +0 -0
  35. data/public/images/midas/toolbars/htmleditor/_line_separator.png +0 -0
  36. data/public/images/midas/toolbars/htmleditor/_separator.png +0 -0
  37. data/public/images/midas/toolbars/htmleditor/buttons.png +0 -0
  38. data/public/javascripts/midas/config.js +181 -0
  39. data/public/javascripts/midas/dialog.js +9 -0
  40. data/public/javascripts/midas/midas.js +307 -0
  41. data/public/javascripts/midas/native_extensions.js +43 -0
  42. data/public/javascripts/midas/palette.js +108 -0
  43. data/public/javascripts/midas/region.js +194 -0
  44. data/public/javascripts/midas/statusbar.js +84 -0
  45. data/public/javascripts/midas/toolbar.js +255 -0
  46. data/public/javascripts/prototype.js +6001 -0
  47. data/public/midas/backcolor.html +97 -0
  48. data/public/midas/examples/bundled.html +60 -0
  49. data/public/midas/examples/iframe.html +73 -0
  50. data/public/midas/examples/index.html +73 -0
  51. data/public/midas/examples/javascript_archive.js +111 -0
  52. data/public/midas/forecolor.html +97 -0
  53. data/public/stylesheets/midas/dialog.css +2 -0
  54. data/public/stylesheets/midas/midas.css +9 -0
  55. data/public/stylesheets/midas/palette.css +50 -0
  56. data/public/stylesheets/midas/region.css +16 -0
  57. data/public/stylesheets/midas/statusbar.css +17 -0
  58. data/public/stylesheets/midas/toolbar.css +262 -0
  59. data/rails/init.rb +1 -0
  60. data/spec/javascripts/dialog_spec.js +7 -0
  61. data/spec/javascripts/fixtures/midas_fixture.html +27 -0
  62. data/spec/javascripts/fixtures/midas_styles.css +14 -0
  63. data/spec/javascripts/fixtures/native_extensions_fixture.html +5 -0
  64. data/spec/javascripts/helpers/browser_detection.js +15 -0
  65. data/spec/javascripts/helpers/event_simulation.js +505 -0
  66. data/spec/javascripts/helpers/spec_helper.js +125 -0
  67. data/spec/javascripts/midas_spec.js +284 -0
  68. data/spec/javascripts/native_extensions_spec.js +39 -0
  69. data/spec/javascripts/palette_spec.js +59 -0
  70. data/spec/javascripts/region_spec.js +441 -0
  71. data/spec/javascripts/statusbar_spec.js +61 -0
  72. data/spec/javascripts/support/jasmine.yml +82 -0
  73. data/spec/javascripts/support/jasmine_config.rb +39 -0
  74. data/spec/javascripts/support/jasmine_runner.rb +19 -0
  75. data/spec/javascripts/toolbar_spec.js +149 -0
  76. data/spec/ruby/helpers/spec_helper.rb +9 -0
  77. data/spec/ruby/midas_spec.rb +9 -0
  78. data/spec/spec.opts +1 -0
  79. data/tasks/midas_tasks.rake +105 -0
  80. metadata +166 -0
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_WITHOUT: ""
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,32 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## RUBYMINE
9
+ .idea
10
+
11
+ ## EMACS
12
+ *~
13
+ \#*
14
+ .\#*
15
+
16
+ ## VIM
17
+ *.swp
18
+
19
+ ## RVM
20
+ .rvmrc
21
+
22
+ ## PROJECT::GENERAL
23
+ coverage
24
+ rdoc
25
+ pkg
26
+
27
+ ## PROJECT::SPECIFIC
28
+ public/javascripts/midas.js
29
+ public/javascripts/midas.min.js
30
+ spec/javascripts/fixtures/fixtures.js
31
+ public/stylesheets/midas.bundle.css
32
+ public/stylesheets/midas.css
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source :rubyforge
2
+ source 'http://gems.github.com'
3
+
4
+ gem 'ruby-debug'
5
+ gem 'cucumber', '0.7.3'
6
+ gem 'capybara', '0.3.8'
7
+ gem 'rspec', '1.3.0'
8
+ gem 'rack', '~>1.1'
9
+ gem 'activesupport', '~>2.3'
10
+ gem 'jasmine', '0.10.3.5'
11
+ gem 'packr', '3.1.0'
12
+ gem 'jeweler', '1.4.0'
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jeremy Jackson
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.
@@ -0,0 +1,21 @@
1
+ = Installation
2
+
3
+
4
+
5
+ = Development
6
+
7
+ Testing:
8
+
9
+ ruby:
10
+ rake spec
11
+
12
+ javascript:
13
+ rake jasmine:server
14
+ or
15
+ rake jasmine:ci
16
+
17
+ integration:
18
+ rake midas:minify_js
19
+ rake jasmine:server
20
+
21
+ navigate to http://localhost:8888/integration/midas.html
@@ -0,0 +1,84 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ Dir[File.join(File.dirname(__FILE__), "/tasks/**/*.rake")].sort.each { |ext| load ext }
4
+
5
+ ENV['PATH'] += ':/opt/local/bin'
6
+
7
+ begin
8
+ require 'jeweler'
9
+ Jeweler::Tasks.new do |gem|
10
+ gem.name = "midas"
11
+ gem.summary = %Q{A rich text editor gem for Rails}
12
+ gem.description = %Q{Provides a front end for editing content in a contextual way with WYSIWYG editing}
13
+ gem.email = "jejacks0n@gmail.com"
14
+ gem.homepage = "http://github.com/jejacks0n/midas"
15
+ gem.authors = ["Jeremy Jackson"]
16
+ gem.add_dependency "packr", ">= 3.1.0"
17
+ gem.add_development_dependency "rspec", ">= 1.3.0"
18
+ gem.add_development_dependency "jasmine", ">= 0.10.3.5"
19
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20
+ end
21
+ Jeweler::GemcutterTasks.new
22
+ rescue LoadError
23
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
24
+ rescue Git::GitExecuteError
25
+ puts "Unable to locate git in your path. If you have git installed, and it's not being found, edit this Rakefile and adjust the ENV['PATH']"
26
+ end
27
+
28
+ require 'spec/rake/spectask'
29
+ Spec::Rake::SpecTask.new(:spec) do |spec|
30
+ spec.libs << 'lib' << 'spec'
31
+ spec.spec_files = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
35
+ spec.libs << 'lib' << 'spec'
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :spec => :check_dependencies
41
+
42
+ task :default => :spec
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "midas #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
53
+
54
+ namespace :jasmine do
55
+ task :require do
56
+ require 'jasmine'
57
+ end
58
+
59
+ desc "Run continuous integration tests"
60
+ task :ci => "jasmine:require" do
61
+ require "spec"
62
+ require 'spec/rake/spectask'
63
+
64
+ Spec::Rake::SpecTask.new(:jasmine_continuous_integration_runner) do |t|
65
+ t.spec_opts = ["--color", "--format", "specdoc"]
66
+ t.verbose = true
67
+ t.spec_files = ['spec/javascripts/support/jasmine_runner.rb']
68
+ end
69
+ Rake::Task["jasmine_continuous_integration_runner"].invoke
70
+ end
71
+
72
+ task :server => "jasmine:require" do
73
+ jasmine_config_overrides = 'spec/javascripts/support/jasmine_config.rb'
74
+ require jasmine_config_overrides if File.exists?(jasmine_config_overrides)
75
+
76
+ puts "your tests are here:"
77
+ puts " http://localhost:8888/"
78
+
79
+ Jasmine::Config.new.start_server
80
+ end
81
+ end
82
+
83
+ desc "Run specs via server"
84
+ task :jasmine => ['jasmine:server']
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,16 @@
1
+
2
+
3
+ When /^(?:|I)click into the editable area(?: (within .*))?$/ do |selector|
4
+ with_scope(selector) do
5
+ editable = find("div.editable")
6
+ editable.click
7
+ editable.node.send_keys 'f u you f\'n bastard'
8
+ end
9
+ end
10
+
11
+ When /I debug/i do
12
+ require 'ruby-debug'
13
+ debugger
14
+ true
15
+ end
16
+
@@ -0,0 +1,205 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ require 'uri'
9
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
10
+
11
+ module WithinHelpers
12
+ def with_scope(locator)
13
+ locator ? within(locator) { yield } : yield
14
+ end
15
+ end
16
+ World(WithinHelpers)
17
+
18
+ Given /^(?:|I )am on (.+)$/ do |page_name|
19
+ visit path_to(page_name)
20
+ end
21
+
22
+ When /^(?:|I )go to (.+)$/ do |page_name|
23
+ visit path_to(page_name)
24
+ end
25
+
26
+ When /^(?:|I )press "([^\"]*)"(?: (within .*))?$/ do |button, selector|
27
+ with_scope(selector) do
28
+ click_button(button)
29
+ end
30
+ end
31
+
32
+ When /^(?:|I )follow "([^\"]*)"(?: (within .*))?$/ do |link, selector|
33
+ with_scope(selector) do
34
+ click_link(link)
35
+ end
36
+ end
37
+
38
+ When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"(?: (within .*))?$/ do |field, value, selector|
39
+ with_scope(selector) do
40
+ fill_in(field, :with => value)
41
+ end
42
+ end
43
+
44
+ When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"(?: (within .*))?$/ do |value, field, selector|
45
+ with_scope(selector) do
46
+ fill_in(field, :with => value)
47
+ end
48
+ end
49
+
50
+ # Use this to fill in an entire form with data from a table. Example:
51
+ #
52
+ # When I fill in the following:
53
+ # | Account Number | 5002 |
54
+ # | Expiry date | 2009-11-01 |
55
+ # | Note | Nice guy |
56
+ # | Wants Email? | |
57
+ #
58
+ # TODO: Add support for checkbox, select og option
59
+ # based on naming conventions.
60
+ #
61
+ When /^(?:|I )fill in the following(?: (within .*))?:$/ do |selector, fields|
62
+ with_scope(selector) do
63
+ fields.rows_hash.each do |name, value|
64
+ When %{I fill in "#{name}" with "#{value}"}
65
+ end
66
+ end
67
+ end
68
+
69
+ When /^(?:|I )select "([^\"]*)" from "([^\"]*)"(?: (within .*))?$/ do |value, field, selector|
70
+ with_scope(selector) do
71
+ select(value, :from => field)
72
+ end
73
+ end
74
+
75
+ When /^(?:|I )check "([^\"]*)"(?: (within .*))?$/ do |field, selector|
76
+ with_scope(selector) do
77
+ check(field)
78
+ end
79
+ end
80
+
81
+ When /^(?:|I )uncheck "([^\"]*)"(?: (within .*))?$/ do |field, selector|
82
+ with_scope(selector) do
83
+ uncheck(field)
84
+ end
85
+ end
86
+
87
+ When /^(?:|I )choose "([^\"]*)"(?: (within .*))?$/ do |field, selector|
88
+ with_scope(selector) do
89
+ choose(field)
90
+ end
91
+ end
92
+
93
+ When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"(?: (within .*))?$/ do |path, field, selector|
94
+ with_scope(selector) do
95
+ attach_file(field, File.expand_path(path))
96
+ end
97
+ end
98
+
99
+ Then /^(?:|I )should see "([^\"]*)"(?: (within .*))?$/ do |text, selector|
100
+ with_scope(selector) do
101
+ if defined?(Spec::Matchers)
102
+ page.should have_content(text)
103
+ else
104
+ assert page.has_content?(text)
105
+ end
106
+ end
107
+ end
108
+
109
+ Then /^(?:|I )should see \/([^\/]*)\/(?: (within .*))?$/ do |regexp, selector|
110
+ regexp = Regexp.new(regexp)
111
+ with_scope(selector) do
112
+ if defined?(Spec::Matchers)
113
+ page.should have_xpath('//*', :text => regexp)
114
+ else
115
+ assert page.has_xpath?('//*', :text => regexp)
116
+ end
117
+ end
118
+ end
119
+
120
+ Then /^(?:|I )should not see "([^\"]*)"(?: (within .*))?$/ do |text, selector|
121
+ with_scope(selector) do
122
+ if defined?(Spec::Matchers)
123
+ page.should have_no_content(text)
124
+ else
125
+ assert page.has_no_content?(text)
126
+ end
127
+ end
128
+ end
129
+
130
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: (within .*))?$/ do |regexp, selector|
131
+ regexp = Regexp.new(regexp)
132
+ with_scope(selector) do
133
+ if defined?(Spec::Matchers)
134
+ page.should have_no_xpath('//*', :text => regexp)
135
+ else
136
+ assert page.has_no_xpath?('//*', :text => regexp)
137
+ end
138
+ end
139
+ end
140
+
141
+ Then /^the "([^\"]*)" field(?: (within .*))? should contain "([^\"]*)"$/ do |field_name, selector, value|
142
+ with_scope(selector) do
143
+ field = find_field(field_name)
144
+ field_value = field.value || field.text
145
+ if defined?(Spec::Matchers)
146
+ field_value.should =~ /#{value}/
147
+ else
148
+ assert_match(/#{value}/, field_value)
149
+ end
150
+ end
151
+ end
152
+
153
+ Then /^the "([^\"]*)" field(?: (within .*))? should not contain "([^\"]*)"$/ do |field, selector, value|
154
+ with_scope(selector) do
155
+ if defined?(Spec::Matchers)
156
+ find_field(field).value.should_not =~ /#{value}/
157
+ else
158
+ assert_no_match(/#{value}/, find_field(field).value)
159
+ end
160
+ end
161
+ end
162
+
163
+ Then /^the "([^\"]*)" checkbox(?: (within .*))? should be checked$/ do |label, selector|
164
+ with_scope(selector) do
165
+ if defined?(Spec::Matchers)
166
+ find_field(label)['checked'].should == 'checked'
167
+ else
168
+ assert_equal 'checked', field_labeled(label)['checked']
169
+ end
170
+ end
171
+ end
172
+
173
+ Then /^the "([^\"]*)" checkbox(?: (within .*))? should not be checked$/ do |label, selector|
174
+ with_scope(selector) do
175
+ if defined?(Spec::Matchers)
176
+ find_field(label)['checked'].should_not == 'checked'
177
+ else
178
+ assert_not_equal 'checked', field_labeled(label)['checked']
179
+ end
180
+ end
181
+ end
182
+
183
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
184
+ if defined?(Spec::Matchers)
185
+ URI.parse(current_url).path.should == path_to(page_name)
186
+ else
187
+ assert_equal path_to(page_name), URI.parse(current_url).path
188
+ end
189
+ end
190
+
191
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
192
+ actual_params = CGI.parse(URI.parse(current_url).query)
193
+ expected_params = Hash[expected_pairs.rows_hash.map{|k,v| [k,[v]]}]
194
+
195
+ if defined?(Spec::Matchers)
196
+ actual_params.should == expected_params
197
+ else
198
+ assert_equal expected_params, actual_params
199
+ end
200
+ end
201
+
202
+ Then /^show me the page$/ do
203
+ save_and_open_page
204
+ end
205
+
@@ -0,0 +1,39 @@
1
+ require "rubygems"
2
+ require "bundler"
3
+ Bundler.require
4
+
5
+ require 'rack'
6
+
7
+ require 'cucumber/formatter/unicode'
8
+ require 'capybara/dsl'
9
+
10
+ Capybara.app = Rack::Builder.new do
11
+ map "/" do
12
+ use Rack::Static, :urls => ["/"], :root => "public"
13
+ run lambda {|env| [404, {}, '']}
14
+ end
15
+ end.to_app
16
+
17
+ require 'capybara/cucumber'
18
+ require 'capybara/session'
19
+
20
+ Capybara.default_selector = :css
21
+ Capybara.default_driver = :selenium
22
+
23
+ require 'selenium-webdriver'
24
+ class Capybara::Driver::Selenium < Capybara::Driver::Base
25
+ def self.driver
26
+ unless @driver
27
+ @driver = Selenium::WebDriver.for :firefox, :profile => 'webdriver'
28
+ at_exit do
29
+ @driver.quit
30
+ end
31
+ end
32
+ @driver
33
+ end
34
+ end
35
+
36
+ Before do
37
+ visit '/integration/midas.html'
38
+ end
39
+