Project

General

Profile

Textile Wysiwyg editor

Added by Peter Lawrence over 13 years ago

I'm playing with the idea of developing a textile wysiwyg editor plugin for redmine. The current wysiwyg editor has it use but you need to convert all your existing pages to html and you loose the macro features of a wiki.

Since textile is the wiki format which is quite close to html, I'm using a system which converts the wiki textile page to html for use in Tinymce. Then once editing is complete it is converted back to textile. For the conversion process I'm using a modified versions of html2textile and RedCloth to convert to html.

My current prototype system displays the normal redmine editor however the user can switch to Tinymce via a radio button when editing a wiki page. It seems to work reasonably well except for a few formatting problems and some embedded images are displayed as "link not found" while in the wysiwyg editor.

My question is:-
I'm using a new Conversion controller which does the conversion between the two formats for the wiki editor page. What I was wondering is do I need to set any authorization "before" functions on my methods and/or do some initial string escaping to avoid string inserting attacks. I'm not sure this is necessary since my routines don't run any SQL commands just string manipulation routines.

The routes file is defined as..

#custom routes for this plugin
ActionController::Routing::Routes.draw do |map|
  map.with_options :controller => 'convert' do |convert_routes|
    convert_routes.connect "convert/wysiwygtohtmltotextile", :conditions => { :method => [:post, :put] }, :action 

=> 'wysiwygtohtmltotextile'
    convert_routes.connect "convert/wysiwygtotextiletohtml", :conditions => { :method => [:post, :put] }, :action 

=> 'wysiwygtotextiletohtml'
  end
end

and for example the code to convert from textile to html is...

def wysiwygtotextiletohtml
    @text=params[:content][:text]
    @text=HTMLFormatter.new(@text).to_html
    File.open("after_tohtml.txt", 'w') {|g| 
        g.write(@text)
    }
    render :partial => 'convert'
  end


Replies (77)

RE: Textile Wysiwyg editor - Added by Peter Lawrence over 12 years ago

