Sha256: 4a0c411e3022f1781b7d057dd3509b161bd9bcc40108c7a3aead68de17f2babf

Contents?: true

Size: 371 Bytes

Versions: 9

Compression:

Stored size: 371 Bytes

Contents

description 'Download aspect'

Aspect.create(:download) do
  def accepts?(page); !page.content.empty?; end
  def call(context, page)
    name = page.root? ? :root.t : page.name.gsub(/[^\w.\-_]/, '_')
    context.header['Content-Disposition'] = %{attachment; filename="#{name}"}
    context.header['Content-Length'] = page.content.bytesize.to_s
    page.content
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
olelo-0.9.8 plugins/aspects/download.rb
olelo-0.9.7 plugins/aspects/download.rb
olelo-0.9.6 plugins/aspects/download.rb
olelo-0.9.5 plugins/aspects/download.rb
olelo-0.9.4 plugins/aspects/download.rb
olelo-0.9.3 plugins/aspects/download.rb
olelo-0.9.2 plugins/aspects/download.rb
olelo-0.9.1 plugins/aspects/download.rb
olelo-0.9.0 plugins/aspects/download.rb