I'd like to serve a dynamically generated KML file using ruby on rails. I made some research and I found kamel which looks great. The problem is that kame depends on ruby_kml gem which doesn't seem to be available anymore.
$ gem install kamel
ERROR: While executing gem ... (Gem::DependencyError)
Unable to resolve dependencies: kamel requires ruby_kml (~> 0.1.4)
Searching 'kml' on rubygems.org was unsuccessful.
So does someone know any alternative to achieve KML generation in ruby on rails?
KML is just another XML, you can easily make your own "writer" which parses recursively and formats whatever input is passed in as a parameter and generates a string that looks like valid KML/XML.
Recommended reading for the options and the XML layout:
https://developers.google.com/kml/documentation/kmlreference
Related
I am trying to use the :markdown filter with haml-rails on Rails 5.0.2.
When I first tried to use Markdown in a HAML file, it said it needed pandoc-ruby as a dependency, so I added that to my Gemfile. However, now when I try to use :markdown inside my file, I am getting the following error:
You don’t need Pandoc here, that’s just the first markdown processor Tilt tries to use and reports if it can’t find any others. You do need some markdown processor though.
Your simplest fix would probably be to remove pandoc-ruby from your Gemfile and add a Ruby markdown processor (e.g. kramdown).
If you need more control over which processor Haml uses (e.g. if you want to use kramdown for Haml filters but have RedCarpet in your app for something else), try something like this in an initializer:
require 'tilt/kramdown'
module Haml::Filters
remove_filter("Markdown")
register_tilt_filter "Markdown", :template_class => Tilt::KramdownTemplate
end
If you do want to use Pandoc for rendering markdown then you need to make sure it’s installed, see Chris’ answer.
From its README:
PandocRuby is a wrapper for Pandoc, a Haskell library with command line tools for converting one markup format to another.
It requires Pandoc to be installed separately (emphasis added):
First, make sure to install Pandoc.
Next, add PandocRuby to your Gemfile
gem 'pandoc-ruby'
I am trying to automatically extract strings from ruby views .erb files to config/lang/ files for example en.yml
Is there some updated alternative to this?
http://zigzag.github.io/2009/12/17/get-your-local-rails-application-ready-for-i18n.html
It is supposed to be a gem tool that will extract strings if used like this:
ready_for_i18n <you view path> <target path>
There is a number of gems that do this. One list of such gems is maintained on the i18n-tasks wiki:
Slimkeyfy extracts plain strings from Slim views and Rails Controllers.
haml-i18n-extractor
automates string extraction from HAML.
i15r for ERB and Haml.
i18n-html_extractor another extractor for ERB with an interactive mode.
Try i18n-tasks gem
$ i18n-tasks add-missing
I have one Rails application and all files are in erb format. Is there any quick way to convert whole application's erb file to haml.. without any conflict.
And also would like to know for the Reverse..
Thanks in advance. :)
For erb-to-haml
You can use from the command line html2haml
html2haml your_erb_file new_haml_file
If you want to convert all your files in one go, look at this article : http://shifteleven.com/articles/2008/06/08/converting-erb-to-haml-snippet
erb2haml gem will do the trick.. have a look to https://github.com/dhl/erb2haml
For haml-to-erb
I recommend you HAML2ERB service . It's really cool and generates valid ERB/HTML code! Tested on big HAML views (over 800 lines of markup) from the real production app. Project active :)
have a look to this also http://makandracards.com/makandra/544-convert-haml-to-erb
I'm trying to understand how the gem backbone-on-rails works under the hood.
My problem right now is that I don't know who is in charge of generating the code for the templates it provides.
After installing and setting it up (I'm using the plain js route, not coffeescript, but the question is the same), if I write a template file in /app/assets/templates/hello.jst, it gets "somehow" translated to the following javascript inside application.js:
(function() {
this.JST || (this.JST = {});
this.JST["hello"] = function(obj){ <ugly js here> };
);
But who actually does generate that code? I've browsed the sourcecode of backbone-on-rails, and could not find anything that pointed to template compilation. Is the asset pipeline capable of doing that out of the box?
Ok, I think I found my answer.
The functionality is provided by sprokets, there is a good explanation on its readme.
Will close this in two days.
I'm converting pdf files in my Ruby project. I'm using the pdf toolkit gem for this.
The documentation shows how you can use pdftotext
pdftotext(file,outfile = nil,&block)
In my project I am converting a PDF file without any arguments and can just do this:
PDF::Toolkit.pdftotext("file.pdf", "file.txt)
If I run it from the command line, I can preserve the layout by passing that param
pdftotext -layout file.pdf
What is the correct syntax to achieve this with PDF::Toolkit?
Thanks!
Figured out how to make it work so I'm answering my own question, but if there's a "proper way" to do this, I'd love to see how to do it.
Put the options in the second argument and the text file will be named file_name.txt
PDF::Toolkit.pdftotext("file_name.pdf","-layout" )