Skip to content
Browse files

Transfer from Gollum to Jekyll

  • Loading branch information...
1 parent 609bb69 commit bb6be6c17b7f55eabd8b8389a35ed0db6aee3058 @karmi committed Feb 11, 2011
Showing with 55 additions and 58 deletions.
  1. +2 −2 hide.gemspec
  2. +2 −3 lib/hide.rb
  3. +11 −13 lib/hide/page.rb
  4. +17 −0 lib/hide/site.rb
  5. +0 −13 lib/hide/wiki.rb
  6. +1 −1 test/test_helper.rb
  7. +3 −3 test/unit/page_test.rb
  8. +19 −0 test/unit/site_test.rb
  9. +0 −23 test/unit/wiki_test.rb
View
4 hide.gemspec
@@ -9,15 +9,15 @@ Gem::Specification.new do |s|
s.authors = ["Karel Minarik"]
s.email = ["karmi@karmi.cz"]
s.homepage = ""
- s.summary = %q{Parse/index Gollum pages into ElasticSearch}
+ s.summary = %q{Parse and index Jekyll pages into ElasticSearch}
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_dependency "gollum", "> 1.1.0"
+ s.add_dependency "jekyll", "> 0.10.0"
s.add_dependency "slingshot-rb"
s.add_development_dependency "turn"
View
5 lib/hide.rb
@@ -1,8 +1,7 @@
-require 'gollum'
+require 'jekyll'
require 'slingshot'
-require 'yaml'
-require 'hide/wiki'
+require 'hide/site'
require 'hide/page'
require 'hide/indexer'
View
24 lib/hide/page.rb
@@ -1,27 +1,30 @@
module Hide
class Page
- attr_reader :path, :content, :meta
+ attr_reader :meta
- def initialize(title, path, content)
- @title, @path, @content = title, path, content
- parse_metadata
+ def initialize(page)
+ @page = page
end
def title
- meta['title'] || @title
end
def category
- meta['cat'] || 'page'
+ end
+
+ def content
+ end
+
+ def url
end
def id
- path.tr('/', '__').gsub(/\..+$/, '')
+ # path.tr('/', '__').gsub(/\..+$/, '')
end
def to_hash
- { :id => id, :title => title, :category => category, :content => content, :path => path }
+ { :id => id, :title => title, :category => category, :content => content, :url => url }
end
def to_indexed_json
@@ -30,10 +33,5 @@ def to_indexed_json
private
- def parse_metadata
- meta = @content.split("\n---\n").first.to_s
- @meta = YAML.load(meta)
- end
-
end
end
View
17 lib/hide/site.rb
@@ -0,0 +1,17 @@
+module Hide
+ class Site
+
+ def initialize(path)
+ @site = Jekyll::Site.new Jekyll.configuration({})
+ end
+
+ def pages
+ @site.pages
+ end
+
+ def posts
+ @site.posts
+ end
+
+ end
+end
View
13 lib/hide/wiki.rb
@@ -1,13 +0,0 @@
-module Hide
- class Wiki
-
- def initialize(path, options = {})
- @wiki = Gollum::Wiki.new(path, options)
- end
-
- def pages(treeish = nil)
- @wiki.pages(treeish).map { |p| Hide::Page.new(p.title, p.path, p.raw_data) }
- end
-
- end
-end
View
2 test/test_helper.rb
@@ -9,7 +9,7 @@
class Test::Unit::TestCase
- def wiki_path
+ def test_site_path
File.expand_path( 'wiki', File.dirname(__FILE__) )
end
View
6 test/unit/page_test.rb
@@ -6,13 +6,13 @@ class PageTest < Test::Unit::TestCase
context "Page" do
setup do
- @wiki = Hide::Wiki.new(wiki_path)
- @page = @wiki.pages.first
+ @site = Hide::Site.new(test_site_path)
+ @page = @site.pages.first
end
should "should save title, path and content" do
assert_equal 'You Know, for Search', @page.title
- assert_equal 'blog/_posts/2010-02-08-youknowforsearch.textile', @page.path
+ assert_equal 'blog/_posts/2010-02-08-youknowforsearch.textile', @page.url
assert_match Regexp.new(Regexp.escape("You Know, for Search")), @page.content
end
View
19 test/unit/site_test.rb
@@ -0,0 +1,19 @@
+require 'test_helper'
+
+module Hide
+
+ class SiteTest < Test::Unit::TestCase
+
+ context "Site" do
+ setup { @site = Hide::Site.new test_site_path }
+
+ should "have pages" do
+ assert_not_nil @site.pages
+ assert_equal 10, @site.pages.size
+ assert_instance_of Hide::Page, @site.pages.first
+ end
+ end
+
+ end
+
+end
View
23 test/unit/wiki_test.rb
@@ -1,23 +0,0 @@
-require 'test_helper'
-
-module Hide
-
- class WikiTest < Test::Unit::TestCase
-
- context "Wiki" do
- setup { @wiki = Hide::Wiki.new(wiki_path) }
-
- should "should be initialized with repo" do
- assert_not_nil @wiki
- end
-
- should "have pages" do
- assert_not_nil @wiki.pages
- assert_equal 10, @wiki.pages.size
- assert_instance_of Hide::Page, @wiki.pages.first
- end
- end
-
- end
-
-end

0 comments on commit bb6be6c

Please sign in to comment.
Something went wrong with that request. Please try again.