-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
47 changed files
with
2,989 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule error
added at
15748f
Submodule markdown-notices
added at
b7b896
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# v1.4.2 | ||
## 05/09/2019 | ||
|
||
1. [](#new) | ||
* Add active class for active page [#37](https://github.com/getgrav/grav-plugin-pagination/pull/37) | ||
* Added `ru` and `uk` translations [#38](https://github.com/getgrav/grav-plugin-pagination/pull/38) | ||
|
||
# v1.4.1 | ||
## 08/28/2018 | ||
|
||
1. [](#bugfix) | ||
* Reverted Twig fix to address broken `url` in Twig [#34](https://github.com/getgrav/grav-plugin-pagination/issues/34) | ||
* Removed duplicate README text [#30](https://github.com/getgrav/grav-plugin-pagination/issues/30) | ||
|
||
# v1.4.0 | ||
## 08/20/2018 | ||
|
||
1. [](#new) | ||
* Added Twig pagination function [#22](https://github.com/getgrav/grav-plugin-pagination/pull/22) | ||
1. [](#improved) | ||
* Removed Grav trait in favor of `Grav::instance()` | ||
* Changed delta blueprint type from `text` to `number` | ||
* Code cleanup | ||
|
||
# v1.3.2 | ||
## 05/03/2016 | ||
|
||
1. [](#new) | ||
* Added default pagination to `page.collection.params.pagination` and `base_url` to `page.url` | ||
1. [](#improved) | ||
* Use common lang strings in blueprints | ||
1. [](#bugfix) | ||
* Improved and fixed README.md | ||
|
||
# v1.3.1 | ||
## 08/29/2015 | ||
|
||
1. [](#bugfix) | ||
* Fixed pagination URLs in certain situations | ||
|
||
# v1.3.0 | ||
## 08/25/2015 | ||
|
||
1. [](#improved) | ||
* Added blueprints for Grav Admin plugin | ||
|
||
# v1.2.7 | ||
## 07/13/2015 | ||
|
||
1. [](#new) | ||
* Added ability to provide `/tmpl:template_name` parameter to pagination URL | ||
2. [](#improved) | ||
* Allow checking of `header.content.pagination` **or** `header.pagination` to activate | ||
|
||
# v1.2.6 | ||
## 07/12/2015 | ||
|
||
2. [](#improved) | ||
* no `/page:1` for first page in pagination set | ||
|
||
# v1.2.5 | ||
## 02/19/2015 | ||
|
||
2. [](#improved) | ||
* Implemented new `param_sep` variable from Grav 0.9.18 | ||
|
||
# v1.2.4 | ||
## 02/05/2015 | ||
|
||
2. [](#improved) | ||
* Added support for HHVM | ||
|
||
# v1.2.3 | ||
## 01/23/2015 | ||
|
||
2. [](#improved) | ||
* Added microdata information for links | ||
|
||
# v1.2.2 | ||
## 01/09/2015 | ||
|
||
2. [](#improved) | ||
* NOTE: BREAKING CHANGE: Moved templates into `partials/` subfolder for consistency. | ||
|
||
# v1.2.1 | ||
## 11/30/2014 | ||
|
||
1. [](#new) | ||
* ChangeLog started... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 Grav | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# Grav Pagination Plugin | ||
|
||
|
||
`Pagination` is a [Grav][grav] Plugin that allows to divide articles into discrete pages. | ||
|
||
|
||
# Installation | ||
|
||
To install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `pagination`. | ||
|
||
You should now have all the plugin files under | ||
|
||
/your/site/grav/user/plugins/pagination | ||
|
||
>> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav), the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) plugins, and a theme to be installed in order to operate. | ||
# Config Defaults | ||
|
||
``` | ||
enabled: true | ||
built_in_css: true | ||
delta: 0 | ||
``` | ||
|
||
The 'delta' value controls how many pages left and right of the current page are visible. If set to 0 all pages will be shown. | ||
|
||
If you need to change any value, then the best process is to copy the [pagination.yaml](pagination.yaml) file into your `users/config/plugins/` folder (create it if it doesn't exist), and then modify there. This will override the default settings. | ||
|
||
# Usage for content authors | ||
|
||
To use this plugin: | ||
|
||
- the `pagination` plugin must be installed and enabled | ||
- the active theme must have pagination support (most Grav themes support pagination; if you’re building your own theme, see the next section for adding pagination support) | ||
|
||
On the content side, you should have a blog-like structure, for example: | ||
|
||
``` | ||
blog/ | ||
blog.md | ||
my-cool-blog-post/ | ||
item.md | ||
another-post/ | ||
item.md | ||
``` | ||
|
||
Then in your `blog.md`, set up the page’s collection using YAML front-matter: | ||
|
||
```yaml | ||
--- | ||
title: My Gravtastic Blog | ||
content: | ||
items: '@self.children' | ||
order: | ||
by: header.date | ||
dir: desc | ||
pagination: true | ||
limit: 10 | ||
--- | ||
|
||
# My Gravtastic Blog | ||
## A tale of **awesomazing** adventures | ||
``` | ||
|
||
Your `/blog` page should now list the 10 most recent blog posts, and show pagination links. | ||
|
||
|
||
# Usage for theme developers | ||
|
||
### Including the default pagination template | ||
|
||
If you are developing your own theme and want to support pagination, you need to include the pagination template in the relevant pages. For instance in `blog.html.twig`: | ||
|
||
```twig | ||
{# /your/site/grav/user/themes/custom-theme/templates/blog.html.twig #} | ||
{% set collection = page.collection() %} | ||
{# Render the list of blog posts (automatically filtered when using pagination) #} | ||
{% for child in collection %} | ||
... | ||
{% endfor %} | ||
{# Render the pagination list #} | ||
{% if config.plugins.pagination.enabled and collection.params.pagination %} | ||
{% include 'partials/pagination.html.twig' with {'base_url':page.url, 'pagination':collection.params.pagination} %} | ||
{% endif %} | ||
``` | ||
|
||
### Overriding the pagination HTML | ||
|
||
If you want to override the look and feel of the pagination, copy the template file [pagination.html.twig][pagination] into the templates folder of your custom theme: | ||
|
||
``` | ||
/your/site/grav/user/themes/custom-theme/templates/partials/pagination.html.twig | ||
``` | ||
|
||
You can now edit the override and tweak it to meet your needs. | ||
|
||
[pagination]: templates/partials/pagination.html.twig | ||
[grav]: http://github.com/getgrav/grav | ||
|
||
# Twig pagination function | ||
|
||
It is now possible to create paginated collections on demand in your twig file. You only need to: | ||
|
||
* activate the pagination plugin | ||
* pick or create the collection you want | ||
* paginate it | ||
* render the paginated collection | ||
|
||
## Creating a paginated collection | ||
|
||
### Basic usage | ||
|
||
```twig | ||
{# some collection #} | ||
{% set collection = page.collection() %} | ||
{# number of items per page #} | ||
{% set limit = 5 %} | ||
{% do paginate( collection, limit ) %} | ||
``` | ||
|
||
This creates a paginated collection with `limit` items per page. As usual, any url parameters - except the page parameter, which is recreated - are passed on to the pagination bar's links. | ||
|
||
### Extended usage | ||
|
||
```twig | ||
{% set collection = page.find( '/other/_events' ).children %} | ||
{% set limit = 5 %} | ||
{% set ignore_url_param_array = [ 'event' ] %} | ||
{% do paginate( collection, limit, ignore_url_param_array ) %} | ||
``` | ||
|
||
The above example is taken from http://ami-web.nl/events. This code creates a paginated collection with 5 items per page (the event summary list) which is presented together with an active event. The active event appears in only one of the summary pages. Consequently, the url parameter 'event' should be filtered out so it does not show up in the pagination bar's links, preventing inconsistencies with different page parameters. Any non listed url parameters (except the page parameter) are passed through unaffected. The requested page contains logic to pick a sensible default event. | ||
|
||
### Rendering the paginated collection | ||
|
||
The rest is identical to the standard procedure: | ||
|
||
```twig | ||
{# create list of items #} | ||
{% for item in collection %} | ||
... | ||
{% endfor %} | ||
{# include the pagination bar #} | ||
{% if config.plugins.pagination.enabled and collection.params.pagination %} | ||
{% include 'partials/pagination.html.twig' with {'base_url':page.url, 'pagination':collection.params.pagination} %} | ||
{% endif %} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Pagination | ||
version: 1.4.2 | ||
description: "**Pagination** is a very useful plugin to help navigate a large collection of pages, such as for a **blog**." | ||
icon: list-ol | ||
author: | ||
name: Team Grav | ||
email: [email protected] | ||
url: http://getgrav.org | ||
homepage: https://github.com/getgrav/grav-plugin-pagination | ||
keywords: pagination, plugin, pages, navigation | ||
bugs: https://github.com/getgrav/grav-plugin-pagination/issues | ||
license: MIT | ||
|
||
form: | ||
validation: strict | ||
fields: | ||
enabled: | ||
type: toggle | ||
label: PLUGIN_ADMIN.PLUGIN_STATUS | ||
highlight: 1 | ||
default: 0 | ||
options: | ||
1: PLUGIN_ADMIN.ENABLED | ||
0: PLUGIN_ADMIN.DISABLED | ||
validate: | ||
type: bool | ||
|
||
delta: | ||
type: number | ||
size: x-small | ||
label: PLUGIN_PAGINATION.DELTA | ||
default: 0 | ||
help: PLUGIN_PAGINATION.DELTA_HELP | ||
validate: | ||
type: number | ||
min: 0 | ||
|
||
built_in_css: | ||
type: toggle | ||
label: PLUGIN_PAGINATION.BUILTIN_CSS | ||
help: PLUGIN_PAGINATION.BUILTIN_CSS_HELP | ||
highlight: 1 | ||
default: 1 | ||
options: | ||
1: PLUGIN_ADMIN.ENABLED | ||
0: PLUGIN_ADMIN.DISABLED | ||
validate: | ||
type: bool |
Oops, something went wrong.