Rich text editor for a Rails project - ruby-on-rails

I am very, very new to Rails development. I have read the arguments against using Rich Text editors that are WYSIWYG. For the purpose of making a CMS for my portfolio site, I can understand RedCloth and implement it.
My question is what happens when there is a lengthy post to be written, how does RedCloth make my job faster? Is there a scenario where Rich Text editors would be preferable?
Pardon me if this sounds ignorant. I want to understand what the best approach is to my situation.
Thank you,
Rishi

just initiated a little pro/cons list of both alternatives, feel free to contribute
WYSIWIG editors
pros:
really easy to set up (check ckeditor and this little gem for instance)
easy to use for anyone able to use Word... to some point
lets you insert any html code / script you want
cons:
the Redcloth site gives sound reasons why you shouldn't use WYSIWYG editors ; among them :
often generates bad, redundant, semanticaly incorrect html code
often lets your users mess up with your site's look and feel by defining their own styles, stuffed in html style attributes
may confuse your users, beacuse they don't know what happens "under the hood", in html ("why can't i just place this picture where i want, in the middle of this page ?")
Textile, Markdown, etc.
pros:
easy to learn, easy to use
usually a good incentive on users to produce semantically correct, structured documents
easy to sanitize, unless you need the html not to be escaped
does not mess with your sites style, unless you allow the user to use advanced features of the format
raw content is readable and well-structured
slightly less storage space needed for raw content
cons:
your users have to learn it, and some don't love it (but WYSIWYG-style UIs do exist to help them ; just look at the good job StackOverflow did with theirs)
for advanced features you have to know the format well

It is a personal choice, you should use whatever you feel is comfortable, especially when you have just started.
WYSIWYG editors are some times not advisable for more advanced users and for making special features, this is because they distance you from the actual source code and force you to work within their frame.
These editors are convenient and quick for simpler work exactly because they give a frame to work in.
Since its not like a code framework or library, you can always make a switch when you are at a point when the WYSIWYG editor you are using is beginning to limit you and get in your way. (only you will know this)
Before then go right ahead!

Related

Any WYSIWYG editors that are free and look modern like Froala?

