nugem 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -9
  3. data/README.md +6 -0
  4. data/exe/nugem +9 -0
  5. data/lib/nugem/cli/cli_gem.rb +2 -2
  6. data/lib/nugem/version.rb +1 -1
  7. data/nugem.gemspec +2 -2
  8. data/templates/common/LICENCE.txt.tt +21 -0
  9. data/templates/common/executable_scaffold/exe/%gem_name%.tt +5 -0
  10. data/templates/common/executable_scaffold/lib/%gem_name%/cli.rb.tt +13 -0
  11. data/templates/common/gem_scaffold/%gem_name%.gemspec.tt +58 -0
  12. data/templates/common/gem_scaffold/CHANGELOG.md.tt +2 -0
  13. data/templates/common/gem_scaffold/Gemfile.tt +56 -0
  14. data/templates/common/gem_scaffold/README.md.tt +62 -0
  15. data/templates/common/gem_scaffold/Rakefile.tt +51 -0
  16. data/templates/common/gem_scaffold/bin/attach +34 -0
  17. data/templates/common/gem_scaffold/bin/console.tt +10 -0
  18. data/templates/common/gem_scaffold/bin/rake +13 -0
  19. data/templates/common/gem_scaffold/bin/setup.tt +24 -0
  20. data/templates/common/gem_scaffold/lib/%gem_name%/version.rb.tt +3 -0
  21. data/templates/common/gem_scaffold/lib/%gem_name%.rb.tt +12 -0
  22. data/templates/common/gem_scaffold/test/%gem_name%_test.rb.tt +11 -0
  23. data/templates/common/gem_scaffold/test/test_helper.rb.tt +96 -0
  24. data/templates/jekyll/block_no_arg_scaffold/lib/%block_name%.rb.tt +23 -0
  25. data/templates/jekyll/block_scaffold/lib/%block_name%.rb.tt +50 -0
  26. data/templates/jekyll/common_scaffold/spec/%gem_name%_spec.rb.tt +13 -0
  27. data/templates/jekyll/common_scaffold/spec/spec_helper.rb +79 -0
  28. data/templates/jekyll/demo/demo/Gemfile.tt +21 -0
  29. data/templates/jekyll/demo/demo/_bin/debug +71 -0
  30. data/templates/jekyll/demo/demo/_config.yml.tt +48 -0
  31. data/templates/jekyll/demo/demo/_drafts/2022/2022-05-01-test2.html +15 -0
  32. data/templates/jekyll/demo/demo/_includes/block_tag_template_wrapper +9 -0
  33. data/templates/jekyll/demo/demo/_layouts/default.html.tt +67 -0
  34. data/templates/jekyll/demo/demo/_posts/2022/2022-01-02-redact-test.html +12 -0
  35. data/templates/jekyll/demo/demo/assets/css/style.css +218 -0
  36. data/templates/jekyll/demo/demo/assets/images/404-error.png +0 -0
  37. data/templates/jekyll/demo/demo/assets/images/404-error.webp +0 -0
  38. data/templates/jekyll/demo/demo/assets/images/favicon.png +0 -0
  39. data/templates/jekyll/demo/demo/assets/images/jekyll.png +0 -0
  40. data/templates/jekyll/demo/demo/assets/images/jekyll.webp +0 -0
  41. data/templates/jekyll/demo/demo/assets/js/clipboard.min.js +7 -0
  42. data/templates/jekyll/demo/demo/assets/js/jquery-3.4.1.min.js +2 -0
  43. data/templates/jekyll/demo/demo/blog/blogsByDate.html +22 -0
  44. data/templates/jekyll/demo/demo/blog/index.html +36 -0
  45. data/templates/jekyll/demo/demo/index.html.tt +5 -0
  46. data/templates/jekyll/filter_scaffold/lib/%filter_name%.rb.tt +30 -0
  47. data/templates/jekyll/generator_scaffold/lib/%generator_name%.rb.tt +34 -0
  48. data/templates/jekyll/hooks_scaffold/lib/dumpers.rb +172 -0
  49. data/templates/jekyll/hooks_scaffold/lib/hooks.rb.tt +238 -0
  50. data/templates/jekyll/tag_no_arg_scaffold/lib/%tag_name%.rb.tt +18 -0
  51. data/templates/jekyll/tag_scaffold/lib/%tag_name%.rb.tt +43 -0
  52. data/templates/rails/engine_scaffold/bin/rails.tt +15 -0
  53. data/templates/rails/engine_scaffold/config/routes.rb.tt +6 -0
  54. data/templates/rails/engine_scaffold/lib/%gem_name%/engine.rb.tt +7 -0
  55. data/templates/rails/engine_scaffold/test/integration/navigation_test.rb +7 -0
  56. data/templates/rails/mountable_scaffold/app/assets/javascripts/%gem_name%/application.js +13 -0
  57. data/templates/rails/mountable_scaffold/app/assets/stylesheets/%gem_name%/application.css +15 -0
  58. data/templates/rails/mountable_scaffold/app/controllers/%gem_name%/application_controller.rb.tt +5 -0
  59. data/templates/rails/mountable_scaffold/app/helpers/%gem_name%/application_helper.rb.tt +4 -0
  60. data/templates/rails/mountable_scaffold/app/views/layouts/%gem_name%/application.html.erb.tt +14 -0
  61. data/templates/rails/plugin_scaffold/test/dummy/README.rdoc +28 -0
  62. data/templates/rails/plugin_scaffold/test/dummy/Rakefile +6 -0
  63. data/templates/rails/plugin_scaffold/test/dummy/app/assets/javascripts/application.js +13 -0
  64. data/templates/rails/plugin_scaffold/test/dummy/app/controllers/application_controller.rb +7 -0
  65. data/templates/rails/plugin_scaffold/test/dummy/app/helpers/application_helper.rb +2 -0
  66. data/templates/rails/plugin_scaffold/test/dummy/app/mailers/application_mailer.rb +4 -0
  67. data/templates/rails/plugin_scaffold/test/dummy/app/views/layouts/application.html.erb +14 -0
  68. data/templates/rails/plugin_scaffold/test/dummy/app/views/layouts/mailer.html.erb +9 -0
  69. data/templates/rails/plugin_scaffold/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  70. data/templates/rails/plugin_scaffold/test/dummy/bin/bundle +4 -0
  71. data/templates/rails/plugin_scaffold/test/dummy/bin/rails +5 -0
  72. data/templates/rails/plugin_scaffold/test/dummy/bin/rake +6 -0
  73. data/templates/rails/plugin_scaffold/test/dummy/bin/setup +30 -0
  74. data/templates/rails/plugin_scaffold/test/dummy/config/application.rb.tt +26 -0
  75. data/templates/rails/plugin_scaffold/test/dummy/config/boot.rb +5 -0
  76. data/templates/rails/plugin_scaffold/test/dummy/config/database.yml +25 -0
  77. data/templates/rails/plugin_scaffold/test/dummy/config/environment.rb +5 -0
  78. data/templates/rails/plugin_scaffold/test/dummy/config/environments/development.rb +41 -0
  79. data/templates/rails/plugin_scaffold/test/dummy/config/environments/production.rb +79 -0
  80. data/templates/rails/plugin_scaffold/test/dummy/config/environments/test.rb +42 -0
  81. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/assets.rb +11 -0
  82. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  83. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  84. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  85. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/inflections.rb +16 -0
  86. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/mime_types.rb +4 -0
  87. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/session_store.rb +3 -0
  88. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  89. data/templates/rails/plugin_scaffold/test/dummy/config/locales/en.yml +23 -0
  90. data/templates/rails/plugin_scaffold/test/dummy/config/routes.rb.tt +5 -0
  91. data/templates/rails/plugin_scaffold/test/dummy/config/secrets.yml +22 -0
  92. data/templates/rails/plugin_scaffold/test/dummy/config.ru +4 -0
  93. data/templates/rails/plugin_scaffold/test/dummy/db/seeds.rb +7 -0
  94. data/templates/rails/plugin_scaffold/test/dummy/public/404.html +67 -0
  95. data/templates/rails/plugin_scaffold/test/dummy/public/422.html +67 -0
  96. data/templates/rails/plugin_scaffold/test/dummy/public/500.html +66 -0
  97. data/templates/rails/plugin_scaffold/test/dummy/public/favicon.ico +0 -0
  98. data/templates/rails/rails_scaffold/lib/tasks/%gem_name%_tasks.rake.tt +4 -0
  99. data/templates/rails/rails_scaffold/test/dummy/README.rdoc +28 -0
  100. data/templates/rails/rails_scaffold/test/dummy/Rakefile +6 -0
  101. data/templates/rails/rails_scaffold/test/dummy/app/assets/javascripts/application.js +13 -0
  102. data/templates/rails/rails_scaffold/test/dummy/app/assets/stylesheets/application.sass +0 -0
  103. data/templates/rails/rails_scaffold/test/dummy/app/controllers/application_controller.rb +7 -0
  104. data/templates/rails/rails_scaffold/test/dummy/app/helpers/application_helper.rb +2 -0
  105. data/templates/rails/rails_scaffold/test/dummy/app/mailers/application_mailer.rb +4 -0
  106. data/templates/rails/rails_scaffold/test/dummy/app/views/layouts/application.html.erb +14 -0
  107. data/templates/rails/rails_scaffold/test/dummy/app/views/layouts/mailer.html.erb +9 -0
  108. data/templates/rails/rails_scaffold/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  109. data/templates/rails/rails_scaffold/test/dummy/bin/bundle +4 -0
  110. data/templates/rails/rails_scaffold/test/dummy/bin/rails +5 -0
  111. data/templates/rails/rails_scaffold/test/dummy/bin/rake +6 -0
  112. data/templates/rails/rails_scaffold/test/dummy/bin/setup +30 -0
  113. data/templates/rails/rails_scaffold/test/dummy/config/application.rb.tt +26 -0
  114. data/templates/rails/rails_scaffold/test/dummy/config/boot.rb +5 -0
  115. data/templates/rails/rails_scaffold/test/dummy/config/database.yml +25 -0
  116. data/templates/rails/rails_scaffold/test/dummy/config/environment.rb +5 -0
  117. data/templates/rails/rails_scaffold/test/dummy/config/environments/development.rb +41 -0
  118. data/templates/rails/rails_scaffold/test/dummy/config/environments/production.rb +79 -0
  119. data/templates/rails/rails_scaffold/test/dummy/config/environments/test.rb +42 -0
  120. data/templates/rails/rails_scaffold/test/dummy/config/initializers/assets.rb +11 -0
  121. data/templates/rails/rails_scaffold/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  122. data/templates/rails/rails_scaffold/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  123. data/templates/rails/rails_scaffold/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  124. data/templates/rails/rails_scaffold/test/dummy/config/initializers/inflections.rb +16 -0
  125. data/templates/rails/rails_scaffold/test/dummy/config/initializers/mime_types.rb +4 -0
  126. data/templates/rails/rails_scaffold/test/dummy/config/initializers/session_store.rb +3 -0
  127. data/templates/rails/rails_scaffold/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  128. data/templates/rails/rails_scaffold/test/dummy/config/locales/en.yml +23 -0
  129. data/templates/rails/rails_scaffold/test/dummy/config/routes.rb.tt +5 -0
  130. data/templates/rails/rails_scaffold/test/dummy/config/secrets.yml +22 -0
  131. data/templates/rails/rails_scaffold/test/dummy/config.ru +4 -0
  132. data/templates/rails/rails_scaffold/test/dummy/db/seeds.rb +7 -0
  133. data/templates/rails/rails_scaffold/test/dummy/public/404.html +67 -0
  134. data/templates/rails/rails_scaffold/test/dummy/public/422.html +67 -0
  135. data/templates/rails/rails_scaffold/test/dummy/public/500.html +66 -0
  136. data/templates/rails/rails_scaffold/test/dummy/public/favicon.ico +0 -0
  137. metadata +135 -4
  138. /data/{spec/status_persistence.txt → templates/rails/plugin_scaffold/test/dummy/app/assets/stylesheets/application.sass} +0 -0
