jekyll-paginate-v2 1.3.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -1
  3. data/README.md +107 -3
  4. data/examples/01-typicalblog/Gemfile +28 -0
  5. data/examples/01-typicalblog/README.md +91 -0
  6. data/examples/01-typicalblog/_config.yml +51 -0
  7. data/examples/01-typicalblog/_includes/header.html +31 -0
  8. data/examples/01-typicalblog/_layouts/home.html +52 -0
  9. data/examples/01-typicalblog/_posts/2016-11-20-geography-of-minneapolis.md +29 -0
  10. data/examples/01-typicalblog/_posts/2016-11-21-sailing-summer-olympics-1988.md +15 -0
  11. data/examples/01-typicalblog/_posts/2016-11-22-rotary-engine.md +27 -0
  12. data/examples/01-typicalblog/_posts/2016-11-23-luft-fahrzeug-gesellschaft.md +27 -0
  13. data/examples/01-typicalblog/_posts/2016-11-24-narcisse-snake-pits.md +18 -0
  14. data/examples/01-typicalblog/_posts/2016-11-25-tele7jours.md +43 -0
  15. data/examples/01-typicalblog/_posts/2016-11-26-columbia-river.md +41 -0
  16. data/examples/01-typicalblog/_posts/2016-11-27-welcome-to-jekyll-paginate-v2.md +33 -0
  17. data/examples/01-typicalblog/about.md +15 -0
  18. data/examples/01-typicalblog/index.html +8 -0
  19. data/examples/02-category/Gemfile +28 -0
  20. data/examples/02-category/README.md +119 -0
  21. data/examples/02-category/_config.yml +47 -0
  22. data/examples/02-category/_includes/header.html +31 -0
  23. data/examples/02-category/_layouts/home.html +52 -0
  24. data/examples/02-category/_posts/2016-10-27-welcome-to-jekyll-paginate-v2.md +32 -0
  25. data/examples/02-category/about.md +15 -0
  26. data/examples/02-category/cars/_posts/2016-10-18-Porsche-918-Spyder.md +13 -0
  27. data/examples/02-category/cars/_posts/2016-10-19-Porsche-964.md +12 -0
  28. data/examples/02-category/cars/_posts/2016-10-20-porsche-911-gt3.md +13 -0
  29. data/examples/02-category/cars/_posts/2016-10-21-porsche-911.md +13 -0
  30. data/examples/02-category/cars/_posts/2016-10-22-porsche-962.md +18 -0
  31. data/examples/02-category/cars/_posts/2016-10-23-Toyota-GT-One.md +20 -0
  32. data/examples/02-category/cars/_posts/2016-10-24-Mercedes-Benz-CLK-GTR.md +40 -0
  33. data/examples/02-category/cars/_posts/2016-10-25-rolls-royce-silver-ghost.md +31 -0
  34. data/examples/02-category/categories/byname.md +11 -0
  35. data/examples/02-category/categories/porsche.md +10 -0
  36. data/examples/02-category/index.md +13 -0
  37. data/examples/02-category/toyota/index.md +7 -0
  38. data/examples/03-tags/Gemfile +28 -0
  39. data/examples/03-tags/README.md +60 -0
  40. data/examples/03-tags/_config.yml +45 -0
  41. data/examples/03-tags/_includes/header.html +31 -0
  42. data/examples/03-tags/_layouts/home.html +51 -0
  43. data/examples/03-tags/_layouts/post.html +20 -0
  44. data/examples/03-tags/biography/_posts/2016-10-27-born-to-run.md +26 -0
  45. data/examples/03-tags/biography/_posts/2016-10-27-forty-autumns.md +26 -0
  46. data/examples/03-tags/biography/_posts/2016-10-27-life-in-questions-a.md +27 -0
  47. data/examples/03-tags/biography/_posts/2016-10-27-not-dead-yet.md +24 -0
  48. data/examples/03-tags/biography/_posts/2016-10-27-princess-diarist-the.md +26 -0
  49. data/examples/03-tags/biography/_posts/2016-10-27-when-breath-becomes-air.md +24 -0
  50. data/examples/03-tags/biography/biography-musicians.md +13 -0
  51. data/examples/03-tags/biography/biography.md +12 -0
  52. data/examples/03-tags/blog/_posts/2016-09-30-welcome-to-jekyll-paginate-v2.md +32 -0
  53. data/examples/03-tags/byisbn.md +13 -0
  54. data/examples/03-tags/fantasy/_posts/2016-10-27-harry-potter-deathly-hallows.md +24 -0
  55. data/examples/03-tags/fantasy/_posts/2016-10-27-harry-potter-philosophers-stone.md +24 -0
  56. data/examples/03-tags/fantasy/_posts/2016-10-27-mistborn-trilogy.md +24 -0
  57. data/examples/03-tags/fantasy/_posts/2016-10-27-ready-player-one.md +24 -0
  58. data/examples/03-tags/fantasy/_posts/2016-10-27-sword-of-destiny.md +24 -0
  59. data/examples/03-tags/fantasy/_posts/2016-10-27-terry-pratchet-diary-2017.md +24 -0
  60. data/examples/03-tags/index.md +18 -0
  61. data/examples/03-tags/romance/_posts/2016-10-27-breath-of-snow-and-ashes-a.md +25 -0
  62. data/examples/03-tags/romance/_posts/2016-10-27-dressmaker-the.md +24 -0
  63. data/examples/03-tags/romance/_posts/2016-10-27-fiery-cross-the.md +26 -0
  64. data/examples/03-tags/romance/_posts/2016-10-27-it-ends-with-us.md +28 -0
  65. data/examples/03-tags/romance/_posts/2016-10-27-outlander-novel.md +34 -0
  66. data/examples/03-tags/romance/_posts/2016-10-27-virgins-outlander-short-story.md +26 -0
  67. data/examples/03-tags/romance/romance-historical.md +14 -0
  68. data/examples/03-tags/tags/contemporary.md +10 -0
  69. data/examples/03-tags/tags/fantasy.md +12 -0
  70. data/examples/03-tags/tags/sci-fi.md +13 -0
  71. data/examples/README.md +21 -0
  72. data/examples/img/01-example-screenshot-main.png +0 -0
  73. data/examples/img/02-example-screenshot-main.png +0 -0
  74. data/examples/img/03-example-screenshot-main.png +0 -0
  75. data/lib/jekyll-paginate-v2.rb +1 -0
  76. data/lib/jekyll-paginate-v2/compatibilityUtils.rb +4 -3
  77. data/lib/jekyll-paginate-v2/paginationGenerator.rb +15 -8
  78. data/lib/jekyll-paginate-v2/paginationModel.rb +58 -37
  79. data/lib/jekyll-paginate-v2/paginationPage.rb +38 -0
  80. data/lib/jekyll-paginate-v2/paginator.rb +3 -3
  81. data/lib/jekyll-paginate-v2/utils.rb +47 -1
  82. data/lib/jekyll-paginate-v2/version.rb +2 -2
  83. data/spec/spec_helper.rb +1 -0
  84. metadata +74 -2
