Getting the content of Joomla page into Rails page - ruby-on-rails

I have a web page created in Joomla. How do I get the content of that page into my Rails app's page ?

If you used joomla, then you can just grab the rss feed from the page and parse the xml with Nokogiri.
https://github.com/tenderlove/nokogiri

If you're using the same db for both, simply create a rails model to read that db table, and bring the content in.
OTOH, if you're wanting Joomla to assemble and create the entire page, then pass it to rails to view unmodified, why force Rails into the mix at all and just let some pages be rendered by Joomla and some by Rails? You'll need some creativity in the routing and positioning, but then you'll need that to do the RSS read mentioned above, anyway.

Thanks for your hint #chrisBarretto. There wasn't any rss feed associated with the joomla page. However, I managed to grab the content from Joomla page with just using Nokogiri.
Here's what I did in the controller :
#page = Nokogiri::HTML(open(" ... <joomla page url>..."))
Then in the view,
<%=raw #page.css("body table").first.to_s :%>
This worked perfectly as I wanted to be.

Related

Send email as PDF in ruby on rails in Typo3

I have an web-application in RoR which calculates some energy values and investment money. I use ajax to send the data from the web-browser to the server. It is something like this: Browser-server-Browser-Server-Browser
This web-application is already integrated in typo3 and I want to implement a PDF button to send the results per email (in other words, a photo of the page with the results).
I have heard an option would be to generate some links in RoR to be used in typo3 (when clicking on it, it would open exactly the web-application with the results already calculated). But as a newbie, I do not really know which would be the best approach.
Any recommendation?
A screenshot of the page can be done client-side:
http://html2canvas.hertzen.com/
You could even have another page with the same results that you use only for the rendering of the result page what you use for making a clean screen-shot (you might not want to have the footer, menu and other elements on that page, only the results)
Once you have your screenshot, you can upload it to your server where you can use it to create a PDF of that image and then send it with any mail API you prefer to use.
info about TYPO3's mail api can be found here:
https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Mail/Index.html

DNN Site Redirection

I am trying to migrate one html website into DNN. The problem I am facing is the URL. The old website had a URL like www.mywebsite/page.html and after migration it had become www.mywebsite/page .So when the user search for the old url it do not show up.I want that whenever the user enters any of the above url it should redirect me to www.mywebsite/page.
How to deal with the Site Redirection.
You have a couple of options.
1) You put a redirect in the HTML files, and put them in place, so that they redirect to the DNN pages (this is not the recommended option)
2) You add the URLs that you want a DNN page to respond to through the Page Settings in DNN when you configure pages. I believe they end up going into a TabURLS table, so you can add a couple, see the format of the data, and then do a bulk insert into the database for the rest of your pages/urls.
Chris

Display current page in rails haml template

I know this is crazy simple, but I can't figure it out even after reviewing the HAML docs. How do you return the current page/path (current_page). I want to add a simple share on Twitter link to my app that contains the current path.
%a.twitter{href: "https://twitter.com/intent/tweet?url=CURRENT_PAGE_?????&text=#{blah}"} Tweet
Use request.url. It's available in controllers and views.

How to update iframe page tab content using a form?

I am trying to pass data using a form to a Facebook iFrame page tab but can't seem to figure how to do it.
I have a page tab on my Facebook page with several elements such as links and images directing users to various pages on the main website. This is updated every week, so rather than update the HTML file and upload via FTP everyweek i would like to see if i can create a form to pass the new data to the iframe.
In addition the Facebook page tab cannot be created in PHP as the server is running ASP.NET
I am trying to do this without the use of a database table if possible, using POST or GET would be preferable.
If anyone knows of any tutorials or has any tips i would be very grateful.
Cheers
You can only pass content or interact with iframe content if it's on the same domain as the parent webpage that has the iframe. All browsers have a "same origin policy" that prevent you from being able to do that - sorry :(

Server side rendering for dynamic pages with PhantomJS on Ruby On Rails

I have a WebPage made that is 90% Javascript. All of the WebSite is rendered dynamically.
I want this content to be rendered by the server as well so that Google can crawl and index all of my content and links.
I know that in order not to get banned by google, the content of the dynamic page and the server rendered page must be almost identical.
I don't want to code two different pages (one from the client with Handlebars and one from the server with ERB in this case).
So I thought of PhantomJS. What I want is that when I get the _escaped_fragment_ param from google, I open the page without that with PhantomJS and I render this to HTML from PhantomJS and return that from the server to Google. This way, I don't have to create two different pages for anything.
I know that I can use Handlebars for Server Side templating as well, but I'd have to code everything twice anyway.
Does anybody know how to accomplish this with PhantomJS? Is there any other way for not repeating the Logic and code Twice and have Google index the Site?
Thanks!!!
Yes you can.
Add the following to the of your Javascript intensive page
<meta name="fragment" content="!">
When the Google bot finds this tag, it will issue a new http GET request. This time, it will add ?_escaped_fragment_= to your URL.
So if your web page with Javascript is located at:
www.mysite.com/mypage
Google will issue a new GET using the following URL:
www.mysite.com/mypage?_escaped_fragment_=
In your Ruby GET handler, you simply call PhantomJs with the unescaped URL (just do a string replace). In your PhantomJs javascript code, wait for the page to render and then then extract the HTML using regular javascript and return it back to your Ruby GET handler where you will simply respond to the GET with the HTML text string.
In this way you do not have to write your code twice. The solution is generic and will snapshot anything.

Resources