GithubHelp home page GithubHelp logo

more's Introduction

This repo is DEPRECATED and is only here for historical reasons.

More

LESS on Rails.

More is a plugin for Ruby on Rails applications. It automatically parses your applications .less files through LESS and outputs CSS files.

In details, More does the following:

  • Recursively looks for LESS (.less) files in app/stylesheets
  • Ignores partials (prefixed with underscore: _partial.less) - these can be included with @import in your LESS files
  • Saves the resulting CSS files to public/stylesheets using the same directory structure as app/stylesheets

LESS

LESS extends CSS with: variables, mixins, operations and nested rules. For more information, see http://lesscss.org.

Upgrading from less-for-rails

The old less-for-rails plugin looked for .less files in public/stylesheets. This plugin looks in app/stylesheets.

To migrate, you can either set Less::More.source_path = Rails.root + "/public/stylesheets", or move your .less files to app/stylesheets.

Installation

More depends on the LESS gem. Please install LESS first:

$ gem install less

Rails Plugin

Use this to install as a plugin in a Ruby on Rails app:

$ script/plugin install git://github.com/cloudhead/more.git

Rails Plugin (using git submodules)

Use this if you prefer to use git submodules for plugins:

$ git submodule add git://github.com/cloudhead/more.git vendor/plugins/more
$ script/runner vendor/plugins/more/install.rb

Usage

Upon installation, a new directory will be created in app/stylesheets. Any LESS file placed in this directory, including subdirectories, will automatically be parsed through LESS and saved as a corresponding CSS file in public/stylesheets. Example:

app/stylesheets/clients/screen.less => public/stylesheets/clients/screen.css

If you prefix a file with an underscore, it is considered to be a partial, and will not be parsed unless included in another file. Example:

<file: app/stylesheets/clients/partials/_form.less>
@text_dark: #222;

<file: app/stylesheets/clients/screen.less>
@import "partials/_form";

input { color: @text_dark; }

The example above will result in a single CSS file in public/stylesheets/clients/screen.css.

Any .css file placed in app/stylesheets will be copied into public/stylesheets without being parsed through LESS.

Configuration

Source path: the location of your LESS files (default: app/stylesheets)

Less::More.source_path = "public/stylesheets/less"

Destination Path: where the css goes (public/destination_path) (default: stylesheets)

Less::More.destination_path = "css"

More can compress your files by removing extra line breaks (default: true)

Less::More.compression = false

More inserts headers in the generated CSS files, letting people know that the file is in fact generated and shouldn't be edited directly. (default: true)

Less::More.header = false

To configure More for a specific environment, add configuration options into the environment file, such as config/environments/development.rb.

If you wish to apply the configuration to all environments, place them in config/environment.rb.

Tasks

More provides a set of Rake tasks to help manage your CSS files.

To parse all LESS files and save the resulting CSS files to the destination path, run:

$ rake more:generate

To delete all generated CSS files, run:

$ rake more:clean

This task will not delete any CSS files from the destination path, that does not have a corresponding LESS file in the source path.

Git / SVN

Check in all the generated css(destination path), they are only generated in development

Documentation

To view the full RDoc documentation, go to http://rdoc.info/projects/cloudhead/more

Contributors

LESS is maintained by Alexis Sellier http://github.com/cloudhead

more's People

Contributors

aub avatar augustl avatar dasch avatar grosser avatar logandk avatar matthew-dean avatar sikachu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

more's Issues

Ruby 1.9.1 path gsub wants regexp

Ruby looking for a regexp in the gsub method

At line 126:

destination_dir = source.dirname.to_s.gsub(source_path, cache_path)
destination = File.join(destination_dir, source.basename.to_s.gsub('.less', '.css').gsub('.lss', '.css'))

needs to be

