Using Server-Side Javascript (in Rails 3)

There is an excellent bookmarklet script that accepts an HTML document and, using javascript, removes the main content of the article (e.g. Instapaper, but better).

I want to find out the most efficient way to use the same server side javascript script with Rails 3.

Is it possible? It would be ideal to be able to request the URL from the server (in Rails), and then parse the response using javascript and return the processed text (and then be saved in db).

I thought just adapting the script in Ruby, but it seems silly, especially since jQuery and javascript themselves have a bunch of built-in functions for parsing the DOM. On the other hand, the script uses DOM constructs from the browser, so this might require a server browser?

Any suggestions?

+3
source share
3 answers

We really do this in one of our web applications. If you want to implement this server-side functionality in your Ruby on Rails application, it is best to use an HTML / XML Ruby parsing library such as Nokogiri .

, , -, , Instapaper, Ruby + Nokogiri.

- Ruby Nokogiri

+2

, script - Rhino Shell ?

0

Node.js comes to mind when talking about server-side Javascript.

I think that Javascript reading material can also be translated into Ruby, but this will probably require some serious work.

0
source

Source: https://habr.com/ru/post/1772679/


All Articles