mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
Number of posts per page is now configurable through .env
This commit is contained in:
@@ -6,3 +6,4 @@ POSTGRES_PASSWORD=yourpasswordhere
|
|||||||
APP_NAME="You App Name Here"
|
APP_NAME="You App Name Here"
|
||||||
|
|
||||||
EMAIL_CONFIRMATION=0
|
EMAIL_CONFIRMATION=0
|
||||||
|
POSTS_PER_PAGE=15
|
||||||
1
app/javascript/constants/index.js
Normal file
1
app/javascript/constants/index.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export const POSTS_PER_PAGE = parseInt(process.env.POSTS_PER_PAGE);
|
||||||
@@ -5,6 +5,8 @@ import { FiltersState } from './filtersReducer';
|
|||||||
import postReducer from './postReducer';
|
import postReducer from './postReducer';
|
||||||
import filtersReducer from './filtersReducer';
|
import filtersReducer from './filtersReducer';
|
||||||
|
|
||||||
|
import { POSTS_PER_PAGE } from '../constants';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
PostsRequestActionTypes,
|
PostsRequestActionTypes,
|
||||||
POSTS_REQUEST_START,
|
POSTS_REQUEST_START,
|
||||||
@@ -60,7 +62,7 @@ const postsReducer = (
|
|||||||
:
|
:
|
||||||
[...state.items, ...action.posts.map(post => postReducer(undefined, postRequestSuccess(post)))],
|
[...state.items, ...action.posts.map(post => postReducer(undefined, postRequestSuccess(post)))],
|
||||||
page: action.page,
|
page: action.page,
|
||||||
haveMore: action.posts.length === 15,
|
haveMore: action.posts.length === POSTS_PER_PAGE,
|
||||||
areLoading: false,
|
areLoading: false,
|
||||||
error: '',
|
error: '',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Post < ApplicationRecord
|
|||||||
|
|
||||||
validates :title, presence: true, length: { in: 4..64 }
|
validates :title, presence: true, length: { in: 4..64 }
|
||||||
|
|
||||||
paginates_per 15
|
paginates_per Rails.application.posts_per_page
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def find_with_post_status_in(post_statuses)
|
def find_with_post_status_in(post_statuses)
|
||||||
|
|||||||
@@ -23,5 +23,9 @@ module App
|
|||||||
def email_confirmation?
|
def email_confirmation?
|
||||||
ENV["EMAIL_CONFIRMATION"] == "1"
|
ENV["EMAIL_CONFIRMATION"] == "1"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def posts_per_page
|
||||||
|
ENV["POSTS_PER_PAGE"].to_i
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user