Readme fixes
This commit is contained in:
parent
588fdd0f64
commit
722c155a42
44
README.md
44
README.md
|
@ -1,24 +1,46 @@
|
||||||
# Cdnjs::Rails
|
# [cdnjs](http://cdnjs.com) helpers for Rails apps
|
||||||
|
|
||||||
TODO: Write a gem description
|
This gem adds view helpers to Ruby on Rails applications that embed javascripts
|
||||||
|
and stylesheets directly from [cdnjs](http://cdnjs.com)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Add this line to your application's Gemfile:
|
Add this line to your application's Gemfile:
|
||||||
|
```ruby
|
||||||
gem 'cdnjs-rails'
|
gem 'cdnjs-rails'
|
||||||
|
```
|
||||||
|
|
||||||
And then execute:
|
And then execute:
|
||||||
|
```
|
||||||
$ bundle
|
$ bundle
|
||||||
|
```
|
||||||
Or install it yourself as:
|
|
||||||
|
|
||||||
$ gem install cdnjs-rails
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
TODO: Write usage instructions here
|
From view files
|
||||||
|
```
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Hello World!</title>
|
||||||
|
<%= stylesheet_cdnjs_tag 'normalize' %>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<%= yield %>
|
||||||
|
<%= javascript_cdnjs_tag 'jquery', version: '2.0.3', protocol: 'https' %>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
|
|
||||||
|
From anywhere in the app
|
||||||
|
```ruby
|
||||||
|
CdnjsRails.package_url('chosen', v: '0.9.10', proto: 'http')
|
||||||
|
```
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
`version` (aliases: `ver`, `v`): package version, latest by default
|
||||||
|
|
||||||
|
`protocol` (alias: `proto`): url protocol, relative by default
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|
4
Rakefile
4
Rakefile
|
@ -22,10 +22,10 @@ namespace :cdnjs do
|
||||||
}
|
}
|
||||||
end.inject(:merge)
|
end.inject(:merge)
|
||||||
|
|
||||||
# Format JSON for better diffs and smaller patches
|
# Pretty format JSON for better diffs and smaller patches
|
||||||
json = MultiJson.dump(data, :pretty => true)
|
json = MultiJson.dump(data, :pretty => true)
|
||||||
|
|
||||||
File.open(file_path, 'wb') do |file|
|
File.open file_path, 'wb' do |file|
|
||||||
file.write json
|
file.write json
|
||||||
file.close
|
file.close
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
module CdnjsRails
|
module CdnjsRails
|
||||||
module ViewHelpers
|
module ViewHelpers
|
||||||
def javascript_cdnjs_tag name, version = nil
|
def javascript_cdnjs_tag name, options = {}
|
||||||
javascript_include_tag CdnjsRails.package_url(name, version)
|
javascript_include_tag CdnjsRails.package_url(name, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def stylesheet_cdnjs_tag name, version = nil
|
def stylesheet_cdnjs_tag name, options = {}
|
||||||
stylesheet_include_tag CdnjsRails.package_url(name, version)
|
stylesheet_include_tag CdnjsRails.package_url(name, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue