Class: Jekyll::Latex::Pdf::Document
- Inherits:
-
Page
- Object
- Page
- Jekyll::Latex::Pdf::Document
- Defined in:
- lib/jekyll/latex/pdf/document.rb
Overview
The document adds the file.
Instance Attribute Summary collapse
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #bibtex_files ⇒ Object
- #check_figure ⇒ Object
- #check_scholar ⇒ Object
-
#initialize(site, page) ⇒ Document
constructor
A new instance of Document.
- #permalink ⇒ Object
- #write(dest) ⇒ Object
Constructor Details
#initialize(site, page) ⇒ Document
Returns a new instance of Document.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jekyll/latex/pdf/document.rb', line 14 def initialize(site, page) @site = site @page = page @base = site.source @dir = File.dirname(page.url) @name = File.basename(page.url, File.extname(page.url)) + ".pdf" @texname = File.basename(page.url, File.extname(page.url)) + ".tex" process(@name) self.data = page.data.clone self.content = page.content.clone self.source = page.content.dup page.data["pdf_url"] = url data["html_url"] = page.url data["date_str"] = data["date"].strftime("%Y-%m-%d") @config = Defaults.defaults.merge(site.config["pdf"] || {}) @kramdowndata = KramdownData.new data @kramdowndata.add(@site.config["pdf"] || {}) @kramdowndata.add(page.data || {}) check_scholar check_figure end |
Instance Attribute Details
#source ⇒ Object
Returns the value of attribute source.
12 13 14 |
# File 'lib/jekyll/latex/pdf/document.rb', line 12 def source @source end |
Instance Method Details
#bibtex_files ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/jekyll/latex/pdf/document.rb', line 74 def bibtex_files if @site.config["scholar"]['bibliography'].include? '*' @bibtex_files ||= Dir.glob(File.join(@site.config["scholar"]["source"], @site.config["scholar"]["bibliography"])). collect do |f| Pathname(f).relative_path_from(Pathname(@site.config["scholar"]['source'])).to_s end end @bibtex_files ||= [@site.config["scholar"]['bibliography']] end |
#check_figure ⇒ Object
52 53 54 55 56 |
# File 'lib/jekyll/latex/pdf/document.rb', line 52 def check_figure if site.config["plugins"].include? "jekyll-figure" require "jekyll/latex/pdf/figure" end end |
#check_scholar ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/jekyll/latex/pdf/document.rb', line 41 def check_scholar if @site.config["plugins"].include? "jekyll-scholar" require "jekyll/latex/pdf/scholar" @kramdowndata.add(bibtex_files: bibtex_files.map do |bibfile| File.join(@site.config["scholar"]["source"], bibfile) end) end end |
#permalink ⇒ Object
58 59 60 |
# File 'lib/jekyll/latex/pdf/document.rb', line 58 def permalink data.key?("permalink") ? (data["permalink"] + ext) : nil end |
#write(dest) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/jekyll/latex/pdf/document.rb', line 62 def write(dest) path = File.join(dest, CGI.unescape(url)) latex = Latex.new(source, @site, @page, @kramdowndata, @name) if 0 == latex.compile # Create target directory if not existing yet (in case of a new post - the HTML rendering which creates folders if needed happens later, so we need to do it here first) FileUtils.mkdir_p(File.dirname(path.to_s)) FileUtils.cp(latex.pdf_file, path) Jekyll.logger.debug "cp " + latex.pdf_file.to_s + " " + path.to_s end end |