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}
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.
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.
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
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
Tuesday, March 16, 2010
Hpricot? Here we go again
Steven suggested that the list could benefit by showing more human words, aka the site's title. After cursory attempts to find a quick fix, I remembered Hpricot! What the hell did I do for half my thesis if not read data from websites? Some quick memory refreshing was all I needed:
Install:
sudo gem install hpricot
To use:
require 'rubygems'
require 'hpricot'
require 'open-uri'
doc = Hpricot(open(url, 'User-Agent' => 'whatever'))
doc.search("title").text
I guess User-Agent tells the site what browser I'm using? digg wouldn't work without it. Odd...
http://stackoverflow.com/questions/1386985/timeout-error-with-hpricot-in-rails-controller
"title" looks for the title tag hopefully. Seems to work for now.
Added alternating row colors.
http://blogs.csuchico.edu/ik/2006/04/12/alternating-row-colors-with-ruby-on-rails/
http://paulsturgess.co.uk/articles/show/15-alternate-row-classes-with-ruby-on-rails
Install:
sudo gem install hpricot
To use:
require 'rubygems'
require 'hpricot'
require 'open-uri'
doc = Hpricot(open(url, 'User-Agent' => 'whatever'))
doc.search("title").text
I guess User-Agent tells the site what browser I'm using? digg wouldn't work without it. Odd...
http://stackoverflow.com/questions/1386985/timeout-error-with-hpricot-in-rails-controller
"title" looks for the title tag hopefully. Seems to work for now.
Added alternating row colors.
http://blogs.csuchico.edu/ik/2006/04/12/alternating-row-colors-with-ruby-on-rails/
http://paulsturgess.co.uk/articles/show/15-alternate-row-classes-with-ruby-on-rails
Monday, March 15, 2010
Radio buttons
Successfully added radio buttons to replace the drop down list, for choosing categories. Not aligned the way I'd like, but still clean and effective.
Next: Cannot submit without choosing a category - forces all sites to have a category. How would we deal with sites that are already submitted - can we suggest (pre select) the existing category?
Digg seems to be updating themselves - no need to log in, more categories, faster. Sounds like they're copying us! Jerks.
Next: Cannot submit without choosing a category - forces all sites to have a category. How would we deal with sites that are already submitted - can we suggest (pre select) the existing category?
Digg seems to be updating themselves - no need to log in, more categories, faster. Sounds like they're copying us! Jerks.
Wednesday, March 10, 2010
Too close, squeezing in?
At times I worry - how similar is this site to Digg and Delicious? Kind of like a middle ground I think. Perhaps I should use those sites more, contribute, get a better feel for them.
Tuesday, March 9, 2010
Category organization idea
class of categories
sports
# access into category and sub-category will be accomplished by a 2 dimensional index pair
# e.g. (1,4) = sports,mls, (3,1) = business,stocks
end
Novel idea: how about we let the first person who submits an idea control what category it is?
Once its set, its set for life. Might give people incentive to be the first to submit.
Maybe this is a cooky idea. What if they mess up and label incorrectly?
No "news" category?
sports
- nba
- nfl
- mlb
- mls
- epl
- sl
- nhl
- us
- world
- stocks
- gov
# access into category and sub-category will be accomplished by a 2 dimensional index pair
# e.g. (1,4) = sports,mls, (3,1) = business,stocks
end
Novel idea: how about we let the first person who submits an idea control what category it is?
Once its set, its set for life. Might give people incentive to be the first to submit.
Maybe this is a cooky idea. What if they mess up and label incorrectly?
No "news" category?
Sunday, March 7, 2010
Updated hyperlinks, ranking formula, background image!
1. Hyperlinks now update the num_clicks variable. The links also redirect to the named url. One issue I have: I'd like to be able to stay on the current page, open the url in a new window, but I can't figure out how to do that. As it stands, clicking the link will navigate away from the page.
I was able to open a new window if it was just a straight up link (no num_click processing). It might be impossible to do both, we'll see.
2. In the 'index' controller method I had originally sorted the list of url's by number of submissions. It was trivial to update it to use a formula. Basically it is now ranked by the value of: (num_submissions * 10) + (num_clicks * 2) + (num_votes * 5). No way to vote yet though.
3. Found a pretty background image, added it to public/images, inserted a line into the CSS file, bam. The site looks way better for such a simple thing.
How should I implement the Categories? User picked (from drop down), or Steven's original 'keywords' idea?
I was able to open a new window if it was just a straight up link (no num_click processing). It might be impossible to do both, we'll see.
2. In the 'index' controller method I had originally sorted the list of url's by number of submissions. It was trivial to update it to use a formula. Basically it is now ranked by the value of: (num_submissions * 10) + (num_clicks * 2) + (num_votes * 5). No way to vote yet though.
3. Found a pretty background image, added it to public/images, inserted a line into the CSS file, bam. The site looks way better for such a simple thing.
How should I implement the Categories? User picked (from drop down), or Steven's original 'keywords' idea?
Saturday, March 6, 2010
incrementing submissions, links, url validation
God, so much grunt work this past week. I think I've made some decent progress though.
1. incrementing submissions - Using form_tag to call a controller method, a preexisting url is incremented
2. Spent WAY too long trying to figure out the link/url showing up on the page properly. For some reason the View would keep adding things to the string I passed it (if it wasn't a "proper" url). After spending days trying to fix it, I decided it would just be easier (and possibly better practice) to validate URLs as they're submitted. Used a model validation.
3. See #2.
UPDATE:
Apparently, http: is a valid URL, as is http:/, http://, http://anything.
This is the info I used: http://mbleigh.com/2009/02/18/quick-tip-rails-url-validation.html
Perhaps there is a better way to do this.
1. incrementing submissions - Using form_tag to call a controller method, a preexisting url is incremented
2. Spent WAY too long trying to figure out the link/url showing up on the page properly. For some reason the View would keep adding things to the string I passed it (if it wasn't a "proper" url). After spending days trying to fix it, I decided it would just be easier (and possibly better practice) to validate URLs as they're submitted. Used a model validation.
3. See #2.
UPDATE:
Apparently, http: is a valid URL, as is http:/, http://, http://anything.
This is the info I used: http://mbleigh.com/2009/02/18/quick-tip-rails-url-validation.html
Perhaps there is a better way to do this.
Subscribe to:
Posts (Atom)