-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d57c0f4
commit 53e4ea1
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
require 'awestruct/handlers/base_handler' | ||
require 'org-ruby' | ||
|
||
module Awestruct | ||
module Handlers | ||
class OrgmodeHandler < BaseHandler | ||
|
||
def initialize(site, delegate) | ||
super( site, delegate ) | ||
end | ||
|
||
def simple_name | ||
File.basename( relative_source_path, '.org' ) | ||
end | ||
|
||
def output_filename | ||
File.basename( relative_source_path, '.org' ) + '.html' | ||
end | ||
|
||
def output_extension | ||
'.html' | ||
end | ||
|
||
def content_syntax | ||
:orgmode | ||
end | ||
|
||
def rendered_content(context, with_layouts=true) | ||
Orgmode::Parser.new(super( context, with_layouts) ).to_html | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
require 'awestruct/handlers/file_handler' | ||
require 'awestruct/handlers/orgmode_handler' | ||
|
||
require 'hashery/open_cascade' | ||
|
||
describe Awestruct::Handlers::OrgmodeHandler do | ||
|
||
before :all do | ||
@site = OpenCascade.new :encoding=>false, :dir=>Pathname.new( File.dirname(__FILE__) + '/test-data/handlers' ) | ||
end | ||
|
||
def handler_file(path) | ||
"#{@site.dir}/#{path}" | ||
end | ||
|
||
def create_context | ||
OpenCascade.new :site=>@site | ||
end | ||
|
||
it "should provide a simple name for the page" do | ||
file_handler = Awestruct::Handlers::FileHandler.new( @site, handler_file( "orgmode-page.org" ) ) | ||
orgmode_handler = Awestruct::Handlers::OrgmodeHandler.new( @site, file_handler ) | ||
|
||
orgmode_handler.simple_name.should == 'orgmode-page' | ||
end | ||
|
||
it "should successfully render an org-mode page" do | ||
file_handler = Awestruct::Handlers::FileHandler.new( @site, handler_file( "orgmode-page.org" ) ) | ||
orgmode_handler = Awestruct::Handlers::OrgmodeHandler.new( @site, file_handler ) | ||
|
||
rendered = orgmode_handler.rendered_content( create_context ) | ||
rendered.should_not be_nil | ||
rendered.should =~ %r(<h1 class="title">Fruit</h1>) | ||
rendered.should =~ %r(<p>Apples are red</p>) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* Fruit | ||
** Apples | ||
Apples are red | ||
** Oranges | ||
Oranges are orange | ||
*Vegetables |