monad 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.markdown +91 -0
  3. data/Gemfile +1 -1
  4. data/History.markdown +772 -0
  5. data/{README.md → README.markdown} +5 -2
  6. data/Rakefile +163 -1
  7. data/bin/monad +86 -30
  8. data/features/create_sites.feature +54 -25
  9. data/features/data.feature +65 -0
  10. data/features/data_sources.feature +10 -10
  11. data/features/drafts.feature +5 -5
  12. data/features/embed_filters.feature +10 -10
  13. data/features/include_tag.feature +48 -0
  14. data/features/markdown.feature +5 -5
  15. data/features/pagination.feature +38 -10
  16. data/features/permalinks.feature +31 -11
  17. data/features/post_data.feature +41 -41
  18. data/features/post_excerpts.feature +50 -0
  19. data/features/site_configuration.feature +47 -26
  20. data/features/site_data.feature +30 -24
  21. data/features/step_definitions/{monad_steps.rb → jekyll_steps.rb} +66 -52
  22. data/features/support/env.rb +27 -8
  23. data/lib/jekyll.rb +99 -0
  24. data/lib/jekyll/cleaner.rb +73 -0
  25. data/lib/{monad → jekyll}/command.rb +6 -6
  26. data/lib/{monad → jekyll}/commands/build.rb +9 -9
  27. data/lib/jekyll/commands/doctor.rb +67 -0
  28. data/lib/jekyll/commands/new.rb +67 -0
  29. data/lib/jekyll/commands/serve.rb +65 -0
  30. data/lib/{monad → jekyll}/configuration.rb +60 -18
  31. data/lib/{monad → jekyll}/converter.rb +1 -1
  32. data/lib/{monad → jekyll}/converters/identity.rb +1 -1
  33. data/lib/{monad → jekyll}/converters/markdown.rb +2 -2
  34. data/lib/jekyll/converters/markdown/kramdown_parser.rb +29 -0
  35. data/lib/{monad → jekyll}/converters/markdown/maruku_parser.rb +12 -8
  36. data/lib/{monad → jekyll}/converters/markdown/rdiscount_parser.rb +4 -2
  37. data/lib/{monad → jekyll}/converters/markdown/redcarpet_parser.rb +1 -1
  38. data/lib/{monad → jekyll}/converters/textile.rb +1 -1
  39. data/lib/{monad → jekyll}/convertible.rb +39 -17
  40. data/lib/{monad → jekyll}/core_ext.rb +22 -4
  41. data/lib/jekyll/deprecator.rb +36 -0
  42. data/lib/{monad → jekyll}/draft.rb +1 -1
  43. data/lib/{monad → jekyll}/drivers/json_driver.rb +1 -1
  44. data/lib/{monad → jekyll}/drivers/yaml_driver.rb +1 -1
  45. data/lib/{monad → jekyll}/errors.rb +1 -1
  46. data/lib/jekyll/excerpt.rb +113 -0
  47. data/lib/{monad → jekyll}/filters.rb +16 -6
  48. data/lib/{monad → jekyll}/generator.rb +1 -1
  49. data/lib/jekyll/generators/pagination.rb +214 -0
  50. data/lib/{monad → jekyll}/layout.rb +4 -1
  51. data/lib/{monad → jekyll}/mime.types +0 -0
  52. data/lib/{monad → jekyll}/page.rb +36 -39
  53. data/lib/{monad → jekyll}/plugin.rb +1 -1
  54. data/lib/{monad → jekyll}/post.rb +58 -123
  55. data/lib/jekyll/related_posts.rb +59 -0
  56. data/lib/{monad → jekyll}/site.rb +120 -123
  57. data/lib/{monad → jekyll}/static_file.rb +1 -1
  58. data/lib/jekyll/stevenson.rb +89 -0
  59. data/lib/jekyll/tags/gist.rb +48 -0
  60. data/lib/{monad → jekyll}/tags/highlight.rb +3 -3
  61. data/lib/jekyll/tags/include.rb +135 -0
  62. data/lib/{monad → jekyll}/tags/post_url.rb +8 -6
  63. data/lib/jekyll/url.rb +67 -0
  64. data/lib/monad.rb +36 -27
  65. data/lib/site_template/_config.yml +2 -1
  66. data/lib/site_template/_layouts/default.html +21 -23
  67. data/lib/site_template/_layouts/post.html +1 -1
  68. data/lib/site_template/_posts/{0000-00-00-welcome-to-monad.markdown.erb → 0000-00-00-welcome-to-jekyll.markdown.erb} +6 -6
  69. data/lib/site_template/css/main.css +22 -27
  70. data/lib/site_template/index.html +2 -2
  71. data/monad.gemspec +153 -52
  72. data/site/.gitignore +4 -0
  73. data/site/CNAME +1 -0
  74. data/site/README +1 -0
  75. data/site/_config.yml +6 -0
  76. data/site/_includes/analytics.html +32 -0
  77. data/site/_includes/docs_contents.html +16 -0
  78. data/site/_includes/docs_contents_mobile.html +23 -0
  79. data/site/_includes/docs_option.html +11 -0
  80. data/site/_includes/docs_ul.html +20 -0
  81. data/site/_includes/footer.html +15 -0
  82. data/site/_includes/header.html +18 -0
  83. data/site/_includes/news_contents.html +23 -0
  84. data/site/_includes/news_contents_mobile.html +11 -0
  85. data/site/_includes/news_item.html +24 -0
  86. data/site/_includes/primary-nav-items.html +14 -0
  87. data/site/_includes/section_nav.html +22 -0
  88. data/site/_includes/top.html +17 -0
  89. data/site/_layouts/default.html +12 -0
  90. data/site/_layouts/docs.html +23 -0
  91. data/site/_layouts/news.html +19 -0
  92. data/site/_layouts/news_item.html +27 -0
  93. data/site/_posts/2013-05-06-jekyll-1-0-0-released.markdown +23 -0
  94. data/site/_posts/2013-05-08-jekyll-1-0-1-released.markdown +27 -0
  95. data/site/_posts/2013-05-12-jekyll-1-0-2-released.markdown +28 -0
  96. data/site/_posts/2013-06-07-jekyll-1-0-3-released.markdown +25 -0
  97. data/site/_posts/2013-07-14-jekyll-1-1-0-released.markdown +27 -0
  98. data/site/_posts/2013-07-24-jekyll-1-1-1-released.markdown +31 -0
  99. data/site/_posts/2013-07-25-jekyll-1-0-4-released.markdown +20 -0
  100. data/site/_posts/2013-07-25-jekyll-1-1-2-released.markdown +20 -0
  101. data/site/_posts/2013-09-06-jekyll-1-2-0-released.markdown +23 -0
  102. data/site/_posts/2013-09-14-jekyll-1-2-1-released.markdown +19 -0
  103. data/site/css/gridism.css +110 -0
  104. data/site/css/normalize.css +1 -0
  105. data/site/css/pygments.css +70 -0
  106. data/site/css/style.css +946 -0
  107. data/site/docs/configuration.md +373 -0
  108. data/site/docs/contributing.md +128 -0
  109. data/site/docs/datafiles.md +63 -0
  110. data/site/docs/deployment-methods.md +109 -0
  111. data/site/docs/drafts.md +20 -0
  112. data/site/docs/extras.md +56 -0
  113. data/site/docs/frontmatter.md +180 -0
  114. data/site/docs/github-pages.md +91 -0
  115. data/site/docs/heroku.md +9 -0
  116. data/site/docs/history.md +722 -0
  117. data/site/docs/index.md +52 -0
  118. data/site/docs/installation.md +76 -0
  119. data/site/docs/migrations.md +257 -0
  120. data/site/docs/pages.md +86 -0
  121. data/site/docs/pagination.md +211 -0
  122. data/site/docs/permalinks.md +180 -0
  123. data/site/docs/plugins.md +508 -0
  124. data/site/docs/posts.md +181 -0
  125. data/site/docs/quickstart.md +32 -0
  126. data/site/docs/resources.md +46 -0
  127. data/site/docs/sites.md +29 -0
  128. data/site/docs/structure.md +190 -0
  129. data/site/docs/templates.md +319 -0
  130. data/site/docs/troubleshooting.md +150 -0
  131. data/site/docs/upgrading.md +146 -0
  132. data/site/docs/usage.md +63 -0
  133. data/site/docs/variables.md +322 -0
  134. data/site/favicon.png +0 -0
  135. data/site/feed.xml +36 -0
  136. data/site/freenode.txt +1 -0
  137. data/site/img/article-footer.png +0 -0
  138. data/site/img/footer-arrow.png +0 -0
  139. data/site/img/footer-logo.png +0 -0
  140. data/site/img/logo-2x.png +0 -0
  141. data/site/img/octojekyll.png +0 -0
  142. data/site/img/tube.png +0 -0
  143. data/site/img/tube1x.png +0 -0
  144. data/site/index.html +90 -0
  145. data/site/js/modernizr-2.5.3.min.js +4 -0
  146. data/site/news/index.html +10 -0
  147. data/site/news/releases/index.html +10 -0
  148. data/test/helper.rb +6 -3
  149. data/test/source/+/foo.md +7 -0
  150. data/test/source/_data/languages.yml +2 -0
  151. data/test/source/_data/members.yaml +7 -0
  152. data/test/source/_data/products.yml +4 -0
  153. data/test/source/_includes/params.html +7 -0
  154. data/test/source/_layouts/default.html +1 -1
  155. data/test/source/_layouts/post/simple.html +1 -0
  156. data/test/source/_plugins/dummy.rb +1 -1
  157. data/test/source/_posts/2013-01-02-post-excerpt.markdown +1 -1
  158. data/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown +23 -0
  159. data/test/source/_posts/2013-08-01-mkdn-extension.mkdn +0 -0
  160. data/test/source/deal.with.dots.html +1 -1
  161. data/test/source/products.yml +4 -0
  162. data/test/test_configuration.rb +46 -11
  163. data/test/test_convertible.rb +2 -2
  164. data/test/test_excerpt.rb +78 -0
  165. data/test/test_filters.rb +4 -4
  166. data/test/test_generated_site.rb +13 -13
  167. data/test/test_json_driver.rb +9 -9
  168. data/test/test_kramdown.rb +32 -5
  169. data/test/test_new_command.rb +8 -8
  170. data/test/test_page.rb +12 -3
  171. data/test/test_pager.rb +34 -33
  172. data/test/test_post.rb +34 -26
  173. data/test/test_redcloth.rb +3 -3
  174. data/test/test_related_posts.rb +47 -0
  175. data/test/test_site.rb +102 -44
  176. data/test/test_tags.rb +168 -23
  177. data/test/test_url.rb +28 -0
  178. data/test/test_yaml_driver.rb +6 -6
  179. metadata +215 -137
  180. data/lib/monad/commands/doctor.rb +0 -29
  181. data/lib/monad/commands/new.rb +0 -50
  182. data/lib/monad/commands/serve.rb +0 -33
  183. data/lib/monad/converters/markdown/kramdown_parser.rb +0 -44
  184. data/lib/monad/deprecator.rb +0 -32
  185. data/lib/monad/generators/pagination.rb +0 -143
  186. data/lib/monad/logger.rb +0 -54
  187. data/lib/monad/tags/gist.rb +0 -30
  188. data/lib/monad/tags/include.rb +0 -37
