Show
Ignore:
Timestamp:
02/08/08 02:44:39 (2 years ago)
Author:
eevee
Message:

Database refactoring. Renamed columns and tables to be more consistent and more readable. (#58)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • veekun/trunk/lib/Vee/Utils.pm

    r283 r406  
    5050 
    5151sub postrank { 
    52     my ($postct) = @_; 
     52    my ($post_count) = @_; 
    5353    for my $rank ( 
    5454        sort { $b <=> $a } 
    5555        keys %{ Vee->config->{site}->{post_ranks} } 
    5656    ) { 
    57         return Vee->config->{site}->{post_ranks}->{$rank} if $rank <= $postct; 
     57        return Vee->config->{site}->{post_ranks}->{$rank} if $rank <= $post_count; 
    5858    } 
    5959    return "ERRORZ0RZ"; 
     
    6363# XXX: decide the best way to do this, preferably a smooth log curve 
    6464sub post_width { 
    65     my ($postct) = @_; 
    66     return $postct / 1000; 
     65    my ($post_count) = @_; 
     66    return $post_count / 1000; 
    6767} 
    6868 
     
    109109} 
    110110 
     111# URL-validation regex 
     112# Inferred from the W3's BNF: http://www.w3.org/Addressing/URL/5_BNF.html 
     113# n.b.: Technically, the BNF says hostname parts (as delimited by dots) 
     114# should begin with a letter, but given that 'xalpha' includes dot this was 
     115# a bit clumsy to pull off in practice, so I left it lazy. 
     116my $url_xalphas = qr/[-$_@.&+!*"'(),a-zA-Z0-9]/; 
     117our $IsValidURL = qr/ ^ 
     118    (?: http | https | ftp ) :\/\/          # protocol 
     119    (?: 
     120        [a-zA-Z] $url_xalphas*              # hostname 
     121        | (?: \d{1,3} \. ){3} \d{1,3}       # IP 
     122    ) 
     123    (?: : [0-9]+ )?                         # port 
     124    (?: \/                                  # path: leading slash 
     125        (?: $url_xalphas*                   # path: path part name 
     126          | %[a-fA-F][a-fA-F] )*            # path: escape 
     127    )*                                      # path: as many as you want 
     128    (?: \? $url_xalphas+ )?                 # query string 
     129    (?: \# $url_xalphas+ )?                 # anchor 
     130$ /x; 
     131 
     132 
    111133sub pad { sprintf "%0$_[1]d", $_[0] } 
    112134sub round { $_[1] ||= 0; return int($_[0] * 10 ** $_[1] + .5) / 10 ** $_[1]; }