Rails 3 Twitter Anywhere For Profile Links? - ruby-on-rails-3

I was using the Twitter Widget for the longest time but I was looking to step it up a level and add additional styling and filtering. Recently I got started with the Rails Twitter Gem and so far so good, but I wanted to be able to link back to profiles wherever #username appears.
Looking around it seems that Twitter Anywhere is the way to go, but I was wondering if there was a better implementation in a Rails environment? Perhaps a gem that loads the required JS files and provides helper methods?
Also I should note that I don't necessarily require all of the functionality that the anywhere api offers, at the moment my main focus is just to provide the #username links (though it is certainly nice to have the option for future expansion).

It turns out that Twitter Anywhere might have been a little overkill for what I was trying to do. All I really needed was the following helper method as mentioned here
def linkup_mentions_and_hashtags(text)
text.gsub!(/#([\w]+)(\W)?/, '#\1\2')
text.gsub!(/#([\w]+)(\W)?/, '#\1\2')
text
end

Related

Best way to implement a multi-user goal list?

I want to make a list of goals for my family and I that we are all going to follow.
I generally know how I'll implement the list part. Just a todo-list-esque app where you only cross or uncross things off on it. I haven't decided with what I'll implement that part, mostly because I'm not sure how the multi-user part will go.
I figured each person can log in with Facebook or Twitter, and based on your login you'd be able to see what you've checked off.
I've never built a login before, or built based off of a logged in user.
Which web frameworks would be best for this? How would you implement this?
Since you said you know Javascript well, it sounds like you're best bet is to just use Node.js and a simple web framework like Express.js.
This will allow you to write you server-side code in Javascript, which should make the process simpler for you.
For handling authentication / etc., if you're looking for a stupid-simple authentication library you can use express-stormpath -- it supports social login as well as username/password stuff.
If you're looking for a smaller solution, you can use something like passport.js and use the third-party plugins for social login.

Trying to understand Capybara and mock data

I've got a Twitter app. All our users come directly from Twitter. This means, you cannot do any significant interactions with the app unless you are logged on, from Twitter. Our app caches (saves the user's Twitter data in the db).
It is possible to integrate Capybara with Omniauth. For example to test OAuth integration with Twitter. I've read a few articles online about this. However, the tricky part is getting it to work with Devise + Omniauth (I've only seen a scarce number of articles, have tried them to no avail).
Second, I've also looked into testing file uploads to S3, which make it quite difficult, since we are uploading directly to S3 using JS (Uploadify) and then instructing Carrierwave to grab the file.
A few have mentioned that it is best to provide mock data instead of trying to test OAuth directly. I guess, what they are trying to suggest, is to seed the test database with mock Twitter data. That way, I can test the user directly in the app. Without having to worry about how to get testing with Rspec + Capybara + Devise + Omniauth + Twitter to work.
I could do the same for file uploads as well. Does this make sense? Is this a sensible approach?
By seeding the database with the appropriate data beforehand, you avoid dealing with all the integration testing issues of Omniauth etc. As the library itself is already tested anyhow, you also avoid and unnecessary overhead.
So yes - seed your db with the data right away.
OmniAuth has helpers for integration testing.. i wrote a post about that, it may help you..

Rails 3 Authentication: Authlogic vs Devise

I have always used Authlogic in Rails 2.3 but now that I am using Rails 3 I think I might try out a new authentication solution.
How does Devise compare with Authlogic? What are their differences?
I've used them both, but not extensively. In my last project, I gave Devise a shot. I ended up using Rails-Warden instead.
Devise is a full authentication framework built on top of Warden. To customize its looks, you use generators, then edit the resulting views. Its routes, and view logic are hard coded. For example, successful login will always take you to /session/new? This was a dealbreaker or me, I wanted my users to end up on "welcome/index". Devise is not as well documented, or intuitive as authlogic.
Warden is a middleware framework Devise is based upon. It has plugins for many web authentication schemes (fb, openid, oauth), and it is easy to build a plugin for your own authentication back end. It comes with no UI, and docs are not as good as authlogic.
I ended up using rails-warden because I needed to plugin multiple custom authentication schemes.
Also, see OmniAuth answer below, that's what I am using in 2012.
for devise, if you want to send successful login to "welcome/index" you add to routes.rb
namespace :user do
root :to => "welcome#index"
end
as documented https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-in
personally, i like devise. it think it's great and i guess you can call it "opinionated" but those opinions can be easily overwritten.
I found Devise too opinionated for me. If you just want to accept the way it does things out of the box it is good and easy to get going. I had some specific requirements and found myself writing things to get round Devise so ended up ripping it out and updating Authlogic to Rails3 instead.
Like the original questioner, I too had always used AuthLogic in the Rails 2.3 days but made the choice to use Devise when AuthLogic wasn't ready for Rails 3.1 (when it was at the RC stage). Overall I've made Devise do what I want but I'm unhappy and wish I hadn't made the change.
User Authentication seems simple on the surface and an ideal thing to "componentize" but so many times you want to let a user engage with your site fully before requiring login and Devise makes this harder.
Yes features like putting after_sign_in_path_for / after_sign_up_path_for into Application Controller work but these functions are really intended to do nothing more than return a path and if you're using Devise you'll find yourself sticking big blocks of code into them. It works but having your own users controller to handle user related actions is, to me, more elegant.
If you need multiple OAuth authentication to Twitter, Facebook, LinkedIn and Google, you can use the OmniAuth gem along with Authlogic. Easy to figure out and gives you complete control over what happens as users authenticate from different social sites, which you do in authorizations_controller.rb.
I like Devise. You can use OmniAuth with Devise too. I think that the Devise project is very active, and it has a big support on the internet.

