Sha256: f123db1f1a378489cb434716774470bfbc98e87ef7e869bbd72e1646159e24dd

Contents?: true

Size: 1.18 KB

Versions: 15

Compression:

Stored size: 1.18 KB

Contents

require_dependency "polyblock/application_controller"

module Polyblock
  class PolyblocksController < ApplicationController

    def update
      if params.has_key? :pbs and params[:pbs].any?
        params[:pbs].each do |id,content|
          pb = Block.find(id)
          pb.update_attributes!(:content => content) if pb.present?
        end
      end
      render :text => "OK!"
    end

    def convert_haml_to_html
      haml = params[:haml]

      # Remove the pesky helpers
      haml = haml.split("= succeed \"")
      lines = [haml.shift]
      haml.each do |chunk|
        arg = chunk.split("\"",2)[0]
        block = chunk.split("\n")[1..-1].map{|line| line[2..-1]}.join("\n")
        lines << "#{block}\narg"
      end
      haml = lines.join("")

      # Run it through the engine
      render :text => Haml::Engine.new(haml).render
    end

    def convert_html_to_haml
      # html = if params.has_key? :cbid then ContentBlock.find(params[:cbid]).content else params[:html] end
      # engine = Html2haml::HTML.new html, :erb => false, :xhtml => false
      engine = Html2haml::HTML.new params[:html], :erb => false, :xhtml => false
      render :text => engine.render
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
polyblock-0.3.0 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.2.9 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.2.8 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.2.7 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.2.5 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.2.4 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.2.3 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.2.2 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.2.1 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.2.0 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.1.8 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.1.7 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.1.6 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.1.2 app/controllers/polyblock/polyblocks_controller.rb
polyblock-0.0.7 app/controllers/polyblock/polyblocks_controller.rb