destination_dir = source.dirname.to_s.gsub(/#{source_path}/, cache_path)
destination = File.join(destination_dir, source.basename.to_s.gsub(/.less/, '.css').gsub(/.lss/, '.css'))

Any plan to upgrade?

Do you have any plan to upgrade this plugin with rails 3 compatibility support??

CSS files in source path

If .css files is placed in app/stylesheets, they should be saved directly to public/stylesheets if mtime is newer than the destination file.

:cache => true in stylesheet_link_tag

Breaks when using :cache => true for stylesheet_link_tag. Probably because Rails attempts to read the .css file from the file system before the controller is ever poked.

Should be a Gem plugin

It would be easier to install the More plugin if it was available as a Rails Gem plugin. I've begun working toward this goal, but unfortunately I can't seem to get GitHub's Gem hosting to publish it.

Would you guys mind if I pushed it to Gemcutter?

Use the actual page cache setting from the environment

Instead of setting defaults for the page cache in the various environments in Less::More::DEFAULTS, use the actual config settings. It's probably something along the lines of ActionController::Base.config.page_cache.

Problems with running more on Heroku

Hi,

I've just tried to run more on Heroku, but it can't generate css files (because of Heroku's readonly filesystem). I think that the 7990548 commit broke everything. Should I use an older version of more?

@import conflicts with parser

It seems like parsing @imports is conflicting with what the parser is trying to do, and breaks some functionality:

In lib.less
@var: 1px;

In all.less
@import "lib";
h1 { border-width: @var }

Doesn't work as expected, raising a NameError on @var

changing the parse function as so, to remove the import parsing seems to fix the issue:

modified = self.read_imports(file[:source]).push(file[:source]).max { |x, y| x.mtime <=> y.mtime }.mtime

to

modified = file[:source].mtime

script/plugin remove doesn't inactive plugin

script/plugin remove more - it removes the "more" directory out of vendor/plugins - but the plugin in is still loaded somewhere, because you get a "No such file or directory" error whenever you try to access the app.

.lss extension

More currently only parses .less files, but should also look for .lss files

not parsing .less files on each request in development. only on initialization.

Just attempted to transition from less-on-rails to to more...and it's not exactly working in development. it does generate the css files upon initialization, but each following request does not regenerate the .css files. it does remove them though, so all I see is unstyled html.

I don't think I'm doing anything out of the ordinary.
using all the default settings and the less 1.1.13 gem.

Don't check mtime

Checking mtime has minimal benefits and creates a bunch of problems for us. In development mode, you won't really notice the difference between the css regenerating on every request, or only when the .less files has changed. In production mode, the css is only generated one time anyway, only to be purged on re-deploys.

Move init.rb file

With Rails 3, I get these two deprecation warnings in my app when running specs.

DEPRECATION WARNING: Use toplevel init.rb; rails/init.rb is deprecated: /vagrant/vendor/plugins/more/rails/init.rb. (called from /vagrant/config/environment.rb:5)
DEPRECATION WARNING: RAILS_ENV is deprecated. Please use ::Rails.env. (called from /vagrant/vendor/plugins/more/rails/init.rb:1)

To fix it, I moved init.rb one directory up, and changed the contents to read

require File.join(File.dirname(FILE), 'lib', 'less', 'controller_extension') if ::Rails.env == 'development'

Rails 3 Support

Currently, when you try to install more into a Rails 3 app, you get

Plugin not found: ["git://github.com/cloudhead/more.git"]

If you try to run script server, you get a NameError on the first request. Here's part of the stack:

/path/to/railsapp/vendor/plugins/more/rails/init.rb:3: undefined local variable or method `config' for main:Object (NameError)
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from /path/to/railsapp/vendor/gems/dirs/rails/activesupport/lib/active_support/dependencies.rb:167:in `require'
    from /path/to/railsapp/vendor/gems/dirs/rails/activesupport/lib/active_support/dependencies.rb:537:in `new_constants_in'
    from /path/to/railsapp/vendor/gems/dirs/rails/activesupport/lib/active_support/dependencies.rb:167:in `require'
    from /path/to/railsapp/vendor/plugins/more/init.rb:1
  ...

Problems caused by setting logger to nil

Hey guys,

Great work!

I noticed that when I remove a css file and then try to load it in the browser (without restarting the browser) I was getting and error from LessCacheController where it was setting logger to nil.

The problem is that I have some before filters that use the logger, I was able to resolve it by removing the method. My fork is here, and the tests pass:
http://github.com/jxson/more

  • J

Use init.rb, not rails/init.rb

Rails 3.rc has deprecated rails/init.rb. You should update the root init.rb like so:

require File.join(File.dirname(__FILE__), 'lib', 'less', 'controller_extension') if Rails.env.development?

Please note RAILS_ENV is also deprecated.

using with package systems like jammit

hi,
Jammit looks for files in a particular folder (like public/stylesheets/...) and if that file exists it does a bunch of stuff to it (combines, compresses, embed images or fonts, etc). In development, More uses a controller, so the file doesn't exist on disk and it ends up that jammit won't serve up the file.

the simple solution is to do something like:
before_filter { Less::More.parse } unless Less::More.page_cache?

I'm not sure if there is a more elegant, automated way of working with packaging systems like Jammit, but I suspect as long as More goes through the controller in dev instead of creating a file in public/stylesheets (like SASS does) then this is the only solution.

One approach would be to make an option that behaves more like sass and creates the physical file on each request. IF you would like to make that an option in More, let me know and I'll submit a patch.

Error "can't convert Pathname into String" when loading plugin (ruby 1.9)

I firstly installed the plugin with gem install more, then added the line

config.gem "more", :source => "git://github.com/cloudhead/more.git"

to environment.rb. However, when I try starting the server, I get the error:

$ script/server start
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
/usr/lib/ruby/gems/1.9.1/gems/more-0.0.3/lib/more.rb:158:in `[]': can't convert Pathname into String (TypeError)
    from /usr/lib/ruby/gems/1.9.1/gems/more-0.0.3/lib/more.rb:158:in `all_less_files'
    from /usr/lib/ruby/gems/1.9.1/gems/more-0.0.3/lib/more.rb:148:in `clean'
    from /usr/lib/ruby/gems/1.9.1/gems/more-0.0.3/rails/init.rb:11:in `block (2 levels) in evaluate_init_rb'
    from /usr/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:614:in `call'
    from /usr/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:614:in `block in after_initialize'
    from /usr/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:613:in `each'
    from /usr/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:613:in `after_initialize'
    from /usr/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:179:in `process'
    from /usr/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
    from /home/david/public_html/programmingevolved/config/environment.rb:9:in `<top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `block in require'
    from /usr/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /usr/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/commands/server.rb:84:in `<top (required)>'
    from script/server:3:in `require'
    from script/server:3:in `<main>'

This is running with rails 2.3.5, and rails 1.9.1p243 under archlinux. Is this a bug or am I doing something wrong?

not creating files in non-development mode

hello, their is a comment in lib/less/more.rb that states:

By default, Less::More.parse will be called for each request in development environment and on application initialization in production environment.

However, this doesn't seem to be the case, and I didn't find any information that highlighted as such. Two suggestions for rails/init.rb

  • don't hardcode development. Instead use ActionController::Base.perform_caching, which means we can change the behavior in our dev environment (like making sure everything comes together).
  • make it an if/else statement, and if performing caching, call Less::More.generate_all, else load the action_controller_ext, which puts that on a before_filter hook.

what do you think?

rake more:parse

In some situations (when working with asset_packager for example) you need to parse the less files. Now this can't be done because the task has gone away. Can it be back?

Insert HEADER if config says so

Prepend the generated CSS with Less::More::HEADER if the config says we should (which it does, by default). It's currently ignored. E.g. not handled at all.

Heroku support

Suggesting that we do a major rewrite of the functionality to achieve this. First, how heroku has to be supported.

Heroku doesn't allow write access to the file system. The generated CSS has to be served through controllers. If you set the correct headers, heroku will use varnish to cache the output so that it isn't served dynamically on every request. This is what http://github.com/augustl/less_for_rails_with_cache_control does.

In order to avoid duplicate code, I'm thinking that we should use this controller when we aren't on heroku as well, and use Rails' page caching functionality to create the files. The page cache for the stylesheets controller will be wiped in a before_filter to the application controller in development mode, and left as-is in production mode.

This way, we'll end up with a lot less code, because we'll avoid doing things twice in different ways.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.