textarea that was using plain text with option of markdown or textile filter now needs images - ruby-on-rails

My clients can enter text into textarea and have the option to use the markdown or textile filters for each textarea.
With some models (articles, newsletter, etc) they can upload images to associate with the model, which are displayed in a column next to the text of the text.
This worked fine for a while, but they have now told me that the want the ability to put the images INSIDE the text a specific positions.
What is the best way to go about this? I suppose I may have to use a wysiwyg for this, but would rather not. And how would this work for images which are not yet on the server, etc?

There are different directions you could go to:
Follow the path of Confluence, which released in their new version 4.0 a rewritten WYSIWYG editor, that stores as source XHTML, not any more wiki markup.
Leads to an update of all pages when migrating.
Was pretty difficult to implement. I do not know if they use any more the TinyMCE editor of previous versions.
Follow the format of markdown how to include images in your source format. So by typing: This is my text. !image.png! The inline image shows ..., you will have a format that is understandable.
You have to expand the interpretation, so that the !<filename>! will be mapped that is stored locally anyway.
You have to add clear-up dialogs for the images that are yet not known, so doing bulk uploads ...
You may provide a drag area on your view, that then shows the filename and gives examples how to include that inside the text area.
Go for something in between, by allowing users to drag images inside the editor. There are plugins written in Javascript that allow you to do that, e.g. UI Draggable for jquery
I have no idea how to integrate that image inside the text editor. Overlay?
So the second one is the easiest, and the user knows how to do it. If they only decide that this is the solution they want to have :-)

I think I'm going to use a combination of #2 above, and the Liquid templating engine.

Related

How To Create a Standalone Swift SDK

I would like to create a SDK to use without iOS or Xcode.
Let me explain. I would like to use Swift language to create a framework with which to develop front-end. In few words with this framework I would like create html pages for web and substitute HTML, CSS and javascript with swift. The idea get from what Apple does with iOS. If you look how is made a xib or storyboard you can see xml file. I would like to do the same thing or take the idea and applicate for the web.
To do this I need to create an SDK that is not connected to iOS but that I can use in any IDE like VSCode or similar or also in a my own IDE created by me.
An other thing that could help you to understand what I mean is Javascript. In javascript there is a command createElement that let you to create an element, adding class, attribute and, yes, style. But create UI in this way, you understand well that is very hard. So, I Would like create a framework in iOS style, to create frontend in simpler and easier way.
I would like create create this framework (if it's possible) in Xcode and I don't want have any interference by iOS.
So, have you any suggests about how to start?
thank you
XIB layout is constraint-based, which means you describe your view hierarchy and constraints, and autolayout system does the layout for you every time according to constraints you've provided. Technically, inside it converts constraints to a system of linear equations and solves it in run-time, thus calculating frames for every UIView. And .xib file is just an XML with all the views, their properties and constraints. (that's a bit simplified, but you've got the idea)
HTML layout is totally different: HTML is a declarative way to describe elements on a page, i.e you describe every element with tags, and every tag (or its parent, or CSS file) already contains all necessary information about its positioning and appearance, so browser just parses and renders a page accordingly.
Theoretically, you could've reinvented a web browser: write your HTML parser, then write UI to somehow render it, and add feature to alter HTML tags by moving the page elements with mouse. But that would've taken a lot of time and effort :)
There are many website constructors on WWW, which allow you to build simple sites only with drag-and-drop (no coding needed). Also, you can inspect element in your browser, and then change some attributes of some element right in the debug window, and see changes in realtime.
P.S Im not a web/frontend developer, but I suppose that IDE's popular among frontenders already have some features or plugins that allow them to render HTML/CSS code and see changes in realtime, just like browser's debug menu.

Explanation of (undocumented?) XUL dialog attribute buttoniconaccept (and similar)

