Skip to content
Permalink
Browse files

Make Page an interface

The main motivation of this commit is to add a `page.Page` interface to replace the very file-oriented `hugolib.Page` struct.
This is all a preparation step for issue  #5074, "pages from other data sources".

But this also fixes a set of annoying limitations, especially related to custom output formats, and shortcodes.

Most notable changes:

* The inner content of shortcodes using the `{{%` as the outer-most delimiter will now be sent to the content renderer, e.g. Blackfriday.
  This means that any markdown will partake in the global ToC and footnote context etc.
* The Custom Output formats are now "fully virtualized". This removes many of the current limitations.
* The taxonomy list type now has a reference to the `Page` object.
  This improves the taxonomy template `.Title` situation and make common template constructs much simpler.

See #5074
Fixes #5763
Fixes #5758
Fixes #5090
Fixes #5204
Fixes #4695
Fixes #5607
Fixes #5707
Fixes #5719
Fixes #3113
Fixes #5706
Fixes #5767
Fixes #5723
Fixes #5769
Fixes #5770
Fixes #5771
Fixes #5759
Fixes #5776
Fixes #5777
Fixes #5778
  • Loading branch information...
bep committed Jan 2, 2019
1 parent 44f5c1c commit 597e418cb02883418f2cebb41400e8e61413f651
Showing with 14,197 additions and 9,434 deletions.
  1. +2 −0 benchbep.sh
  2. +529 −0 codegen/methods.go
  3. +7 −10 hugolib/page_resource.go → codegen/methods2_test.go
  4. +100 −0 codegen/methods_test.go
  5. +8 −1 commands/commandeer.go
  6. +17 −3 commands/commands.go
  7. +17 −4 commands/commands_test.go
  8. +12 −10 commands/convert.go
  9. +152 −17 commands/hugo.go
  10. +7 −3 commands/import_jekyll.go
  11. +8 −6 commands/list.go
  12. +6 −6 commands/new_content_test.go
  13. +5 −5 commands/server.go
  14. +2 −4 common/collections/append.go
  15. +3 −3 common/collections/slice_test.go
  16. +2 −1 common/hugio/readers.go
  17. +19 −1 common/maps/scratch.go
  18. +23 −1 common/types/types.go
  19. +13 −1 config/configProvider.go
  20. +13 −1 config/services/servicesConfig.go
  21. +7 −8 {hugolib → config}/sitemap.go
  22. +4 −4 create/content.go
  23. +4 −3 deps/deps.go
  24. +4 −11 docs/content/en/variables/page.md
  25. +0 −1 go.mod
  26. +0 −2 go.sum
  27. +4 −4 helpers/content.go
  28. +3 −3 helpers/content_renderer_test.go
  29. +12 −12 helpers/content_test.go
  30. +7 −4 helpers/general.go
  31. +23 −2 helpers/general_test.go
  32. +8 −1 helpers/path.go
  33. +2 −2 helpers/pygments.go
  34. +51 −2 htesting/test_structs.go
  35. +99 −0 hugofs/createcounting_fs.go
  36. +7 −1 hugofs/fs.go
  37. +1 −5 hugofs/hashing_fs.go
  38. +70 −0 hugofs/stacktracer_fs.go
  39. +16 −13 hugolib/alias.go
  40. +2 −2 hugolib/alias_test.go
  41. +9 −66 hugolib/collections.go
  42. +9 −9 hugolib/collections_test.go
  43. +4 −19 hugolib/config.go
  44. +3 −3 hugolib/datafiles_test.go
  45. +21 −19 hugolib/disableKinds_test.go
  46. +7 −3 hugolib/embedded_shortcodes_test.go
  47. +6 −8 hugolib/gitinfo.go
  48. +346 −177 hugolib/hugo_sites.go
  49. +90 −85 hugolib/hugo_sites_build.go
  50. +65 −58 hugolib/hugo_sites_build_errors_test.go
  51. +323 −186 hugolib/hugo_sites_build_test.go
  52. +12 −14 hugolib/hugo_sites_multihost_test.go
  53. +303 −0 hugolib/hugo_smoke_test.go
  54. +48 −30 hugolib/language_content_dir_test.go
  55. +0 −60 hugolib/media.go
  56. +3 −3 hugolib/menu_test.go
  57. +6 −14 hugolib/minify_publisher_test.go
  58. +6 −10 hugolib/multilingual.go
  59. +0 −99 hugolib/orderedMap.go
  60. +0 −69 hugolib/orderedMap_test.go
  61. +573 −1,827 hugolib/page.go
  62. +112 −0 hugolib/page__common.go
  63. +135 −0 hugolib/page__content.go
  64. +70 −0 hugolib/page__data.go
  65. +74 −0 hugolib/page__menus.go
  66. +652 −0 hugolib/page__meta.go
  67. +291 −0 hugolib/page__new.go
  68. +107 −0 hugolib/page__output.go
  69. +83 −0 hugolib/page__paginator.go
  70. +148 −0 hugolib/page__paths.go
  71. +445 −0 hugolib/page__per_output.go
  72. +76 −0 hugolib/page__position.go
  73. +39 −22 hugolib/{page_ref.go → page__ref.go}
  74. +113 −0 hugolib/page__tree.go
  75. +0 −233 hugolib/page_content.go
  76. +0 −47 hugolib/page_errors.go
  77. +40 −0 hugolib/page_kinds.go
  78. +0 −320 hugolib/page_output.go
  79. +0 −312 hugolib/page_paths.go
  80. +0 −194 hugolib/page_paths_test.go
  81. +24 −20 hugolib/page_permalink_test.go
  82. +0 −96 hugolib/page_taxonomy_test.go
  83. +187 −714 hugolib/page_test.go
  84. +0 −183 hugolib/page_time_integration_test.go
  85. +50 −0 hugolib/page_unwrap.go
  86. +15 −16 hugolib/{path_separators_test.go → page_unwrap_test.go}
  87. +0 −67 hugolib/page_without_content.go
  88. +20 −22 hugolib/pagebundler.go
  89. +5 −5 hugolib/pagebundler_capture.go
  90. +5 −7 hugolib/pagebundler_capture_test.go
  91. +52 −89 hugolib/pagebundler_handlers.go
  92. +214 −94 hugolib/pagebundler_test.go
  93. +165 −114 hugolib/pagecollections.go
  94. +44 −42 hugolib/pagecollections_test.go
  95. +21 −19 hugolib/pages_language_merge_test.go
  96. +0 −75 hugolib/pages_related_test.go
  97. +0 −579 hugolib/pagination_test.go
  98. +2 −2 hugolib/paths/themes.go
  99. +2 −3 hugolib/permalinker.go
  100. +0 −213 hugolib/permalinks.go
  101. +0 −85 hugolib/permalinks_test.go
  102. +4 −4 hugolib/resource_chain_test.go
  103. +23 −2 hugolib/rss_test.go
  104. +142 −348 hugolib/shortcode.go
  105. +56 −0 hugolib/shortcode_page.go
  106. +163 −237 hugolib/shortcode_test.go
  107. +591 −541 hugolib/site.go
  108. +12 −22 hugolib/siteJSONEncode_test.go
  109. +8 −7 hugolib/site_output.go
  110. +20 −22 hugolib/site_output_test.go
  111. +176 −268 hugolib/site_render.go
  112. +67 −206 hugolib/site_sections.go
  113. +78 −72 hugolib/site_sections_test.go
  114. +63 −60 hugolib/site_test.go
  115. +8 −6 hugolib/site_url_test.go
  116. +5 −5 hugolib/sitemap_test.go
  117. +81 −70 hugolib/taxonomy.go
  118. +92 −69 hugolib/taxonomy_test.go
  119. +63 −60 hugolib/testhelpers_test.go
  120. +25 −31 hugolib/translations.go
  121. +13 −3 langs/language.go
  122. +199 −0 lazy/init.go
  123. +150 −0 lazy/init_test.go
  124. +69 −0 lazy/once.go
  125. +34 −1 magefile.go
  126. +8 −1 media/mediaType.go
  127. +2 −2 media/mediaType_test.go
  128. +18 −23 {hugolib → navigation}/menu.go
  129. +240 −0 navigation/pagemenus.go
  130. +23 −12 output/outputFormat.go
  131. +4 −1 output/outputFormat_test.go
  132. +16 −0 parser/pageparser/itemtype_string.go
  133. +20 −7 parser/pageparser/pageparser.go
  134. +3 −3 parser/pageparser/pageparser_test.go
  135. +2 −2 publisher/publisher.go
  136. +16 −9 related/inverted_index.go
  137. +37 −5 related/inverted_index_test.go
  138. +5 −15 resources/image.go
  139. +10 −10 resources/image_cache.go
  140. +365 −0 resources/page/page.go
  141. +2 −2 hugolib/author.go → resources/page/page_author.go
  142. +42 −0 resources/page/page_data.go
  143. +57 −0 resources/page/page_data_test.go
  144. +1 −0 resources/page/page_generate/.gitignore
  145. +212 −0 resources/page/page_generate/generate_page_wrappers.go
  146. +11 −10 common/hugo/site.go → resources/page/page_kinds.go
  147. +31 −0 resources/page/page_kinds_test.go
  148. +198 −0 resources/page/page_marshaljson.autogen.go
  149. +463 −0 resources/page/page_nop.go
  150. +85 −0 resources/page/page_outputformat.go
  151. +334 −0 resources/page/page_paths.go
  152. +258 −0 resources/page/page_paths_test.go
  153. +97 −0 resources/page/page_wrappers.autogen.go
  154. +103 −32 hugolib/pageGroup.go → resources/page/pagegroup.go
  155. +24 −72 hugolib/pageGroup_test.go → resources/page/pagegroup_test.go
  156. +8 −7 {hugolib → resources/page}/pagemeta/page_frontmatter.go
  157. +21 −20 {hugolib → resources/page}/pagemeta/page_frontmatter_test.go
  158. +1 −12 {hugolib → resources/page}/pagemeta/pagemeta.go
  159. +115 −0 resources/page/pages.go
  160. +2 −2 hugolib/pageCache.go → resources/page/pages_cache.go
  161. +6 −8 hugolib/pageCache_test.go → resources/page/pages_cache_test.go
  162. +3 −3 {hugolib → resources/page}/pages_language_merge.go
  163. +6 −6 hugolib/pagesPrevNext.go → resources/page/pages_prev_next.go
  164. +8 −11 hugolib/pagesPrevNext_test.go → resources/page/pages_prev_next_test.go
  165. +30 −22 {hugolib → resources/page}/pages_related.go
  166. +86 −0 resources/page/pages_related_test.go
  167. +61 −45 hugolib/pageSort.go → resources/page/pages_sort.go
  168. +57 −59 hugolib/pageSort_test.go → resources/page/pages_sort_test.go
  169. +38 −229 {hugolib → resources/page}/pagination.go
  170. +307 −0 resources/page/pagination_test.go
  171. +248 −0 resources/page/permalinks.go
  172. +180 −0 resources/page/permalinks_test.go
  173. +53 −0 resources/page/site.go
  174. +554 −0 resources/page/testhelpers_test.go
  175. +140 −0 resources/page/weighted.go
  176. +36 −27 resources/resource.go
  177. +81 −0 resources/resource/dates.go
  178. +89 −0 resources/resource/params.go
  179. +70 −0 resources/resource/resource_helpers.go
  180. +79 −19 resources/resource/resourcetypes.go
  181. +0 −1 resources/resource_metadata.go
  182. +2 −2 resources/resource_metadata_test.go
  183. +2 −4 resources/resource_test.go
  184. +13 −6 resources/testhelpers_test.go
  185. +2 −2 resources/transform.go
  186. +37 −15 source/fileInfo.go
  187. +5 −1 tpl/collections/apply_test.go
  188. +6 −2 tpl/collections/collections.go
  189. +19 −19 tpl/collections/collections_test.go
  190. +41 −2 tpl/template.go
  191. +35 −0 tpl/template_info.go
  192. +7 −8 tpl/tplimpl/ace.go
  193. +2 −2 tpl/tplimpl/embedded/generate/generate.go
  194. +16 −8 tpl/tplimpl/embedded/templates.autogen.go
  195. +7 −1 tpl/tplimpl/embedded/templates/_default/rss.xml
  196. +3 −2 tpl/tplimpl/embedded/templates/_default/sitemap.xml
  197. +1 −0 tpl/tplimpl/embedded/templates/_default/sitemapindex.xml
  198. +1 −1 tpl/tplimpl/embedded/templates/disqus.html
  199. +148 −0 tpl/tplimpl/shortcodes.go
  200. +94 −0 tpl/tplimpl/shortcodes_test.go
  201. +163 −38 tpl/tplimpl/template.go
  202. +1 −45 tpl/tplimpl/templateFuncster.go
  203. +120 −12 tpl/tplimpl/template_ast_transformers.go
  204. +50 −16 tpl/tplimpl/template_ast_transformers_test.go
  205. +1 −19 tpl/tplimpl/template_funcs_test.go
  206. +19 −29 tpl/tplimpl/{template_test.go → template_info_test.go}
@@ -0,0 +1,2 @@
gobench -package=./hugolib -bench="BenchmarkSiteBuilding/TOML,num_langs=3,num_pages=5000,tags_per_page=5,shortcodes,render" -count=3 > 1.bench
benchcmp -best 0.bench 1.bench
Oops, something went wrong.

0 comments on commit 597e418

Please sign in to comment.
You can’t perform that action at this time.