nanoc 2.2.2 → 3.0.0a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/bin/nanoc +29 -11
  2. data/bin/nanoc-select +85 -0
  3. metadata +27 -161
  4. data/ChangeLog +0 -3
  5. data/LICENSE +0 -19
  6. data/README +0 -75
  7. data/Rakefile +0 -76
  8. data/lib/nanoc.rb +0 -73
  9. data/lib/nanoc/base.rb +0 -26
  10. data/lib/nanoc/base/asset.rb +0 -117
  11. data/lib/nanoc/base/asset_defaults.rb +0 -21
  12. data/lib/nanoc/base/asset_rep.rb +0 -282
  13. data/lib/nanoc/base/binary_filter.rb +0 -44
  14. data/lib/nanoc/base/code.rb +0 -41
  15. data/lib/nanoc/base/compiler.rb +0 -67
  16. data/lib/nanoc/base/core_ext.rb +0 -2
  17. data/lib/nanoc/base/core_ext/hash.rb +0 -78
  18. data/lib/nanoc/base/core_ext/string.rb +0 -8
  19. data/lib/nanoc/base/data_source.rb +0 -286
  20. data/lib/nanoc/base/defaults.rb +0 -30
  21. data/lib/nanoc/base/filter.rb +0 -93
  22. data/lib/nanoc/base/layout.rb +0 -91
  23. data/lib/nanoc/base/notification_center.rb +0 -66
  24. data/lib/nanoc/base/page.rb +0 -132
  25. data/lib/nanoc/base/page_defaults.rb +0 -20
  26. data/lib/nanoc/base/page_rep.rb +0 -324
  27. data/lib/nanoc/base/plugin.rb +0 -71
  28. data/lib/nanoc/base/proxies.rb +0 -5
  29. data/lib/nanoc/base/proxies/asset_proxy.rb +0 -29
  30. data/lib/nanoc/base/proxies/asset_rep_proxy.rb +0 -26
  31. data/lib/nanoc/base/proxies/layout_proxy.rb +0 -25
  32. data/lib/nanoc/base/proxies/page_proxy.rb +0 -35
  33. data/lib/nanoc/base/proxies/page_rep_proxy.rb +0 -28
  34. data/lib/nanoc/base/proxy.rb +0 -37
  35. data/lib/nanoc/base/router.rb +0 -72
  36. data/lib/nanoc/base/site.rb +0 -274
  37. data/lib/nanoc/base/template.rb +0 -64
  38. data/lib/nanoc/binary_filters.rb +0 -1
  39. data/lib/nanoc/binary_filters/image_science_thumbnail.rb +0 -28
  40. data/lib/nanoc/cli.rb +0 -9
  41. data/lib/nanoc/cli/base.rb +0 -132
  42. data/lib/nanoc/cli/commands.rb +0 -10
  43. data/lib/nanoc/cli/commands/autocompile.rb +0 -80
  44. data/lib/nanoc/cli/commands/compile.rb +0 -311
  45. data/lib/nanoc/cli/commands/create_layout.rb +0 -85
  46. data/lib/nanoc/cli/commands/create_page.rb +0 -85
  47. data/lib/nanoc/cli/commands/create_site.rb +0 -323
  48. data/lib/nanoc/cli/commands/create_template.rb +0 -76
  49. data/lib/nanoc/cli/commands/help.rb +0 -69
  50. data/lib/nanoc/cli/commands/info.rb +0 -125
  51. data/lib/nanoc/cli/commands/switch.rb +0 -141
  52. data/lib/nanoc/cli/commands/update.rb +0 -91
  53. data/lib/nanoc/cli/logger.rb +0 -72
  54. data/lib/nanoc/data_sources.rb +0 -2
  55. data/lib/nanoc/data_sources/filesystem.rb +0 -707
  56. data/lib/nanoc/data_sources/filesystem_combined.rb +0 -495
  57. data/lib/nanoc/extra.rb +0 -6
  58. data/lib/nanoc/extra/auto_compiler.rb +0 -285
  59. data/lib/nanoc/extra/context.rb +0 -22
  60. data/lib/nanoc/extra/core_ext.rb +0 -2
  61. data/lib/nanoc/extra/core_ext/hash.rb +0 -54
  62. data/lib/nanoc/extra/core_ext/time.rb +0 -13
  63. data/lib/nanoc/extra/file_proxy.rb +0 -29
  64. data/lib/nanoc/extra/vcs.rb +0 -48
  65. data/lib/nanoc/extra/vcses.rb +0 -5
  66. data/lib/nanoc/extra/vcses/bazaar.rb +0 -21
  67. data/lib/nanoc/extra/vcses/dummy.rb +0 -20
  68. data/lib/nanoc/extra/vcses/git.rb +0 -21
  69. data/lib/nanoc/extra/vcses/mercurial.rb +0 -21
  70. data/lib/nanoc/extra/vcses/subversion.rb +0 -21
  71. data/lib/nanoc/filters.rb +0 -16
  72. data/lib/nanoc/filters/bluecloth.rb +0 -13
  73. data/lib/nanoc/filters/erb.rb +0 -19
  74. data/lib/nanoc/filters/erubis.rb +0 -14
  75. data/lib/nanoc/filters/haml.rb +0 -21
  76. data/lib/nanoc/filters/markaby.rb +0 -14
  77. data/lib/nanoc/filters/maruku.rb +0 -14
  78. data/lib/nanoc/filters/old.rb +0 -19
  79. data/lib/nanoc/filters/rainpress.rb +0 -13
  80. data/lib/nanoc/filters/rdiscount.rb +0 -13
  81. data/lib/nanoc/filters/rdoc.rb +0 -23
  82. data/lib/nanoc/filters/redcloth.rb +0 -14
  83. data/lib/nanoc/filters/relativize_paths.rb +0 -16
  84. data/lib/nanoc/filters/relativize_paths_in_css.rb +0 -16
  85. data/lib/nanoc/filters/relativize_paths_in_html.rb +0 -16
  86. data/lib/nanoc/filters/rubypants.rb +0 -14
  87. data/lib/nanoc/filters/sass.rb +0 -18
  88. data/lib/nanoc/helpers.rb +0 -9
  89. data/lib/nanoc/helpers/blogging.rb +0 -217
  90. data/lib/nanoc/helpers/capturing.rb +0 -63
  91. data/lib/nanoc/helpers/filtering.rb +0 -54
  92. data/lib/nanoc/helpers/html_escape.rb +0 -25
  93. data/lib/nanoc/helpers/link_to.rb +0 -113
  94. data/lib/nanoc/helpers/render.rb +0 -49
  95. data/lib/nanoc/helpers/tagging.rb +0 -56
  96. data/lib/nanoc/helpers/text.rb +0 -38
  97. data/lib/nanoc/helpers/xml_sitemap.rb +0 -63
  98. data/lib/nanoc/routers.rb +0 -3
  99. data/lib/nanoc/routers/default.rb +0 -54
  100. data/lib/nanoc/routers/no_dirs.rb +0 -66
  101. data/lib/nanoc/routers/versioned.rb +0 -79
  102. data/vendor/cri/ChangeLog +0 -0
  103. data/vendor/cri/LICENSE +0 -19
  104. data/vendor/cri/NEWS +0 -0
  105. data/vendor/cri/README +0 -4
  106. data/vendor/cri/Rakefile +0 -25
  107. data/vendor/cri/lib/cri.rb +0 -12
  108. data/vendor/cri/lib/cri/base.rb +0 -153
  109. data/vendor/cri/lib/cri/command.rb +0 -104
  110. data/vendor/cri/lib/cri/core_ext.rb +0 -8
  111. data/vendor/cri/lib/cri/core_ext/string.rb +0 -41
  112. data/vendor/cri/lib/cri/option_parser.rb +0 -186
  113. data/vendor/cri/test/test_base.rb +0 -6
  114. data/vendor/cri/test/test_command.rb +0 -6
  115. data/vendor/cri/test/test_core_ext.rb +0 -21
  116. data/vendor/cri/test/test_option_parser.rb +0 -279
