Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some hard-coded values #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/PearlBee.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ BEGIN {
set rbac => RBAC::Tiny->new( roles => config()->{'permissions'} || {} );

our $is_static = config->{static} || '';

# some defaults
setting( posts_on_page => 5 ) if !config->{posts_on_page};
setting( pages_per_set => 7 ) if !config->{pages_per_set};
}

# has to be *after* the configuration is set above
Expand Down
4 changes: 2 additions & 2 deletions lib/PearlBee/Comments/Builtin/Dashboard.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ prefix '/dashboard/comments' => sub {
get '/?' => needs_permission view_comment => sub {
my $page = query_parameters->{'page'} || 1;
my $status = query_parameters->{'status'} || '';
my $nr_of_rows = 5;
my $nr_of_rows = config->{posts_on_page};
my $search_parameters = $status ? { status => $status } : {};

my @comments = resultset('Comment')->search(
Expand Down Expand Up @@ -70,7 +70,7 @@ prefix '/dashboard/comments' => sub {
my $total_comments = $all;
my $posts_per_page = $nr_of_rows;
my $current_page = $page;
my $pages_per_set = 7;
my $pages_per_set = config->{pages_per_set};
my $pagination = generate_pagination_numbering(
$total_comments, $posts_per_page,
$current_page, $pages_per_set
Expand Down
4 changes: 2 additions & 2 deletions lib/PearlBee/Dashboard/Posts.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ prefix '/dashboard/posts' => sub {
get '/?' => needs_permission view_post => sub {
my $page = query_parameters->{'page'} || 1;
my $status = query_parameters->{'status'} || '';
my $nr_of_rows = 5;
my $nr_of_rows = config->{posts_on_page};
my $search_parameters = $status ? { status => $status } : {};

my @posts = resultset('Post')->search(
Expand Down Expand Up @@ -69,7 +69,7 @@ prefix '/dashboard/posts' => sub {
my $total_posts = $all;
my $posts_per_page = $nr_of_rows;
my $current_page = $page;
my $pages_per_set = 7;
my $pages_per_set = config->{pages_per_set};
my $pagination
= generate_pagination_numbering( $total_posts, $posts_per_page,
$current_page, $pages_per_set );
Expand Down
4 changes: 2 additions & 2 deletions lib/PearlBee/Dashboard/Users.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ prefix '/dashboard/users' => sub {
get '/?' => needs_permission view_user => sub {
my $page = query_parameters->{'page'} || 1;
my $status = query_parameters->{'status'};
my $nr_of_rows = 5;
my $nr_of_rows = config->{posts_on_page};

my $search_parameters = {};

Expand Down Expand Up @@ -93,7 +93,7 @@ prefix '/dashboard/users' => sub {
my $total_users = $all;
my $posts_per_page = $nr_of_rows;
my $current_page = $page;
my $pages_per_set = 7;
my $pages_per_set = config->{pages_per_set};
my $pagination
= generate_pagination_numbering( $total_users, $posts_per_page,
$current_page, $pages_per_set );
Expand Down
3 changes: 1 addition & 2 deletions lib/PearlBee/Posts.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use PearlBee::Helpers::Captcha;

prefix '/posts' => sub {
get '' => sub {
my $nr_of_rows
= config->{'posts_on_page'} || 5; # Number of posts per page
my $nr_of_rows = config->{'posts_on_page'};
my $page = query_parameters->{'page'} || 1; # for paging
my @posts = resultset('Post')->search(
{ status => 'published' },
Expand Down