Rails warning message after clicking a 3rd party link - ruby-on-rails

I am trying to find a way to show a "You are navigating away from this site" message every time someone clicks on a link that takes them away from my site.
I know this can be done for individual links but is there a way to apply it to all links that don't begin with https://www.genericwebsite.com or http://www.genericwebsite.com?
I hope this is clear. Thanks!

Yes, you can achieve this by java script. http://www.codepotato.co.uk/2012/08/09/how-to-create-a-warning-when-opening-external-links-in-jquery/ answers your question.

Related

Hackathon project regarding Twitter

I will be attending my first hackathon this upcoming weekend, and plan to create a Twitter-based Chrome extension. Basically, when someone wants to tweet or reply to something, and they click the 'tweet' button, it will open up a pop-up modal that asks them some questions about their tweet (so as to encourage them to be mindful about what they post). Within the modal, there will be a button that then publishes the tweet.
So, to sum it up, my modal will be an intermediary in the process of posting a tweet.
What technologies will be useful in implementing this? Specifically, how can I implement the feature in which someone clicks the tweet/reply button, and it opens up my web app's modal on the same screen? Correct me if I am wrong, but I think this is called event capture? Does this have anything to do with Web Intents?
Thanks!
I have done similar things on other sites. A high level overview of what you should try doing:
Find out how twitter sends tweets, the "tweet" button has a "js-send-tweets" class, I would start by investigating that. They probably have a piece of js listening to the button press.
Once you figured it out you can override that function by injecting your own script to the page after twitter's. This way when you press tweet your function will execute.
You should write your own logic in there then add twitter's function logic too which would conditionally execute based on the user's action.

How to automatically link a word(s) to an external site every time it appears anywhere on the site?

For the life of me I do not know what the terminology is for this. And my search engine searches are straight up hopeless. I know I'm not the only one wanting to know this; I just don't know how to ask it or what keywords to use to figure this out on my own. So I'm here to explain it to you all the best I can in hopes someone might now and shed some light on my darkness. Okay here goes...
Site page 1 content:
Georgio went to the store after he stopped by to see how Nichols was doing.
Site page 2 content:
The cat was afraid of Georgio and his dog.
Site page 3 content:
My best friend is not a friend of Nichols, who is the best friend of Georgio, but is a friend of Georgio.
What I need done:
On each page (1, 2, 3) and each time it appears on each page, I want "Georgio" to be linked to the same external website (like http://geethr33whiskers.net <---I just made that up), but without me having to manually link each "Georgio". I want to be able to link "Georgio" once and then automatically the other instances will be linked to the same external website.
On each page (1, 3) and each time it appears on each page, I want "Nichols" to be linked to the same external website (like http://www.nichols2zzz4wedding.com <---I just made that up), but without me having to manually link each "Nichols". I want to be able to link "Nichols" once and then automatically the other instances will be linked to the same external website.
I hope this makes sense. If you know what I'm talking about, how do I set this up? I've got the site hosted on Netfirms (so it's not a wordpress.org site) with the WP blog platform set up on it. Or is there a WP plugin that will help me out doing this?
Also, what is this kind of process called? Oh, and I have tons of words that need this kind of automatic linking or whatever you call it.
You should use the_content to filter the text displayed.
add_filter( 'the_content', 'function_to_replace_text' );
function function_to_replace_text($content){
//add PHP code to replace your word by link in $content
return $content
}

Google Analytics Link Tracking

OK, so I've set up a website where the content is split into modals that are hidden. There are links on the page that when clicked on, the relevant modal appears. I want to be able to track the links being clicked on so I can see what content is being viewed by users. Ideally I want the data to appear as fake pageviews. I know this used to be possible but not sure how to do it nowadays.
I can't seem to find any decent up to date documentation online for how to do this. Can anyone shed some light?
Once you have the Analytics initialized for asynchrounous, just call
_gaq.push(['_trackPageview', 'FAKE_URL']);
This should work and will not slow down your page load. You might want to consider using "events" rather than fake page views; it's also quite simple
_gaq.push(['_trackEvent', "EVENT NAME", "PARAMETER"]);
See Google's Documentation for more info.

Filling in a web page with Delphi using TWebBrowser

I use Delphi 7 on Vista. So far, I have implemented a simple browser (using TWebBrowser) but I would like to automatically enter information when the web page asks for it. For example, I want to tell my app to go to Google, detect the Search field, enter a search phrase, and then click the Search button and then get the result.
Can someone shed some light on how this is done?
You need to use the DOM to do this. The best online resource for learning this in a Delphi setting is at Brian Cryer's site. Take a look at How to read and write form elements.
In the google instance you could simply call the search URL directly yourself.
Eg. This URL searches for 'jam'
http://www.google.ie/search?q=jam&ie=UTF-8&oe=UTF-8&hl=en&client=safari
Get your code to change jam for your search string and go to that URL. I hope this is what you are looking for.

Click on Print gives a screen shot to save in rails3

I may fall under the list of possible duplicates but still i could not find the answer according to my req.In my rails application i have some web pages with a link of print option.
Now what i need is when i click on this print ,i should get a screen shot of the current web page and a popup box to save the image .Is there any plugin available for the same.
Also any queries for code are welcome
Thanx
You could go for phantomJs. Where you can alter the page HTML, manipulate CSS, insert & call javascript snippets, the way you need it.
Good documentation available and also you can find great deal of help in stackoverflow-phantomjs
Regards,
HBK
May i suggest that you use http://www.w3.org/TR/css-print/
if you want to make a screeenshot you have to work with the user env, so i suggest you look at this topic How do I take screenshots of web pages using ruby and a unix server?

Resources