@@ -1,29 +0,0 @@
1
- module Monad
2
- module Commands
3
- class Doctor < Command
4
- class << self
5
- def process(options)
6
- site = Monad::Site.new(options)
7
- site.read
8
-
9
- unless deprecated_relative_permalinks(site)
10
- Monad::Logger.info "Your test results", "are in. Everything looks fine."
11
- end
12
- end
13
-
14
- def deprecated_relative_permalinks(site)
15
- contains_deprecated_pages = false
16
- site.pages.each do |page|
17
- if page.uses_relative_permalinks
18
- Monad::Logger.warn "Deprecation:", "'#{page.path}' uses relative" +
19
- " permalinks which will be deprecated in" +
20
- " Monad v1.1 and beyond."
21
- contains_deprecated_pages = true
22
- end
23
- end
24
- contains_deprecated_pages
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,50 +0,0 @@
1
- require 'erb'
2
-
3
- module Monad
4
- module Commands
5
- class New < Command
6
- def self.process(args)
7
- raise ArgumentError.new('You must specify a path.') if args.empty?
8
-
9
- new_blog_path = File.expand_path(args.join(" "), Dir.pwd)
10
- FileUtils.mkdir_p new_blog_path
11
- unless Dir["#{new_blog_path}/**/*"].empty?
12
- Monad::Logger.error "Conflict:", "#{new_blog_path} exists and is not empty."
13
- exit(1)
14
- end
15
-
16
- create_sample_files new_blog_path
17
-
18
- File.open(File.expand_path(self.initialized_post_name, new_blog_path), "w") do |f|
19
- f.write(self.scaffold_post_content(site_template))
20
- end
21
- puts "New monad site installed in #{new_blog_path}."
22
- end
23
-
24
- def self.scaffold_post_content(template_site)
25
- ERB.new(File.read(File.expand_path(scaffold_path, site_template))).result
26
- end
27
-
28
- # Internal: Gets the filename of the sample post to be created
29
- #
30
- # Returns the filename of the sample post, as a String
31
- def self.initialized_post_name
32
- "_posts/#{Time.now.strftime('%Y-%m-%d')}-welcome-to-monad.markdown"
33
- end
34
-
35
- private
36
- def self.create_sample_files(path)
37
- FileUtils.cp_r site_template + '/.', path
38
- FileUtils.rm File.expand_path(scaffold_path, path)
39
- end
40
-
41
- def self.site_template
42
- File.expand_path("../../site_template", File.dirname(__FILE__))
43
- end
44
-
45
- def self.scaffold_path
46
- "_posts/0000-00-00-welcome-to-monad.markdown.erb"
47
- end
48
- end
49
- end
50
- end
@@ -1,33 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- module Monad
3
- module Commands
4
- class Serve < Command
5
- def self.process(options)
6
- require 'webrick'
7
- include WEBrick
8
-
9
- destination = options['destination']
10
-
11
- FileUtils.mkdir_p(destination)
12
-
13
- mime_types_file = File.expand_path('../mime.types', File.dirname(__FILE__))
14
- mime_types = WEBrick::HTTPUtils::load_mime_types(mime_types_file)
15
-
16
- # recreate NondisclosureName under utf-8 circumstance
17
- fh_option = WEBrick::Config::FileHandler
18
- fh_option[:NondisclosureName] = ['.ht*','~*']
19
-
20
- s = HTTPServer.new(
21
- :Port => options['port'],
22
- :BindAddress => options['host'],
23
- :MimeTypes => mime_types
24
- )
25
-
26
- s.mount(options['baseurl'], HTTPServlet::FileHandler, destination, fh_option)
27
- t = Thread.new { s.start }
28
- trap("INT") { s.shutdown }
29
- t.join()
30
- end
31
- end
32
- end
33
- end
@@ -1,44 +0,0 @@
1
- module Monad
2
- module Converters
3
- class Markdown
4
- class KramdownParser
5
- def initialize(config)
6
- require 'kramdown'
7
- @config = config
8
- rescue LoadError
9
- STDERR.puts 'You are missing a library required for Markdown. Please run:'
10
- STDERR.puts ' $ [sudo] gem install kramdown'
11
- raise FatalException.new("Missing dependency: kramdown")
12
- end
13
-
14
- def convert(content)
15
- # Check for use of coderay
16
- kramdown_configs = if @config['kramdown']['use_coderay']
17
- base_kramdown_configs.merge({
18
- :coderay_wrap => @config['kramdown']['coderay']['coderay_wrap'],
19
- :coderay_line_numbers => @config['kramdown']['coderay']['coderay_line_numbers'],
20
- :coderay_line_number_start => @config['kramdown']['coderay']['coderay_line_number_start'],
21
- :coderay_tab_width => @config['kramdown']['coderay']['coderay_tab_width'],
22
- :coderay_bold_every => @config['kramdown']['coderay']['coderay_bold_every'],
23
- :coderay_css => @config['kramdown']['coderay']['coderay_css']
24
- })
25
- else
26
- # not using coderay
27
- base_kramdown_configs
28
- end
29
- Kramdown::Document.new(content, kramdown_configs).to_html
30
- end
31
-
32
- def base_kramdown_configs
33
- {
34
- :auto_ids => @config['kramdown']['auto_ids'],
35
- :footnote_nr => @config['kramdown']['footnote_nr'],
36
- :entity_output => @config['kramdown']['entity_output'],
37
- :toc_levels => @config['kramdown']['toc_levels'],
38
- :smart_quotes => @config['kramdown']['smart_quotes']
39
- }
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,32 +0,0 @@
1
- module Monad
2
- class Deprecator
3
- def self.process(args)
4
- no_subcommand(args)
5
- deprecation_message args, "--server", "The --server command has been replaced by the \
6
- 'serve' subcommand."
7
- deprecation_message args, "--no-server", "To build Monad without launching a server, \
8
- use the 'build' subcommand."
9
- deprecation_message args, "--auto", "The switch '--auto' has been replaced with '--watch'."
10
- deprecation_message args, "--no-auto", "To disable auto-replication, simply leave off \
11
- the '--watch' switch."
12
- deprecation_message args, "--pygments", "The 'pygments' setting can only be set in \
13
- your config files."
14
- deprecation_message args, "--paginate", "The 'paginate' setting can only be set in your \
15
- config files."
16
- deprecation_message args, "--url", "The 'url' setting can only be set in your config files."
17
- end
18
-
19
- def self.no_subcommand(args)
20
- if args.size > 0 && args.first =~ /^--/ && !%w[--help --version].include?(args.first)
21
- Monad::Logger.error "Deprecation:", "Monad now uses subcommands instead of just \
22
- switches. Run `monad help' to find out more."
23
- end
24
- end
25
-
26
- def self.deprecation_message(args, deprecated_argument, message)
27
- if args.include?(deprecated_argument)
28
- Monad::Logger.error "Deprecation:", message
29
- end
30
- end
31
- end
32
- end
@@ -1,143 +0,0 @@
1
- module Monad
2
- module Generators
3
- class Pagination < Generator
4
- # This generator is safe from arbitrary code execution.
5
- safe true
6
-
7
- # Generate paginated pages if necessary.
8
- #
9
- # site - The Site.
10
- #
11
- # Returns nothing.
12
- def generate(site)
13
- site.pages.dup.each do |page|
14
- paginate(site, page) if Pager.pagination_enabled?(site.config, page)
15
- end
16
- end
17
-
18
- # Paginates the blog's posts. Renders the index.html file into paginated
19
- # directories, e.g.: page2/index.html, page3/index.html, etc and adds more
20
- # site-wide data.
21
- #
22
- # site - The Site.
23
- # page - The index.html Page that requires pagination.
24
- #
25
- # {"paginator" => { "page" => <Number>,
26
- # "per_page" => <Number>,
27
- # "posts" => [<Post>],
28
- # "total_posts" => <Number>,
29
- # "total_pages" => <Number>,
30
- # "previous_page" => <Number>,
31
- # "next_page" => <Number> }}
32
- def paginate(site, page)
33
- all_posts = site.site_payload['site']['posts']
34
- pages = Pager.calculate_pages(all_posts, site.config['paginate'].to_i)
35
- (1..pages).each do |num_page|
36
- pager = Pager.new(site.config, num_page, all_posts, pages)
37
- if num_page > 1
38
- newpage = Page.new(site, site.source, page.dir, page.name)
39
- newpage.pager = pager
40
- newpage.dir = File.join(page.dir, Pager.paginate_path(site.config, num_page))
41
- site.pages << newpage
42
- else
43
- page.pager = pager
44
- end
45
- end
46
- end
47
-
48
- end
49
- end
50
-
51
- class Pager
52
- attr_reader :page, :per_page, :posts, :total_posts, :total_pages,
53
- :previous_page, :previous_page_path, :next_page, :next_page_path
54
-
55
- # Calculate the number of pages.
56
- #
57
- # all_posts - The Array of all Posts.
58
- # per_page - The Integer of entries per page.
59
- #
60
- # Returns the Integer number of pages.
61
- def self.calculate_pages(all_posts, per_page)
62
- (all_posts.size.to_f / per_page.to_i).ceil
63
- end
64
-
65
- # Determine if pagination is enabled for a given file.
66
- #
67
- # config - The configuration Hash.
68
- # page - The Monad::Page with which to paginate
69
- #
70
- # Returns true if pagination is enabled, false otherwise.
71
- def self.pagination_enabled?(config, page)
72
- !config['paginate'].nil? &&
73
- page.name == 'index.html' &&
74
- subdirectories_identical(config['paginate_path'], page.dir)
75
- end
76
-
77
- # Determine if the subdirectories of the two paths are the same relative to source
78
- #
79
- # paginate_path - the paginate_path configuration setting
80
- # page_dir - the directory of the Monad::Page
81
- #
82
- # Returns whether the subdirectories are the same relative to source
83
- def self.subdirectories_identical(paginate_path, page_dir)
84
- File.dirname(paginate_path).gsub(/\A\./, '') == page_dir.gsub(/\/\z/, '')
85
- end
86
-
87
- # Static: Return the pagination path of the page
88
- #
89
- # site_config - the site config
90
- # num_page - the pagination page number
91
- #
92
- # Returns the pagination path as a string
93
- def self.paginate_path(site_config, num_page)
94
- return nil if num_page.nil? || num_page <= 1
95
- format = File.basename(site_config['paginate_path'])
96
- format.sub(':num', num_page.to_s)
97
- end
98
-
99
- # Initialize a new Pager.
100
- #
101
- # config - The Hash configuration of the site.
102
- # page - The Integer page number.
103
- # all_posts - The Array of all the site's Posts.
104
- # num_pages - The Integer number of pages or nil if you'd like the number
105
- # of pages calculated.
106
- def initialize(config, page, all_posts, num_pages = nil)
107
- @page = page
108
- @per_page = config['paginate'].to_i
109
- @total_pages = num_pages || Pager.calculate_pages(all_posts, @per_page)
110
-
111
- if @page > @total_pages
112
- raise RuntimeError, "page number can't be greater than total pages: #{@page} > #{@total_pages}"
113
- end
114
-
115
- init = (@page - 1) * @per_page
116
- offset = (init + @per_page - 1) >= all_posts.size ? all_posts.size : (init + @per_page - 1)
117
-
118
- @total_posts = all_posts.size
119
- @posts = all_posts[init..offset]
120
- @previous_page = @page != 1 ? @page - 1 : nil
121
- @previous_page_path = Pager.paginate_path(config, @previous_page)
122
- @next_page = @page != @total_pages ? @page + 1 : nil
123
- @next_page_path = Pager.paginate_path(config, @next_page)
124
- end
125
-
126
- # Convert this Pager's data to a Hash suitable for use by Liquid.
127
- #
128
- # Returns the Hash representation of this Pager.
129
- def to_liquid
130
- {
131
- 'page' => page,
132
- 'per_page' => per_page,
133
- 'posts' => posts,
134
- 'total_posts' => total_posts,
135
- 'total_pages' => total_pages,
136
- 'previous_page' => previous_page,
137
- 'previous_page_path' => previous_page_path,
138
- 'next_page' => next_page,
139
- 'next_page_path' => next_page_path
140
- }
141
- end
142
- end
143
- end
@@ -1,54 +0,0 @@
1
- require 'logger'
2
-
3
- module Monad
4
- class Logger < Logger
5
- # Public: Print a monad message to stdout
6
- #
7
- # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
8
- # message - the message detail
9
- #
10
- # Returns nothing
11
- def self.info(topic, message)
12
- $stdout.puts message(topic, message)
13
- end
14
-
15
- # Public: Print a monad message to stderr
16
- #
17
- # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
18
- # message - the message detail
19
- #
20
- # Returns nothing
21
- def self.warn(topic, message)
22
- $stderr.puts message(topic, message).yellow
23
- end
24
-
25
- # Public: Print a monad error message to stderr
26
- #
27
- # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
28
- # message - the message detail
29
- #
30
- # Returns nothing
31
- def self.error(topic, message)
32
- $stderr.puts message(topic, message).red
33
- end
34
-
35
- # Public: Build a Monad topic method
36
- #
37
- # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
38
- # message - the message detail
39
- #
40
- # Returns the formatted message
41
- def self.message(topic, message)
42
- formatted_topic(topic) + message.gsub(/\s+/, ' ')
43
- end
44
-
45
- # Public: Format the topic
46
- #
47
- # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc.
48
- #
49
- # Returns the formatted topic statement
50
- def self.formatted_topic(topic)
51
- "#{topic} ".rjust(20)
52
- end
53
- end
54
- end
@@ -1,30 +0,0 @@
1
- # Gist Liquid Tag
2
- #
3
- # Example:
4
- # {% gist 1234567 %}
5
- # {% gist 1234567 file.rb %}
6
-
7
- module Monad
8
- class GistTag < Liquid::Tag
9
- def render(context)
10
- if tag_contents = @markup.strip.match(/\A(\d+) ?(\S*)\Z/)
11
- gist_id, filename = tag_contents[1].strip, tag_contents[2].strip
12
- gist_script_tag(gist_id, filename)
13
- else
14
- "Error parsing gist id"
15
- end
16
- end
17
-
18
- private
19
-
20
- def gist_script_tag(gist_id, filename=nil)
21
- if filename.empty?
22
- "<script src=\"https://gist.github.com/#{gist_id}.js\"> </script>"
23
- else
24
- "<script src=\"https://gist.github.com/#{gist_id}.js?file=#{filename}\"> </script>"
25
- end
26
- end
27
- end
28
- end
29
-
30
- Liquid::Template.register_tag('gist', Monad::GistTag)
@@ -1,37 +0,0 @@
1
- module Monad
2
- module Tags
3
- class IncludeTag < Liquid::Tag
4
- def initialize(tag_name, file, tokens)
5
- super
6
- @file = file.strip
7
- end
8
-
9
- def render(context)
10
- includes_dir = File.join(context.registers[:site].source, '_includes')
11
-
12
- if File.symlink?(includes_dir)
13
- return "Includes directory '#{includes_dir}' cannot be a symlink"
14
- end
15
-
16
- if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
17
- return "Include file '#{@file}' contains invalid characters or sequences"
18
- end
19
-
20
- Dir.chdir(includes_dir) do
21
- choices = Dir['**/*'].reject { |x| File.symlink?(x) }
22
- if choices.include?(@file)
23
- source = File.read(@file)
24
- partial = Liquid::Template.parse(source)
25
- context.stack do
26
- partial.render(context)
27
- end
28
- else
29
- "Included file '#{@file}' not found in _includes directory"
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
36
-
37
- Liquid::Template.register_tag('include', Monad::Tags::IncludeTag)