@@ -1,5 +0,0 @@
1
- require 'nanoc/extra/vcses/bazaar'
2
- require 'nanoc/extra/vcses/dummy'
3
- require 'nanoc/extra/vcses/git'
4
- require 'nanoc/extra/vcses/mercurial'
5
- require 'nanoc/extra/vcses/subversion'
@@ -1,21 +0,0 @@
1
- module Nanoc::Extra::VCSes
2
-
3
- class Bazaar < Nanoc::Extra::VCS
4
-
5
- identifiers :bazaar, :bzr
6
-
7
- def add(filename)
8
- system('bzr', 'add', filename)
9
- end
10
-
11
- def remove(filename)
12
- system('bzr', 'rm', filename)
13
- end
14
-
15
- def move(src, dst)
16
- system('bzr', 'mv', src, dst)
17
- end
18
-
19
- end
20
-
21
- end
@@ -1,20 +0,0 @@
1
- module Nanoc::Extra::VCSes
2
-
3
- class Dummy < Nanoc::Extra::VCS
4
-
5
- identifiers :dummy
6
-
7
- def add(filename)
8
- end
9
-
10
- def remove(filename)
11
- FileUtils.rm_rf(filename)
12
- end
13
-
14
- def move(src, dst)
15
- FileUtils.move(src, dst)
16
- end
17
-
18
- end
19
-
20
- end
@@ -1,21 +0,0 @@
1
- module Nanoc::Extra::VCSes
2
-
3
- class Git < Nanoc::Extra::VCS
4
-
5
- identifiers :git
6
-
7
- def add(filename)
8
- system('git', 'add', filename)
9
- end
10
-
11
- def remove(filename)
12
- system('git', 'rm', filename)
13
- end
14
-
15
- def move(src, dst)
16
- system('git', 'mv', src, dst)
17
- end
18
-
19
- end
20
-
21
- end
@@ -1,21 +0,0 @@
1
- module Nanoc::Extra::VCSes
2
-
3
- class Mercurial < Nanoc::Extra::VCS
4
-
5
- identifiers :mercurial, :hg
6
-
7
- def add(filename)
8
- system('hg', 'add', filename)
9
- end
10
-
11
- def remove(filename)
12
- system('hg', 'rm', filename)
13
- end
14
-
15
- def move(src, dst)
16
- system('hg', 'mv', src, dst)
17
- end
18
-
19
- end
20
-
21
- end
@@ -1,21 +0,0 @@
1
- module Nanoc::Extra::VCSes
2
-
3
- class Subversion < Nanoc::Extra::VCS
4
-
5
- identifiers :subversion, :svn
6
-
7
- def add(filename)
8
- system('svn', 'add', filename)
9
- end
10
-
11
- def remove(filename)
12
- system('svn', 'rm', filename)
13
- end
14
-
15
- def move(src, dst)
16
- system('svn', 'mv', src, dst)
17
- end
18
-
19
- end
20
-
21
- end
@@ -1,16 +0,0 @@
1
- require 'nanoc/filters/bluecloth'
2
- require 'nanoc/filters/erb'
3
- require 'nanoc/filters/erubis'
4
- require 'nanoc/filters/haml'
5
- require 'nanoc/filters/markaby'
6
- require 'nanoc/filters/maruku'
7
- require 'nanoc/filters/old'
8
- require 'nanoc/filters/rainpress'
9
- require 'nanoc/filters/rdiscount'
10
- require 'nanoc/filters/rdoc'
11
- require 'nanoc/filters/redcloth'
12
- require 'nanoc/filters/relativize_paths'
13
- require 'nanoc/filters/relativize_paths_in_css'
14
- require 'nanoc/filters/relativize_paths_in_html'
15
- require 'nanoc/filters/rubypants'
16
- require 'nanoc/filters/sass'
@@ -1,13 +0,0 @@
1
- module Nanoc::Filters
2
- class BlueCloth < Nanoc::Filter
3
-
4
- identifiers :bluecloth
5
-
6
- def run(content)
7
- require 'bluecloth'
8
-
9
- ::BlueCloth.new(content).to_html
10
- end
11
-
12
- end
13
- end
@@ -1,19 +0,0 @@
1
- module Nanoc::Filters
2
- class ERB < Nanoc::Filter
3
-
4
- identifiers :erb
5
-
6
- def run(content)
7
- require 'erb'
8
-
9
- # Create context
10
- context = ::Nanoc::Extra::Context.new(assigns)
11
-
12
- # Get result
13
- erb = ::ERB.new(content)
14
- erb.filename = filename
15
- erb.result(context.get_binding)
16
- end
17
-
18
- end
19
- end
@@ -1,14 +0,0 @@
1
- module Nanoc::Filters
2
- class Erubis < Nanoc::Filter
3
-
4
- identifiers :erubis
5
-
6
- def run(content)
7
- require 'erubis'
8
-
9
- # Get result
10
- ::Erubis::Eruby.new(content).evaluate(assigns)
11
- end
12
-
13
- end
14
- end
@@ -1,21 +0,0 @@
1
- module Nanoc::Filters
2
- class Haml < Nanoc::Filter
3
-
4
- identifiers :haml
5
-
6
- def run(content)
7
- require 'haml'
8
-
9
- # Get options
10
- options = @obj_rep.attribute_named(:haml_options) || {}
11
- options[:filename] = filename
12
-
13
- # Create context
14
- context = ::Nanoc::Extra::Context.new(assigns)
15
-
16
- # Get result
17
- ::Haml::Engine.new(content, options).render(context, assigns)
18
- end
19
-
20
- end
21
- end
@@ -1,14 +0,0 @@
1
- module Nanoc::Filters
2
- class Markaby < Nanoc::Filter
3
-
4
- identifiers :markaby
5
-
6
- def run(content)
7
- require 'markaby'
8
-
9
- # Get result
10
- ::Markaby::Builder.new(assigns).instance_eval(content).to_s
11
- end
12
-
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- module Nanoc::Filters
2
- class Maruku < Nanoc::Filter
3
-
4
- identifiers :maruku
5
-
6
- def run(content)
7
- require 'maruku'
8
-
9
- # Get result
10
- ::Maruku.new(content).to_html
11
- end
12
-
13
- end
14
- end
@@ -1,19 +0,0 @@
1
- module Nanoc::Filters
2
- class Old < Nanoc::Filter
3
-
4
- identifiers :eruby, :markdown, :smartypants, :textile
5
-
6
- def run(content)
7
- raise Nanoc::Error.new(
8
- "The 'eruby', markdown', 'smartypants' and 'textile' filters no " +
9
- "longer exist. Instead, use the following filters:\n" +
10
- "\n" +
11
- "* for Markdown: bluecloth, rdiscount, redcloth\n" +
12
- "* for Textile: redcloth\n" +
13
- "* for embedded Ruby: erb, erubis\n" +
14
- "* for Smartypants: rubypants"
15
- )
16
- end
17
-
18
- end
19
- end
@@ -1,13 +0,0 @@
1
- module Nanoc::Filters
2
- class Rainpress < Nanoc::Filter
3
-
4
- identifier :rainpress
5
-
6
- def run(content)
7
- require 'rainpress'
8
-
9
- ::Rainpress.compress(content)
10
- end
11
-
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- module Nanoc::Filters
2
- class RDiscount < Nanoc::Filter
3
-
4
- identifiers :rdiscount
5
-
6
- def run(content)
7
- require 'rdiscount'
8
-
9
- ::RDiscount.new(content).to_html
10
- end
11
-
12
- end
13
- end
@@ -1,23 +0,0 @@
1
- module Nanoc::Filters
2
- class RDoc < Nanoc::Filter
3
-
4
- identifiers :rdoc
5
-
6
- def run(content)
7
- begin
8
- # new RDoc
9
- require 'rdoc/markup'
10
- require 'rdoc/markup/to_html'
11
-
12
- ::RDoc::Markup.new.convert(content, ::RDoc::Markup::ToHtml.new)
13
- rescue LoadError
14
- # old RDoc
15
- require 'rdoc/markup/simple_markup'
16
- require 'rdoc/markup/simple_markup/to_html'
17
-
18
- ::SM::SimpleMarkup.new.convert(content, ::SM::ToHtml.new)
19
- end
20
- end
21
-
22
- end
23
- end
@@ -1,14 +0,0 @@
1
- module Nanoc::Filters
2
- class RedCloth < Nanoc::Filter
3
-
4
- identifiers :redcloth
5
-
6
- def run(content)
7
- require 'redcloth'
8
-
9
- # Get result
10
- ::RedCloth.new(content).to_html
11
- end
12
-
13
- end
14
- end
@@ -1,16 +0,0 @@
1
- module Nanoc::Filters
2
- class RelativizePaths < Nanoc::Filter
3
-
4
- identifier :relativize_paths
5
-
6
- def run(content)
7
- raise RuntimeError.new(
8
- "The relativize_paths filter itself does not exist anymore. " +
9
- "If you want to relativize paths in HTML, use the " +
10
- "relativize_paths_in_html filter; if you want to relativize paths " +
11
- "in CSS, use the relativize_paths_in_css filter."
12
- )
13
- end
14
-
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Nanoc::Filters
2
- class RelativizePathsInCSS < Nanoc::Filter
3
-
4
- identifier :relativize_paths_in_css
5
-
6
- require 'nanoc/helpers/link_to'
7
- include Nanoc::Helpers::LinkTo
8
-
9
- def run(content)
10
- content.gsub(/url\((['"]?)(\/.+?)\1\)/) do
11
- 'url(' + $1 + relative_path_to($2) + $1 + ')'
12
- end
13
- end
14
-
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Nanoc::Filters
2
- class RelativizePathsInHTML < Nanoc::Filter
3
-
4
- identifier :relativize_paths_in_html
5
-
6
- require 'nanoc/helpers/link_to'
7
- include Nanoc::Helpers::LinkTo
8
-
9
- def run(content)
10
- content.gsub(/(src|href)=(['"]?)(\/.+?)\2([ >])/) do
11
- $1 + '=' + $2 + relative_path_to($3) + $2 + $4
12
- end
13
- end
14
-
15
- end
16
- end
@@ -1,14 +0,0 @@
1
- module Nanoc::Filters
2
- class SmartyPants < Nanoc::Filter
3
-
4
- identifiers :rubypants
5
-
6
- def run(content)
7
- require 'rubypants'
8
-
9
- # Get result
10
- ::RubyPants.new(content).to_html
11
- end
12
-
13
- end
14
- end
@@ -1,18 +0,0 @@
1
- module Nanoc::Filters
2
- class Sass < Nanoc::Filter
3
-
4
- identifiers :sass
5
-
6
- def run(content)
7
- require 'sass'
8
-
9
- # Get options
10
- options = @obj_rep.attribute_named(:sass_options) || {}
11
- options[:filename] = filename
12
-
13
- # Get result
14
- ::Sass::Engine.new(content, options).render
15
- end
16
-
17
- end
18
- end
@@ -1,9 +0,0 @@
1
- require 'nanoc/helpers/blogging'
2
- require 'nanoc/helpers/capturing'
3
- require 'nanoc/helpers/filtering'
4
- require 'nanoc/helpers/html_escape'
5
- require 'nanoc/helpers/link_to'
6
- require 'nanoc/helpers/render'
7
- require 'nanoc/helpers/tagging'
8
- require 'nanoc/helpers/text'
9
- require 'nanoc/helpers/xml_sitemap'
@@ -1,217 +0,0 @@
1
- module Nanoc::Helpers
2
-
3
- # Nanoc::Helpers::Blogging provides some functionality for building blogs,
4
- # such as finding articles and constructing feeds.
5
- #
6
- # This helper has a few requirements. First, all blog articles should have
7
- # the following attributes:
8
- #
9
- # * 'kind', set to 'article'.
10
- #
11
- # * 'created_at', set to the creation timestamp.
12
- #
13
- # Some functions in this blogging helper, such as the +atom_feed+ function,
14
- # require additional attributes to be set; these attributes are described in
15
- # the documentation for these functions.
16
- #
17
- # The two main functions are sorted_articles and atom_feed.
18
- #
19
- # To activate this helper, +include+ it, like this:
20
- #
21
- # include Nanoc::Helpers::Blogging
22
- module Blogging
23
-
24
- # Returns an unsorted list of articles.
25
- def articles
26
- @pages.select { |page| page.kind == 'article' }
27
- end
28
-
29
- # Returns a list of articles, sorted by descending creation date (so newer
30
- # articles appear first).
31
- def sorted_articles
32
- articles.sort_by { |a| a.created_at }.reverse
33
- end
34
-
35
- # Returns a string representing the atom feed containing recent articles,
36
- # sorted by descending creation date. +params+ is a hash where the
37
- # following keys can be set:
38
- #
39
- # +limit+:: The maximum number of articles to show. Defaults to 5.
40
- #
41
- # +articles+:: A list of articles to include in the feed. Defaults to the
42
- # list of articles returned by the articles function.
43
- #
44
- # +content_proc+:: A proc that returns the content of the given article,
45
- # passed as a parameter. By default, given the argument
46
- # +article+, this proc will return +article.content+.
47
- # This function may not return nil.
48
- #
49
- # +excerpt_proc+:: A proc that returns the excerpt of the given article,
50
- # passed as a parameter. By default, given the argument
51
- # +article+, this proc will return +article.excerpt+.
52
- # This function may return nil.
53
- #
54
- # The following attributes must be set on blog articles:
55
- #
56
- # * 'title', containing the title of the blog post.
57
- #
58
- # * all other attributes mentioned above.
59
- #
60
- # The following attributes can optionally be set on blog articles to
61
- # change the behaviour of the Atom feed:
62
- #
63
- # * 'excerpt', containing an excerpt of the article, usually only a few
64
- # lines long.
65
- #
66
- # * 'custom_path_in_feed', containing the path that will be used instead
67
- # of the normal path in the feed. This can be useful when including
68
- # non-outputted pages in a feed; such pages could have their custom feed
69
- # path set to the blog path instead, for example.
70
- #
71
- # The feed will also include dates on which the articles were updated.
72
- # These are generated automatically; the way this happens depends on the
73
- # used data source (the filesystem data source checks the file mtimes, for
74
- # instance).
75
- #
76
- # The feed page will need to have the following attributes:
77
- #
78
- # * 'base_url', containing the URL to the site, without trailing slash.
79
- # For example, if the site is at "http://example.com/", the base_url
80
- # would be "http://example.com". It is probably a good idea to define
81
- # this in the page defaults, i.e. the 'meta.yaml' file (at least if the
82
- # filesystem data source is being used, which is probably the case).
83
- #
84
- # * 'title', containing the title of the feed, which is usually also the
85
- # title of the blog.
86
- #
87
- # * 'author_name', containing the name of the page's author. This will
88
- # likely be a global attribute, unless the site is managed by several
89
- # people/
90
- #
91
- # * 'author_uri', containing the URI for the page's author, such as the
92
- # author's web site URL. This will also likely be a global attribute.
93
- #
94
- # The feed page can have the following optional attributes:
95
- #
96
- # * 'feed_url', containing the custom URL of the feed. This can be useful
97
- # when the private feed URL shouldn't be exposed; for example, when
98
- # using FeedBurner this would be set to the public FeedBurner URL.
99
- #
100
- # To construct a feed, create a blank page with no layout, only the 'erb'
101
- # (or 'erubis') filter, and an 'xml' extension. It may also be useful to
102
- # set 'is_hidden' to true, so that helpers such as the sitemap helper will
103
- # ignore the page. The content of the feed page should be:
104
- #
105
- # <%= atom_feed %>
106
- def atom_feed(params={})
107
- require 'builder'
108
-
109
- # Extract parameters
110
- limit = params[:limit] || 5
111
- relevant_articles = params[:articles] || articles || []
112
- content_proc = params[:content_proc] || lambda { |a| a.content }
113
- excerpt_proc = params[:excerpt_proc] || lambda { |a| a.excerpt }
114
-
115
- # Check feed page attributes
116
- if @page.base_url.nil?
117
- raise RuntimeError.new('Cannot build Atom feed: feed page has no base_url')
118
- end
119
- if @page.title.nil?
120
- raise RuntimeError.new('Cannot build Atom feed: feed page has no title')
121
- end
122
- if @page.author_name.nil?
123
- raise RuntimeError.new('Cannot build Atom feed: feed page has no author_name')
124
- end
125
- if @page.author_uri.nil?
126
- raise RuntimeError.new('Cannot build Atom feed: feed page has no author_uri')
127
- end
128
-
129
- # Check article attributes
130
- if relevant_articles.empty?
131
- raise RuntimeError.new('Cannot build Atom feed: no articles')
132
- end
133
- if relevant_articles.any? { |a| a.created_at.nil? }
134
- raise RuntimeError.new('Cannot build Atom feed: one or more articles lack created_at')
135
- end
136
-
137
- # Get sorted relevant articles
138
- sorted_relevant_articles = relevant_articles.sort_by { |a| a.created_at }.reverse.first(limit)
139
-
140
- # Get most recent article
141
- last_article = sorted_relevant_articles.first
142
-
143
- # Create builder
144
- buffer = ''
145
- xml = Builder::XmlMarkup.new(:target => buffer, :indent => 2)
146
-
147
- # Build feed
148
- xml.instruct!
149
- xml.feed(:xmlns => 'http://www.w3.org/2005/Atom') do
150
- # Add primary attributes
151
- xml.id @page.base_url + '/'
152
- xml.title @page.title
153
-
154
- # Add date
155
- xml.updated last_article.created_at.to_iso8601_time
156
-
157
- # Add links
158
- xml.link(:rel => 'alternate', :href => @page.base_url)
159
- xml.link(:rel => 'self', :href => feed_url)
160
-
161
- # Add author information
162
- xml.author do
163
- xml.name @page.author_name
164
- xml.uri @page.author_uri
165
- end
166
-
167
- # Add articles
168
- sorted_relevant_articles.each do |a|
169
- xml.entry do
170
- # Add primary attributes
171
- xml.id atom_tag_for(a)
172
- xml.title a.title, :type => 'html'
173
-
174
- # Add dates
175
- xml.published a.created_at.to_iso8601_time
176
- xml.updated a.mtime.to_iso8601_time
177
-
178
- # Add link
179
- xml.link(:rel => 'alternate', :href => url_for(a))
180
-
181
- # Add content
182
- summary = excerpt_proc.call(a)
183
- xml.content content_proc.call(a), :type => 'html'
184
- xml.summary summary, :type => 'html' unless summary.nil?
185
- end
186
- end
187
- end
188
-
189
- buffer
190
- end
191
-
192
- # Returns the URL for the given page. It will return the URL containing
193
- # the custom path in the feed if possible, otherwise the normal path.
194
- def url_for(page)
195
- @page.base_url + (page.custom_path_in_feed || page.path)
196
- end
197
-
198
- # Returns the URL of the feed. It will return the custom feed URL if set,
199
- # or otherwise the normal feed URL.
200
- def feed_url
201
- @page[:feed_url] || @page.base_url + @page.path
202
- end
203
-
204
- # Returns an URI containing an unique ID for the given page. This will be
205
- # used in the Atom feed to uniquely identify articles. These IDs are
206
- # created using a procedure suggested by Mark Pilgrim in this blog post:
207
- # http://diveintomark.org/archives/2004/05/28/howto-atom-id.
208
- def atom_tag_for(page)
209
- hostname = @page.base_url.sub(/.*:\/\/(.+?)\/?$/, '\1')
210
- formatted_date = page.created_at.to_iso8601_date
211
-
212
- 'tag:' + hostname + ',' + formatted_date + ':' + page.path
213
- end
214
-
215
- end
216
-
217
- end