@@ -0,0 +1,24 @@
1
+ ---
2
+ layout: post
3
+ title: Sword of Destiny
4
+ date: 2016-10-27 19:16:49 +0100
5
+ author: Andrzej Sapkowski
6
+ book:
7
+ cover: https://d4rri9bdfuube.cloudfront.net/assets/images/book/large/9781/4732/9781473211544.jpg
8
+ format: paperback
9
+ pages: 400
10
+ publisher: Orion Publishing Co
11
+ ISBN10: 1473211549
12
+ ISBN13: 9781473211544
13
+ rank: 1305
14
+ price:
15
+ usd: 11.72
16
+ eur: 11.07
17
+ tags: Fantasy, Knights
18
+ ---
19
+
20
+ Geralt is a witcher, a man whose magic powers, enhanced by long training and a mysterious elixir, have made him a brilliant fighter and a merciless assassin. Yet he is no ordinary murderer: his targets are the multifarious monsters and vile fiends that ravage the land and attack the innocent.
21
+
22
+ He roams the country seeking assignments, but gradually comes to realise that while some of his quarry are unremittingly vile, vicious grotesques, others are the victims of sin, evil or simple naivety.
23
+
24
+ In this collection of short stories, following the adventures of the hit collection THE LAST WISH, join Geralt as he battles monsters, demons and prejudices alike ...
@@ -0,0 +1,24 @@
1
+ ---
2
+ layout: post
3
+ title: The Terry Pratchett Diary 2017
4
+ date: 2016-10-27 19:16:49 +0100
5
+ author: Terry Pratchett
6
+ book:
7
+ cover: https://d39ttiideeq0ys.cloudfront.net/assets/images/book/large/9781/4732/9781473208339.jpg
8
+ format: hardback
9
+ pages: 128
10
+ publisher: Orion Publishing Co
11
+ ISBN10: 1473208335
12
+ ISBN13: 9781473208339
13
+ rank: 4576
14
+ price:
15
+ usd: 22.19
16
+ eur: 20.97
17
+ tags: Fantasy, Humor
18
+ ---
19
+
20
+ Sir Terry Pratchett left us, far too early, in March 2015. To celebrate his life and works, we've given over the 2017 Discworld Diary - which will be a perennial diary - to remembrances and tributes from some of those who knew and loved him and his extraordinary body of work.
21
+
22
+ Contributors include Neil Gaiman, A S Byatt, Terry Pratchett's literary agent Colin Smythe, co-author of the Long Earth books Stephen Baxter, famed bookseller Rog Peyton, and many more.
23
+
24
+ With an introduction from his daughter Rhianna Pratchett and an afterword from longtime friend and colleague Rob Wilkins.
@@ -0,0 +1,18 @@
1
+ ---
2
+ # You don't need to edit this file, it's empty on purpose.
3
+ # Edit theme's home layout instead if you wanna make some changes
4
+ # See: https://jekyllrb.com/docs/themes/#overriding-theme-defaults
5
+ layout: home
6
+ title: Home
7
+ pagination:
8
+ enabled: true
9
+ sort_field: 'title'
10
+ sort_reverse: false
11
+ ---
12
+
13
+
14
+ <p>This page lists all posts available and paginates them in ascending order by title.</p>
15
+
16
+
17
+ <p>Try clicking the category pages at the top of this page.</p>
18
+
@@ -0,0 +1,25 @@
1
+ ---
2
+ layout: post
3
+ title: A Breath of Snow and Ashes
4
+ date: 2016-10-27 19:16:49 +0100
5
+ author: Diana Gabaldon
6
+ book:
7
+ cover: https://d1w7fb2mkkr3kw.cloudfront.net/assets/images/book/large/9780/4402/9780440225805.jpg
8
+ format: paperback
9
+ pages: 1438
10
+ publisher: Random House USA Inc
11
+ ISBN10: 0440225809
12
+ ISBN13: 9780440225805
13
+ rank: 844
14
+ price:
15
+ usd: 10.35
16
+ eur: 9.78
17
+ tags: Historical,Fantasy, Romance, Science, Fiction
18
+ ---
19
+
20
+ Eagerly anticipated by her legions of fans, this sixth novel in Diana Gabaldon s bestselling Outlander saga is a masterpiece of historical fiction from one of the most popular authors of our time.
21
+
22
+ Since the initial publication of Outlander fifteen years ago, Diana Gabaldon s "New York Times" bestselling saga has won the hearts of readers the world over and sold more than twelve million books. Now, A Breath of Snow and Ashes continues the extraordinary story of 18th-century Scotsman Jamie Fraser and his 20th-century wife, Claire.
23
+ The year is 1772, and on the eve of the American Revolution, the long fuse of rebellion has already been lit. Men lie dead in the streets of Boston, and in the backwoods of North Carolina, isolated cabins burn in the forest. With chaos brewing, the governor calls upon Jamie Fraser to unite the backcountry and safeguard the colony for King and Crown.
24
+
25
+ But from his wife Jamie knows that three years hence the shot heard round the world will be fired, and the result will be independence with those loyal to the King either dead or in exile. And there is also the matter of a tiny clipping from "The Wilmington Gazette," dated 1776, which reports Jamie s death, along with his kin. For once, he hopes, his time-traveling family may be wrong about the future. "From the Hardcover edition.""
@@ -0,0 +1,24 @@
1
+ ---
2
+ layout: post
3
+ title: The Dressmaker
4
+ date: 2016-10-27 19:16:49 +0100
5
+ author: Rosalie Ham
6
+ book:
7
+ cover: https://d20eq91zdmkqd.cloudfront.net/assets/images/book/large/9781/8466/9781846689949.jpg
8
+ format: paperback
9
+ pages: 320
10
+ publisher: Profile Books Ltd
11
+ ISBN10: 1846689945
12
+ ISBN13: 9781846689949
13
+ rank: 80
14
+ price:
15
+ usd: 10.44
16
+ eur: 9.86
17
+ tags: Contemporary, Fiction, Romance,Historical
18
+ ---
19
+
20
+ Tilly Dunnage left her hometown of Dungatar in rural Australia under a black cloud of accusation. Years later Tilly, now a couturier for the Paris fashion houses, returns home to make amends with her mentally unstable mother.
21
+
22
+ Mid-century Dungatar is a small town, and small towns have long memories. At first she wins over the suspicious locals with her extraordinary dressmaking skills. But when the eccentric townsfolk turn on Tilly for a second time, she decides to teach them a lesson and exact long-overdue revenge...
23
+
24
+ Packed with memorable characters, acid humour and luscious clothes, The Dressmaker is an irresistible gothic tale of small-town revenge.
@@ -0,0 +1,26 @@
1
+ ---
2
+ layout: post
3
+ title: The Fiery Cross
4
+ date: 2016-10-27 19:16:49 +0100
5
+ author: Diana Gabaldon
6
+ book:
7
+ cover: https://d20eq91zdmkqd.cloudfront.net/assets/images/book/large/9780/4402/9780440221661.jpg
8
+ format: paperback
9
+ pages: 1443
10
+ publisher: Random House USA Inc
11
+ ISBN10: 0440221668
12
+ ISBN13: 9780440221661
13
+ rank: 820
14
+ price:
15
+ usd: 10.86
16
+ eur: 10.26
17
+ tags: Historical, Fantasy, Romance, Fiction
18
+ ---
19
+
20
+ Crossing the boundaries of genre with its unrivalled storytelling, Diana Gabaldon s new novel is a gift both to her millions of loyal fans and to the lucky readers who have yet to discover her.
21
+
22
+ In the ten years since her extraordinary debut novel, Outlander, was published, beloved author Diana Gabaldon has entertained scores of readers with her heart-stirring stories and remarkable characters. The four volumes of her bestselling saga, featuring eighteenth-century Scotsman James Fraser and his twentieth-century, time-travelling wife, Claire Randall, boasts nearly 5 million copies in the U.S.
23
+
24
+ The story of Outlander begins just after the Second World War, when a British field nurse named Claire Randall walks through a cleft stone in the Scottish highlands and is transported back some two hundred years to 1743. Here, now, is The Fiery Cross, the eagerly awaited fifth volume in this remarkable, award-winning series of historical novels. The year is 1771, and war is approaching. Jamie Fraser s wife has told him so.
25
+
26
+ Little as he wishes to, he must believe it, for hers is a gift of dreadful prophecy a time-traveller s certain knowledge. To break his oath to the Crown will brand him a traitor; to keep it is certain doom. Jamie Fraser stands in the shadow of the fiery cross a standard that leads nowhere but to the bloody brink of war.
@@ -0,0 +1,28 @@
1
+ ---
2
+ layout: post
3
+ title: It Ends with Us
4
+ date: 2016-10-27 19:16:49 +0100
5
+ author: Colleen Hoover
6
+ book:
7
+ cover: https://d1w7fb2mkkr3kw.cloudfront.net/assets/images/book/large/9781/4711/9781471156267.jpg
8
+ format: paperback
9
+ pages: 384
10
+ publisher: Simon and Schuster Ltd
11
+ ISBN10: 1471156265
12
+ ISBN13: 9781471156267
13
+ rank: 355
14
+ price:
15
+ usd: 10.51
16
+ eur: 9.93
17
+ tags: Tragic, Romance
18
+ ---
19
+
20
+ SOMETIMES THE ONE WHO LOVES YOU IS THE ONE WHO HURTS YOU THE MOST.
21
+
22
+ Lily hasn't always had it easy, but that's never stopped her from working hard for the life she wants. She's come a long way from the small town in Maine where she grew up - she graduated from college, moved to Boston, and started her own business.
23
+
24
+ So when she feels a spark with a gorgeous neurosurgeon named Ryle Kincaid, everything in Lily's life suddenly seems almost too good to be true. Ryle is assertive, stubborn, maybe even a little arrogant. He's also sensitive, brilliant, and has a total soft spot for Lily, but Ryle's complete aversion to relationships is disturbing.
25
+
26
+ As questions about her new relationship overwhelm her, so do thoughts of Atlas Corrigan - her first love and a link to the past she left behind. He was her kindred spirit, her protector. When Atlas suddenly reappears, everything Lily has built with Ryle is threatened.
27
+
28
+ With this bold and deeply personal novel, Colleen Hoover delivers a heart-wrenching story that breaks exciting new ground for her as a writer. It Ends With Us is an unforgettable tale of love that comes at the ultimate price.
@@ -0,0 +1,34 @@
1
+ ---
2
+ layout: post
3
+ title: Outlander
4
+ date: 2016-10-27 19:16:49 +0100
5
+ author: Diana Gabaldon
6
+ book:
7
+ cover: https://d4rri9bdfuube.cloudfront.net/assets/images/book/large/9780/4402/9780440212560.jpg
8
+ format: paperback
9
+ pages: 850
10
+ publisher: Bantam Doubleday Dell Publishing Group Inc
11
+ ISBN10: 0440212561
12
+ ISBN13: 9780440212560
13
+ rank: 297
14
+ price:
15
+ usd: 9.20
16
+ eur: 8.69
17
+ tags: Contemporary,Fiction,Fantasy,Romance,Historical
18
+ ---
19
+
20
+ Claire Randall is leading a double life. She has a husband in one century, and a lover in another...
21
+
22
+ In 1945, Claire Randall, a former combat nurse, is back from the war and reunited with her husband on a second honeymoon--when she innocently touches aboulder in one of the ancient stone circles that dot the British Isles. Suddenly she is a Sassenach--an "outlander"--in a Scotland torn by war and raiding border clans in the year of our Lord...1743.
23
+
24
+ Hurled back in time by forces she cannot understand, Claire's destiny in soon inextricably intertwined with Clan MacKenzie and the forbidden Castle Leoch. She is catapulted without warning into the intrigues of lairds and spies that may threaten her life ...and shatter her heart.
25
+
26
+ For here, James Fraser, a gallant young Scots warrior, shows her a passion so fierce and a love so absolute that Claire becomes a woman torn between fidelity and desire...and between two vastly different men in two irreconcilable lives.
27
+
28
+ ---
29
+
30
+ "Absorbing and heartwarming...lavishly evokes the land and lore of Scotland." "--Publishers Weekly"
31
+
32
+ "Stunning!" "--Los Angeles Daily News"
33
+
34
+ "It is a large canvas that Gabaldon paints, filled with strong passions and derring-do. Strong willed and sensual, Claire is an engaging modern heroine plopped down in a simpler, more primitive time.... Great fun ...marvelous and fantastic adventures, romance, sex ...perfect escape reading!" "--San Francisco Chronicle"
@@ -0,0 +1,26 @@
1
+ ---
2
+ layout: post
3
+ title: "Virgins: An Outlander Short Story"
4
+ date: 2016-10-27 19:16:49 +0100
5
+ author: Diana Gabaldon
6
+ book:
7
+ cover: https://d4rri9bdfuube.cloudfront.net/assets/images/book/large/9781/7808/9781780896618.jpg
8
+ format: hardback
9
+ pages: 256
10
+ publisher: Cornerstone
11
+ ISBN10: 1780896611
12
+ ISBN13: 9781780896618
13
+ rank: 701
14
+ price:
15
+ usd: 13.04
16
+ eur: 12.32
17
+ tags: Historical, Adventure, Romance
18
+ ---
19
+
20
+ FIND OUT WHAT HAPPENED BEFORE JAMIE MET CLAIRE IN THIS BRILLIANT NEW OUTLANDER SHORT STORY.
21
+
22
+ 1740: Young Jamie Fraser has left Scotland and, with his best friend Ian Murray, is running with a band of mercenaries in France.
23
+
24
+ Both men have good reason not to go back to their homeland: both are nursing wounds, and despite their best efforts to remedy the situation, both are still virgins. So when a Jewish doctor hires them to escort his granddaughter to Paris, they readily agree. Both men are instantly drawn to the beautiful young lady.
25
+
26
+ What neither know is that their lives and their friendships are about to become infinitely more complicated - and a lot more dangerous...
@@ -0,0 +1,14 @@
1
+ ---
2
+ layout: home
3
+ title: Historical Romance
4
+ pagination:
5
+ enabled: true
6
+ category: romance
7
+ tag: historical, fiction
8
+ per_page: 2
9
+ permalink: /:num/
10
+ sort_field: 'book:rank'
11
+ sort_reverse: false
12
+ ---
13
+
14
+ All books in category _romance_ that are also tagged with _historical_ and _fiction_
@@ -0,0 +1,10 @@
1
+ ---
2
+ layout: home
3
+ title: Contemporary
4
+ pagination:
5
+ enabled: true
6
+ tag: contemporary
7
+ permalink: /:num/
8
+ ---
9
+
10
+ All books tagged with _Contemporary_
@@ -0,0 +1,12 @@
1
+ ---
2
+ layout: home
3
+ title: Fantasy
4
+ pagination:
5
+ enabled: true
6
+ tag: fantasy
7
+ permalink: /:num/
8
+ sort_field: 'book:rank'
9
+ sort_reverse: false
10
+ ---
11
+
12
+ All books tagged with _Fantasy_
@@ -0,0 +1,13 @@
1
+ ---
2
+ layout: home
3
+ title: Sci-Fi
4
+ pagination:
5
+ enabled: true
6
+ tag: Science, Fiction
7
+ per_page: 2
8
+ permalink: /:num/
9
+ sort_field: 'book:rank'
10
+ sort_reverse: false
11
+ ---
12
+
13
+ All books tagged with _science_ and _fiction_
@@ -0,0 +1,21 @@
1
+ # Jekyll::Paginate V2::Examples
2
+
3
+ Here are a few example sites that use the new jekyll-paginate-v2 gem. They can serve as a help and guide on the nitty gritty details of configuring the gem and leveraging its more advanced features.
4
+
5
+ Please feel free to fork and play around with this code to quickly test out different scenarios and site structures.
6
+
7
+ All examples are generated from running the `jekyll new .` command and they all use the [default `minima` theme](https://github.com/jekyll/minima).
8
+
9
+ ## Example 1: Typical Blog
10
+ Simple blog that only has one type of post pages. The index.html page does the pagination.
11
+
12
+ This example also demonstrates how the page can operate as a zero-config replacement for the old [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) gem.
13
+
14
+ ## Example 2: Category Pagination
15
+ Car site that has multiple paginated pages and multiple post categories.
16
+
17
+ ## Example 3: Tag Pagination
18
+ Book review site that organizes its content by tags and categories. Uses the `pretty` permalink structure for the site.
19
+
20
+ This site also demonstrates how to sort posts by nested front-matter attributes.
21
+
@@ -14,6 +14,7 @@ require "jekyll-paginate-v2/defaults"
14
14
  require "jekyll-paginate-v2/compatibilityUtils"
15
15
  require "jekyll-paginate-v2/utils"
16
16
  require "jekyll-paginate-v2/paginator"
17
+ require "jekyll-paginate-v2/paginationPage"
17
18
  require "jekyll-paginate-v2/paginationModel"
18
19
  require "jekyll-paginate-v2/paginationGenerator"
19
20
 
@@ -51,11 +51,12 @@ module Jekyll
51
51
  def self.paginate(legacy_config, all_posts, page, page_create_lambda, logging_lambda )
52
52
  pages = Utils.calculate_number_of_pages(all_posts, legacy_config['per_page'].to_i)
53
53
  (1..pages).each do |num_page|
54
- pager = Paginator.new( legacy_config['per_page'], legacy_config['permalink'], all_posts, num_page, pages, page.url )
54
+ pager = Paginator.new( legacy_config['per_page'], legacy_config['permalink'], all_posts, num_page, pages, page.url, page.path )
55
55
  if num_page > 1
56
- newpage = page_create_lambda.call( page.dir, page.name )
56
+ newpage = page_create_lambda.call( page.path )
57
57
  newpage.pager = pager
58
- newpage.dir = Utils.paginate_path(page.url, num_page, legacy_config['permalink'])
58
+ newpage.dir = Utils.paginate_path(page.url, page.path, num_page, legacy_config['permalink'])
59
+ newpage.data['autogen'] = "jekyll-paginate-v2" # Signals that this page is automatically generated by the pagination logic
59
60
  else
60
61
  page.pager = pager
61
62
  end
@@ -66,13 +66,20 @@ module Jekyll
66
66
  ################ 2 ####################
67
67
  # Create the proc that constructs the real-life site page
68
68
  # This is necessary to decouple the code from the Jekyll site object
69
- page_create_lambda = lambda do | template_dir, template_name |
70
- # Create the new page
71
- newpage = Page.new( site, site.source, template_dir, template_name)
72
- # Add the page to the site so that it is generated correctly
73
- site.pages << newpage
74
- # Return the site to the calling code
75
- return newpage
69
+ page_create_lambda = lambda do | template_path |
70
+ template_full_path = File.join(site.source, template_path)
71
+ template_dir = File.dirname(template_path)
72
+
73
+ # Create the Jekyll page entry for the page
74
+ newpage = PaginationPage.new( site, site.source, template_dir, template_full_path)
75
+ site.pages << newpage # Add the page to the site so that it is generated correctly
76
+ return newpage # Return the site to the calling code
77
+ end
78
+
79
+ ################ 2.5 ####################
80
+ # lambda that removes a page from the site pages list
81
+ page_remove_lambda = lambda do | page_to_remove |
82
+ site.pages.delete_if {|page| page == page_to_remove }
76
83
  end
77
84
 
78
85
  ################ 3 ####################
@@ -96,7 +103,7 @@ module Jekyll
96
103
  if( default_config['legacy'] ) #(REMOVE AFTER 2018-01-01)
97
104
  model.run_compatability(default_config, all_pages, site_title, all_posts, page_create_lambda, logging_lambda) #(REMOVE AFTER 2018-01-01)
98
105
  else
99
- model.run(default_config, all_pages, site_title, all_posts, page_create_lambda, logging_lambda)
106
+ model.run(default_config, all_pages, site_title, all_posts, page_create_lambda, logging_lambda, page_remove_lambda)
100
107
  end
101
108
 
102
109
  end
@@ -3,7 +3,7 @@ module Jekyll
3
3
 
4
4
  class PaginationModel
5
5
 
6
- def run(default_config, site_pages, site_title, all_posts, page_create_lambda, logging_lambda)
6
+ def run(default_config, site_pages, site_title, all_posts, page_create_lambda, logging_lambda, page_remove_lambda)
7
7
  # By default if pagination is enabled we attempt to find all index.html pages in the site
8
8
  templates = self.discover_paginate_templates(site_pages)
9
9
  if( templates.size.to_i <= 0 )
@@ -14,11 +14,11 @@ module Jekyll
14
14
 
15
15
  # Create the necessary indexes for the posts
16
16
  all_categories = self.index_posts_by(all_posts, 'categories')
17
- all_categories['posts'] = all_posts; # Popuplate a category for all posts
17
+ all_categories['posts'] = all_posts; # Populate a category for all posts
18
18
  # (this is a default and must not be used in the category system)
19
19
  all_tags = self.index_posts_by(all_posts, 'tags')
20
20
  all_locales = self.index_posts_by(all_posts, 'locale')
21
-
21
+
22
22
  # Now for each template page generate the paginator for it
23
23
  for template in templates
24
24
  # All pages that should be paginated need to include the pagination config element
@@ -32,7 +32,7 @@ module Jekyll
32
32
  logging_lambda.call "found page: "+template.path
33
33
  # Now construct the pagination data for this template page
34
34
  #self.paginate(site, template, template_config, all_posts, all_tags, all_categories, all_locales)
35
- self.paginate(template, template_config, site_title, all_posts, all_tags, all_categories, all_locales, page_create_lambda, logging_lambda)
35
+ self.paginate(template, template_config, site_title, all_posts, all_tags, all_categories, all_locales, page_create_lambda, logging_lambda, page_remove_lambda)
36
36
  end
37
37
  end
38
38
  end #for
@@ -166,20 +166,7 @@ module Jekyll
166
166
  # The fully filtered final post list
167
167
  return posts
168
168
  end #function read_config_value_and_filter_posts
169
-
170
- #
171
- # Sorting routine used for ordering posts by custom fields.
172
- # Handles Strings separately as we want a case-insenstive sorting
173
- #
174
- def _sort_posts(a, b)
175
- if a.is_a?(String)
176
- return a.downcase <=> b.downcase
177
- end
178
-
179
- # By default use the built in sorting for the data type
180
- return a <=> b
181
- end
182
-
169
+
183
170
  # Paginates the blog's posts. Renders the index.html file into paginated
184
171
  # directories, e.g.: page2/index.html, page3/index.html, etc and adds more
185
172
  # site-wide data.
@@ -188,7 +175,7 @@ module Jekyll
188
175
  # template - The index.html Page that requires pagination.
189
176
  # config - The configuration settings that should be used
190
177
  #
191
- def paginate(template, config, site_title, all_posts, all_tags, all_categories, all_locales, page_create_lambda, logging_lambda)
178
+ def paginate(template, config, site_title, all_posts, all_tags, all_categories, all_locales, page_create_lambda, logging_lambda, page_remove_lambda)
192
179
  # By default paginate on all posts in the site
193
180
  using_posts = all_posts
194
181
 
@@ -200,8 +187,7 @@ module Jekyll
200
187
  # Apply sorting to the posts if configured, any field for the post is available for sorting
201
188
  if config['sort_field']
202
189
  sort_field = config['sort_field'].to_s
203
- using_posts.sort!{ |a,b| self._sort_posts(a.data[sort_field], b.data[sort_field]) }
204
-
190
+ using_posts.sort!{ |a,b| Utils.sort_values(Utils.sort_get_post_data(a, sort_field), Utils.sort_get_post_data(b, sort_field)) }
205
191
  if config['sort_reverse']
206
192
  using_posts.reverse!
207
193
  end
@@ -219,23 +205,58 @@ module Jekyll
219
205
  # This .pager member is a built in thing in Jekyll and defines the paginator implementation
220
206
  # Simpy override to use mine
221
207
  (1..total_pages).each do |cur_page_nr|
222
- pager = Paginator.new( config['per_page'], config['permalink'], using_posts, cur_page_nr, total_pages, template.url )
223
- if( cur_page_nr > 1)
224
- # External Proc call to create the actual page for us (this is passed in when the pagination is run)
225
- newpage = page_create_lambda.call( template.dir, template.name )
226
- newpage.pager = pager
227
- newpage.dir = Utils.paginate_path(template.url, cur_page_nr, config['permalink'])
228
- if( config.has_key?('title_suffix'))
229
- if( !template.data['title'] )
230
- tmp_title = site_title
231
- else
232
- tmp_title = template.data['title']
233
- end
234
-
235
- newpage.data['title'] = "#{tmp_title}#{Utils.format_page_number(config['title_suffix'], cur_page_nr)}"
236
- end
208
+ logging_lambda.call "-------------------------------", 'debug'
209
+ logging_lambda.call "Template.name: "+ template.name, 'debug'
210
+ logging_lambda.call "Template.url: "+ template.url, 'debug'
211
+ logging_lambda.call "Template.dir: "+ template.dir, 'debug'
212
+ logging_lambda.call "Template.basename: "+ template.basename, 'debug'
213
+ logging_lambda.call "Template.path: "+ template.path, 'debug'
214
+ logging_lambda.call "Template.ext: "+ template.ext, 'debug'
215
+
216
+ pager = Paginator.new( config['per_page'], config['permalink'], using_posts, cur_page_nr, total_pages, template.url, template.path )
217
+
218
+ # External Proc call to create the actual page for us (this is passed in when the pagination is run)
219
+ newpage = page_create_lambda.call( template.path )
220
+ newpage.pager = pager
221
+
222
+ # Force the newly created files to live under the same dir as the template plus the permalink structure
223
+ new_path = Utils.paginate_path(template.url, template.path, cur_page_nr, config['permalink'])
224
+ newpage.dir = new_path
225
+
226
+ # Update the permalink for the paginated pages as well if the template had one
227
+ if( template.data['permalink'] )
228
+ newpage.data['permalink'] = new_path
229
+ end
230
+
231
+ # Transfer the title across to the new page
232
+ if( !template.data['title'] )
233
+ tmp_title = site_title
234
+ else
235
+ tmp_title = template.data['title']
236
+ end
237
+ # If the user specified a title suffix to be added then let's add that to all the pages except the first
238
+ if( cur_page_nr > 1 && config.has_key?('title_suffix') )
239
+ newpage.data['title'] = "#{tmp_title}#{Utils.format_page_number(config['title_suffix'], cur_page_nr)}"
237
240
  else
238
- template.pager = pager
241
+ newpage.data['title'] = tmp_title
242
+ end
243
+
244
+
245
+ # Signals that this page is automatically generated by the pagination logic
246
+ # (we don't do this for the first page as it is there to mask the one we removed)
247
+ if cur_page_nr > 1
248
+ newpage.data['autogen'] = "jekyll-paginate-v2"
249
+ end
250
+
251
+ logging_lambda.call "newpage.name: "+ newpage.name, 'debug'
252
+ logging_lambda.call "newpage.url: "+ newpage.url, 'debug'
253
+ logging_lambda.call "newpage.dir: "+ newpage.dir, 'debug'
254
+
255
+ # Only request that the template page be removed from the output once
256
+ # We actually create a dummy page for this actual page in the Jekyll output
257
+ # so we don't need the original page anymore
258
+ if cur_page_nr == 1
259
+ page_remove_lambda.call( template )
239
260
  end
240
261
  end
241
262
  end # function paginate