@import "newslash/progress_bar.less";
@import "newslash/wiki_content.less";
@import "newslash/timeline.less";
+@import "newslash/authors.less";
@import "newslash/ads.less";
@import "newslash/system_error.less";
--- /dev/null
+.authors-list {
+ .authors {
+ dt {
+ &:extend(.rectangle-header);
+ &:extend(.medium-text);
+ }
+ dd {
+ margin-bottom: 1em;
+ }
+ }
+
+ h2 {
+ &:extend(.rectangle-header);
+ &:extend(.large-text);
+ }
+}
use constant FACULTIES => { 1000 => [qw(hits hitparade)] };
+sub count_by_author {
+ my $self = shift;
+ my $sql = <<"EOSQL";
+SELECT uid, COUNT(stoid) AS count
+ FROM stories
+ WHERE stories.time <= NOW()
+ GROUP BY uid;
+EOSQL
+
+ my $dbh = $self->connect_db;
+ my $sth = $dbh->prepare($sql);
+ $sth->execute();
+ my $rs = $sth->fetchall_hashref("uid");
+ if (!defined $rs) {
+ $self->set_error("select failed", $dbh->errstr, $dbh->err);
+ $self->disconnect_db;
+ return;
+ }
+ $self->disconnect_db;
+ return $rs;
+}
+
sub count {
my $self = shift;
my $join = 'LEFT JOIN firehose ON (stories.stoid = firehose.srcid AND firehose.type = "story")';
the_path
get_timestamp_by_id
tidy_html clean_html escape_html format_htmltext escape_plaintext strip_by_mode
+ get_authors
]) {
$app->helper($k => $self->can("_$k"))
}
my ($c, $content_type, $id) = @_;
}
+=head2 get_authors()
+
+ get authors
+
+=cut
+
+sub _get_authors {
+ my ($c) = @_;
+ my $users = $c->model('users');
+ my $authors = $users->select(author => { gt => 0 });
+ return $authors;
+}
+
######################################################################
#
# about
$r->get('/about')->to('about#about');
- #faq
+ # faq
$r->get('/faq/editorial')->to('faq#editorial');
$r->get('/faq/UI')->to('faq#UI');
$r->get('/faq/firehose')->to('faq#firehose');
$r->get('/faq/tech')->to('faq#tech');
$r->get('/faq/')->to('faq#faq');
+ # authors
+ $r->get('/authors')->to('authors#authors');
+
# Admin
# pages under /admin needs seclev equal or greater than 10000;
my $admin = $r->under('/admin' => sub { my $c = shift; $c->stash(seclev => 10000); return 1; });
--- /dev/null
+package Newslash::Web::Controller::Authors;
+use Mojo::Base 'Mojolicious::Controller';
+use Data::Dumper;
+
+sub authors {
+ my $c = shift;
+ my $authors = $c->get_authors();
+
+ if (!$authors) {
+ $c->rendered(500);
+ return;
+ }
+
+ if (!@$authors) {
+ $c->rendered(500);
+ return;
+ }
+
+ # get stories count
+ my $stories = $c->model('stories');
+ my $users= $c->model('users');
+ my $counts = $stories->count_by_author;
+ if (!defined $counts) {
+ $c->rendered(500);
+ return;
+ }
+
+ for my $author (@$authors) {
+ $users->get_user_config($author);
+ if ($counts->{$author->{uid}}) {
+ $author->{number_of_stories} = $counts->{$author->{uid}}->{count} || 0;
+ }
+ else {
+ $author->{number_of_stories} = 0;
+ }
+ }
+
+ my @sorted = sort { $b->{number_of_stories} <=> $a->{number_of_stories} } @$authors;
+
+ $c->render(page => { type => "authors" },
+ authors => \@sorted);
+}
+
+
+1;
+