Creating a "pop out window" for user login - ruby-on-rails

I've searched stackoverflow as well as google and can't seem to find a specific enough answer, so I thought I would go ahead and ask it myself!
To provide some background: I am a fairly new rails developer and I've just created a basic app albeit it is lacking some wanted functionality. So far I have integrated Devise, and Omniauth for user login. However, I'd like to have a "pop out window" when users click 'Login' instead of being re-directed to an actual Login page.
If you click on the login button on this website you will see what I am referring to: http://geckodesigns.kinja.com/so-i-bought-a-firetruck-252516685
What sort of Ruby or perhaps Java code would one have to use to implement such functionality?
I look forward to reading your answers!

You could use something like jQuery UI Dialog for this.
Here's the website for jQuery UI. There's also a Rails gem that wraps this library and makes it quite easy to put in your project. You can find that gem on github here.

Suppose you have a login page: html/login.html
In original page:
<a onclick='popupLoginWindow'>Login</a>
JavaScript:
function popupLoginWindow(){
window.open('html/login.html');
}

Related

Ruby on Rails: Simple share button by koala gem

I want to do a simple facebook share button in Ruby on Rails app using koala gem.
The button should be very simple - like this
<a href="https://www.facebook.com/sharer/sharer.php?u=example.org" target="_blank">
Share on Facebook
</a>
I would like to click on it and then should be opened new browser window to put post on my wall (or login to facebook).
I'm beginner in koala gem so I don't know how to do this. Until know I add to controller show method
# part of object_controller.rb
def
#graph = Koala::Facebook::API.
end
and on the view
# part of show.html.erb
<%=graph.put_wall_post("hey, i'm learning koala")%>
but it wants the token access and I think that there is a better (simpler) solution.
The easiest way I have found to add social links from many sites, including the Facebook share button is using the gem 'social-share-buttom'.
Here is a great little tutorial to start using it immediately in your Rails app.
https://richonrails.com/articles/adding-social-sharing-buttons-to-your-rails-app
Koala gem is a realy powerfull tool. If you want just add a share button use more simplest ways: a lot info about share buttons.
But if you want to do some specific just write about it, I will try to help you.

Login to a site using the cocoa framework

I am creating an ios app that needs to download a html page and extract some information from it. To get to the page I also need to login. I have looked everywhere for some code on how to login to a site using the cocoa framework, but every answer I see only seems to answer half the question. Here is the login site: romres.ist-asp.com. I need some code for writing something in the first field (the other two are left blank), then submit the form and then I need to be able to see the next page. I believe apps like Facebook should use som of the same technology, where you log in to a facebook and then you can see the contents of your profile.
Basically what you want to do is called scraping.
Scraping is really easy for sites that don't require authentication, but in your case what you should do is to inspect the POST request being made when logging in the site your interested in (try to understand of the service respond) and the POST request made, when already logged in, to retrieve each page.
The purpose of all of this is to have later the possibility to simulate regular HTTP requests that should came from a browser via code.
If you have any doubt ask in the comments.

Posting a comment on a page through native iOS UI

Ok so I've scoured the docs and stackoverflow for an answer, but maybe I'm asking the wrong questions or looking in the wrong places. I'm working on an native iOS app and I want to give the user a way to post a comment to a page, but through native UI and not through a UIWebView with the comments plugin embedded. I can make a comment on a comment on the page, but I can't seem to make a comment from an authenticated user on the page itself. Is this even possible?
Apple's URL Loading System provides you with the ability to set credentials for basic HTTP authentication, but it sounds like you're talking about logging in to some kind of forum system. The way those generally work is that you send your credentials to the site, and get an authentication cookie back. You then need to provide that cookie to the system when you interact with the site.
Here's a blog post with an example of how to do that.

How can I get it work: Embedding Twitter's Web Intent

Normally Web Intent is used as a pop-up. According to Twitter, it also provides embedding functionality.
"Some sites may prefer to embed the unobtrusive Web Intents pop-up Javascript inline or without a dependency to platform.twitter.com. The snippet below will offer the equivalent functionality without the external dependency."
The snippet can be found at https://gist.github.com/894540#file_intents.html
See: http://dev.twitter.com/pages/intents
However, I can't get this snippet work. I copied the snippet(JavaScript) code to an html file and open that in a browser. Nothing happened! What should I do to make it work?
I had the same problem during NYC Startup Weekend.
The snippet they provide does open up the Twitter popup, as required, but the ability of the Twitter popup window to pass a message back to your web page is a little more complicated. You will need to understand how their widgets.js code works and reproduce what's necessary to set up the RPC framework. My short-term workaround was to include a slightly modified (un-obfuscated) version of widgets.js that would not replace my button with theirs.
I will be tackling this in a week or two, if you can wait.
... or you can just include their widgets.js directly :)
Welcome to the vague world of the Twitter API documentation.. I think you're misunderstanding, no small part to the incredibly poor wording on the API page:
Embedding that javascript code allows you to open the twitter web intent pages in a "twitter style" popup without requiring a dependency on platform.twitter.com. It does not allow you to embed a twitter intent.
You can see it at work by adding that javascript and then adding the following to your page
<p>New</p>
Clicking "New" will open it in a popup. Remove the javascript, and clicking "New" will navigate the page away to the tweet box.
It's incredibly frustrating to me they don't, at least to my knowledge, allow for proper embedding. I know why they oped for this method, but it's frustrating none the less.

What is a good openid selector control?

Now that idselector has been upgraded to RPXNow and you can't "just use" the selector code, what is a good replacement?
I want to implement OpenId on a new website that I am using, but the users are going to be just dumb when it comes to logging in unless I provide an easy way for them to.
As a reference, I will be using .Net Open Id for the background in an ASP.Net MVC web application.
EDIT
After some cheap thought, what about using the rpxlib?
Jarrett Vance made a "version" of open-selector that is much more developer/designer friendly.
This selector is different because it does not hide the markup details in javascript. Therefore, you can easily add new providers or rearrange the existing ones without digging into the javascript. The login form will still work for normal OpenID logins if javascript is disabled
The best of all, is that it comes with documentation, demo, and lots of images both cropped and as raw .pdn files (paint.net)
Jarrett Vance's openid-selector can be found here
(source: jvance.com)
PS: I would suggest reading this article before implementing RPX.
Another one to consider is http://code.google.com/p/openid-realselector/ (which is a rewrite/update of http://code.google.com/p/openid-selector/)
I have done an implementation with RPXLib and RPXNow, and it is really pretty straight forward.
I wanted to minimize the amount of work done in the OpenId format, and the RxpLib definately helped with that one.
RpxNow also has a nice feature of telling me new users, number of logins per day, etc...
I've made Open-selector, which you just add to your site and switches the regular OpenID box into a provider list and a username text input.
The code is pretty simple (in case you need extra customization) and there is an inline mode so it doesn't alter your original layout.
I was using that one, but then I found a few people using a different one which made me investigate, and I found this OpenID selector. There aren't any instructions per se other than the demo.html, but it shouldn't be too hard to figure out. Just include the css and js, then call the javascript function with the right parameter.
Edit about rpx: I chose to stay away from rpx because I didn't want to have a 'central point of failure,' and a site that isn't my own that users would authenticate to/through. It seems kind of counter-intuitive being that I'm using openid, but if you consider that the openid provider that the user is using as part of the user, then it kind of makes sense.

Resources