Permalink
Browse files

support external select

Unsupported modes in an external select are handled gracefully (with notice dialogs and all)
added haml mode
update Rack module
added test/support dir
toText/toHTML works flexibly
hide preview button if its not supported
Mode change works asynchronously
hide changeDataMode, if there is only one option
rewriting dialog plugin
added overlays to dialog and modechange
better haml-html to textile conversion
load from div with source attribute works
fixed initFromTextarea

Fixed bugs and added specs for them
  • Loading branch information...
1 parent 02138b2 commit 624f31a9964aaeccec184e80dd57aef16ae0cade @johnny committed Oct 27, 2011
View
@@ -4,3 +4,4 @@ gem "middleman"
gem "closure-compiler"
gem "selenium-webdriver"
gem "rspec"
+gem 'hpricot'
View
@@ -18,7 +18,7 @@ GEM
sass (~> 3.1)
daemons (1.1.4)
diff-lcs (1.1.3)
- em-websocket (0.3.1)
+ em-websocket (0.3.5)
addressable (>= 2.1.1)
eventmachine (>= 0.12.9)
eventmachine (0.12.10)
@@ -34,6 +34,7 @@ GEM
multi_json (~> 1.0.3)
haml (3.1.3)
hike (1.2.1)
+ hpricot (0.8.4)
http_router (0.10.2)
rack (>= 1.0.0)
url_mount (~> 0.2.1)
@@ -42,62 +43,66 @@ GEM
libv8 (3.3.10.2)
maruku (0.6.0)
syntax (>= 1.0.0)
- middleman (2.0.11)
+ middleman (2.0.13.1)
coffee-script (~> 2.2.0)
compass (~> 0.11.3)
+ execjs (~> 1.2.7)
guard (~> 0.6.2)
haml (~> 3.1.0)
maruku (~> 0.6.0)
middleman-livereload (~> 0.2.0)
- padrino-core (= 0.10.2)
- padrino-helpers (= 0.10.2)
- rack (~> 1.3.0)
+ padrino-core (~> 0.10.5)
+ padrino-helpers (~> 0.10.5)
+ rack (~> 1.3.5)
rack-test (~> 0.6.1)
sass (~> 3.1.7)
- sinatra (~> 1.2.6)
+ sinatra (~> 1.3.1)
slim (~> 1.0.2)
- sprockets (~> 2.0.0)
+ sprockets (~> 2.0.3)
thin (~> 1.2.11)
thor (~> 0.14.0)
tilt (~> 1.3.1)
uglifier (~> 1.0.0)
- middleman-livereload (0.2.0)
- guard-livereload (~> 0.3.0)
+ middleman-livereload (0.2.1)
+ guard-livereload (~> 0.3.1)
multi_json (1.0.3)
- padrino-core (0.10.2)
+ padrino-core (0.10.5)
activesupport (~> 3.1.0)
http_router (~> 0.10.2)
- sinatra (~> 1.2.6)
+ sinatra (~> 1.3.1)
thor (~> 0.14.3)
tilt (~> 1.3.0)
- padrino-helpers (0.10.2)
+ padrino-helpers (0.10.5)
i18n (~> 0.6)
- padrino-core (= 0.10.2)
- rack (1.3.4)
+ padrino-core (= 0.10.5)
+ rack (1.3.5)
+ rack-protection (1.1.4)
+ rack
rack-test (0.6.1)
rack (>= 1.0)
- rspec (2.6.0)
- rspec-core (~> 2.6.0)
- rspec-expectations (~> 2.6.0)
- rspec-mocks (~> 2.6.0)
- rspec-core (2.6.4)
- rspec-expectations (2.6.0)
+ rspec (2.7.0)
+ rspec-core (~> 2.7.0)
+ rspec-expectations (~> 2.7.0)
+ rspec-mocks (~> 2.7.0)
+ rspec-core (2.7.1)
+ rspec-expectations (2.7.0)
diff-lcs (~> 1.1.2)
- rspec-mocks (2.6.0)
+ rspec-mocks (2.7.0)
rubyzip (0.9.4)
sass (3.1.10)
- selenium-webdriver (2.8.0)
+ selenium-webdriver (2.10.0)
childprocess (>= 0.2.1)
- ffi (>= 1.0.7)
+ ffi (= 1.0.9)
json_pure
rubyzip
- sinatra (1.2.7)
- rack (~> 1.1)
- tilt (>= 1.2.2, < 2.0)
- slim (1.0.3)
+ sinatra (1.3.1)
+ rack (~> 1.3, >= 1.3.4)
+ rack-protection (~> 1.1, >= 1.1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ slim (1.0.4)
temple (~> 0.3.4)
tilt (~> 1.3.2)
- sprockets (2.0.2)
+ sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
@@ -111,7 +116,7 @@ GEM
rack (>= 1.0.0)
thor (0.14.6)
tilt (1.3.3)
- uglifier (1.0.3)
+ uglifier (1.0.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
url_mount (0.2.1)
@@ -122,6 +127,7 @@ PLATFORMS
DEPENDENCIES
closure-compiler
+ hpricot
middleman
rspec
selenium-webdriver
View
42 TODO
@@ -1,7 +1,5 @@
-* [22/32] Further improvements
- - [ ] flexible toolbar, which stays on top
- - [ ] textileCompiler
- - [ ] "* item1":src should compile as a link
+* [29/40] Further improvements
+ - [ ] fix multiple.html
- [-] wysiwyg
- [ ] Toolbar should work only if there is a range inside the preview
(also the state checking)
@@ -29,8 +27,6 @@
- [X] enter in the middle of a heading does not move the rest of the heading down
- [X] selecting all by hand and deleting it leaves empty tags
this is a result of the current implementation of checkIfDeletedAll
- - [ ] provide support for external mode select
- - [ ] support haml
- [-] Better Dialogs (for inspiration see gollum)
- [ ] display errors as tooltips
- [X] reset errors on open
@@ -44,17 +40,51 @@
- [X] values for the selects should be defined by a method call if functions are defined
- [X] fields should share the combobox
- [ ] localization
+ - [ ] flexible toolbar, which stays on top
+ - [ ] split up markupEditor.js
+ - [ ] look how ender handles the extensability
+ perhaps (... ME.Mode = Mode;})(ME, jQuery) is an option
+ - [ ] spec closing of editors
+ - [ ] should work with external select
+ - [ ] handle multiple init
- [ ] spec with selenium
- [ ] spec press enter
- [ ] in list
- [ ] in heading
- [ ] spec press shift enter
- [ ] in list
+ - [ ] spec press entf
+ - [ ] between lists
+ - [ ] between blocks
+ - [ ] spec backspace
+ - [ ] between lists
+ - [ ] between blocks
- [ ] show window in different awesome tab
- [ ] use existing window (not supported in ruby bindings)
- [ ] fire native events (not supported in awesome, try in kde or windows)
- [ ] clean and parse pasted html
- [ ] handle blocktags within lists
+ - [X] textile: fix align with single caret
+ - [X] fix wysiwyg specs. probably an error in initFromHTMLDiv
+ - [X] provide support for external mode select
+ - [X] basics
+ - [X] hide select if it has just one option
+ - [X] handle and spec different edgecases
+ - [X] toHTML/toText
+ - [X] getText or similar
+ - [X] loadFromDiv in case mode has no toText/getText
+ - [X] Support haml in preview mode
+ - [X] basics
+ - [X] handle asynchronus update
+ - [X] fix spec
+ - [X] should block all other actions until mode change is finished
+ - [X] should block all other actions if a dialog is open
+ - [X] fix enter in lists
+ - [X] doesn't add #*
+ - [X] at the beginning of the line it should not add tags
+ - [X] list trace at the end of a line does not work
+ - [X] textileCompiler
+ - [X] "* item1":src should compile as a link
- [X] Decouple mode and editor
- [X] fix all specs
- [X] add link error: place cursor at the end of a word and click link -> add uri -> ok -> link is after word
View
@@ -47,3 +47,6 @@ def text_field(name, options = {})
# set :http_prefix, "file:///home/jonas/projects/markup_editor/build/"
set :http_prefix, "/markupEditor"
end
+
+require 'lib/markup'
+use Rack::Markup
View
@@ -1,4 +0,0 @@
-require 'rubygems'
-require 'middleman'
-
-run Middleman::Server
View
@@ -0,0 +1,53 @@
+require 'haml'
+require 'haml/html'
+
+module Rack
+ class Markup
+
+ def initialize(app, options={})
+ @app = app
+ end
+
+ def call(env)
+ if env["REQUEST_PATH"] == "/api/markup/to_html"
+ # [404,{'Content-Type' => 'text/plain'},'not found']
+ call_method('_to_html', env)
+ elsif env["REQUEST_PATH"] == "/api/markup/from_html"
+ call_method('_from_html', env)
+ elsif env["REQUEST_PATH"] == "/api/markup/get"
+ render_file(env)
+ else
+ @app.call(env)
+ end
+ end
+
+ protected
+
+ def render_file(env)
+ file = ::Rack::Request.new(env).params['file']
+ text = ::File.open(::File.join(Dir.pwd, 'source/textareas', file)).read
+ [200,{'Content-Type' => 'text/plain'}, text]
+ rescue => e
+ p e, e.message
+ [500,{'Content-Type' => 'text/plain'},'no valid markup type']
+ end
+
+ def call_method(method_part, env)
+ params = ::Rack::Request.new(env).params
+ return_string = self.send(params['type'] + method_part, params['content'])
+ [200,{'Content-Type' => 'text/plain'}, return_string]
+ rescue => e
+ p e, e.message, params['content']
+ [500,{'Content-Type' => 'text/plain'},'no valid markup type']
+ end
+
+ def haml_to_html(string)
+ Haml::Engine.new(string, :ugly => true).render
+ end
+
+ def haml_from_html(string)
+ Haml::HTML.new(string).render
+ end
+
+ end
+end
Oops, something went wrong.

0 comments on commit 624f31a

Please sign in to comment.