There are several WYSIWYG editors out there, such as TinyMCE, CKEditor, etc. However, IMHO these editors don't have a nice and modern appearance like Froala. Problem is that Froala costs, and it sucks because this is just an internal app that I plan on using long-term without anyone else even looking at it.
TinyMCE and CKEditor also seem to have some pretty terrible themes. I'm ultimately wanting to get something inside of my ruby on rails application.
Does anyone know of any modern looking WYSIWYG editors that actually look like they were developed in the last 10 years? I have a beautiful theme for my rails app and I just don't want to kill it with some old looking theme.
Not looking to get flamed and yes I've googled, but I came here because I really can't find what I'm looking for and hoping someone else can shed some light.
I really don't see a whole lot of difference between Freola and TinyMCE, or the HTML editor this website uses.
Can you list specific features you're looking for that the items in the list don't do? I know you mentioned theming, but there are literally hundreds of themes for TinyMCE and you can roll your own without much effort at all.
The best WYSIWYG I've come across is Redactor. It costs $500 for a developer license:
There is a gem called redactor-rails which provides it for free (I don't know how).
It is the most efficient & good-looking I've come across.
If you want functionality with the likes of Paperclip etc, we've used CKEditor extensively. Yes, it looks crappy but I believe there are ways to style it:
I can give you the code we use if you want to try it. Once you get rid of 99% of the non-essential elements, it starts to look good.

Is Rails much better for interactive website compare to Django?

Just got a new website project for my company internal use. The whole website isn't that complicating but requires quite a lot of real time interaction. Basically, it's an interactive time line table where we can freely drag and drop each elements to move and resize them.
At first I wanted to use this opportunity to learn Python+Django (I'm given a huge amount of time) but then I read around and a lot of people mentioned Rails is better for creating rich interactive website.
So, for a website with a lot of drag & drop interaction like this, is Rails really the better choice? Is Rails built-in ajax that much easier to work with compare to Django+jQuery? How flexible and customizable is Rails' built-in ajax? I want to learn RoR just as much as Python by thee way.
I don't think AJAX functionality will define which framework you find yourself preferring.
I can't answer most of your question relating to ajax, but still think this post could be useful for you: it's highlighting a huge difference between ROR and django -- mainly RoR uses magic, django doesn't.
I prefer django for exactly that. Others may prefer RoR for the same reason I don't.
What's wrong with "magic"?
Rails' developers are of the opinion
that this sort of "magic" is a good
thing because it makes it easier to
quickly get something working, and
doesn't bore you with lots of details
unless you want to reach in and start
overriding things.
Django's developers are of the opinion
that this sort of "magic" is a bad
thing because doesn't really save all
that much time (a few import
statements isn't a big deal in the
grand scheme of things), and has the
effect of hiding what's really going
on, making it harder to work out how
to override stuff, or harder to debug
if something goes wrong.
Both of these are, of course, valid
stances to take, and generally it
seems that people just naturally
gravitate to one or the other; those
who like the "magic" congregate around
Rails or frameworks which try to
emulate it, those who don't congregate
around Django or frameworks which try
to emulate it (and, in a broader
sense, these stances are somewhat
stereotypical of Ruby and Python
developers; Ruby developers tend to
like doing things one way, Python
developers tend to like doing things
another way).
So I think one will click for you regardless of out of the box ajax support.
Speaking as someone who mostly works on Rails, I would say take a day with each framework, follow a "getting started" screencast or tutorial, or pick up a book. ( For rails, I recommend Beginning Rails 3 ). Then, keep going with whichever one you feel more comfortable with.
One amazing resource rails has is Railscasts. Railscasts almost single-handedly converted me from PHP to ROR. I don't know if Django has a similar volume of quality screencasts available or not.
All frameworks are pretty heavily focused on the server-side of the equation. Now, Rails has a lot of things that help make writing views (your drag and drop stuff) nice, such as HAML (a fantastic template language)... and while I don't know enough to post links I'm sure Django has similar helpers. It's worth noting that both Django and Rails can use jQuery or any other javascript framework.
But, in the end, just by the nature of the web as stateless, there's going to be a degree of independence between your client-side templates and javascript, and what's serving that from the server side.
The real question you should probably be focused on is: Do you want to become a jQuery ninja, or do you want to scale up a notch and focus on Javascript itself, perhaps using tool suites like MooTools or Prototype. Your drag and drop stuff is client-side, so that's where your toughest decisions will have to be made.
Good luck!
I used to worry about things like this and would try new frameworks all the time because people would say it was a big improvement over the last one I was using until I realised I wasn't doing anything. Now I just pick one and stick with it. The fact that I know it much better than any others means I am more productive, even though the other frameworks probably include nice little tricks and shortcuts, and because I know it better I can debug problems faster.
Basically what I am trying to say is that just about every popular web framework can do everything that you want it to. Some are better than others but what really matters is that you become an expert in at least one of them. Being able to dabble in lots is not helpful, you really need to know one inside and out. Committing some code to the project helps this process.
Mainly depends on which programming language you prefer to work and most comfortable with. Some prefer the flexible syntax of Ruby others like the cleanliness of Python. Also need to take into consideration the production environment (aka what OS is it going to be hosted on).
Django does not do interactive web applications, it is agnostic to the whole "frontend" part, this is done in Javascript with little to no support from Django (except for transferring data from AJAX calls).
So if you want to use Django for this, you will have not only to learn Python but also to learn loads of Javascript.
I like this solution as hand-written Javascript feels a lot clearer than any of these generating tools to me, plus there are plenty of libraries that make writing advanced Javascript GUIs a breeze these days, check out Jquery UI or ExtJS.
From there, the server side will only be AJAX calls that (de)serialize data in JSON, nothing else.
Both Rails and Django are good. Try them both out and see which you like better.

Is it possible to make an advanced rich text editor for web that would allow copy-pasting of pictures?

The long story:
The larger problem is that I'm trying to convince people from switching away from Outlook to a more sane bugtracker, preferably web-based that we could also use as a public bugtracker. But the current argument against it is that the Outlook editor (which is really Word with all the bells and whistles) allows easy inserting of pictures, advanced formatting, etc. So I wonder if I'm at a dead end, or there is hope yet.
The problem in a nutshell:
I want to know - is it possible to create a website component that would be a REALLY powerful rich text editor. A must-have feature is to insert pictures into the editor straight from the clipboard. Better yet - does something like that exist?
There is no limit on the allowed technology. It can be flash based, java based, work only in IE, etc.
Is it possible: Yes, but not with JavaScript alone. You will need a plugin or client software to accomplish this.
As far as the technology allowed, this really depends on how you want to implement it. You could use the JRE and write everything in Java. If you're more focused on IE you might consider VB or C#.

WYSIWYG vs WYSIWYM

Which one is better and ideal in a web based application?
Edit:
Actually I am developing a community site. So the level of users may vary. Heard about XSS security issues with WYSIWYG editors. Also I am not familiar with WYSIWYM editors and its features. As far as I know the features in WYSIWYM editor is less compared to the other one. I figured one named as "WMD: The Wysiwym Markdown Editor". Its quite easy to use.
So security and ease of usability should be there. In such a situation which editor will be better.
If your users can handle WYSIWYM, I'd go with that.
I'm considering your system will be visual, that is, if you say something is a title it'll look like a title (otherwise the WYS part wouldn't apply). If the user has to manually type markup, then only the most savvy or technical users will be able to handle it.
What I've seen with most users is that they have trouble giving meaning to what they want in a document. They don't think "this is a title", they think "this should be bigger and bold". People that cannot think "this is a title" can't handle a WYSIWYM or they'll find it hard.
Who is going to be your user base? If it's people writing academic papers I'd go with WYSIWYM because they'll have no trouble handling it. If it's for house wives writing recipes, they may not be able to handle it or they'll find it so hard that they'll decide it's not worth the effort.
For me the ideal is WYSIWYM, but do it only if you think your target users will be able to handle it, otherwise you'll have to go with WYSIWYG.
I personally love the WYSIWYM mechanism. I use it for my own work as much as possible. I like it so much that I try to get others to try it too.
Boy, that goes over like a fart in a space-suit.
My cynical self assumes this to mean that most folks are ruined by tools like Word. Everyone knows to make a meaningful document. They also know what a meaningful document looks like. If it doesn't look like that, the tool is wrong! What's actually happening is these document producers don't actually know what they mean, and are used to hiding that fact with pretty borders and adjusting tab-stops.
What I really think is happening, though, is that these folks who are resistant to WYSIWYM are that way because it's a harder way of thinking about something they already invested in learning. This is a level of abstraction above WYSIWYG, though not quite as far removed as composing documents in markup like LaTeX or HTML. And since they can already create any sort of document in a tool that requires no abstraction, it's just a hard sell.
That being said, I think you should force WYSIWYM on your users if that is feasable. There are some good reasons for this
All of the benefits that naturally come with two stage composition. Formatting is not decidable until the document is composed, so any time spent before the document is finished on formatting is time wasted. Get it composed quickly.
The document is marked up with semantic information. This can be used in searches, or for other tasks that strictly visual markup cannot. This is especially useful for accessibility.
By depriving your users of arbitrary formatting decisions, all of your documents will follow company branding. Everything will be in a standard font and color. All text will use the same spacing and height. It will look to readers like it came from a single entity.
Check this
http://www.wymeditor.org/
Could you be a bit more specific? What kind of web application? How many users? Who will the users be?
In general though I've had quite of bit of experience implementing WYSIWYG editors for various CMSs and found them to be quite problematic because clients often like to go wild with formatting their content repeatedly over and over again and often end up having the editor generate HTML of poor quality. This causes all sorts of layout issues or simply pages that look really messy because everyone likes to fancy themselves as graphic designers.
If done properly WYSIWYG can work very well, but it is more work to really get it right, especially when taking into consideration CSS. Most of the good editors are nicely configurable and allow to specify just how much control to give the client over visual formatting.
As for the quality of the code they generate, tools such as FCKEditor and TinyMCE are very mature and do a good job of editing out the irrelevant crud in the source code, but be prepared to provide support for clients using a WYSIWYG when their content doesn't look the way they would like it to.
Since WYSIWYM editors are much like WYSIWYG with structural formatting instead of visual formatting, philosophically I think they are better and less problem prone. So if the client doesn't have a need to visually format the content I think WYSIWYM is bound to cause less headaches down the road.
The editor used here in Stack Overflow is a good example of restrained WYSIWYG. You can format the content visually but only to a certain extent.
If your users a tech savy and understand how the basics of markup go and you think they will feel more empowered using WYSIWYM, then use that. If your application is going to be used to people who have little technical knowledge, use WYSIWYG.
Unless you are doing a tool for print layout (i.e. Indesign or maybe a mailing list printing tool) you are probably better to stick with WYSIWYM.
It is likely to be easier to implement
Web browsers are highly configurable and you may not have fine grained control over items like font size.
The structure is explicit so rendering to different media is comparatively easy.
It avoids the temptation on the part of users to over-design the document or whatever they are entering.
Document structure facilitates indexing, table-of-contents generation and cross-referencing where this is relevant. Compare (for example) maintianing a large index in Word with doing in LaTeX or Framemaker.
Anecdotal experience from LaTeX users (in particular) suggests that organising a document by structure is likely to produce a better document.
From my experience with MYSIWYM, I was very seduced by the idea and the looks, but I was then deceived to know that the editor didn't give me a simple and efficient way to restrict the user, for example the user can insert images inside paragraphs... and I don't want that... I want more control over what the user can do.

Latex styles - what do you use and where to find them

What Latex styles do you use and where do you find them?
The reason I'm asking this is that it seems that some 99.9999% of all styles on the internet are copies of each other and of a physics exam paper
However, when you try to find a style for a paper like this one... Good luck, you are never going to find it.
Creating your own style is often not really an option, because it requires you to dig quite deep into the very advanced features of TeX/LaTeX and fighting your way against possible incompatibilities with document classes/packages/whatnot.
LaTeX was originally designed as a reasonably flexible system on which a few standard classes were distributed — that were themselves rather inflexible.
In the current state of affairs, if you want a custom layout, you need to write a few amount of supporting code yourself. How else would it happen? It's not like HTML+CSS gives you templates to work with; you need to implement the design yourself.
Creating your own style is often not really an option
Ah, well, not unless you know how to program in LaTeX!
Seriously, it all depends on knowing where to start and what to build on top of. That catalogue you give as an example would, in my opinion, be reasonably easy to do in LaTeX; it's just a bunch of boxes.
You could write something like
\newcommand\catalogueEntry[4]{%
\parbox[t]{0.23\linewidth}{\textbf{#1}}%
\hfill
\parbox[t]{0.23\linewidth}{\includegraphics{#2}}%
\hfill
\parbox[t]{0.23\linewidth}{\textbf{Characteristics}\\ #3}%
\hfill
\parbox[t]{0.23\linewidth}{\textbf{Application}\\ #4}
}
and use it as so
\catalogueEntry{Spotlights}{spotlight.jpg}
{Eclipse spotlights are...}
{Narrow to medium...}
This is just a basic illustration of what could be knocked up quickly — much more sophistication could be used to turn this into a more flexible system.
I see LaTeX as an extensible markup system. If you separate your markup from its presentation on the page, it's not too hard to get your information represented in whichever form you wish. But getting started is a little tricky, I have to admit; the learning curve for LaTeX programming can be rather steep.
Memoir is a more flexible document class than the default ones, and its manual is excellent.
Well I think CTAN is the best resource for LaTeX and TeX-related stuff. Also lots of scientific organizations provide their own styles, it makes sense to try tracing who was the author/publisher of the paper you like and check their websites.

Resources