twitter-bootswatch-rails 2.3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +259 -0
- data/Rakefile +57 -0
- data/lib/generators/bootswatch/import/import_generator.rb +50 -0
- data/lib/generators/bootswatch/install/install_generator.rb +120 -0
- data/lib/generators/bootswatch/install/templates/application.css.tt +6 -0
- data/lib/generators/bootswatch/install/templates/application.js.tt +5 -0
- data/lib/generators/bootswatch/install/templates/base.less.tt +8 -0
- data/lib/generators/bootswatch/install/templates/bootstrap.less +63 -0
- data/lib/generators/bootswatch/install/templates/bootswatch.coffee.tt +9 -0
- data/lib/generators/bootswatch/install/templates/bootswatch.less.tt +8 -0
- data/lib/generators/bootswatch/install/templates/loader.coffee.tt +25 -0
- data/lib/generators/bootswatch/install/templates/loader.css.less.tt +22 -0
- data/lib/generators/bootswatch/install/templates/mixins.less.tt +704 -0
- data/lib/generators/bootswatch/install/templates/variables.less.tt +303 -0
- data/lib/generators/bootswatch/layout/layout_generator.rb +23 -0
- data/lib/generators/bootswatch/layout/templates/layout.html.erb +50 -0
- data/lib/generators/bootswatch/layout/templates/layout.html.haml +30 -0
- data/lib/generators/bootswatch/themed/templates/_form.html.erb +16 -0
- data/lib/generators/bootswatch/themed/templates/_form.html.haml +10 -0
- data/lib/generators/bootswatch/themed/templates/edit.html.erb +6 -0
- data/lib/generators/bootswatch/themed/templates/edit.html.haml +4 -0
- data/lib/generators/bootswatch/themed/templates/index.html.erb +40 -0
- data/lib/generators/bootswatch/themed/templates/index.html.haml +25 -0
- data/lib/generators/bootswatch/themed/templates/new.html.erb +6 -0
- data/lib/generators/bootswatch/themed/templates/new.html.haml +4 -0
- data/lib/generators/bootswatch/themed/templates/show.html.erb +23 -0
- data/lib/generators/bootswatch/themed/templates/show.html.haml +15 -0
- data/lib/generators/bootswatch/themed/templates/simple_form/_form.html.erb +14 -0
- data/lib/generators/bootswatch/themed/templates/simple_form/_form.html.haml +11 -0
- data/lib/generators/bootswatch/themed/themed_generator.rb +99 -0
- data/lib/tasks/setup.thor +90 -0
- data/lib/twitter-bootswatch-rails.rb +10 -0
- data/lib/twitter/bootswatch/rails/bootswatch.rb +2 -0
- data/lib/twitter/bootswatch/rails/engine.rb +32 -0
- data/lib/twitter/bootswatch/rails/version.rb +7 -0
- data/vendor/assets/fonts/font-awesome/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.svg +284 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.woff +0 -0
- data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-affix.js +117 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +99 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-button.js +105 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +207 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +167 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +165 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +247 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +114 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +162 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +144 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +361 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +60 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +335 -0
- data/vendor/toolkit/font-awesome/font-awesome-ie7.less +350 -0
- data/vendor/toolkit/font-awesome/font-awesome.less +537 -0
- data/vendor/toolkit/twitter/bootstrap/accordion.less +34 -0
- data/vendor/toolkit/twitter/bootstrap/alerts.less +79 -0
- data/vendor/toolkit/twitter/bootstrap/bootstrap.less +63 -0
- data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +24 -0
- data/vendor/toolkit/twitter/bootstrap/button-groups.less +229 -0
- data/vendor/toolkit/twitter/bootstrap/buttons.less +228 -0
- data/vendor/toolkit/twitter/bootstrap/carousel.less +158 -0
- data/vendor/toolkit/twitter/bootstrap/close.less +32 -0
- data/vendor/toolkit/twitter/bootstrap/code.less +61 -0
- data/vendor/toolkit/twitter/bootstrap/component-animations.less +22 -0
- data/vendor/toolkit/twitter/bootstrap/dropdowns.less +237 -0
- data/vendor/toolkit/twitter/bootstrap/forms.less +690 -0
- data/vendor/toolkit/twitter/bootstrap/grid.less +21 -0
- data/vendor/toolkit/twitter/bootstrap/hero-unit.less +25 -0
- data/vendor/toolkit/twitter/bootstrap/labels-badges.less +84 -0
- data/vendor/toolkit/twitter/bootstrap/layouts.less +16 -0
- data/vendor/toolkit/twitter/bootstrap/media.less +55 -0
- data/vendor/toolkit/twitter/bootstrap/mixins.less +702 -0
- data/vendor/toolkit/twitter/bootstrap/modals.less +95 -0
- data/vendor/toolkit/twitter/bootstrap/navbar.less +497 -0
- data/vendor/toolkit/twitter/bootstrap/navs.less +409 -0
- data/vendor/toolkit/twitter/bootstrap/pager.less +43 -0
- data/vendor/toolkit/twitter/bootstrap/pagination.less +123 -0
- data/vendor/toolkit/twitter/bootstrap/popovers.less +133 -0
- data/vendor/toolkit/twitter/bootstrap/progress-bars.less +122 -0
- data/vendor/toolkit/twitter/bootstrap/reset.less +216 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-1200px-min.less +28 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-767px-max.less +193 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-768px-979px.less +19 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-navbar.less +189 -0
- data/vendor/toolkit/twitter/bootstrap/responsive-utilities.less +59 -0
- data/vendor/toolkit/twitter/bootstrap/responsive.less +48 -0
- data/vendor/toolkit/twitter/bootstrap/scaffolding.less +53 -0
- data/vendor/toolkit/twitter/bootstrap/sprites.less +197 -0
- data/vendor/toolkit/twitter/bootstrap/tables.less +244 -0
- data/vendor/toolkit/twitter/bootstrap/thumbnails.less +53 -0
- data/vendor/toolkit/twitter/bootstrap/tooltip.less +70 -0
- data/vendor/toolkit/twitter/bootstrap/type.less +247 -0
- data/vendor/toolkit/twitter/bootstrap/utilities.less +30 -0
- data/vendor/toolkit/twitter/bootstrap/variables.less +301 -0
- data/vendor/toolkit/twitter/bootstrap/wells.less +29 -0
- metadata +269 -0
data/README.md
ADDED
@@ -0,0 +1,259 @@
|
|
1
|
+
# Twitter Bootswatch Rails gem
|
2
|
+
|
3
|
+
- Integrates Twitter Bootstrap CSS & Font Awesome toolkit into the Rails 3.1+ Asset Pipeline
|
4
|
+
- Easy control over which javascript and less modules are loaded by default. Not every app needs a carousel
|
5
|
+
- Simple default less files for custom application themes ("[theme_name]/variables.less" and "[theme_name]/bootswatch.less")
|
6
|
+
- Easily apply different custom themes or bootswatches from a site like [bootswatch.com](http://bootswatch.com/)
|
7
|
+
- Create several themed swatches for your project with theme_names, (e.g. an admin theme and a storefront theme using namespaced theme_names)
|
8
|
+
- Gem version semantics extend Twitter Bootstrap version semantics, making it simple to know what version of bootstrap the gem is using
|
9
|
+
|
10
|
+
## Includes Twitter Bootstrap for Rails 3.1+ Asset Pipeline
|
11
|
+
[Twitter Bootstrap](http://twitter.github.com/bootstrap/index.html) is a toolkit from Twitter designed to kickstart development of webapps and sites. It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.
|
12
|
+
|
13
|
+
## Includes Font Awesome for Rails 3.1+ Asset Pipeline
|
14
|
+
[Font Awesome](http://fortawesome.github.io/Font-Awesome) is a toolkit with iconic fonts designed for use with Twitter Bootstrap.
|
15
|
+
|
16
|
+
|
17
|
+
```css
|
18
|
+
/*
|
19
|
+
*= require_self
|
20
|
+
*= require [theme_name]/loader
|
21
|
+
*= require font-awesome/font-awesome
|
22
|
+
*/
|
23
|
+
```
|
24
|
+
|
25
|
+
If you need the ie7 fix:
|
26
|
+
|
27
|
+
```css
|
28
|
+
/*
|
29
|
+
*= require_self
|
30
|
+
*= require [theme_name]/loader
|
31
|
+
*= require font-awesome/font-awesome-ie7
|
32
|
+
*/
|
33
|
+
```
|
34
|
+
|
35
|
+
## Demo
|
36
|
+
|
37
|
+
The [demo](https://github.com/scottvrosenthal/twitter-bootswatch-rails-demo) will show you how this gem can be used in a rails 3.1+ application.
|
38
|
+
|
39
|
+
![Demo Screen Shot](https://github.com/scottvrosenthal/twitter-bootswatch-rails-demo/raw/master/demo.png)
|
40
|
+
|
41
|
+
## View Helpers
|
42
|
+
The gem [twitter-bootswatch-rails-helpers](https://github.com/scottvrosenthal/twitter-bootswatch-rails-helpers) provides rails view helpers for twitter bootstrap's breadcrumbs and alerts components.
|
43
|
+
|
44
|
+
|
45
|
+
## Install
|
46
|
+
|
47
|
+
Include the [Twitter Bootswatch Rails gem](http://rubygems.org/gems/twitter-bootswatch-rails) in Gemfile to install it from [RubyGems.org](http://rubygems.org):
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
group :assets do
|
51
|
+
# rails default gems
|
52
|
+
...
|
53
|
+
|
54
|
+
# just put after rails asset defaults
|
55
|
+
gem 'twitter-bootswatch-rails', '~= 2.3.1.1'
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
# View Helpers Gem can go outside the assets group
|
60
|
+
gem 'twitter-bootswatch-rails-helpers', '>= 2.3.1'
|
61
|
+
```
|
62
|
+
|
63
|
+
or you can install from latest build;
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
gem 'twitter-bootswatch-rails', :git => 'git://github.com/scottvrosenthal/twitter-bootswatch-rails.git'
|
67
|
+
```
|
68
|
+
|
69
|
+
Run bundle from command line
|
70
|
+
|
71
|
+
bundle
|
72
|
+
|
73
|
+
|
74
|
+
## Installing to App (using Generators)
|
75
|
+
|
76
|
+
You can run the following generators to get started with Twitter Bootstrap & Font Awesome quickly.
|
77
|
+
|
78
|
+
|
79
|
+
If you don't provide a [theme_name] the value defaults to **bootswatch** and adds directives to your application.css and application.js files.
|
80
|
+
|
81
|
+
|
82
|
+
Usage:
|
83
|
+
|
84
|
+
|
85
|
+
rails g bootswatch:install [theme_name]
|
86
|
+
|
87
|
+
Example:
|
88
|
+
|
89
|
+
|
90
|
+
rails g bootswatch:install admin
|
91
|
+
rails g bootswatch:install storefront
|
92
|
+
|
93
|
+
***
|
94
|
+
|
95
|
+
Layout (generates a basic Twitter Bootstrap compatible layout) - ([haml-rails](https://github.com/indirect/haml-rails) gem supported)
|
96
|
+
|
97
|
+
|
98
|
+
Usage:
|
99
|
+
|
100
|
+
|
101
|
+
rails g bootswatch:layout [theme_name]
|
102
|
+
|
103
|
+
|
104
|
+
Example:
|
105
|
+
|
106
|
+
|
107
|
+
rails g bootswatch:layout admin
|
108
|
+
rails g bootswatch:layout storefront
|
109
|
+
|
110
|
+
***
|
111
|
+
|
112
|
+
Themed (generates Twitter Bootstrap compatible scaffold views.) - ([simple_form](https://github.com/plataformatec/simple_form) and [haml-rails](https://github.com/indirect/haml-rails) gems supported)
|
113
|
+
|
114
|
+
|
115
|
+
Usage (model and table must already exist):
|
116
|
+
|
117
|
+
|
118
|
+
rails g bootswatch:themed [RESOURCE_NAME]
|
119
|
+
|
120
|
+
|
121
|
+
Example:
|
122
|
+
|
123
|
+
|
124
|
+
rails g scaffold Post title:string description:text
|
125
|
+
rake db:migrate
|
126
|
+
rails g bootswatch:themed Posts
|
127
|
+
|
128
|
+
## Import a free [bootswatch.com](http://bootswatch.com/) theme
|
129
|
+
|
130
|
+
### Just follow these three steps in the following order :)
|
131
|
+
|
132
|
+
rails g bootswatch:install cyborg
|
133
|
+
rails g bootswatch:import cyborg
|
134
|
+
rails g bootswatch:layout cyborg
|
135
|
+
|
136
|
+
The above creates a namespaced theme under assets/javascript/cyborg assets/stylesheets/cyborg and a new layout file.
|
137
|
+
|
138
|
+
The import generator pulls directly from the [bootswatch.com](http://bootswatch.com/) git repo [cyborg](https://github.com/thomaspark/bootswatch/tree/gh-pages/cyborg) directory.
|
139
|
+
|
140
|
+
* bootswatch.less
|
141
|
+
* variables.less
|
142
|
+
|
143
|
+
In your rails controllers just tell it to use the cyborg layout.
|
144
|
+
|
145
|
+
layout: 'cyborg'
|
146
|
+
|
147
|
+
You can also create an admin namespaced theme and import the cyborg bootswatch.less and variable.less files:
|
148
|
+
|
149
|
+
rails g bootswatch:install admin
|
150
|
+
rails g bootswatch:import admin/cyborg
|
151
|
+
rails g bootswatch:layout admin
|
152
|
+
|
153
|
+
Need more examples? Check out the [demo](https://github.com/scottvrosenthal/twitter-bootswatch-rails-demo)
|
154
|
+
|
155
|
+
## Using stylesheets with the [less-rails](https://github.com/metaskills/less-rails/) gem
|
156
|
+
|
157
|
+
You have to require "[theme_name]/loader.css.less" in your application.css
|
158
|
+
|
159
|
+
```css
|
160
|
+
/*
|
161
|
+
*= require_self
|
162
|
+
*= require [theme_name]/loader
|
163
|
+
*= require font-awesome/font-awesome
|
164
|
+
*/
|
165
|
+
```
|
166
|
+
|
167
|
+
"[theme_name]/loader.css.less" allows you to easily comment out less modules you don't need in your application.
|
168
|
+
|
169
|
+
For instance, as per the [Twitter Bootstrap](http://twitter.github.io/bootstrap/scaffolding.html#responsive) project we don't include the responsive styles by default. Uncomment `@import "twitter/bootstrap/responsive";` in "[theme_name]/loader.css.less" to enable it.
|
170
|
+
|
171
|
+
"[theme_name]/variables.less" customize Twitter Bootstrap "variables.less" defaults in this file.
|
172
|
+
|
173
|
+
"[theme_name]/bootswatch.less" customize the style of Twitter Bootstrap base css and component style here.
|
174
|
+
|
175
|
+
Check out some of the swatches at [bootswatch.com](http://bootswatch.com/)
|
176
|
+
|
177
|
+
Read up on the [less-rails](https://github.com/metaskills/less-rails/) gem.
|
178
|
+
|
179
|
+
***
|
180
|
+
|
181
|
+
#### base.less
|
182
|
+
|
183
|
+
When importing a custom bootswatch.less file manually you'll need to include the following import directive at the top of the file:
|
184
|
+
|
185
|
+
```css
|
186
|
+
@import "base";
|
187
|
+
```
|
188
|
+
|
189
|
+
The import base.less directive allows the importing less file to access and override inherited less variables.
|
190
|
+
|
191
|
+
Example:
|
192
|
+
|
193
|
+
```css
|
194
|
+
@import "base";
|
195
|
+
// Cyborg 2.3.1
|
196
|
+
// bootswatch.less
|
197
|
+
```
|
198
|
+
|
199
|
+
## Using Javascripts
|
200
|
+
|
201
|
+
You have to require the coffeescript file "[theme_name]/loader.coffee" in your application.js:
|
202
|
+
|
203
|
+
```javascript
|
204
|
+
//= require jquery
|
205
|
+
//= require jquery_ujs
|
206
|
+
//= require [theme_name]/loader
|
207
|
+
```
|
208
|
+
|
209
|
+
"[theme_name]/loader.coffee" allows you to easily comment out modules you don't need in your application:
|
210
|
+
|
211
|
+
```coffee
|
212
|
+
# [theme_name]/loader.coffee
|
213
|
+
|
214
|
+
#= require twitter/bootstrap/bootstrap-transition
|
215
|
+
#= require twitter/bootstrap/bootstrap-alert
|
216
|
+
#= require twitter/bootstrap/bootstrap-button
|
217
|
+
#= require twitter/bootstrap/bootstrap-carousel
|
218
|
+
#= require twitter/bootstrap/bootstrap-collapse
|
219
|
+
#= require twitter/bootstrap/bootstrap-dropdown
|
220
|
+
#= require twitter/bootstrap/bootstrap-modal
|
221
|
+
#= require twitter/bootstrap/bootstrap-tooltip
|
222
|
+
#= require twitter/bootstrap/bootstrap-popover
|
223
|
+
#= require twitter/bootstrap/bootstrap-scrollspy
|
224
|
+
#= require twitter/bootstrap/bootstrap-tab
|
225
|
+
#= require twitter/bootstrap/bootstrap-typeahead
|
226
|
+
#= require twitter/bootstrap/bootstrap-affix
|
227
|
+
|
228
|
+
|
229
|
+
#= require [theme_name]/bootswatch
|
230
|
+
```
|
231
|
+
|
232
|
+
"[theme_name]/bootswatch.coffee" allows you to easily add swatch customization to javascript modules loaded:
|
233
|
+
|
234
|
+
Check out some of the swatches at [bootswatch.com](http://bootswatch.com/)
|
235
|
+
|
236
|
+
### Responsive styling?
|
237
|
+
As per the [Twitter Bootstrap](http://twitter.github.io/bootstrap/scaffolding.html#responsive) project we don't include the responsive styles by default. Uncomment `@import "twitter/bootstrap/responsive";` in "[theme_name]/loader.css.less" to enable it.
|
238
|
+
|
239
|
+
### Local rails development assets not updating?
|
240
|
+
|
241
|
+
```sh
|
242
|
+
RAILS_ENV=development rake assets:clean
|
243
|
+
```
|
244
|
+
|
245
|
+
## Versioning
|
246
|
+
Bootstrap [claims](https://github.com/twitter/bootstrap#versioning) to use SemVer, although this is for values of public API that don't seem to include selectively requiring CSS components (see breaking change 2.0.4 -> 2.1.0). Since many people using bootstrap-swatch-rails *do* selectively require CSS components and I consider it part of the public API we can't really follow SemVer without becoming wildly out of sync with the Bootstrap version number, which is confusing for everyone involved. Further releases to bootstrap-swatch-rails will therefore have version numbers of the form `2.x.x.y`, where `2.x.x` is the release of Bootstrap we should be compatible with, and `y` is the patch version.
|
247
|
+
|
248
|
+
## Changelog
|
249
|
+
- v2.3.1.0
|
250
|
+
* Updated to bootstrap 2.3.1
|
251
|
+
- v2.3.1.1
|
252
|
+
* Added theme_name functionality, if a theme_name isn't passed in you get the default install, i.e, uses bootswatch as theme_name
|
253
|
+
* Included bootstrap version number at the top of each asset file created by generators
|
254
|
+
* Added Font Awesome to the asset pipeline as an opt in using an asset directive
|
255
|
+
* Added import generator to dynamically pull in free bootswatch.com themes and add correct import directives
|
256
|
+
- v2.3.1.2
|
257
|
+
* Updated gemspec docs
|
258
|
+
* Updated import generator to allow importing bootswatch.com themes under existing namespaced themes
|
259
|
+
* rails g bootswatch:import admin/cyborg
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
desc "Configure then bundle the gem"
|
6
|
+
task :bundle do
|
7
|
+
|
8
|
+
sh 'bundle install'
|
9
|
+
|
10
|
+
## begin bootstrap config ##
|
11
|
+
|
12
|
+
sh 'rm -f vendor/assets/images/twitter/bootstrap/*.png'
|
13
|
+
sh 'cp -f bootstrap/img/*.png vendor/assets/images/twitter/bootstrap'
|
14
|
+
|
15
|
+
sh 'rm -f vendor/assets/javascripts/twitter/bootstrap/*.js'
|
16
|
+
sh 'cp -f bootstrap/js/bootstrap-*.js vendor/assets/javascripts/twitter/bootstrap'
|
17
|
+
|
18
|
+
sh 'rm -f vendor/toolkit/twitter/bootstrap/*.less'
|
19
|
+
sh 'cp -f bootstrap/less/*.less vendor/toolkit/twitter/bootstrap'
|
20
|
+
|
21
|
+
sh 'thor setup:bootstrap_update_less_files_for_asset_pipeline'
|
22
|
+
sh 'thor setup:bootstrap_update_js_files_compilation_order'
|
23
|
+
|
24
|
+
sh 'cp -f vendor/toolkit/twitter/bootstrap/bootstrap.less lib/generators/bootswatch/install/templates/bootstrap.less'
|
25
|
+
sh 'cp -f vendor/toolkit/twitter/bootstrap/variables.less lib/generators/bootswatch/install/templates/variables.less.tt'
|
26
|
+
sh 'cp -f vendor/toolkit/twitter/bootstrap/mixins.less lib/generators/bootswatch/install/templates/mixins.less.tt'
|
27
|
+
|
28
|
+
sh 'thor setup:bootstrap_update_less_files_with_theme_info'
|
29
|
+
|
30
|
+
## end bootstrap config ##
|
31
|
+
|
32
|
+
## begin font-awesome config ##
|
33
|
+
|
34
|
+
sh 'rm -f vendor/assets/fonts/font-awesome/*.*'
|
35
|
+
sh 'cp -f font-awesome/font/*.* vendor/assets/fonts/font-awesome'
|
36
|
+
|
37
|
+
sh 'rm -f vendor/toolkit/font-awesome/*.less'
|
38
|
+
sh 'cp -f font-awesome/less/*.less vendor/toolkit/font-awesome'
|
39
|
+
|
40
|
+
sh 'thor setup:fontawesome_update_less_files_for_asset_pipeline'
|
41
|
+
|
42
|
+
## end font-awesome config ##
|
43
|
+
|
44
|
+
sh 'gem build *.gemspec'
|
45
|
+
sh 'gem install *.gem'
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
task(:default).clear
|
50
|
+
task :default => :bundle
|
51
|
+
|
52
|
+
desc "Clean up files"
|
53
|
+
task :clean do
|
54
|
+
|
55
|
+
sh 'rm *.gem'
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Bootswatch
|
4
|
+
module Generators
|
5
|
+
class ImportGenerator < ::Rails::Generators::NamedBase
|
6
|
+
|
7
|
+
def theme_name
|
8
|
+
file_name
|
9
|
+
end
|
10
|
+
|
11
|
+
def theme_directory
|
12
|
+
if class_path.empty?
|
13
|
+
theme_name
|
14
|
+
else
|
15
|
+
class_path.first
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def theme_repo_url
|
20
|
+
"https://raw.github.com/thomaspark/bootswatch/gh-pages/#{theme_name}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def import_less
|
24
|
+
|
25
|
+
stylesheets_dest_path = "app/assets/stylesheets/#{theme_directory}"
|
26
|
+
empty_directory stylesheets_dest_path
|
27
|
+
|
28
|
+
# let's auto backup if a custom variables.less already exists
|
29
|
+
if File.exist?(File.join(stylesheets_dest_path,'variables.less'))
|
30
|
+
File.rename(File.join(stylesheets_dest_path,'variables.less'), File.join(stylesheets_dest_path,'variables.less_bak'))
|
31
|
+
end
|
32
|
+
|
33
|
+
get File.join(theme_repo_url,'variables.less'), File.join(stylesheets_dest_path,'variables.less')
|
34
|
+
|
35
|
+
# let's auto backup if a custom bootswatch.less already exists
|
36
|
+
if File.exist?(File.join(stylesheets_dest_path,'bootswatch.less'))
|
37
|
+
File.rename(File.join(stylesheets_dest_path,'bootswatch.less'), File.join(stylesheets_dest_path,'bootswatch.less_bak'))
|
38
|
+
end
|
39
|
+
|
40
|
+
get File.join(theme_repo_url,'bootswatch.less'), File.join(stylesheets_dest_path,'bootswatch.less')
|
41
|
+
|
42
|
+
prepend_to_file File.join(stylesheets_dest_path,'bootswatch.less') do
|
43
|
+
"@import \"base\";\n"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Bootswatch
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < ::Rails::Generators::NamedBase
|
6
|
+
|
7
|
+
DEFAULT_THEME_NAME='bootswatch'
|
8
|
+
|
9
|
+
argument :name, type: :string, default: DEFAULT_THEME_NAME,
|
10
|
+
desc: 'The theme name for this bootswatch'
|
11
|
+
|
12
|
+
# needed for thor templates
|
13
|
+
source_root File.expand_path("../templates", __FILE__)
|
14
|
+
|
15
|
+
def theme_name
|
16
|
+
file_name
|
17
|
+
end
|
18
|
+
|
19
|
+
def use_default_theme_name?
|
20
|
+
theme_name === DEFAULT_THEME_NAME
|
21
|
+
end
|
22
|
+
|
23
|
+
def theme_info
|
24
|
+
"#{use_default_theme_name? ? 'bootstrap'.capitalize : theme_name.capitalize} #{Twitter::Bootswatch::Rails::VERSION.chop.chop}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_assets
|
28
|
+
|
29
|
+
if use_default_theme_name?
|
30
|
+
if File.exist?('app/assets/javascripts/application.js')
|
31
|
+
unless File.read('app/assets/javascripts/application.js').include?(theme_name)
|
32
|
+
insert_into_file "app/assets/javascripts/application.js",
|
33
|
+
"//= require #{theme_name}/loader\n",
|
34
|
+
:after => "jquery_ujs\n"
|
35
|
+
end
|
36
|
+
else
|
37
|
+
template 'application.js.tt', 'app/assets/stylesheets/application.js', {theme_name: theme_name, theme_info: theme_info}
|
38
|
+
end
|
39
|
+
|
40
|
+
if File.exist?('app/assets/stylesheets/application.css')
|
41
|
+
unless File.read('app/assets/stylesheets/application.css').include?(theme_name)
|
42
|
+
insert_into_file "app/assets/stylesheets/application.css",
|
43
|
+
" *= require #{theme_name}/loader\n",
|
44
|
+
:after => "require_self\n"
|
45
|
+
end
|
46
|
+
|
47
|
+
unless File.read('app/assets/stylesheets/application.css').include?('font-awesome')
|
48
|
+
insert_into_file "app/assets/stylesheets/application.css",
|
49
|
+
" *= require font-awesome/font-awesome\n",
|
50
|
+
:after => "*= require #{theme_name}/loader\n"
|
51
|
+
end
|
52
|
+
|
53
|
+
else
|
54
|
+
template 'application.css.tt', 'app/assets/stylesheets/application.css', {theme_name: theme_name, theme_info: theme_info}
|
55
|
+
end
|
56
|
+
else
|
57
|
+
template 'application.js.tt', "app/assets/javascripts/#{theme_name}.js", {theme_name: theme_name, theme_info: theme_info}
|
58
|
+
template 'application.css.tt', "app/assets/stylesheets/#{theme_name}.css", {theme_name: theme_name, theme_info: theme_info}
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def add_javascripts
|
64
|
+
|
65
|
+
javascripts_dest_path = "app/assets/javascripts/#{theme_name}"
|
66
|
+
empty_directory javascripts_dest_path
|
67
|
+
|
68
|
+
template 'loader.coffee.tt', File.join(javascripts_dest_path,'loader.coffee'), {theme_name: theme_name, theme_info: theme_info}
|
69
|
+
|
70
|
+
# let's auto backup if a custom bootswatch.coffee already exists
|
71
|
+
if File.exist?(File.join(javascripts_dest_path,'bootswatch.coffee'))
|
72
|
+
File.rename(File.join(javascripts_dest_path,'bootswatch.coffee'), File.join(javascripts_dest_path,'bootswatch.coffee_bak'))
|
73
|
+
end
|
74
|
+
|
75
|
+
template 'bootswatch.coffee.tt', File.join(javascripts_dest_path,'bootswatch.coffee'), {theme_name: theme_name, theme_info: theme_info}
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_stylesheets
|
80
|
+
|
81
|
+
stylesheets_dest_path = "app/assets/stylesheets/#{theme_name}"
|
82
|
+
empty_directory stylesheets_dest_path
|
83
|
+
|
84
|
+
less_imports = File.read(find_in_source_paths('bootstrap.less')).scan(Less::Rails::ImportProcessor::IMPORT_SCANNER).flatten.compact.uniq
|
85
|
+
|
86
|
+
# let's auto backup if a custom loader.css.less already exists
|
87
|
+
if File.exist?(File.join(stylesheets_dest_path,'loader.css.less'))
|
88
|
+
File.rename(File.join(stylesheets_dest_path,'loader.css.less'), File.join(stylesheets_dest_path,'loader.css.less_bak'))
|
89
|
+
end
|
90
|
+
template 'loader.css.less.tt', File.join(stylesheets_dest_path,'loader.css.less'), {less_imports: less_imports, theme_name: theme_name, theme_info: theme_info}
|
91
|
+
|
92
|
+
# let's auto backup if a custom variables.less already exists
|
93
|
+
if File.exist?(File.join(stylesheets_dest_path,'variables.less'))
|
94
|
+
File.rename(File.join(stylesheets_dest_path,'variables.less'), File.join(stylesheets_dest_path,'variables.less_bak'))
|
95
|
+
end
|
96
|
+
template 'variables.less.tt', File.join(stylesheets_dest_path,'variables.less'), {theme_name: theme_name, theme_info: theme_info}
|
97
|
+
|
98
|
+
# let's auto backup if a custom mixins.less already exists
|
99
|
+
if File.exist?(File.join(stylesheets_dest_path,'mixins.less'))
|
100
|
+
File.rename(File.join(stylesheets_dest_path,'mixins.less'), File.join(stylesheets_dest_path,'mixins.less_bak'))
|
101
|
+
end
|
102
|
+
template 'mixins.less.tt', File.join(stylesheets_dest_path,'mixins.less'), {theme_name: theme_name, theme_info: theme_info}
|
103
|
+
|
104
|
+
# let's auto backup if a custom bootswatch.less already exists
|
105
|
+
if File.exist?(File.join(stylesheets_dest_path,'bootswatch.less'))
|
106
|
+
File.rename(File.join(stylesheets_dest_path,'bootswatch.less'), File.join(stylesheets_dest_path,'bootswatch.less_bak'))
|
107
|
+
end
|
108
|
+
template 'bootswatch.less.tt', File.join(stylesheets_dest_path,'bootswatch.less'), {theme_name: theme_name, theme_info: theme_info}
|
109
|
+
|
110
|
+
# let's auto backup if a custom base.less already exists
|
111
|
+
if File.exist?(File.join(stylesheets_dest_path,'base.less'))
|
112
|
+
File.rename(File.join(stylesheets_dest_path,'base.less'), File.join(stylesheets_dest_path,'base.less_bak'))
|
113
|
+
end
|
114
|
+
template 'base.less.tt', File.join(stylesheets_dest_path,'base.less'), {theme_name: theme_name, theme_info: theme_info}
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|