Is it possible to develop a Facebook app that filters updates out of a feed?

Namely, does the Facebook API make this possible? I'd like to leave my news feed intact, but remove posts that meet some criteria for things I don't want to see (e.g., don't show me anything that sounds like Dick Cheney might have said it). Does the Facebook API allow apps to customize a user's normal news feed? I spent a few minutes looking at the facebook developer pages, but didn't see any direct answers to my question, so I was hoping some developers who were experienced with Facebook's API could help me here.
Before anyone mentions it, I don't want to just hide updates from those users. They may post other updates that I want to see, so I'd prefer to filter out updates based on content.
There is a Greasemonkey script called "Facebook Purity" which does this. You could probably look at the source and alter it to your specifications.
You could parse the news feed into a database on your site then use code to parse whether or not to display it.
yes this is possible but only if all your friends decide to add your application! otherwise you may be not able to access their feeds.
Its been a while since i used Facebook SDK so this may have changed.
The API provides very little news feed integration, and no you can't use the api to prevent news feed items from showing up in a users feed. All you can do is post and get, and you can only post 10 items a day, "significant" interactions. The Facebook API wasn't designed to enhance or alter the core Facebook experience, it was designed to allow developers to create third party apps that add to Facebook within a very limited and tightly controlled sandbox.
The Linq to facebook project looks quite interesting and may allow you to do what you are asking (if using .NET 3.5). My apologies for a link to such a pink website ;-)

Creating a login section - Im new an need some serious direction please!

Alright. So I am new, I know my way around html pretty well, and have gotten by for a while now doing so. But today I am presented with a seemingly simple issue.
My client needs the ability for users to create their own LOGIN/PASSWORD, my client wants to be able to MANUALLY approve visitors. And he want to be able to track how many times they login.
The login section will just be about 4 pages of PDF file downloads.
I cant imagine this is the hardest thing in the world, I just have no clue where to even start. Perhaps there is a code already written, as things like this are done every day using forum technologies...
Please help!
It may also help to mention that I am using Dreamweaver cs4 on a MAC
I'd check out Ruby on Rails if I were you. It's pretty easy to get something quick up with it that you can have users create accounts with that send e-mails to the client with approve/reject options, and be able to track downloads and users via MySQL or other databases.
I've found Agile Development with Rails to be a great source of info on how to do stuff like this (they do an online bookstore as the book's example) and with a little modification I think it should work for what you say you want to do (and the book is pretty cheap as far as programming books go).
If you want just really basic static login features without lots of coding, you can start with Password protecting your pages with htaccess. You can password protect directories like this without any effort at all. This way, you can be sure that your login routine is secure.
Then, you can continue with advanced features like account administration and login statistics. These will require some programming skills.
Tracking count of user logins should be easy too. You can put simple PHP code to the source of protected pages that will save the info about login to the database. This will require you to study some basics of databases. You can use plaintext files which is not as clean but much easier and it will allow you to export info for your client more easily.
If you want to do it profesionally, you should invest in learning about web development or hire someone to do it for you. These tasks might not be trivial.
Have you worked with PHP, ASP.Net or some other web language yet? What you're trying to isn't too difficult in the grand scheme of things but it may be somewhat challenging if you haven't programmed before and/or haven't had any experience with web development.
(P.s. Alter your question as a response and comment on my answer when you're finished.)
As you are looking into Ruby on Rails, take a look at bort which is a RoR app skeletton with RESTful authentication included, it should help (Chris Bunch answered on the general RoR question).
There is also this bort fork. There is also Authlogic which may be easier to work with.
Have a look at the ASP.net Membership provider and also the login controls which provides the UI for the login as well as registration screens out of the box.
Here is a Multipart Series on ASP.NET's Membership, Roles, and Profile
If this is too complex than probably you can also design you application from scratch using ASP.net. If you don't know asp.net than the best place to start is www.asp.net it has several videos and tutorials which would help you get going soon.