Monday, May 3, 2010

Users

Haven't had much chance to work on this recently, but made some time for the past week or so. I found Authlogic, a premade Rails user package that seems pretty powerful and easy to use. Following some tutorials the site is now capable of simple user registration, login and logout, and profile editing.

Things to work on:
1. User registration validated by email or Captcha
2. Limiting certain site functions (like new site submission?) to logged in users.

I still haven't figured out how to do the FMyLife voting scheme. For those that don't know, fmylife's entries each have a vote up and vote down function. The magic is that you don't need to be logged in or registered to vote, it simply allows you to vote. When you do, the option to vote goes away for that entry. How do they do it?? Some sort of javascript, but what? That's what I'd like U's voting to be.

Monday, March 29, 2010

"Refresh" idea

Using some AJAX or something, how about have the site update every 30 seconds or so, and the links move up or down automagically? It would look cool and people wouldn't have to constantly refresh. Pipe dream for now, so far off.

Minor updates

Brian made a great observation. Presently the site treats votes as a single entity. That is, voting up or down causes the overall votes tally to go up or down. His idea was that there should be a separate count for "vote ups" and "vote downs". This way, there is a measure of total votes, which can indicate general interest in a topic.

I asked Brian and Steven to populate the site so there's a good base for a search to work on. I must say, I enjoy using the site. I find articles I wouldn't have found on my own, some entertaining stuff. Another simple improvement I can make: add Vote Up and Vote Down in the specific category pages. Also, alternating row color changes.

UPDATE:
Removed "num_votes", replaced with "vote_ups" and "vote_downs". Vote up and vote down buttons now work to increment these two values. Had a hell of a time getting such a simple thing to work. Used migrations to add/remove/change the columns, then when I tried to populate vote_downs with default values, it freaked out. Turns out it was because my model had some num_votes usage, and that was screwing everything up. Fixed that, everything is now peachy keen.

check out:
Change values/add defaults during migration:
http://api.rubyonrails.org/classes/ActiveRecord/Migration.html

Interesting way to go through an array of things: array_name.map {|x| do stuff}, maybe sometimes array_name.map!{|x| do stuff}

Sunday, March 28, 2010

Categorizing

I haven't been able to get the search working yet, it's a bit complicated obviously. Instead I added the categorizing functionality. In the main page, the categories are now clickable. The links take you to a new page showing just links of that category. Score is calculated (and used to sort descending as usual). There is a link to go back home.

Moving to MySQL

When I first started this project I wanted to use MySQL as the database: it was already installed on my computer, and in general MySQL enjoys widespread use. I couldn't get it to work, so I went with the default SQLite db, which worked fine.

The next major addition I'd like to make to U is a full text search. After some exploration, I settled on Sphinx. However, it seems Sphinx only supports MySQL and PostgreSQL, and maybe some commercial stuff. I went back to trying to use MySQL. After some installing, uninstalling with apt-get and gem (and remembering my root password), I got it working. We are now on "kepplerapp3".

Now on to getting Sphinx to work.

Thursday, March 18, 2010

Voting

Added voting functionality - super easy! Created two new controller methods, links for each URL. Up and down arrow images added as well (using image_tag), looks decent.

http://snipplr.com/view/5595/rails-link-to-an-image-instead-of-text/

Used GIMP to crop and shrink a stock image for the arrows. Pretty decent, easy to use.

URL validations

Added more robust URL validations. Some manual checking is done, as well as a URI request to read the http header.

http://snippets.dzone.com/posts/show/10225
http://actsasblog.wordpress.com/2006/10/16/url-validation-in-rubyrails/

vim show line numbers => :set number
remove numbers => :set nonumber