bootcolor 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +18 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +1 -0
- data/app/controllers/themes_controller.rb +44 -0
- data/app/views/themes/switch.html.erb +40 -0
- data/bootcolor.gemspec +22 -0
- data/config/routes.rb +3 -0
- data/lib/bootcolor.rb +1 -0
- data/lib/bootcolor/engine.rb +7 -0
- data/lib/bootcolor/version.rb +4 -0
- metadata +95 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 xdite
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# BootColor
|
2
|
+
|
3
|
+
|
4
|
+
The original idea is from [lavish](http://lavishbootstrap.com/). An online bootstrap theme generator.
|
5
|
+
I decide to wrap it as a gem.
|
6
|
+
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add these lines to your application's Gemfile:
|
11
|
+
|
12
|
+
gem "bootcolor"
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
You should create a `bootstrap-wrapper.css.scss` and mount in `application.css.scss`
|
19
|
+
|
20
|
+
```
|
21
|
+
//= require bootstrap-wrapper.css.scss
|
22
|
+
```
|
23
|
+
|
24
|
+
And add these two lines in `bootstrap-wrapper.css.css` (i.e. Bootcolor required `anjlab-bootstrap-rails` )
|
25
|
+
|
26
|
+
```
|
27
|
+
@import "bootstrap-color-config";
|
28
|
+
@import "twitter/bootstrap";
|
29
|
+
|
30
|
+
```
|
31
|
+
|
32
|
+
Create empty `bootstrap-color-config.css.scss`
|
33
|
+
|
34
|
+
`$ touch app/assets/stylesheets/bootstrap-color-config.css.scss`
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
visit <http://your.project.url/switch_theme>, paste the image url, what BootColor do is generate bootstrap theme variable for you.
|
39
|
+
|
40
|
+
|
41
|
+
## Thanks
|
42
|
+
|
43
|
+
Special thanks for [mquan](https://github.com/mquan/lavish) for this idea.
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'prizm'
|
2
|
+
class ThemesController < ApplicationController
|
3
|
+
|
4
|
+
def switch
|
5
|
+
if params[:image_url]
|
6
|
+
@url = params[:image_url]
|
7
|
+
begin
|
8
|
+
extr = Prizm::Extractor.new(@url)
|
9
|
+
@colors = extr.get_colors(7, false).sort { |a, b| b.to_hsla[2] <=> a.to_hsla[2] }.map { |p| extr.to_hex(p) }
|
10
|
+
extr = nil
|
11
|
+
rescue
|
12
|
+
@colors = []
|
13
|
+
end
|
14
|
+
|
15
|
+
write_css
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def write_css
|
22
|
+
content = <<-RUBY
|
23
|
+
$white: #{@colors[0]};
|
24
|
+
$grayLighter: #{@colors[1]};
|
25
|
+
$grayLight: #{@colors[2]};
|
26
|
+
$gray: #{@colors[3]};
|
27
|
+
$linkColor: #{@colors[4]};
|
28
|
+
$grayDark: #{@colors[5]};
|
29
|
+
$black: #{@colors[6]};
|
30
|
+
|
31
|
+
$navbarBackgroundHighlight: $grayDark;
|
32
|
+
|
33
|
+
$navbarText: $gray;
|
34
|
+
$navbarLinkColor: $gray;
|
35
|
+
$navbarLinkColorHover: $grayLighter;
|
36
|
+
$navbarLinkColorActive: $grayLighter;
|
37
|
+
|
38
|
+
RUBY
|
39
|
+
|
40
|
+
File.open(Rails.root + "app/assets/stylesheets/bootstrap-color-config.css.scss", "w+") do |f|
|
41
|
+
f.write(content)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<div class="span12">
|
2
|
+
|
3
|
+
|
4
|
+
<div class="hero-unit">
|
5
|
+
<h1> BootColor</h1>
|
6
|
+
<p>Generate your own Bootstrap color scheme from an image</p>
|
7
|
+
<div style="text-align:center;"><a href="https://github.com/xdite/bootcolor" class="btn btn-large">View project on Github</a></div>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<a class="btn btn-primary" href="#"> Primary</a>
|
11
|
+
|
12
|
+
<div class="btn-group">
|
13
|
+
<button class="btn dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></button>
|
14
|
+
<ul class="dropdown-menu">
|
15
|
+
<li><a href="#">Action</a></li>
|
16
|
+
<li><a href="#">Another action</a></li>
|
17
|
+
<li><a href="#">Something else here</a></li>
|
18
|
+
<li class="divider"></li>
|
19
|
+
<li><a href="#">Separated link</a></li>
|
20
|
+
</ul>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
|
24
|
+
<h2>Provide an image</h2>
|
25
|
+
|
26
|
+
|
27
|
+
<%= form_tag "/switch_theme", :class => "form-search", :method => :get do %>
|
28
|
+
|
29
|
+
<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"></div>
|
30
|
+
<%= text_field_tag :image_url, @url, { :class => "input input-xxlarge" } %>
|
31
|
+
|
32
|
+
<input class="btn btn-primary" name="commit" type="submit" value="Generate Color">
|
33
|
+
|
34
|
+
<% end %>
|
35
|
+
</form>
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
</div>
|
data/bootcolor.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bootcolor/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "bootcolor"
|
8
|
+
gem.version = Bootcolor::VERSION
|
9
|
+
gem.authors = ["xdite"]
|
10
|
+
gem.email = ["xdite@rocodev.com"]
|
11
|
+
gem.description = %q{Auto Generate Color for Bootstrap}
|
12
|
+
gem.summary = %q{Auto Generate Color for Bootstrap}
|
13
|
+
gem.homepage = "http://github.com/xdite/bootcolor"
|
14
|
+
|
15
|
+
gem.add_dependency 'prizm'
|
16
|
+
gem.add_dependency 'anjlab-bootstrap-rails'
|
17
|
+
|
18
|
+
gem.files = `git ls-files`.split($/)
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
gem.require_paths = ["lib"]
|
22
|
+
end
|
data/config/routes.rb
ADDED
data/lib/bootcolor.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bootcolor/engine"
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bootcolor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- xdite
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: prizm
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: anjlab-bootstrap-rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Auto Generate Color for Bootstrap
|
47
|
+
email:
|
48
|
+
- xdite@rocodev.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- app/controllers/themes_controller.rb
|
59
|
+
- app/views/themes/switch.html.erb
|
60
|
+
- bootcolor.gemspec
|
61
|
+
- config/routes.rb
|
62
|
+
- lib/bootcolor.rb
|
63
|
+
- lib/bootcolor/engine.rb
|
64
|
+
- lib/bootcolor/version.rb
|
65
|
+
homepage: http://github.com/xdite/bootcolor
|
66
|
+
licenses: []
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
hash: 2219971421188351728
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
hash: 2219971421188351728
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 1.8.25
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: Auto Generate Color for Bootstrap
|
95
|
+
test_files: []
|