-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backup old ruby-stylus code suitable for Rails 3.2.0
- Loading branch information
Showing
37 changed files
with
906 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
## Changelog | ||
|
||
### 0.3.0 (Master) | ||
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.2.2...master) | ||
|
||
* Adds a `debug` configuration option, that enables the `linenos` and `firebug` flags on Stylus. Inside Rails, this configuration option will be copied from the `config.assets.debug`. | ||
|
||
### 0.2.2 (2011-09-14) | ||
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.2.1...v0.2.2) | ||
|
||
* ExecJS 1.2.5+ compatibility: Using a custom `ExternalRuntime`. | ||
|
||
### 0.2.1 (2011-08-30) | ||
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.2.0...v0.2.1) | ||
|
||
* Removed a hack for a Sprockets loading order issue; | ||
* Testing on 1.9.2, REE and Rubinius thanks to [Travis CI](travis-ci.org/#!/lucasmazza/ruby-stylus); | ||
* Enables compression if `Sprockets` is configured to do so; | ||
* Added Rails and Sprockets tests. | ||
|
||
### 0.2.0 (2011-07-14) | ||
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.1.2...v0.2.0) | ||
|
||
* Replaced `stylus:install` with proper generators for Rails 3.1 - now all hooks for the `stylesheet_engine` will generate `.styl` files. | ||
|
||
### 0.1.2 (2011-07-08) | ||
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.1.1...v0.1.2) | ||
|
||
* Fixes missing `require` for Rails apps. | ||
|
||
### 0.1.1 (2011-07-07) | ||
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.1.0...v0.1.1) | ||
|
||
* Requiring `stylus/tilt` outside the `Railtie`, by [DAddYE](https://github.com/DAddYE). | ||
|
||
### 0.1.0 (2011-06-21) | ||
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.0.3...v0.1.0) | ||
|
||
* Support for Stylus plugins via `Stylus.use`. | ||
* Docco documentation live at [http://lucasmazza.github.com/ruby-stylus](http://lucasmazza.github.com/ruby-stylus). | ||
|
||
|
||
### 0.0.3 (2011-06-06) | ||
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.0.2...v0.0.3) | ||
|
||
* Bugfix: stylus now works in production environment. | ||
|
||
### 0.0.2 (2011-06-02) | ||
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.0.1...v0.0.2) | ||
|
||
* Added a Rails Generator called `stylus:install` to copy sample files on your `lib/` folder. | ||
* Added `Stylus.convert` to parse CSS back to Stylus syntax. | ||
|
||
### 0.0.1 (2011-05-18) | ||
* Initial Release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
# Specify your gem's dependencies in stylus.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(The MIT License) | ||
|
||
Copyright (c) 2011 Lucas Mazza <luc4smazza@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,105 @@ | ||
ruby-stylus | ||
=========== | ||
# Ruby Stylus | ||
|
||
ruby-stylus | ||
[![Build Status](https://secure.travis-ci.org/lucasmazza/ruby-stylus.png)](http://travis-ci.org/lucasmazza/ruby-stylus) | ||
|
||
`stylus` is a bridge between your Ruby code and the [Stylus](https://github.com/LearnBoost/stylus) library that runs on [node.js](http://nodejs.org). It has support for the Rails 3.1 asset pipeline (thanks to a [Tilt](https://github.com/rtomayko/tilt) Template) and it's backed by the [ExecJS](https://github.com/sstephenson/execjs) gem. | ||
|
||
## Installation | ||
|
||
Be sure to have [node.js](http://nodejs.org) available on your system, and [npm](npmjs.org) to install the [Stylus](https://github.com/LearnBoost/stylus) package (but you can also do a manual installation). | ||
|
||
### With npm | ||
|
||
You can make a local install (inside your application folder, so the package will be at `./node_modules`) or a global one (with the `-g` flag). With a global install you will need to make sure that the global installation folder is present at the `NODE_PATH` env variable. A global install will also enable the [Stylus](https://github.com/LearnBoost/stylus) command line interface. | ||
|
||
### Manual | ||
|
||
You can clone Stylus [git repository](http://github.com/learnboost/stylus) into `node_modules/stylus`. Any `node` commands and/or shells from the current directory will be able to find the cloned package. | ||
|
||
Check your installation with `node -e "require('stylus')"`. It should print something like [this](https://gist.github.com/1182631) and exit successfully. | ||
|
||
## Usage | ||
|
||
The interaction is done by the `Stylus` module. You can compile stylus syntax to CSS, convert it back, enable plugins and tweak some other options: | ||
|
||
```ruby | ||
require 'stylus' | ||
|
||
# Accepts a raw string or an IO object (File, StringIO or anything that responds to 'read'). | ||
Stylus.compile(File.new('application.styl')) # returns the compiled stylesheet. | ||
|
||
# Using the compress option, removing most newlines from the code. | ||
Stylus.compile(File.read('application.styl'), :compress => true) | ||
|
||
# Or use the global compress flag | ||
Stylus.compress = true | ||
Stylus.compile(File.read('application.styl')) | ||
|
||
# Converting old and boring CSS to awesome Stylus. | ||
Stylus.convert(File.new('file.css')) | ||
|
||
# Importing plugins directly from Node.js, like nib. | ||
Stylus.use :nib | ||
|
||
# Enabling debug info, which sends the 'linenos' and 'firebug' options to Stylus. | ||
# If you provide a raw content String to the `Stylus.compile` method, remember to send | ||
# a `:filename` option so Stylus can locate your stylesheet for proper inspection. | ||
Stylus.debug = true | ||
``` | ||
### With the Rails 3.1 Asset Pipeline. | ||
|
||
Adding `stylus` to your Gemfile should let you work with `.styl` files with the Rails 3.1 Pipeline. Any asset generated with `rails generate` will be created with a `.css.styl` extension. | ||
|
||
While [Stylus](https://github.com/LearnBoost/stylus) has a `@import` directive, inside a Rails application you should use the `//= require` directive from Sprockets, so the caching mechanism will look after the changes made on the required file. If you're using mixins (for vendor prefixes or any common statements) or plugins inside your `.styl` files, you should use [Stylus](https://github.com/LearnBoost/stylus) `@import` **and** Sprockets `//= depend_on`. The latter is to ensure the proper dependency management on the Sprockets side. | ||
|
||
Any `.styl` file on the Sprockets load path (`app/assets`, `lib/assets`, `vendor/assets` or `assets` folder inside any other gem) will be available via the `@import` directive. | ||
|
||
If the `config.assets.debug` is turned on, Stylus will emit exta comments on your stylesheets to help debugging and inspection using the `linenos` and `firebug` options. Check the [FireStylus extension for Firebug](https://github.com/LearnBoost/stylus/blob/master/docs/firebug.md) for more info. | ||
|
||
## Plugins | ||
|
||
[Stylus](https://github.com/LearnBoost/stylus) exposes a nice API to create plugins written on [node.js](http://nodejs.org), like [nib](https://github.com/visionmedia/nib). The installation process should be same as described above for [Stylus](https://github.com/LearnBoost/stylus) (since they're all npm packages after all). You can hook them'up on your Ruby code with `Stylus.use`: | ||
|
||
```ruby | ||
Stylus.use :fingerprint, :literal => 'caa8c262e23268d2a7062c6217202343b84f472b' | ||
``` | ||
|
||
Will run something like this on javascript: | ||
|
||
```javascript | ||
stylus(file).use(fingerprint({literal:'caa8c262e23268d2a7062c6217202343b84f472b'})); | ||
``` | ||
|
||
## Question, Bugs or Support | ||
|
||
You can [submit an issue](https://github.com/lucasmazza/ruby-stylus/issues) or ping me at [GitHub](http://github.com/lucasmazza) or [twitter](http://twitter.com/lucasmazza). | ||
|
||
For more info about the [Stylus](https://github.com/LearnBoost/stylus) syntax and it's features you can check the [project repository](https://github.com/learnboost/stylus) and [GitHub page](learnboost.github.com/stylus). | ||
|
||
## Changelog | ||
[It's available here.](https://github.com/lucasmazza/ruby-stylus/blob/master/CHANGELOG.md) | ||
|
||
## License | ||
|
||
(The MIT License) | ||
|
||
Copyright (c) 2011 Lucas Mazza <luc4smazza@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'fileutils' | ||
require 'bundler' | ||
require 'rspec/core/rake_task' | ||
require 'rocco/tasks' | ||
Bundler::GemHelper.install_tasks | ||
|
||
desc "Run specs" | ||
RSpec::Core::RakeTask.new do |task| | ||
task.rspec_opts = ["-c -b"] | ||
end | ||
|
||
task :default => :spec | ||
|
||
Rocco::make 'docs/' | ||
|
||
desc 'Builds Rocco docs' | ||
task :docs => :rocco do | ||
Dir['docs/lib/**/*.html'].each do |file| | ||
path = file.gsub(/lib/,'') | ||
FileUtils.mkdir_p(File.dirname(path)) | ||
FileUtils.mv(file, path) | ||
end | ||
cp 'docs/stylus.html', 'docs/index.html', :preserve => true | ||
end | ||
directory 'docs/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require "rails/generators/named_base" | ||
|
||
module Stylus | ||
module Generators | ||
class AssetsGenerator < ::Rails::Generators::NamedBase | ||
source_root File.expand_path("../templates", __FILE__) | ||
|
||
def copy_stylus | ||
template "stylesheet.css.styl", File.join('app/assets/stylesheets', class_path, "#{file_name}.css.styl") | ||
end | ||
end | ||
end | ||
end |
3 changes: 3 additions & 0 deletions
3
lib/rails/generators/stylus/assets/templates/stylesheet.css.styl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the matching controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Stylus syntax here: http://learnboost.github.com/stylus |
11 changes: 11 additions & 0 deletions
11
lib/rails/generators/stylus/scaffold/scaffold_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'rails/generators/css/scaffold/scaffold_generator' | ||
|
||
module Stylus | ||
module Generators | ||
# Just inherit from the original Generator from Rails | ||
# because `scaffold.css` it's just to help people to start up | ||
# their Rails applications. | ||
class ScaffoldGenerator < Css::Generators::ScaffoldGenerator | ||
end | ||
end | ||
end |
Oops, something went wrong.