@@ -0,0 +1,238 @@
1
+ require 'jekyll_plugin_logger'
2
+ require_relative 'dumpers'
3
+
4
+ # See https://www.mslinn.com/jekyll/10200-jekyll-plugin-background.html
5
+ # See https://www.mslinn.com/jekyll/10400-jekyll-plugin-template-collection.html
6
+ #
7
+ # The Jekyll log level defaults to :info, which means all the Jekyll.logger statements below will not generate output.
8
+ # You can control the log level when you start Jekyll.
9
+ # To set the log level to :debug, write an entery into _config.yml, like this:
10
+ # plugin_loggers:
11
+ # JekyllPluginHooks: debug
12
+ #
13
+ # Jekyll::Hooks.register accepts an optional parameter:
14
+ # :priority determines the load order for the hook plugins.
15
+ # Valid values are: :lowest, :low, :normal, :high, and :highest.
16
+ # Highest priority matches are applied first, lowest priority are applied last.
17
+ # The default value is :normal
18
+ #
19
+ # Each hook, except the clean hook, can set a boolean flag, called `site.safe`, that informs Jekyll if this plugin may be safely executed in an environment
20
+ # where arbitrary code execution is not allowed. This is used by GitHub Pages to determine which
21
+ # core plugins may be used, and which are unsafe to run. If your plugin does not allow for arbitrary
22
+ # code execution, set this to true. GitHub Pages still will not load your plugin, but if you submit it
23
+ # for inclusion in core, it is best for this to be correct!
24
+ # Default value is false.
25
+ # The hooks for pages, posts and documents access safe via pages.site.safe, posts.site.safe and documents.site.safe, respectively.
26
+ module <%= @class_name %>
27
+ # PLUGIN_NAME = '<%= @gem_name %>'.freeze unless defined? PLUGIN_NAME
28
+
29
+ ########## :site hooks
30
+ # These hooks influence the entire site
31
+
32
+ # Called just after the site resets during regeneration
33
+ # This is the first hook called, so you might think that this is the best place to define loggers.
34
+ # However, this hook will not be called unless safe mode is OFF, so define loggers in the :site :after_init hook instead
35
+ Jekyll::Hooks.register(:site, :after_reset, priority: :normal) do |site|
36
+ @log_site ||= PluginMetaLogger.instance.new_logger(:SiteHooks, PluginMetaLogger.instance.config)
37
+ @log_site.info { 'Jekyll::Hooks.register(:site, :after_reset) invoked.' }
38
+ Dumpers.dump_site(@log_site, 'Jekyll::Hooks.register(:site, :after_reset)', site)
39
+ end
40
+
41
+ # This hook is called just after the site initializes.
42
+ # It is a good place to modify the configuration of the site.
43
+ # This hook is triggered once per build / serve session.
44
+ Jekyll::Hooks.register(:site, :after_init, priority: :normal) do |site|
45
+ @log_clean = PluginMetaLogger.instance.new_logger(:CleanHook, PluginMetaLogger.instance.config)
46
+ @log_docs = PluginMetaLogger.instance.new_logger(:DocumentHooks, PluginMetaLogger.instance.config)
47
+ @log_pages = PluginMetaLogger.instance.new_logger(:PageHooks, PluginMetaLogger.instance.config)
48
+ @log_posts = PluginMetaLogger.instance.new_logger(:PostHooks, PluginMetaLogger.instance.config)
49
+ @log_site ||= PluginMetaLogger.instance.new_logger(:SiteHooks, PluginMetaLogger.instance.config)
50
+
51
+ @log_site.info { "Loaded #{<%= @plugin_name %>} plugin." }
52
+ @log_site.info { 'Jekyll::Hooks.register(:site, :after_init) invoked.' }
53
+ Dumpers.dump_site(@log_site, 'Jekyll::Hooks.register(:site, :after_init)', site)
54
+ end
55
+
56
+ # Called after all source files have been read and loaded from disk.
57
+ # This is a good hook for enriching posts;
58
+ # for example, adding links to author pages or adding posts to author pages.
59
+ Jekyll::Hooks.register(:site, :post_read, priority: :normal) do |site|
60
+ @log_site.info { 'Jekyll::Hooks.register(:site, :post_read) invoked.' }
61
+ Dumpers.dump_site(@log_site, 'Jekyll::Hooks.register(:site, :post_read)', site)
62
+ end
63
+
64
+ # Called before rendering the whole site
65
+ # This is the first hook in the site generation sequence where site['env'] has a value.
66
+ # Consequently, this is the first hook that defines mode (production, development or test),
67
+ # because it is derived from site['env']['JEKYLL_ENV']
68
+ # @param payload [Hash] according to the docs, payload is a hash containing the variables available during rendering; the hash can be modified here.
69
+ # However, the debugger shows payload has type Jekyll::UnifiedPayloadDrop
70
+ Jekyll::Hooks.register(:site, :pre_render, priority: :normal) do |site, payload|
71
+ @log_site.info { 'Jekyll::Hooks.register(:site, :pre_render) invoked.' }
72
+ @log_site.debug { dump(':site, :pre_render payload', payload) }
73
+ Dumpers.dump_site(@log_site, 'Jekyll::Hooks.register(:site, :pre_render)', site)
74
+ Dumpers.dump_payload(@log_site, 'Jekyll::Hooks.register(:site, :pre_render)', payload)
75
+ end
76
+
77
+ # Called after rendering the whole site, but before writing any files.
78
+ # Functionally, this hook is exactly the same as a Jekyll generator.
79
+ # This hook is also similar to invoking the same method on the :post_render hooks for :documents and :pages:
80
+ # Jekyll::Hooks.register(:documents, :post_render, &my_method)
81
+ # Jekyll::Hooks.register(:pages, :post_render, &my_method)
82
+ # ... with the difference that this hook will be called only once, for the entire site, so you will have to iterate over all of the
83
+ # :documents and :pages, whereas the :pages and :documents hooks are called once for each page and document.
84
+ # @param payload [Hash] contains final values of variables after rendering the entire site (useful for sitemaps, feeds, etc).
85
+ Jekyll::Hooks.register(:site, :post_render, priority: :normal) do |site, payload|
86
+ @log_site.info { 'Jekyll::Hooks.register(:site, :post_render) invoked.' }
87
+ @log_site.debug { dump(':site, :post_render payload', payload) }
88
+ Dumpers.dump_site(@log_site, 'Jekyll::Hooks.register(:site, :post_render)', site)
89
+ Dumpers.dump_payload(@log_site, 'Jekyll::Hooks.register(:site, :post_render)', payload)
90
+ end
91
+
92
+ # Called after writing all of the rendered files to disk
93
+ Jekyll::Hooks.register(:site, :post_write, priority: :normal) do |site|
94
+ @log_site.info { 'Jekyll::Hooks.register(:site, :post_write) invoked.' }
95
+ Dumpers.dump_site(@log_site, 'Jekyll::Hooks.register(:site, :post_write)', site)
96
+ end
97
+
98
+ ########## :pages hooks
99
+ # Pages are web pages that do not belong to a collection, such as posts or drafts.
100
+ # These hooks provide fine-grained control over all pages in the site.
101
+
102
+ # Called whenever a page is initialized
103
+ Jekyll::Hooks.register(:pages, :post_init, priority: :normal) do |page|
104
+ @log_pages.info { 'Jekyll::Hooks.register(:pages, :post_init) invoked.' }
105
+ Dumpers.dump_page(@log_pages, 'Jekyll::Hooks.register(:pages, :post_init)', page)
106
+ end
107
+
108
+ # Called just before rendering a page
109
+ Jekyll::Hooks.register(:pages, :pre_render, priority: :normal) do |page, payload|
110
+ @log_pages.info { 'Jekyll::Hooks.register(:pages, :pre_render) invoked.' }
111
+ Dumpers.dump_page(@log_pages, 'Jekyll::Hooks.register(:pages, :pre_render)', page)
112
+ Dumpers.dump_payload(@log_pages, ':pages, :pre_render payload', payload)
113
+ end
114
+
115
+ # Called after converting the page content, but before rendering the page layout
116
+ Jekyll::Hooks.register(:pages, :post_convert, priority: :normal) do |page|
117
+ @log_pages.info { 'Jekyll::Hooks.register(:pages, :post_convert) invoked.' }
118
+ Dumpers.dump_page(@log_pages, 'Jekyll::Hooks.register(:pages, :post_convert)', page)
119
+ end
120
+
121
+ # Called after rendering a page, but before writing it to disk
122
+ Jekyll::Hooks.register(:pages, :post_render, priority: :normal) do |page|
123
+ page.site.safe = true
124
+ @log_pages.info { 'Jekyll::Hooks.register(:pages, :post_render) invoked.' }
125
+ Dumpers.dump_page(@log_pages, 'Jekyll::Hooks.register(:pages, :post_render)', page)
126
+ end
127
+
128
+ # Called after writing a page to disk
129
+ Jekyll::Hooks.register(:pages, :post_write, priority: :normal) do |page|
130
+ @log_pages.info { 'Jekyll::Hooks.register(:pages, :post_write) invoked.' }
131
+ Dumpers.dump_page(@log_pages, 'Jekyll::Hooks.register(:pages, :post_write)', page)
132
+ end
133
+
134
+ ########## :documents hooks
135
+ # Documents are web pages that belong to a collection, for example posts, drafts and custom collections.
136
+ # These hooks provide fine-grained control over all documents in the site.
137
+ # If you want to inspect or process all collections in the same way, use these hooks.
138
+ # If you just want to process a custom collection, use these hooks and filter out the documents
139
+ # that do not belong to that collection.
140
+
141
+ # Called whenever any document is initialized.
142
+ # Front matter data will not have been assigned yet to documents when this hook is invoked, for example:
143
+ # categories, description, last_modified_at, tags, title, and slug;
144
+ # other document attributes that are not yet ready when this hook is invoked include
145
+ # excerpt and ext (file extension).
146
+ # The collection attribute will be set properly for this hook.
147
+ Jekyll::Hooks.register(:documents, :post_init, priority: :normal) do |document|
148
+ @log_docs.info { 'Jekyll::Hooks.register(:documents, :post_init) invoked.' }
149
+ Dumpers.dump_document(@log_docs, 'Jekyll::Hooks.register(:documents, :post_init)', document)
150
+ 'stop'
151
+ end
152
+
153
+ # Called just before rendering a document.
154
+ # Front matter data will have been assigned when this hook is invoked.
155
+ # Liquid variables are still embedded in the content.
156
+ # If the document contains markdown (or some other markup),
157
+ # it will not have been converted to HTML (or whatever the target format is) yet.
158
+ Jekyll::Hooks.register(:documents, :pre_render, priority: :normal) do |document, payload|
159
+ @log_docs.info { 'Jekyll::Hooks.register(:documents, :pre_render) invoked.' }
160
+ Dumpers.dump_document(@log_docs, 'Jekyll::Hooks.register(:documents, :pre_render)', document)
161
+ Dumpers.dump_payload(@log_docs, ':documents, :pre_render payload', payload)
162
+ end
163
+
164
+ # Called after converting the document content to HTML (or whatever),
165
+ # but before rendering the document using the layout.
166
+ Jekyll::Hooks.register(:documents, :post_convert, priority: :normal) do |document|
167
+ @log_docs.info { 'Jekyll::Hooks.register(:documents, :post_convert) invoked.' }
168
+ Dumpers.dump_document(@log_docs, 'Jekyll::Hooks.register(:documents, :post_convert)', document)
169
+ end
170
+
171
+ # Called after rendering a document using the layout, but before writing it to disk.
172
+ # This is your last chance to modify the content.
173
+ Jekyll::Hooks.register(:documents, :post_render, priority: :normal) do |document|
174
+ @log_docs.info { 'Jekyll::Hooks.register(:documents, :post_render) invoked.' }
175
+ Dumpers.dump_document(@log_docs, 'Jekyll::Hooks.register(:documents, :post_render)', document)
176
+ end
177
+
178
+ # Called after writing a document to disk.
179
+ # Useful for statistics regarding completed renderings.
180
+ Jekyll::Hooks.register(:documents, :post_write, priority: :normal) do |document|
181
+ @log_docs.info { 'Jekyll::Hooks.register(:documents, :post_write) invoked.' }
182
+ Dumpers.dump_document(@log_docs, 'Jekyll::Hooks.register(:documents, :post_write)', document)
183
+ end
184
+
185
+ ########## :posts hooks
186
+ # These hooks provide fine-grained control over all posts **and drafts** in the site without affecting
187
+ # documents in user-defined collections
188
+
189
+ # Called whenever any post is initialized
190
+ Jekyll::Hooks.register(:posts, :post_init, priority: :normal) do |post|
191
+ @log_posts.info { 'Jekyll::Hooks.register(:posts, :post_init) invoked.' }
192
+ Dumpers.dump_document(@log_posts, 'Jekyll::Hooks.register(:posts, :post_init)', post)
193
+ end
194
+
195
+ # Called just before rendering a post
196
+ Jekyll::Hooks.register(:posts, :pre_render, priority: :normal) do |post, payload|
197
+ # post is a Jekyll::Document
198
+ @log_posts.info { 'Jekyll::Hooks.register(:posts, :pre_render) invoked.' }
199
+ Dumpers.dump_document(@log_posts, 'Jekyll::Hooks.register(:posts, :pre_render)', post)
200
+ Dumpers.dump_payload(@log_posts, ':posts, :pre_render payload', payload)
201
+ end
202
+
203
+ # Called after converting the post content, but before rendering the post layout.
204
+ # This hook can be used to make edits to rendered pages,
205
+ # regardless of whether they were originally written in markdown or HTML.
206
+ #
207
+ # Changes must modify post.output, as shown in this example:
208
+ # Jekyll::Hooks.register(:posts, :post_convert) do |post|
209
+ # post.output.gsub!('programming PHP', 'banging rocks together')
210
+ # end
211
+ Jekyll::Hooks.register(:posts, :post_convert, priority: :normal) do |post|
212
+ @log_posts.info { 'Jekyll::Hooks.register(:posts, :post_convert) invoked.' }
213
+ Dumpers.dump_document(@log_posts, 'Jekyll::Hooks.register(:posts, :post_convert)', post)
214
+ end
215
+
216
+ # Called after rendering a post, but before writing it to disk.
217
+ # Changing `post.conent` has no effect on visible output.
218
+ Jekyll::Hooks.register(:posts, :post_render, priority: :normal) do |post|
219
+ @log_posts.info { 'Jekyll::Hooks.register(:posts, :post_render) invoked.' }
220
+ Dumpers.dump_document(@log_posts, 'Jekyll::Hooks.register(:posts, :post_render)', post)
221
+ end
222
+
223
+ # Called after writing a post to disk
224
+ Jekyll::Hooks.register(:posts, :post_write, priority: :normal) do |post|
225
+ @log_posts.info { 'Jekyll::Hooks.register(:posts, :post_write) invoked.' }
226
+ Dumpers.dump_document(@log_posts, 'Jekyll::Hooks.register(:posts, :post_write)', post)
227
+ end
228
+
229
+ ########## :clean hooks
230
+ # These hooks provide fine-grained control on the list of obsolete files determined
231
+ # to be deleted during the site's cleanup phase.
232
+
233
+ # Called during the cleanup of a site's destination, before the site is built
234
+ Jekyll::Hooks.register(:clean, :on_obsolete, priority: :normal) do |files|
235
+ # files has type Array[String]
236
+ @log_clean.info { "Jekyll::Hooks.register(:clean, :on_obsolete) invoked for #{files}." }
237
+ end
238
+ end
@@ -0,0 +1,18 @@
1
+ require 'jekyll_plugin_support'
2
+ require_relative '<%= @gem_name %>/version.rb'
3
+
4
+ module <%= @class_name %>
5
+ class <%= @jekyll_class_name %> < JekyllTag
6
+ def initialize(tag_name, argument_string, parse_context)
7
+ class << self
8
+ include NoArgParsing
9
+ end
10
+
11
+ super
12
+ @logger.debug { "#{self.class}: respond_to?(:no_arg_parsing) #{respond_to?(:no_arg_parsing) ? 'yes' : 'no'}." }
13
+ rescue StandardError => e
14
+ @logger.error { "#{self.class} died with a #{e.full_message}" }
15
+ exit 2
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,43 @@
1
+ require 'jekyll_plugin_support'
2
+ require_relative '<%= @gem_name %>/version.rb'
3
+
4
+ # This Jekyll tag plugin is a minimal example.
5
+ #
6
+ # See https://www.mslinn.com/jekyll/10200-jekyll-plugin-background.html
7
+ # See https://www.mslinn.com/jekyll/10400-jekyll-plugin-template-collection.html
8
+ #
9
+ # @example Heading for this example
10
+ # {% <%= @tag_name %> param1='value1' %}
11
+ #
12
+ # The Jekyll log level defaults to :info, which means all the Jekyll.logger statements below will not generate output.
13
+ # You can control the log level when you start Jekyll.
14
+ # To set the log level to :debug, write an entry into _config.yml, like this:
15
+ # plugin_loggers:
16
+ # <%= @jekyll_class_name %>: debug
17
+ module <%= class_name %>
18
+ # This class implements the Jekyll <%= @tag_name %> functionality
19
+ class <%= @jekyll_class_name %> < JekyllSupport::JekyllTag
20
+ PLUGIN_NAME = '<%= @tag_name %>'.freeze
21
+ VERSION = <%= @class_name %>::VERSION
22
+
23
+ # Put your plugin logic here.
24
+ # The following variables are predefined:
25
+ # @argument_string, @config, @envs, @helper, @layout, @logger, @mode, @page, @paginator, @site, @tag_name and @theme
26
+ #
27
+ # @param tag_name [String] is the name of the tag, which we already know.
28
+ # @param argument_string [String] the arguments from the web page.
29
+ # @param tokens [Liquid::ParseContext] tokenized command line
30
+ # @return [void]
31
+ def render_impl
32
+ <%= parse_jekyll_parameters %>
33
+ <<~END_OUTPUT
34
+ <pre class="example">
35
+ <%= dump_jekyll_parameters %>
36
+ Remaining markup: '#{@helper.remaining_markup}'.
37
+ </pre>
38
+ END_OUTPUT
39
+ end
40
+
41
+ JekyllPluginHelper.register(self, PLUGIN_NAME)
42
+ end
43
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
6
+ ENGINE_PATH = File.expand_path('../../lib/<%= gem_name %>/engine', __FILE__)
7
+
8
+ # Set up gems listed in the Gemfile.
9
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
10
+ require 'bundler/setup'
11
+
12
+ require 'rails/all'
13
+ require 'rails/engine/commands'
14
+
15
+ load Gem.bin_path("rails", "rails")
@@ -0,0 +1,6 @@
1
+ <%- if @mountable -%>
2
+ <%= @class_name %>::Engine.routes.draw do
3
+ <%- else -%>
4
+ Rails.application.routes.draw do
5
+ <%- end -%>
6
+ end
@@ -0,0 +1,7 @@
1
+ module <%= @class_name %>
2
+ class Engine < ::Rails::Engine
3
+ <%- if @mountable -%>
4
+ isolate_namespace <%= @class_name %>
5
+ <%- end %>
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+ # test 'the truth' do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ module <%= @class_name %>
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module <%= @class_name %>
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Rplugin</title>
5
+ <%%= stylesheet_link_tag "<%= @gem_name %>/application", media: "all" %>
6
+ <%%= javascript_include_tag "<%= @gem_name %>/application" %>
7
+ <%%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('config/application', __dir__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,7 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+
6
+ add_flash_types :success, :warning, :info
7
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ layout 'mailer'
3
+ default from: 'info@myapp.com'
4
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
5
+ </head>
6
+ <body>
7
+ <%= yield %>
8
+ </body>
9
+ </html>
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
4
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ APP_PATH = File.expand_path('../config/application', __dir__)
4
+ require 'rails/commands'
5
+ require_relative '../config/boot'
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rake'
4
+ require_relative '../config/boot'
5
+
6
+ Rake.application.run
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pathname'
4
+
5
+ # path to the application root.
6
+ APP_ROOT = Pathname.new File.expand_path('../', __dir__)
7
+
8
+ Dir.chdir APP_ROOT do
9
+ # This script is a starting point to setup the new application.
10
+ # Add necessary setup steps to this file
11
+
12
+ puts '== Installing dependencies =='
13
+ system 'gem install bundler --conservative'
14
+ system 'bundle check || bundle install'
15
+
16
+ # unless File.exist?('config/database.yml')
17
+ # puts "\n== Copying sample files =="
18
+ # system 'cp config/database.yml.sample config/database.yml'
19
+ # end
20
+
21
+ puts "\n== Preparing database =="
22
+ system 'bin/rake db:setup'
23
+
24
+ puts "\n== Removing old logs and tempfiles =="
25
+ system 'rm -f log/*'
26
+ system 'rm -rf tmp/cache'
27
+
28
+ puts "\n== Restarting application server =="
29
+ system 'touch tmp/restart.txt'
30
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "<%= @gem_name %>"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+
22
+ # Do not swallow errors in after_commit/after_rollback callbacks.
23
+ config.active_record.raise_in_transactional_callbacks = true
24
+ end
25
+ end
26
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: db/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/production.sqlite3
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('application', __dir__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!