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
Showing
4 changed files
with
93 additions
and
100 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,16 @@ | ||
class KeynoteProcessor | ||
include Appscript | ||
attr_reader :slides, :app | ||
|
||
def initialize(app_name) | ||
@app = Appscript.app(app_name) | ||
@slides = [] | ||
end | ||
|
||
def ingest! | ||
app.slideshows.get.first.slides.get.each do |s| | ||
slide = Slide.new(s.notes.get) | ||
@slides << slide | ||
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,39 @@ | ||
class Slide | ||
attr_reader :raw_text, :formatted_notes | ||
def initialize(raw) | ||
@raw_text = raw | ||
@formatted_notes = process_raw | ||
end | ||
|
||
def process_raw | ||
o = Slide.create_breaks_around(Slide.make_ascii(@raw_text)) | ||
o = Slide.tidy(o) | ||
end | ||
|
||
def self.create_breaks_around(text) | ||
"<p>#{text.gsub(/\n/, "</p>\n\n<p>")}</p>" | ||
end | ||
|
||
def self.tidy(text) | ||
text.gsub("<p></p>", "").gsub("\n\n\n", "\n") | ||
end | ||
|
||
def self.make_ascii(string) | ||
string = string.force_encoding('ASCII-8BIT') | ||
string = string.gsub("\r", "\n") | ||
|
||
string = string.gsub("\xe2\x80\x94", "--") # m dash | ||
string = string.gsub("\xe2\x80\x98", "'") # open single quote | ||
string = string.gsub("\xe2\x80\x99", "'") # close single quote | ||
string = string.gsub("\xe2\x80\x9c", '"') # open double quote | ||
string = string.gsub("\xe2\x80\x9d", '"') # close double quote | ||
|
||
string = string.gsub("\xc3\xa1", "á") # aacute | ||
string = string.gsub("\xc3\x87", "Ç") # Ccedil | ||
string = string.gsub("\xc3\xb6", "ö") # ouml | ||
string = string.gsub("\xc3\xbc", "ü") # uuml | ||
string = string.gsub("\xc3\xa8", "è") # egrave | ||
|
||
string.strip | ||
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,36 @@ | ||
class SlideTemplater | ||
attr_reader :slide_template, :page_template_string, :shortname | ||
|
||
def initialize(slide_template_string, page_template_string, shortname) | ||
@slide_template = slide_template_string | ||
@page_template = page_template_string | ||
@shortname = shortname | ||
end | ||
|
||
def process_keynote(keynote_obj) | ||
process_page(keynote_obj) | ||
end | ||
|
||
def process_slides(keynote_obj) | ||
# take the keynote obj, template up each slide, stick them in an array. | ||
output = [] | ||
keynote_obj.slides.each_with_index do |s, i| | ||
eruby = Erubis::Eruby.new(@slide_template) | ||
notes = s.formatted_notes | ||
index = i | ||
shortname = @shortname | ||
templated = eruby.evaluate(:notes => s.formatted_notes, | ||
:index => i, | ||
:shortname => @shortname) | ||
output << templated | ||
end | ||
# return the entire html | ||
output | ||
end | ||
|
||
def process_page(keynote_obj) | ||
all_slides = process_slides(keynote_obj).join("\n") | ||
eruby = Erubis::Eruby.new(@page_template) | ||
eruby.evaluate(:all_slides => all_slides) | ||
end | ||
end |