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
Thursday, March 18, 2010
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)