Module: CSP
- Included in:
- Jekyll::Document, Jekyll::Page
- Defined in:
- lib/jekyll-csp/csp.rb
Overview
Provides the ability to generate a content security policy for inline scripts and styles. Will reuse an existing CSP or generate a new one and insert in HEAD.
Defined Under Namespace
Classes: Generator
Instance Method Summary collapse
-
#write(dest) ⇒ Object
Write document contents.
-
#write_file_contents(dest, content) ⇒ Object
Write the file contents back.
Instance Method Details
#write(dest) ⇒ Object
Write document contents
316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/jekyll-csp/csp.rb', line 316 def write(dest) dest_path = destination(dest) if File.extname(dest_path) == ".html" content_security_policy_generator = Generator.new output self.write_file_contents(dest_path, content_security_policy_generator.run) else self.write_file_contents(dest_path, output) end end |
#write_file_contents(dest, content) ⇒ Object
Write the file contents back.
307 308 309 310 311 312 |
# File 'lib/jekyll-csp/csp.rb', line 307 def write_file_contents(dest, content) FileUtils.mkdir_p(File.dirname(dest)) File.open(dest, 'w') do |f| f.write(content) end end |