I am pulling this attribute directly from Mozilla Firefox's about.xul file which shows the About dialog box for an add-on. It is a relatively simple XUL dialog with no inputs, locale data pulled from DTD entities, string bundle properties and JavaScript.
<!-- omni.ja!/chrome/toolkit/content/mozapps/extensions/about.xul -->
<!-- chrome://mozapps/content/extensions/about.xul -->
<dialog id="genericAbout"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="init();"
buttons="accept"
buttoniconaccept="close"
onaccept="close();">
MDN: Dialogs and Prompts and MDN: dialog both mention something about attributes that are formed by concatenating (pseudo-regexp):
"button" + "(label|accesskey|oncommand)" + "(accept|cancel|disclosure|help|extra[12])"
For example: buttonlabelaccept.
However, I could not find any documentation about the use of icon. The word icon does not even show up on either of the above-mentioned pages! What does it do? What is the correct way to use it?
I'm trying to make my add-on about page more modular, without loading internal files from omni.ja(r), which pulls in a LOT of unnecessary code with it. I am developing a very streamlined version, that will style itself appropriately depending on calling context.
I want it to look like Firefox's official About < addon.name > dialog if called from about:addons context-menu, or from my add-on's status-bar context-menu. I want a slightly different appearance if viewed from within the Options dialog as an iframe inside a XUL. I already have that structure set up. Just tweaking the little quirks.
This is not critical design or feature wise, and indeed the entire API will go away in a few months, but it just bothers me to not really understand this, so I want to figure it out before I let it go an move on to more important things. But I will if I absolutely can't find an answer. But it's one of those stupid little things that will just bother me a disproportionate amount. =D
If you can point me to documentation I may have missed, or even specific Mozilla source code, and a few examples, or a more complete explanation and typical use-cases, that would be great.
If you check the "blame" for about.xul, you'll see that the line was added to fix bug 422763. Judging from the screenshot in the bug, GNOME (Linux) has (had?) a convention of putting icons on dialog buttons, and this attribute allows overriding the default icon (inferred from the button type).
If you search for buttonicon, you'll find the code that handles this attribute in toolkit/content/widgets/dialog.xml.

Accept pasted image in Rails

I'd like my users to be able to upload an image by pasting it into a form.
Is this possible somehow with Rails?
I'd like to do this safely and limit to a single picture upload, not a completely open textarea.
UPDATE:
I'm looking for something like http://pasteboard.co/ that I can add into a form in a Rails app.
Also, with a paperclip hook like https://github.com/galetahub/ckeditor would be nice
Although I don't have a specific answer (copy & paste), I do have an answer regarding how to implement the uploading within the DOM:
JQuery
If you use something like jquery-file-upload, you'll be able to incorporate a GUI-based upload process to Rails
I think your question can be answered by taking this technology & applying to the specific element where you'd like to "copy & paste" the image
You can drag & drop images from your system into the example above. This is very similar to the copy & paste functionality you're seeking. I would personally look at this technology, and then apply it to the copy & paste procedure
WYSIWYG
You've referenced GMail as a great example of this -- but you have to remember they're allowing you to paste into a WYSIWYG editor
This is very important, as the upload image element will be handled through the WYSIWYG. You may be able to use this resource to help:
Wysiwyg with image copy/paste

iOS // show html -> rich text

What is the best way to show html -> rich text in iOS?
The problem is that some images from this text should be available offline, so I can't use a simple UIWebView.
Ideally I want to show just html with an ability to replace some special tags with other controls (UIImageView etc). I don't need to download this images from html. Both images and html will be downloaded with issues. Just need to manage the layout.
Core Text is not suitable, because to use it I'll need to parse this html manually. It should be a simpler way.
This has to be supported by iOS 6, so I can't use anything new from iOS 7.
I've seen this question. Doesn't look like this OmniGroup framework will work for me.
RTLabel doesn't support everything, what I want to have.
DTCoreText looks good, but it's not free (don't want to show their license text).
Maybe it's another cool fremework, which I didn't find yet?
Have tryed
https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString%2BHTML.h
This will simply give string out of html. It might not be exactly what you are looking for but hope this will solve part of your problem.
But this will not solve your offline image viewing.
For image
https://github.com/rs/SDWebImage
Will do a async download and cache image.

RTF editor

I have a templates written in RTF(with some tags which are replaced by data from DB in app), but when I edit them in MS Word, Word put some invisible tags to the templates, which destruct my tags(I must open template in Notepad and edit code).
Do you know some editor for RTF, which strict follows RTF specification?
Thanks
On Windows, the included app Wordpad is pretty decent in my opinion.
The RTF spec allows an RTF editor such as Word or a third party control to sprinkle the tags in-between the RTF text, provided that the actually RTF display is maintained. For this reason, there is no way to guarantee that your original template text will not be disturbed. For this reason, I recommend using an RTF editor API to do any search/replacement within your template. The RTF editor knows to put aside the RTF tags and access the original text as intended.
OK, I know that google find bunch of editors, but I don`t have time to try each of them to find out best one.
so I search for advice which is good, not which is avialable
EDIT: I found and for weeks use this solution
TE EDIT
and is very good, I recommend it.

Resources