Class: Mdslide::Creator
- Inherits:
-
Object
- Object
- Mdslide::Creator
- Defined in:
- lib/mdslide/creator.rb
Instance Attribute Summary collapse
-
#scripts ⇒ Object
readonly
Returns the value of attribute scripts.
-
#stylesheets ⇒ Object
readonly
Returns the value of attribute stylesheets.
-
#theme_scripts ⇒ Object
readonly
Returns the value of attribute theme_scripts.
-
#theme_stylesheets ⇒ Object
readonly
Returns the value of attribute theme_stylesheets.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #convert_markdown(md) ⇒ Object
- #get_binding ⇒ Object
-
#initialize ⇒ Creator
constructor
A new instance of Creator.
- #set_theme(name) ⇒ Object
Constructor Details
#initialize ⇒ Creator
Returns a new instance of Creator.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mdslide/creator.rb', line 12 def initialize @stylesheets = ['base.css'] @scripts = ['jquery.min.js','slides.js'] @theme_scripts = [] @theme_stylesheets = [] @page_template = File.open(File.dirname(__FILE__) + '/../../templates/page.html.erb','r'){|r| erb = ERB.new(r.read)} @slide_template = File.open(File.dirname(__FILE__) + '/../../templates/slide.html.erb','r'){|r| erb = ERB.new(r.read)} @title = 'Slides converted by Mdslide' end |
Instance Attribute Details
#scripts ⇒ Object (readonly)
Returns the value of attribute scripts.
10 11 12 |
# File 'lib/mdslide/creator.rb', line 10 def scripts @scripts end |
#stylesheets ⇒ Object (readonly)
Returns the value of attribute stylesheets.
10 11 12 |
# File 'lib/mdslide/creator.rb', line 10 def stylesheets @stylesheets end |
#theme_scripts ⇒ Object (readonly)
Returns the value of attribute theme_scripts.
10 11 12 |
# File 'lib/mdslide/creator.rb', line 10 def theme_scripts @theme_scripts end |
#theme_stylesheets ⇒ Object (readonly)
Returns the value of attribute theme_stylesheets.
10 11 12 |
# File 'lib/mdslide/creator.rb', line 10 def theme_stylesheets @theme_stylesheets end |
#title ⇒ Object
Returns the value of attribute title.
11 12 13 |
# File 'lib/mdslide/creator.rb', line 11 def title @title end |
Instance Method Details
#convert_markdown(md) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mdslide/creator.rb', line 36 def convert_markdown md body = '' md.toutf8.gsub(/\r\n?/, "\n").split(/^\/\/+$/).map do || if =~ /(^|\s)(https?:\/\/[^\s]+)($|\s)/ .gsub!(/(^|\s)(https?:\/\/[^\s]+)($|\s)/){"#{$1}[#{$2}](#{$2})#{$3}"} end if =~ /(^|\s)@([a-zA-Z0-9_]+)($|\s)/ .gsub!(/(^|\s)@([a-zA-Z0-9_]+)($|\s)/, "#{$1}[@#{$2}](https://twitter.com/#{$2})#{$3}") end body += @slide_template.result(self.get_binding{Kramdown::Document.new().to_html}) end @page_template.result(self.get_binding{body}) end |
#get_binding ⇒ Object
32 33 34 |
# File 'lib/mdslide/creator.rb', line 32 def get_binding binding end |
#set_theme(name) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/mdslide/creator.rb', line 23 def set_theme name theme = Themes[name.to_sym] if theme theme[:css] && @theme_stylesheets.replace(theme[:css]) theme[:js] && @theme_scripts.replace(theme[:js]) end return theme end |