Permalink
Browse files

extended concept to extensions in general, providing both converters …

…and generators
  • Loading branch information...
krisb committed Feb 28, 2010
1 parent 84b26a3 commit fc86c9dd85ae99bc60dd7ec8c6190a58e6df2ec4
View
@@ -27,10 +27,17 @@
require 'jekyll/tags/include'
require 'jekyll/albino'
require 'jekyll/static_file'
+
+#extensions
+require 'jekyll/extension'
require 'jekyll/converter'
-require 'jekyll/converters/identity'
-require 'jekyll/converters/markdown'
-require 'jekyll/converters/textile'
+Dir["#{File.dirname(__FILE__)}/jekyll/converters/*.rb"].each do |file|
+ require file
+end
+require 'jekyll/generator'
+Dir["#{File.dirname(__FILE__)}/jekyll/generators/*.rb"].each do |file|
+ require file
+end
module Jekyll
# Default options. Overriden by values in _config.yml or command-line opts.
View
@@ -1,31 +1,8 @@
module Jekyll
- class Converter
-
- PRIORITIES = { :lowest => -100,
- :low => -10,
- :normal => 0,
- :high => 10,
- :highest => 100 }
+ class Converter < Extension
class << self
- def subclasses
- @subclasses ||= []
- end
-
- def inherited(base)
- subclasses << base
- subclasses.sort!
- end
-
- # priority order of this converter
- def priority(priority = nil)
- if priority && PRIORITIES.has_key?(priority)
- @priority = priority
- end
- @priority || :normal
- end
-
# prefix for highlighting
def pygments_prefix(pygments_prefix = nil)
@pygments_prefix = pygments_prefix if pygments_prefix
@@ -37,14 +14,6 @@ def pygments_suffix(pygments_suffix = nil)
@pygments_suffix = pygments_suffix if pygments_suffix
@pygments_suffix
end
-
- # Spaceship is priority [higher -> lower]
- #
- # Returns -1, 0, 1
- def <=>(other)
- cmp = PRIORITIES[other.priority] <=> PRIORITIES[self.priority]
- return cmp
- end
end
# prefix for highlighting
@@ -1,11 +1,8 @@
module Jekyll
+
class IdentityConverter < Converter
priority :lowest
- def initialize(config = {})
-
- end
-
def matches(ext)
true
end
@@ -19,4 +16,5 @@ def convert(content)
end
end
+
end
@@ -1,4 +1,5 @@
module Jekyll
+
class MarkdownConverter < Converter
pygments_prefix '\n'
pygments_suffix '\n'
@@ -62,4 +63,5 @@ def output_ext(ext)
end
end
+
end
@@ -1,12 +1,9 @@
module Jekyll
+
class TextileConverter < Converter
pygments_prefix '<notextile>'
pygments_suffix '</notextile>'
- def initialize(config = {})
-
- end
-
def matches(ext)
ext =~ /textile/i
end
@@ -20,4 +17,5 @@ def convert(content)
end
end
+
end
View
@@ -0,0 +1,44 @@
+module Jekyll
+
+ class Extension
+
+ PRIORITIES = { :lowest => -100,
+ :low => -10,
+ :normal => 0,
+ :high => 10,
+ :highest => 100 }
+
+ class << self
+ def subclasses
+ @subclasses ||= []
+ end
+
+ def inherited(base)
+ subclasses << base
+ subclasses.sort!
+ end
+
+ # priority order of this converter
+ def priority(priority = nil)
+ if priority && PRIORITIES.has_key?(priority)
+ @priority = priority
+ end
+ @priority || :normal
+ end
+
+ # Spaceship is priority [higher -> lower]
+ #
+ # Returns -1, 0, 1
+ def <=>(other)
+ cmp = PRIORITIES[other.priority] <=> PRIORITIES[self.priority]
+ return cmp
+ end
+ end
+
+ def initialize(config = {})
+ #no-op for default
+ end
+
+ end
+
+end
View
@@ -0,0 +1,7 @@
+module Jekyll
+
+ class Generator < Extension
+
+ end
+
+end
@@ -0,0 +1,7 @@
+module Jekyll
+
+ class Pagination < Generator
+
+ end
+
+end
View
@@ -3,7 +3,8 @@ module Jekyll
class Site
attr_accessor :config, :layouts, :posts, :pages, :static_files, :categories, :exclude,
:source, :dest, :lsi, :pygments, :permalink_style, :tags, :time,
- :future, :converters
+ :future
+ attr_accessor :converters, :generators
# Initialize the site
# +config+ is a Hash containing site configurations details
@@ -39,6 +40,7 @@ def setup
require 'classifier' if self.lsi
self.converters = Jekyll::Converter.subclasses.collect { |c| c.new(self.config) }
+ self.generators = Jekyll::Generator.subclasses.collect { |c| c.new(self.config) }
end
# Do the actual work of processing the site and generating the

0 comments on commit fc86c9d

Please sign in to comment.