penmanship 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +74 -0
- data/Rakefile +2 -0
- data/lib/penmanship.rb +15 -0
- data/lib/penmanship/action_controller/extension.rb +24 -0
- data/lib/penmanship/action_view/extension.rb +43 -0
- data/lib/penmanship/version.rb +3 -0
- data/penmanship.gemspec +25 -0
- data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/README.md +112 -0
- data/vendor/assets/javascripts/bootstrap-alert.js +90 -0
- data/vendor/assets/javascripts/bootstrap-application.js +184 -0
- data/vendor/assets/javascripts/bootstrap-button.js +96 -0
- data/vendor/assets/javascripts/bootstrap-carousel.js +169 -0
- data/vendor/assets/javascripts/bootstrap-collapse.js +157 -0
- data/vendor/assets/javascripts/bootstrap-dropdown.js +100 -0
- data/vendor/assets/javascripts/bootstrap-modal.js +218 -0
- data/vendor/assets/javascripts/bootstrap-popover.js +98 -0
- data/vendor/assets/javascripts/bootstrap-scrollspy.js +151 -0
- data/vendor/assets/javascripts/bootstrap-tab.js +135 -0
- data/vendor/assets/javascripts/bootstrap-tooltip.js +275 -0
- data/vendor/assets/javascripts/bootstrap-transition.js +61 -0
- data/vendor/assets/javascripts/bootstrap-typeahead.js +285 -0
- data/vendor/assets/javascripts/bootstrap.js +1824 -0
- data/vendor/assets/javascripts/bootstrap.min.js +6 -0
- data/vendor/assets/javascripts/prettify.js +28 -0
- data/vendor/assets/stylesheets/bootstrap-responsive.css +808 -0
- data/vendor/assets/stylesheets/bootstrap.css +4960 -0
- data/vendor/assets/stylesheets/docs.css +841 -0
- data/vendor/assets/stylesheets/prettify.css +30 -0
- metadata +142 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Enocre Shao
|
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,74 @@
|
|
1
|
+
## Penmanship - Rails HTML CSS Javascript made easy.
|
2
|
+
The idea came from Twitter Bootstrap.
|
3
|
+
Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites.
|
4
|
+
Bootstrap provides simple and flexible HTML, CSS, and Javascript for popular user interface components and interactions.
|
5
|
+
twitter-bootstrap-rails project integrates Bootstrap CSS toolkit for Rails 3 projects
|
6
|
+
|
7
|
+
### Twitter Bootstrap
|
8
|
+
Thanks Twitter for Bootstrap http://twitter.github.com/bootstrap
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add it to your Gemfile:
|
13
|
+
|
14
|
+
`gem 'penmanship', :git => 'git://github.com/encoreshao/penmanship.git'`
|
15
|
+
|
16
|
+
Run the following command to install it:
|
17
|
+
|
18
|
+
`bundle install`
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
To start using **Penmanship** you just have to use the application.css it provides:
|
23
|
+
|
24
|
+
```erb
|
25
|
+
*= require_self
|
26
|
+
*= require bootstrap
|
27
|
+
*= require bootstrap-responsive
|
28
|
+
*= require docs
|
29
|
+
```
|
30
|
+
|
31
|
+
To start using **Penmanship** you just have to use the application.js it provides:
|
32
|
+
|
33
|
+
```erb
|
34
|
+
//= require jquery
|
35
|
+
//= require jquery_ujs
|
36
|
+
//= require bootstrap-transition
|
37
|
+
//= require bootstrap-alert
|
38
|
+
//= require bootstrap-modal
|
39
|
+
//= require bootstrap-dropdown
|
40
|
+
//= require bootstrap-scrollspy
|
41
|
+
//= require bootstrap-tab
|
42
|
+
//= require bootstrap-tooltip
|
43
|
+
//= require bootstrap-popover
|
44
|
+
//= require bootstrap-button
|
45
|
+
//= require bootstrap-collapse
|
46
|
+
//= require bootstrap-carousel
|
47
|
+
//= require bootstrap-typeahead
|
48
|
+
```
|
49
|
+
|
50
|
+
|
51
|
+
## Credits
|
52
|
+
Encore Shao - encore.shao [at] gmail com
|
53
|
+
|
54
|
+
[Follow me on Twitter](http://twitter.com/encoreshao "Twitter")
|
55
|
+
|
56
|
+
## Contributors
|
57
|
+
<ul>
|
58
|
+
<li>Encore Shao</li>
|
59
|
+
</ul>
|
60
|
+
|
61
|
+
## License
|
62
|
+
Copyright (c) 2011 Encore Shao
|
63
|
+
|
64
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
65
|
+
you may not use this work except in compliance with the License.
|
66
|
+
You may obtain a copy of the License in the LICENSE file, or at:
|
67
|
+
|
68
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
69
|
+
|
70
|
+
Unless required by applicable law or agreed to in writing, software
|
71
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
72
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
73
|
+
See the License for the specific language governing permissions and
|
74
|
+
limitations under the License.
|
data/Rakefile
ADDED
data/lib/penmanship.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require "penmanship/action_controller/extension"
|
3
|
+
require "penmanship/action_view/extension"
|
4
|
+
|
5
|
+
module Penmanship
|
6
|
+
if ::Rails.version > "3.1"
|
7
|
+
class Engine < ::Rails::Engine; end
|
8
|
+
else
|
9
|
+
class Railtie < ::Rails::Railtie
|
10
|
+
ActiveSupport.on_load(:action_view) do
|
11
|
+
::ActionView::Base.send :include, Penmanship::ActionView::Extension
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Penmanship
|
2
|
+
module ActionController
|
3
|
+
module Extension
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
|
11
|
+
def main_nav_highlight(name)
|
12
|
+
before_filter { |c| c.instance_variable_set(:@main_nav, name) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def sec_nav_highlight(name)
|
16
|
+
before_filter { |c| c.instance_variable_set(:@sec_nav, name) }
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
ActionController::Base.send :include, Penmanship::ActionController::Extension
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Penmanship
|
2
|
+
module ActionView
|
3
|
+
module Extension
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
module InstanceMethods
|
7
|
+
|
8
|
+
# A helper that set the i18n columns
|
9
|
+
def translate_attribute(klass, attribute_name)
|
10
|
+
klass.human_attribute_name(attribute_name)
|
11
|
+
end
|
12
|
+
alias :ta :translate_attribute
|
13
|
+
|
14
|
+
# A helper that renders the sec navigation highlight
|
15
|
+
def main_nav(name, options = {}, &block)
|
16
|
+
if @main_nav == name
|
17
|
+
if options[:class]
|
18
|
+
options[:class] += " active"
|
19
|
+
else
|
20
|
+
options[:class] = "active"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
content = capture(&block)
|
24
|
+
content_tag(:li, content, options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def sec_nav(name, options = {}, &block)
|
28
|
+
if @sec_nav == name
|
29
|
+
if options[:class]
|
30
|
+
options[:class] += " active"
|
31
|
+
else
|
32
|
+
options[:class] = "active"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
content = capture(&block)
|
36
|
+
content_tag(:li, content, options)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
ActionView::Base.send :include, Penmanship::ActionView::Extension::InstanceMethods
|
data/penmanship.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "penmanship/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "penmanship"
|
7
|
+
gem.rubyforge_project = "penmanship"
|
8
|
+
gem.authors = ["Enocre Shao"]
|
9
|
+
gem.email = ["encore.shao@gmail.com"]
|
10
|
+
gem.description = %q{A simple integration bootstrap, Add some cookies.}
|
11
|
+
gem.summary = %q{A simple integration bootstrap, And some cookies...}
|
12
|
+
gem.homepage = "https://github.com/encoreshao/penmanship"
|
13
|
+
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($\)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.version = Penmanship::VERSION
|
20
|
+
|
21
|
+
gem.add_dependency "railties", "~> 3.0"
|
22
|
+
gem.add_dependency "thor", "~> 0.14"
|
23
|
+
gem.add_development_dependency "bundler", "~> 1.1.0"
|
24
|
+
gem.add_development_dependency "rails", "~> 3.0"
|
25
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,112 @@
|
|
1
|
+
## 2.0 BOOTSTRAP JS PHILOSOPHY
|
2
|
+
These are the high-level design rules which guide the development of Bootstrap's plugin apis.
|
3
|
+
|
4
|
+
---
|
5
|
+
|
6
|
+
### DATA-ATTRIBUTE API
|
7
|
+
|
8
|
+
We believe you should be able to use all plugins provided by Bootstrap purely through the markup API without writing a single line of javascript. This is bootstraps first class api.
|
9
|
+
|
10
|
+
We acknowledge that this isn't always the most performant and sometimes it may be desirable to turn this functionality off altogether. Therefore, as of 2.0 we provide the ability to disable the data attribute API by unbinding all events on the body namespaced with `'data-api'`. This looks like this:
|
11
|
+
|
12
|
+
$('body').off('.data-api')
|
13
|
+
|
14
|
+
To target a specific plugin, just include the plugins name as a namespace along with the data-api namespace like this:
|
15
|
+
|
16
|
+
$('body').off('.alert.data-api')
|
17
|
+
|
18
|
+
---
|
19
|
+
|
20
|
+
### PROGRAMATIC API
|
21
|
+
|
22
|
+
We also believe you should be able to use all plugins provided by Bootstrap purely through the JS API.
|
23
|
+
|
24
|
+
All public APIs should be single, chainable methods, and return the collection acted upon.
|
25
|
+
|
26
|
+
$(".btn.danger").button("toggle").addClass("fat")
|
27
|
+
|
28
|
+
All methods should accept an optional options object, a string which targets a particular method, or null which initiates the default behavior:
|
29
|
+
|
30
|
+
$("#myModal").modal() // initialized with defaults
|
31
|
+
$("#myModal").modal({ keyboard: false }) // initialized with no keyboard
|
32
|
+
$("#myModal").modal('show') // initializes and invokes show immediately
|
33
|
+
|
34
|
+
---
|
35
|
+
|
36
|
+
### OPTIONS
|
37
|
+
|
38
|
+
Options should be sparse and add universal value. We should pick the right defaults.
|
39
|
+
|
40
|
+
All plugins should have a default object which can be modified to affect all instances' default options. The defaults object should be available via `$.fn.plugin.defaults`.
|
41
|
+
|
42
|
+
$.fn.modal.defaults = { … }
|
43
|
+
|
44
|
+
An options definition should take the following form:
|
45
|
+
|
46
|
+
*noun*: *adjective* - describes or modifies a quality of an instance
|
47
|
+
|
48
|
+
examples:
|
49
|
+
|
50
|
+
backdrop: true
|
51
|
+
keyboard: false
|
52
|
+
placement: 'top'
|
53
|
+
|
54
|
+
---
|
55
|
+
|
56
|
+
### EVENTS
|
57
|
+
|
58
|
+
All events should have an infinitive and past participle form. The infinitive is fired just before an action takes place, the past participle on completion of the action.
|
59
|
+
|
60
|
+
show | shown
|
61
|
+
hide | hidden
|
62
|
+
|
63
|
+
All infinitive events should provide preventDefault functionality. This provides the abililty to stop the execution of an action.
|
64
|
+
|
65
|
+
$('#myModal').on('show', function (e) {
|
66
|
+
if (!data) return e.preventDefault() // stops modal from being shown
|
67
|
+
})
|
68
|
+
|
69
|
+
---
|
70
|
+
|
71
|
+
### CONSTRUCTORS
|
72
|
+
|
73
|
+
Each plugin should expose its raw constructor on a `Constructor` property -- accessed in the following way:
|
74
|
+
|
75
|
+
|
76
|
+
$.fn.popover.Constructor
|
77
|
+
|
78
|
+
---
|
79
|
+
|
80
|
+
### DATA ACCESSOR
|
81
|
+
|
82
|
+
Each plugin stores a copy of the invoked class on an object. This class instance can be accessed directly through jQuery's data API like this:
|
83
|
+
|
84
|
+
$('[rel=popover]').data('popover') instanceof $.fn.popover.Constructor
|
85
|
+
|
86
|
+
---
|
87
|
+
|
88
|
+
### DATA ATTRIBUTES
|
89
|
+
|
90
|
+
Data attributes should take the following form:
|
91
|
+
|
92
|
+
- data-{{verb}}={{plugin}} - defines main interaction
|
93
|
+
- data-target || href^=# - defined on "control" element (if element controls an element other than self)
|
94
|
+
- data-{{noun}} - defines class instance options
|
95
|
+
|
96
|
+
examples:
|
97
|
+
|
98
|
+
// control other targets
|
99
|
+
data-toggle="modal" data-target="#foo"
|
100
|
+
data-toggle="collapse" data-target="#foo" data-parent="#bar"
|
101
|
+
|
102
|
+
// defined on element they control
|
103
|
+
data-spy="scroll"
|
104
|
+
|
105
|
+
data-dismiss="modal"
|
106
|
+
data-dismiss="alert"
|
107
|
+
|
108
|
+
data-toggle="dropdown"
|
109
|
+
|
110
|
+
data-toggle="button"
|
111
|
+
data-toggle="buttons-checkbox"
|
112
|
+
data-toggle="buttons-radio"
|
@@ -0,0 +1,90 @@
|
|
1
|
+
/* ==========================================================
|
2
|
+
* bootstrap-alert.js v2.0.3
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#alerts
|
4
|
+
* ==========================================================
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ========================================================== */
|
19
|
+
|
20
|
+
|
21
|
+
!function ($) {
|
22
|
+
|
23
|
+
"use strict"; // jshint ;_;
|
24
|
+
|
25
|
+
|
26
|
+
/* ALERT CLASS DEFINITION
|
27
|
+
* ====================== */
|
28
|
+
|
29
|
+
var dismiss = '[data-dismiss="alert"]'
|
30
|
+
, Alert = function (el) {
|
31
|
+
$(el).on('click', dismiss, this.close)
|
32
|
+
}
|
33
|
+
|
34
|
+
Alert.prototype.close = function (e) {
|
35
|
+
var $this = $(this)
|
36
|
+
, selector = $this.attr('data-target')
|
37
|
+
, $parent
|
38
|
+
|
39
|
+
if (!selector) {
|
40
|
+
selector = $this.attr('href')
|
41
|
+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
42
|
+
}
|
43
|
+
|
44
|
+
$parent = $(selector)
|
45
|
+
|
46
|
+
e && e.preventDefault()
|
47
|
+
|
48
|
+
$parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
|
49
|
+
|
50
|
+
$parent.trigger(e = $.Event('close'))
|
51
|
+
|
52
|
+
if (e.isDefaultPrevented()) return
|
53
|
+
|
54
|
+
$parent.removeClass('in')
|
55
|
+
|
56
|
+
function removeElement() {
|
57
|
+
$parent
|
58
|
+
.trigger('closed')
|
59
|
+
.remove()
|
60
|
+
}
|
61
|
+
|
62
|
+
$.support.transition && $parent.hasClass('fade') ?
|
63
|
+
$parent.on($.support.transition.end, removeElement) :
|
64
|
+
removeElement()
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
/* ALERT PLUGIN DEFINITION
|
69
|
+
* ======================= */
|
70
|
+
|
71
|
+
$.fn.alert = function (option) {
|
72
|
+
return this.each(function () {
|
73
|
+
var $this = $(this)
|
74
|
+
, data = $this.data('alert')
|
75
|
+
if (!data) $this.data('alert', (data = new Alert(this)))
|
76
|
+
if (typeof option == 'string') data[option].call($this)
|
77
|
+
})
|
78
|
+
}
|
79
|
+
|
80
|
+
$.fn.alert.Constructor = Alert
|
81
|
+
|
82
|
+
|
83
|
+
/* ALERT DATA-API
|
84
|
+
* ============== */
|
85
|
+
|
86
|
+
$(function () {
|
87
|
+
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
|
88
|
+
})
|
89
|
+
|
90
|
+
}(window.jQuery);
|