Use Padrino and sprockets with sprockets-helpers

Thanks to @arthur_chiu and his post on how to integrate sprockets in Padrino with sprockets-helpers, i’ve create my version :D:D:D:D

1) Create padrino-sprockets in config/sprockets.rb

module Padrino::Sprockets
  def self.registered(base)
    base.set :sprockets, ::Sprockets::Environment.new(Padrino.root)
 
    # Add folder
    base.sprockets.append_path 'assets/javascripts'
    base.sprockets.append_path 'assets/stylesheets'
    base.sprockets.append_path 'assets/images'
    base.set :digest_assets, true
 
    # compress file
    if PADRINO_ENV == 'development'
      base.sprockets.js_compressor = Uglifier.new(mangle: true)
      base.sprockets.css_compressor = YUI::CssCompressor.new
    end
 
    # sprockets-helpers
    base.helpers Sprockets::Helpers
    # We can configure `sprockets-helpers` to find the correct assets for us.
    Sprockets::Helpers.configure do |config|
      manifest_path      = File.join(Padrino.root,'public','assets','manifest.json')
      config.environment = base.sprockets
      config.prefix      = '/assets'
      config.manifest    = Sprockets::Manifest.new(base.sprockets, manifest_path)
      config.digest      = true
      config.public_path = base.public_folder
    end
 
    # call sprockets 😀
    if PADRINO_ENV == 'development'
      base.get '/assets/*splat' do
        env['PATH_INFO'].gsub!(%r{A/?assets}, '')
        settings.sprockets.call(env)
      end
    end
  end
end

In this file you need add all your asset’s folder..

2) Load this file at startup application:
config/boot.rb

# after this line
Bundler.require(:default, PADRINO_ENV)
 
# add this
require Padrino.root('config/sprockets')

3) register Padrino::Sprockets in your application

Module Foo
  class App < Padrino::Application
   register Padrino::Sprockets
 
  end
end

4) Use js,css sprockets version in you layout, es:

layout.slim

link href= stylesheet_path('app') media="screen" type="text/css" rel="stylesheet"

instead

= stylesheet_link_tag :app

5) Use Rakefile to create asstes to pre-compilation :D:D

PADRINO_ENV  = ENV['PADRINO_ENV'] ||= ENV['RACK_ENV'] ||= 'development'  unless defined?(PADRINO_ENV)
 
require 'bundler/setup'
require 'padrino-core/cli/rake'
 
 
require 'sprockets/../rake/sprocketstask'
 
 Bundler.require(PADRINO_ENV)
require File.expand_path("../config/boot.rb", __FILE__)
 
PadrinoTasks.use(:database)
PadrinoTasks.use(:minirecord)
PadrinoTasks.init
 
# Use fake application 
module FakeSprock
  class App < Padrino::Application
    register Padrino::Sprockets
  end
end
 
SPROCKETS = FakeSprock::App.sprockets
 
# or your real app name
# SPROCKETS = RealAppName::App.sprockets
 
Rake::SprocketsTask.new do |t|
  manifest_path = File.join(Padrino.root,'public','assets')
  t.environment = SPROCKETS
  t.output      = File.join(Padrino.root,'public','assets')
  t.manifest    = Sprockets::Manifest.new(SPROCKETS, manifest_path)
  t.assets      = %w[app.js app.css *.png *.gif *.jpg]
end

and call it with

rake assets

To conitnue use stylesheet_link_tag and javascript_include_tag, need to close this issue

Thanks again at @padrino-core.
Special tanks:
DAddYE
@arthur_chiu

Padrino 0.11.0 Released – Padrino Lives!

The Padrino team is very pleased to finally be able to announce the 0.11.0 release of the Padrino Framework! We have been working on this release for almost a year now and we have had dozens of contributors helping us stabilize Padrino. We know our release cycle got out whack and this version took too long to release. We all take accountability for that and will work to pick up release momentum and release patch and minor versions more often.

Since our 0.10.7 release, development on Padrino has been moving forward very actively and as such this is probably our biggest release in terms of code modified and issues resolved that we have had in years. We are very proud of this release which includes several major improvements:

1) Totally Redesigned Admin
2) New brand identity on the way
3) Upgraded Sinatra and http_router
4) CSRF Form Protection
5) ActiveSupport::SafeBuffer
6) New Rakefile format
7) Gemified Apps
8) Performance Tools
9) App Namespacing
10) Project Modules
11) Optimized Reloader

http://www.padrinorb.com/blog/padrino-0-11-0-released-padrino-lives