Yes the source code can be found here..
[[http://github.com/PeterLawrence/redmine_wysiwyg_textile]]
However, Stefan Langemaier has been doing some updates, which can be found here..
[[https://github.com/stefan-langenmaier/redmine_wysiwyg_textile]]

RE: Textile Wysiwyg editor - Added by Alexey Kalmykov over 12 years ago

Good day, everyone,

I finally commited my changes on github: https://github.com/kalmykov/redmine_wysiwyg_textile

I never used git before(I prefer svn, but I don't have svn server :) ), so I've commited files but didn't changed readme.

Changes:
1. Deleted old html2textile converter. Instead of it is used undress gem(I just unzipped gem files into lib directory). But this gem requires hpricot gem. So, don't forget to install it.
2. Many changes in convert controller : added support for all redmine textile tags(if I didn't forget about some :) ).
3. Added support for choosing default editor in user settings(my account page). I've made migration, so don't forget to make migration :)
4. My colleague, Dmitry Belokurov, added print button in tinyMCE.
5. All tags, which you can't add or edit in tinyMCE(such as revision links, wiki links, etc.) are uneditable.

If you'll find any bugs, please write me.

Sorry for my poor english.

RE: Textile Wysiwyg editor - Added by Peter Lawrence over 12 years ago

Alexey, Sounds like some good work. Did you take a look at the branch by Stefan? Since he extended this plugin to almost all "textilizable" fields.
My only other suggestion is that you add your name to the release notes and code, also maybe update the version number. Anyway, I think everyone will appreciate this new version.

RE: Textile Wysiwyg editor - Added by Terence Mill over 12 years ago

This really should be merged soon..
At least tinymce is newer on stefans hub.

What will happen to macros brought in by other plugins, e.g wiki extension , contacts or Polls Plugin Macros ?

RE: Textile Wysiwyg editor - Added by Etienne Massip over 12 years ago

You should consider adding it to the plugin directory.

RE: Textile Wysiwyg editor - Added by Alexey Kalmykov over 12 years ago

Good day,

I've changed version number, added copyrights, changed readme. So, I think, everybody can download it :)

Terence, all macroses and custom tags converts as they are. I mean that they don't disappear, but they aren't shown as they should. It is not easy to develop them, but they are useless in wysiwyg.

I didn't merged new tinymce because I haven't found any bugs in it. It would be good, if anybody would merge a newer version.

RE: Textile Wysiwyg editor - Added by Alexey Kalmykov over 12 years ago

Also, I saw that Stefan made some changes in conversion. I didn't tested them, but I saw that he extended the original html2textile converter. In the beginning I was also trying to make it better, but this converter have problems in recursive descent. I think this problems are in sgmlparser, and I hadn't any desire in extending it. I think undress gem is really better, and it is very simple, and easy extending.

RE: Textile Wysiwyg editor - Added by Tadas A about 12 years ago

Hello,
I am using Textile Wysiwyg editor on redmine 1.3.1 and it works, but my redmine dont understand some Textile Wysiwyg editor tags like subscript and superscript ... how can i make that my textile understand what i write in Textile Wysiwyg editor.

RE: Textile Wysiwyg editor - Added by Robert Gröber almost 12 years ago

Installed on redmine 1.3.0. But it seems only to convert to HTML instead of textile! :(
Got last tar.gz package from github.

RE: Textile Wysiwyg editor - Added by Nikolay Gniteev almost 12 years ago

Aloha! I've made new WYSIWYG plugin using core of your plugin (redmine_wysiwyg_textile).
Please take a look at redmine_aloha_wiki

I had split core of your plugin (HTML to textile conversion) into seperate plugin. Also there were some fixes (as things weren't that fine fom the begining running on Redmine v1.4). My goal was to gain less changes while switching between textile-WYSIWYG-textile.

P.S.: if you think it's no good to use your plugin this way - just let me know.

RE: Textile Wysiwyg editor - Added by Peter Lawrence almost 12 years ago

Nikolay, sounds good.
Please feel free to change the code as you see fit. It's good to know that users are developing their own version of this plugin.

RE: Textile Wysiwyg editor - rails 3 - Added by Pål de Vibe almost 12 years ago

Guys,

I just started on a port for rails 3. It is hacky, but almost running. Forked Stefan's version, but I just wrote Godhart to know how the aloha editor is going. Nikolay, what is the state of your plugin?

RE: Textile Wysiwyg editor - Added by Keats . over 11 years ago

Pål de Vibe wrote:

Url of the fork: https://github.com/paalvibe/redmine_wysiwyg_textile

hi,
saving doesn't work because we get raw html when we view the wiki
http://imm.io/tmLE

RE: Textile Wysiwyg editor - Added by Pål de Vibe over 11 years ago

Yes, it isn't working correctly yet.

RE: Textile Wysiwyg editor - Added by Timur Poperecinii over 11 years ago

Keats . wrote:

Pål de Vibe wrote:

Url of the fork: https://github.com/paalvibe/redmine_wysiwyg_textile

hi,
saving doesn't work because we get raw html when we view the wiki
http://imm.io/tmLE

I have the same effect but only using Peter's version of the plugin. Is there some resolution to this issue?

RE: Textile Wysiwyg editor - Added by Pål de Vibe over 11 years ago

Timur,

I haven't had time to look at this yet.

Pål

RE: Textile Wysiwyg editor - Added by Anthony HERBÉ over 11 years ago

Hi,

It seems that with 2.x releases of Redmine, there is a lot of works to...

The plugin won't be load since "RedmineWysiwygTextile::*" doesn't found (ex. : uninitialized constant RedmineWysiwygTextile::Helper).

Have you any clue to fix it or patch it qeekly ?

Thanks for your great job and time spent.

RE: Textile Wysiwyg editor - Added by Anthony HERBÉ over 11 years ago

The Fork of Stefan Langenmaier seems to be more up to date since somes commit add compatibilities with Redmine 2.0.x versions (with some others bugs).
Bug reported before "RedmineWysiwygTextile::* doesn't found (ex. : uninitialized constant RedmineWysiwygTextile::Helper)" has gone.

Now, in 2.1.x versions of Redmine, no errors are present in log but when "textile wysiwyg" is activated in configuration, radio button "textile/textile wysiwyg" appear but toolbar of text format disappear, so the plugin still doesn't work.

If someone have any clues.

RE: Textile Wysiwyg editor - Added by Anthony HERBÉ over 11 years ago

Somes errors in webbrowser :

Agent : Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)
Date : Fri, 2 Nov 2012 10:08:51 UTC

Message : 'this.textarea.parentNode' have Null value or not an object.
Line : 40
Car. : 2
Code : 0
URI : http://localhost:3000/javascripts/jstoolbar/jstoolbar.js?1349001952

Message : 'Ajax' is undefined.
Line : 294
Car. : 19
Code : 0
URI : http://localhost:3000/issues/308

Same problem with Firefox 17.0 on Windows.

RE: Textile Wysiwyg editor - Added by Ricardo García Fernández over 11 years ago

Hi,

I've traced the error (with firebug and firefox 14.0.1) with Ajax.Request note defined in:

ReferenceError: Ajax is not defined
[Parar en este error]     

...alse, evalScripts:false, method:'post', onSuccess:function(request){UpdateFile(r...

Which library is using Ajax.Request ? I has to be included in helper.rb file ?

Environment

  • Ubuntu 12.04
  • Redmine 2.x
  • Ruby 1.8.7
  • Rails 3.2.8

Solution

Hi! I resolved Ajax is not defined error:

Downloading prototype.js into /redmine_wysiwyg_textile/assets/javascripts/prototype directory:

Adding to helper.rb file prototype.js library (inside wikitoolbar_for_wysiwyg method):

  • javascript_include_tag('prototype.js', :plugin => 'redmine_wysiwyg_textile') +

Makes Ajax.Request call.

RE: Textile Wysiwyg editor - Added by Elissa Garber about 11 years ago

Anthony HERBÉ wrote:

The Fork of Stefan Langenmaier seems to be more up to date since somes commit add compatibilities with Redmine 2.0.x versions (with some others bugs).
Bug reported before "RedmineWysiwygTextile::* doesn't found (ex. : uninitialized constant RedmineWysiwygTextile::Helper)" has gone.

Now, in 2.1.x versions of Redmine, no errors are present in log but when "textile wysiwyg" is activated in configuration, radio button "textile/textile wysiwyg" appear but toolbar of text format disappear, so the plugin still doesn't work.

If someone have any clues.

Same here. Tested on a clean environment with no other plugins, Redmine 2.1.2 & Ubuntu 12.10.
No log indication. Workaround above for Ajax is not defined error did not seem to help.

If anyone has an idea...

RE: Textile Wysiwyg editor - Added by Anonymous about 11 years ago

Hi i just downloaded the latest version of

https://github.com/ricardogarfe/redmine_wysiwyg_textile

and i have the following problem:


Started POST "/redmine/convert/wysiwygtohtmltotextile" for 127.0.0.1 at 2013-01-29 11:17:55 +0100

ActionController::RoutingError (No route matches [POST] "/convert/wysiwygtohtmltotextile"):
  actionpack (3.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (3.2.11) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.11) lib/rails/rack/logger.rb:32:in `call_app'
  railties (3.2.11) lib/rails/rack/logger.rb:18:in `call'
  actionpack (3.2.11) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.4) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.4) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.11) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.4) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.11) lib/action_dispatch/middleware/static.rb:62:in `call'
  rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
  rack-cache (1.2) lib/rack/cache/context.rb:143:in `pass'
  rack-cache (1.2) lib/rack/cache/context.rb:155:in `invalidate'
  rack-cache (1.2) lib/rack/cache/context.rb:71:in `call!'
  rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
  railties (3.2.11) lib/rails/engine.rb:479:in `call'
  railties (3.2.11) lib/rails/application.rb:223:in `call'
  railties (3.2.11) lib/rails/railtie/configurable.rb:30:in `method_missing'
  rack (1.4.4) lib/rack/urlmap.rb:64:in `block in call'
  rack (1.4.4) lib/rack/urlmap.rb:49:in `each'
  rack (1.4.4) lib/rack/urlmap.rb:49:in `call'
  thin (1.5.0) lib/thin/connection.rb:81:in `block in pre_process'
  thin (1.5.0) lib/thin/connection.rb:79:in `catch'
  thin (1.5.0) lib/thin/connection.rb:79:in `pre_process'
  thin (1.5.0) lib/thin/connection.rb:54:in `process'
  thin (1.5.0) lib/thin/connection.rb:39:in `receive_data'
  eventmachine-1.0.0-x86 (mingw32) lib/eventmachine.rb:187:in `run_machine'
  eventmachine-1.0.0-x86 (mingw32) lib/eventmachine.rb:187:in `run'
  thin (1.5.0) lib/thin/backends/base.rb:63:in `start'
  thin (1.5.0) lib/thin/server.rb:159:in `start'
  thin (1.5.0) lib/thin/controllers/controller.rb:86:in `start'
  thin (1.5.0) lib/thin/runner.rb:187:in `run_command'
  thin (1.5.0) lib/thin/runner.rb:152:in `run!'
  thin (1.5.0) bin/thin:6:in `<top (required)>'
  C:/Ruby193/bin/thin:19:in `load'
  C:/Ruby193/bin/thin:19:in `<main>'

So the converting does not work. The editor itself works perfekt, but as i said no converting.
What do i do wrong?

Thanks for your help,

clemens

PS: i work with Redmine 2.2.2 on windows with a thin server.

RE: Textile Wysiwyg editor - Added by Ricardo García Fernández about 11 years ago

Hi Clemens!

I've reset master branch to 'stable' version. You can pull again master branch.

This is a known issue, html to textile doesn't work. I'm working on it in convert-html-to-textile branch.

So, the main problem is the conversion between html to textile doesn't work in GUI.
I'm doing tests in this branch and trying to solve it, if you want help with the test, is much appreciated.

Because I have no idea how to test a ruby controller. Parsing parameters using unit/test.

And the problem with URL could be in routes.rb file.

Thanks!
Ricardo.

RE: Textile Wysiwyg editor - Added by Pierro M. about 11 years ago

Hi and thanks a lot,
With all these forks (ricardo, stefan, kalmykov), which one is the most up-to-date and working in redmine 2.1.x ?
Ricardo does your master branch works now in html->textile ?

(51-75/77)