nex-bootstrap 4.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitattributes +14 -0
- data/.gitignore +19 -0
- data/.travis.yml +31 -0
- data/CHANGELOG.md +25 -0
- data/Gemfile +11 -0
- data/LICENSE +21 -0
- data/README.md +109 -0
- data/Rakefile +63 -0
- data/assets/javascripts/bootstrap/alert.js +183 -0
- data/assets/javascripts/bootstrap/button.js +225 -0
- data/assets/javascripts/bootstrap/carousel.js +640 -0
- data/assets/javascripts/bootstrap/collapse.js +394 -0
- data/assets/javascripts/bootstrap/dropdown.js +557 -0
- data/assets/javascripts/bootstrap/modal.js +660 -0
- data/assets/javascripts/bootstrap/popover.js +243 -0
- data/assets/javascripts/bootstrap/scrollspy.js +337 -0
- data/assets/javascripts/bootstrap/tab.js +259 -0
- data/assets/javascripts/bootstrap/toast.js +265 -0
- data/assets/javascripts/bootstrap/tooltip.js +886 -0
- data/assets/javascripts/bootstrap/util.js +189 -0
- data/assets/javascripts/bootstrap-sprockets.js +12 -0
- data/assets/javascripts/bootstrap.js +4356 -0
- data/assets/javascripts/bootstrap.min.js +6 -0
- data/assets/stylesheets/_bootstrap-grid.scss +30 -0
- data/assets/stylesheets/_bootstrap-reboot.scss +12 -0
- data/assets/stylesheets/_bootstrap.scss +44 -0
- data/assets/stylesheets/bootstrap/_alert.scss +52 -0
- data/assets/stylesheets/bootstrap/_badge.scss +54 -0
- data/assets/stylesheets/bootstrap/_breadcrumb.scss +42 -0
- data/assets/stylesheets/bootstrap/_button-group.scss +163 -0
- data/assets/stylesheets/bootstrap/_buttons.scss +142 -0
- data/assets/stylesheets/bootstrap/_card.scss +286 -0
- data/assets/stylesheets/bootstrap/_carousel.scss +200 -0
- data/assets/stylesheets/bootstrap/_close.scss +40 -0
- data/assets/stylesheets/bootstrap/_code.scss +48 -0
- data/assets/stylesheets/bootstrap/_custom-forms.scss +526 -0
- data/assets/stylesheets/bootstrap/_dropdown.scss +192 -0
- data/assets/stylesheets/bootstrap/_forms.scss +347 -0
- data/assets/stylesheets/bootstrap/_functions.scss +190 -0
- data/assets/stylesheets/bootstrap/_grid.scss +73 -0
- data/assets/stylesheets/bootstrap/_images.scss +42 -0
- data/assets/stylesheets/bootstrap/_input-group.scss +211 -0
- data/assets/stylesheets/bootstrap/_jumbotron.scss +17 -0
- data/assets/stylesheets/bootstrap/_list-group.scss +154 -0
- data/assets/stylesheets/bootstrap/_media.scss +8 -0
- data/assets/stylesheets/bootstrap/_mixins.scss +47 -0
- data/assets/stylesheets/bootstrap/_modal.scss +240 -0
- data/assets/stylesheets/bootstrap/_nav.scss +125 -0
- data/assets/stylesheets/bootstrap/_navbar.scss +332 -0
- data/assets/stylesheets/bootstrap/_pagination.scss +74 -0
- data/assets/stylesheets/bootstrap/_popover.scss +170 -0
- data/assets/stylesheets/bootstrap/_print.scss +132 -0
- data/assets/stylesheets/bootstrap/_progress.scss +47 -0
- data/assets/stylesheets/bootstrap/_reboot.scss +484 -0
- data/assets/stylesheets/bootstrap/_root.scss +19 -0
- data/assets/stylesheets/bootstrap/_spinners.scss +65 -0
- data/assets/stylesheets/bootstrap/_tables.scss +185 -0
- data/assets/stylesheets/bootstrap/_toasts.scss +46 -0
- data/assets/stylesheets/bootstrap/_tooltip.scss +115 -0
- data/assets/stylesheets/bootstrap/_transitions.scss +26 -0
- data/assets/stylesheets/bootstrap/_type.scss +125 -0
- data/assets/stylesheets/bootstrap/_utilities.scss +18 -0
- data/assets/stylesheets/bootstrap/_variables.scss +1149 -0
- data/assets/stylesheets/bootstrap/mixins/_alert.scss +13 -0
- data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +23 -0
- data/assets/stylesheets/bootstrap/mixins/_badge.scss +17 -0
- data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +76 -0
- data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +20 -0
- data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +123 -0
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +110 -0
- data/assets/stylesheets/bootstrap/mixins/_caret.scss +62 -0
- data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_deprecate.scss +10 -0
- data/assets/stylesheets/bootstrap/mixins/_float.scss +14 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +195 -0
- data/assets/stylesheets/bootstrap/mixins/_gradients.scss +45 -0
- data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +80 -0
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +69 -0
- data/assets/stylesheets/bootstrap/mixins/_hover.scss +37 -0
- data/assets/stylesheets/bootstrap/mixins/_image.scss +36 -0
- data/assets/stylesheets/bootstrap/mixins/_list-group.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_lists.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +11 -0
- data/assets/stylesheets/bootstrap/mixins/_pagination.scss +22 -0
- data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +17 -0
- data/assets/stylesheets/bootstrap/mixins/_resize.scss +6 -0
- data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +34 -0
- data/assets/stylesheets/bootstrap/mixins/_size.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_table-row.scss +39 -0
- data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +17 -0
- data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +11 -0
- data/assets/stylesheets/bootstrap/mixins/_text-truncate.scss +8 -0
- data/assets/stylesheets/bootstrap/mixins/_transition.scss +26 -0
- data/assets/stylesheets/bootstrap/mixins/_visibility.scss +8 -0
- data/assets/stylesheets/bootstrap/utilities/_align.scss +8 -0
- data/assets/stylesheets/bootstrap/utilities/_background.scss +19 -0
- data/assets/stylesheets/bootstrap/utilities/_borders.scss +75 -0
- data/assets/stylesheets/bootstrap/utilities/_clearfix.scss +3 -0
- data/assets/stylesheets/bootstrap/utilities/_display.scss +26 -0
- data/assets/stylesheets/bootstrap/utilities/_embed.scss +39 -0
- data/assets/stylesheets/bootstrap/utilities/_flex.scss +51 -0
- data/assets/stylesheets/bootstrap/utilities/_float.scss +11 -0
- data/assets/stylesheets/bootstrap/utilities/_interactions.scss +5 -0
- data/assets/stylesheets/bootstrap/utilities/_overflow.scss +5 -0
- data/assets/stylesheets/bootstrap/utilities/_position.scss +32 -0
- data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +11 -0
- data/assets/stylesheets/bootstrap/utilities/_shadows.scss +6 -0
- data/assets/stylesheets/bootstrap/utilities/_sizing.scss +20 -0
- data/assets/stylesheets/bootstrap/utilities/_spacing.scss +73 -0
- data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +19 -0
- data/assets/stylesheets/bootstrap/utilities/_text.scss +72 -0
- data/assets/stylesheets/bootstrap/utilities/_visibility.scss +13 -0
- data/assets/stylesheets/bootstrap/vendor/_rfs.scss +228 -0
- data/bootstrap.gemspec +38 -0
- data/lib/bootstrap/engine.rb +15 -0
- data/lib/bootstrap/version.rb +6 -0
- data/lib/bootstrap.rb +75 -0
- data/tasks/updater/js.rb +68 -0
- data/tasks/updater/logger.rb +57 -0
- data/tasks/updater/network.rb +103 -0
- data/tasks/updater/scss.rb +26 -0
- data/tasks/updater.rb +67 -0
- data/test/dummy_rails/README.rdoc +3 -0
- data/test/dummy_rails/Rakefile +6 -0
- data/test/dummy_rails/app/assets/config/manifest.js +3 -0
- data/test/dummy_rails/app/assets/images/.keep +0 -0
- data/test/dummy_rails/app/assets/javascripts/application.js +7 -0
- data/test/dummy_rails/app/assets/stylesheets/.browserslistrc +1 -0
- data/test/dummy_rails/app/assets/stylesheets/application.sass +4 -0
- data/test/dummy_rails/app/controllers/application_controller.rb +5 -0
- data/test/dummy_rails/app/controllers/pages_controller.rb +4 -0
- data/test/dummy_rails/app/helpers/application_helper.rb +2 -0
- data/test/dummy_rails/app/views/layouts/application.html.erb +14 -0
- data/test/dummy_rails/app/views/pages/root.html.slim +58 -0
- data/test/dummy_rails/config/application.rb +35 -0
- data/test/dummy_rails/config/boot.rb +5 -0
- data/test/dummy_rails/config/environment.rb +5 -0
- data/test/dummy_rails/config/environments/development.rb +23 -0
- data/test/dummy_rails/config/environments/production.rb +82 -0
- data/test/dummy_rails/config/environments/test.rb +38 -0
- data/test/dummy_rails/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy_rails/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy_rails/config/initializers/inflections.rb +16 -0
- data/test/dummy_rails/config/initializers/mime_types.rb +5 -0
- data/test/dummy_rails/config/initializers/secret_token.rb +18 -0
- data/test/dummy_rails/config/initializers/session_store.rb +3 -0
- data/test/dummy_rails/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy_rails/config/locales/en.yml +3 -0
- data/test/dummy_rails/config/locales/es.yml +3 -0
- data/test/dummy_rails/config/routes.rb +3 -0
- data/test/dummy_rails/config.ru +4 -0
- data/test/dummy_rails/log/.keep +0 -0
- data/test/gemfiles/rails_4_2.gemfile +7 -0
- data/test/gemfiles/rails_5_0.gemfile +8 -0
- data/test/gemfiles/rails_5_1.gemfile +8 -0
- data/test/gemfiles/rails_6_0.gemfile +7 -0
- data/test/rails_test.rb +24 -0
- data/test/support/dummy_rails_integration.rb +31 -0
- data/test/support/reporting.rb +27 -0
- data/test/test_helper.rb +41 -0
- data/test/test_helper_rails.rb +6 -0
- metadata +445 -0
data/lib/bootstrap.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bootstrap/version'
|
4
|
+
require 'popper_js'
|
5
|
+
|
6
|
+
module Bootstrap
|
7
|
+
class << self
|
8
|
+
# Inspired by Kaminari
|
9
|
+
def load!
|
10
|
+
if rails?
|
11
|
+
register_rails_engine
|
12
|
+
elsif hanami?
|
13
|
+
register_hanami
|
14
|
+
elsif sprockets?
|
15
|
+
register_sprockets
|
16
|
+
elsif defined?(::Sass) && ::Sass.respond_to?(:load_paths)
|
17
|
+
# The deprecated `sass` gem:
|
18
|
+
::Sass.load_paths << stylesheets_path
|
19
|
+
end
|
20
|
+
|
21
|
+
if defined?(::Sass::Script::Value::Number)
|
22
|
+
# Set precision to 6 as per:
|
23
|
+
# https://github.com/twbs/bootstrap/blob/da717b03e6e72d7a61c007acb9223b9626ae5ee5/package.json#L28
|
24
|
+
::Sass::Script::Value::Number.precision = [6, ::Sass::Script::Value::Number.precision].max
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Paths
|
29
|
+
def gem_path
|
30
|
+
@gem_path ||= File.expand_path '..', File.dirname(__FILE__)
|
31
|
+
end
|
32
|
+
|
33
|
+
def stylesheets_path
|
34
|
+
File.join assets_path, 'stylesheets'
|
35
|
+
end
|
36
|
+
|
37
|
+
def javascripts_path
|
38
|
+
File.join assets_path, 'javascripts'
|
39
|
+
end
|
40
|
+
|
41
|
+
def assets_path
|
42
|
+
@assets_path ||= File.join gem_path, 'assets'
|
43
|
+
end
|
44
|
+
|
45
|
+
# Environment detection helpers
|
46
|
+
def sprockets?
|
47
|
+
defined?(::Sprockets)
|
48
|
+
end
|
49
|
+
|
50
|
+
def rails?
|
51
|
+
defined?(::Rails)
|
52
|
+
end
|
53
|
+
|
54
|
+
def hanami?
|
55
|
+
defined?(::Hanami)
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def register_rails_engine
|
61
|
+
require 'bootstrap/engine'
|
62
|
+
end
|
63
|
+
|
64
|
+
def register_sprockets
|
65
|
+
Sprockets.append_path(stylesheets_path)
|
66
|
+
Sprockets.append_path(javascripts_path)
|
67
|
+
end
|
68
|
+
|
69
|
+
def register_hanami
|
70
|
+
Hanami::Assets.sources << assets_path
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
Bootstrap.load!
|
data/tasks/updater/js.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'tsort'
|
2
|
+
|
3
|
+
class Updater
|
4
|
+
module Js
|
5
|
+
def update_javascript_assets
|
6
|
+
log_status 'Updating javascripts...'
|
7
|
+
save_to = @save_to[:js]
|
8
|
+
read_files('js/dist', bootstrap_js_files).each do |name, content|
|
9
|
+
save_file("#{save_to}/#{name}", remove_source_mapping_url(content))
|
10
|
+
end
|
11
|
+
log_processed "#{bootstrap_js_files * ' '}"
|
12
|
+
|
13
|
+
log_status 'Updating javascript manifest'
|
14
|
+
manifest = ''
|
15
|
+
bootstrap_js_files.each do |name|
|
16
|
+
name = name.gsub(/\.js$/, '')
|
17
|
+
manifest << "//= require ./bootstrap/#{name}\n"
|
18
|
+
end
|
19
|
+
dist_js = read_files('dist/js', %w(bootstrap.js bootstrap.min.js))
|
20
|
+
{
|
21
|
+
'assets/javascripts/bootstrap-sprockets.js' => manifest,
|
22
|
+
'assets/javascripts/bootstrap.js' => dist_js['bootstrap.js'],
|
23
|
+
'assets/javascripts/bootstrap.min.js' => dist_js['bootstrap.min.js'],
|
24
|
+
}.each do |path, content|
|
25
|
+
save_file path, remove_source_mapping_url(content)
|
26
|
+
log_processed path
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def bootstrap_js_files
|
31
|
+
@bootstrap_js_files ||= begin
|
32
|
+
src_files = get_paths_by_type('js/src', /\.js$/) - %w[index.js tools/sanitizer.js]
|
33
|
+
imports = Deps.new
|
34
|
+
# Get the imports from the ES6 files to order requires correctly.
|
35
|
+
read_files('js/src', src_files).each do |name, content|
|
36
|
+
imports.add name,
|
37
|
+
*content.scan(%r{import [a-zA-Z]* from '\./(\w+)})
|
38
|
+
.flatten(1).map { |f| "#{f}.js" }
|
39
|
+
end
|
40
|
+
imports.tsort
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def remove_source_mapping_url(content)
|
45
|
+
content.sub(%r{^//# sourceMappingURL=.*\n?\z}, '')
|
46
|
+
end
|
47
|
+
|
48
|
+
class Deps
|
49
|
+
include TSort
|
50
|
+
|
51
|
+
def initialize
|
52
|
+
@imports = {}
|
53
|
+
end
|
54
|
+
|
55
|
+
def add(from, *tos)
|
56
|
+
(@imports[from] ||= []).push(*tos.sort)
|
57
|
+
end
|
58
|
+
|
59
|
+
def tsort_each_child(node, &block)
|
60
|
+
@imports[node].each(&block)
|
61
|
+
end
|
62
|
+
|
63
|
+
def tsort_each_node(&block)
|
64
|
+
@imports.each_key(&block)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class Updater
|
2
|
+
class Logger
|
3
|
+
include Term::ANSIColor
|
4
|
+
|
5
|
+
def log_status(status)
|
6
|
+
puts bold status
|
7
|
+
end
|
8
|
+
|
9
|
+
def log_file_info(s)
|
10
|
+
puts " #{magenta s}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def log_transform(*args, from: caller[1][/`.*'/][1..-2].sub(/^block in /, ''))
|
14
|
+
puts " #{cyan from}#{cyan ": #{args * ', '}" unless args.empty?}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def log_processing(name)
|
18
|
+
puts yellow " #{File.basename(name)}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def log_processed(name)
|
22
|
+
puts green " #{name}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def log_http_get_file(url, cached = false)
|
26
|
+
s = " #{'CACHED ' if cached}GET #{url}..."
|
27
|
+
if cached
|
28
|
+
puts dark green s
|
29
|
+
else
|
30
|
+
puts dark cyan s
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def log_http_get_files(files, from, cached = false)
|
35
|
+
return if files.empty?
|
36
|
+
s = " #{'CACHED ' if cached}GET #{files.length} files from #{from} #{files * ' '}..."
|
37
|
+
if cached
|
38
|
+
puts dark green s
|
39
|
+
else
|
40
|
+
puts dark cyan s
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def puts(*args)
|
45
|
+
STDERR.puts *args unless @silence
|
46
|
+
end
|
47
|
+
|
48
|
+
alias log puts
|
49
|
+
|
50
|
+
def silence_log
|
51
|
+
@silence = true
|
52
|
+
yield
|
53
|
+
ensure
|
54
|
+
@silence = false
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
class Updater
|
3
|
+
module Network
|
4
|
+
protected
|
5
|
+
|
6
|
+
WRITE_FILES_MUTEX = Mutex.new
|
7
|
+
|
8
|
+
def get_paths_by_type(dir, file_re, recursive = true)
|
9
|
+
get_file_paths(dir, recursive).select { |path| path =~ file_re }
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_file_paths(dir, recursive = true)
|
13
|
+
get_tree(get_tree_sha(dir), recursive)['tree'].select { |f| f['type'] == 'blob' }.map { |f| f['path'] }
|
14
|
+
end
|
15
|
+
|
16
|
+
def file_url(path)
|
17
|
+
"https://raw.githubusercontent.com/#@repo/#@branch_sha/#{path}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def read_files(path, files)
|
21
|
+
path_url = file_url path
|
22
|
+
contents = read_cached_files(path, files)
|
23
|
+
log_http_get_files contents.keys, path_url, true if contents.keys
|
24
|
+
files -= contents.keys
|
25
|
+
log_http_get_files files, path_url, false
|
26
|
+
files.map do |name|
|
27
|
+
Thread.start {
|
28
|
+
contents[name] = URI.open("#{path_url}/#{name}").read
|
29
|
+
WRITE_FILES_MUTEX.synchronize { write_cached_files path, name => contents[name] }
|
30
|
+
}
|
31
|
+
end.each(&:join)
|
32
|
+
contents
|
33
|
+
end
|
34
|
+
|
35
|
+
def read_cached_files(path, files)
|
36
|
+
full_path = "#@cache_path/#@branch_sha/#{path}"
|
37
|
+
contents = {}
|
38
|
+
if File.directory?(full_path)
|
39
|
+
files.each do |name|
|
40
|
+
path = "#{full_path}/#{name}"
|
41
|
+
contents[name] = File.read(path, mode: 'rb') if File.exists?(path)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
contents
|
45
|
+
end
|
46
|
+
|
47
|
+
def write_cached_files(path, files)
|
48
|
+
full_path = "./#@cache_path/#@branch_sha/#{path}"
|
49
|
+
files.each do |name, content|
|
50
|
+
FileUtils.mkdir_p File.dirname(File.join(full_path, name))
|
51
|
+
File.open("#{full_path}/#{name}", 'wb') { |f| f.write content }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def get_file(url)
|
57
|
+
uri = URI(url)
|
58
|
+
cache_path = "./#@cache_path#{uri.path}#{uri.query.tr('?&=', '-') if uri.query}"
|
59
|
+
FileUtils.mkdir_p File.dirname(cache_path)
|
60
|
+
if File.exists?(cache_path)
|
61
|
+
log_http_get_file url, true
|
62
|
+
File.read(cache_path, mode: 'rb')
|
63
|
+
else
|
64
|
+
log_http_get_file url, false
|
65
|
+
content = URI.open(url).read
|
66
|
+
File.open(cache_path, 'wb') { |f| f.write content }
|
67
|
+
content
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# get sha of the branch (= the latest commit)
|
72
|
+
def get_branch_sha
|
73
|
+
@branch_sha ||= begin
|
74
|
+
if @branch =~ /\A[0-9a-f]{40,}\z/
|
75
|
+
@branch
|
76
|
+
else
|
77
|
+
cmd = "git ls-remote #{Shellwords.escape "https://github.com/#@repo"} #@branch"
|
78
|
+
log cmd
|
79
|
+
result = %x[#{cmd}]
|
80
|
+
raise 'Could not get branch sha!' unless $?.success? && !result.empty?
|
81
|
+
result.split(/\s+/).first
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Get the sha of a dir
|
87
|
+
def get_tree_sha(dir, tree = get_trees)
|
88
|
+
tree['tree'].find { |t| t['path'] == dir }['sha']
|
89
|
+
end
|
90
|
+
|
91
|
+
def get_trees
|
92
|
+
@trees ||= get_tree(@branch_sha)
|
93
|
+
end
|
94
|
+
|
95
|
+
def get_tree(sha, recursive = true)
|
96
|
+
get_json("https://api.github.com/repos/#@repo/git/trees/#{sha}#{'?recursive=1' if recursive}")
|
97
|
+
end
|
98
|
+
|
99
|
+
def get_json(url)
|
100
|
+
JSON.parse get_file(url)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Updater
|
2
|
+
module Scss
|
3
|
+
def update_scss_assets
|
4
|
+
log_status 'Updating scss...'
|
5
|
+
save_to = @save_to[:scss]
|
6
|
+
contents = {}
|
7
|
+
bootstrap_scss_files = get_paths_by_type('scss', /\.scss$/)
|
8
|
+
read_files('scss', bootstrap_scss_files).each do |name, file|
|
9
|
+
contents[name] = file
|
10
|
+
save_file("#{save_to}/#{name}", file)
|
11
|
+
end
|
12
|
+
log_processed "#{bootstrap_scss_files * ' '}"
|
13
|
+
|
14
|
+
log_status 'Updating scss main files'
|
15
|
+
%w(bootstrap bootstrap-grid bootstrap-reboot).each do |name|
|
16
|
+
# Compass treats non-partials as targets to copy into the main project, so make them partials.
|
17
|
+
# Also move them up a level to clearly indicate entry points.
|
18
|
+
from = "#{save_to}/#{name}.scss"
|
19
|
+
to = "#{save_to}/../_#{name}.scss"
|
20
|
+
FileUtils.mv from, to
|
21
|
+
# As we moved the files, adjust imports accordingly.
|
22
|
+
File.write to, File.read(to).gsub(/ "/, ' "bootstrap/')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/tasks/updater.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'open-uri'
|
4
|
+
require 'json'
|
5
|
+
require 'strscan'
|
6
|
+
require 'forwardable'
|
7
|
+
require 'term/ansicolor'
|
8
|
+
require 'fileutils'
|
9
|
+
|
10
|
+
require_relative 'updater/scss'
|
11
|
+
require_relative 'updater/js'
|
12
|
+
require_relative 'updater/logger'
|
13
|
+
require_relative 'updater/network'
|
14
|
+
|
15
|
+
class Updater
|
16
|
+
extend Forwardable
|
17
|
+
include Network
|
18
|
+
include Js
|
19
|
+
include Scss
|
20
|
+
|
21
|
+
def initialize(repo: 'twbs/bootstrap', branch: 'master', save_to: {}, cache_path: 'tmp/bootstrap-cache')
|
22
|
+
@logger = Logger.new
|
23
|
+
@repo = repo
|
24
|
+
@branch = branch || 'master'
|
25
|
+
@branch_sha = get_branch_sha
|
26
|
+
@cache_path = cache_path
|
27
|
+
@repo_url = "https://github.com/#@repo"
|
28
|
+
@save_to = {
|
29
|
+
js: 'assets/javascripts/bootstrap',
|
30
|
+
scss: 'assets/stylesheets/bootstrap'}.merge(save_to)
|
31
|
+
end
|
32
|
+
|
33
|
+
def_delegators :@logger, :log, :log_status, :log_processing, :log_transform, :log_file_info, :log_processed, :log_http_get_file, :log_http_get_files, :silence_log
|
34
|
+
|
35
|
+
def update_bootstrap
|
36
|
+
log_status 'Updating Bootstrap'
|
37
|
+
puts " repo : #@repo_url"
|
38
|
+
puts " branch : #@branch_sha #@repo_url/tree/#@branch"
|
39
|
+
puts " save to: #{@save_to.to_json}"
|
40
|
+
puts " twbs cache: #{@cache_path}"
|
41
|
+
puts '-' * 60
|
42
|
+
|
43
|
+
FileUtils.rm_rf('assets')
|
44
|
+
@save_to.each { |_, v| FileUtils.mkdir_p(v) }
|
45
|
+
|
46
|
+
update_scss_assets
|
47
|
+
update_javascript_assets
|
48
|
+
store_version
|
49
|
+
end
|
50
|
+
|
51
|
+
def save_file(path, content, mode='w')
|
52
|
+
dir = File.dirname(path)
|
53
|
+
FileUtils.mkdir_p(dir) unless File.directory?(dir)
|
54
|
+
File.open(path, mode) { |file| file.write(content) }
|
55
|
+
end
|
56
|
+
|
57
|
+
def upstream_version
|
58
|
+
@upstream_version ||= get_json(file_url 'package.json')['version']
|
59
|
+
end
|
60
|
+
|
61
|
+
# Update version.rb file with BOOTSTRAP_SHA
|
62
|
+
def store_version
|
63
|
+
path = 'lib/bootstrap/version.rb'
|
64
|
+
content = File.read(path).sub(/BOOTSTRAP_SHA\s*=\s*['"][^'"]*['"]/, "BOOTSTRAP_SHA = '#@branch_sha'")
|
65
|
+
File.open(path, 'w') { |f| f.write(content) }
|
66
|
+
end
|
67
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
Chrome >= 25
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>bootstrap Dummy App</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: "all", 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
|
10
|
+
<body>
|
11
|
+
<%= yield %>
|
12
|
+
</body>
|
13
|
+
|
14
|
+
</html>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
.navbar.navbar-dark.bg-inverse: .container-fluid
|
2
|
+
button.navbar-toggler.hidden-sm-up type="button" data-toggle="collapse" data-target="#c1" ☰
|
3
|
+
.collapse.navbar-toggleable-xs#c1
|
4
|
+
a.navbar-brand href="#" Bootstrap Test Rails App
|
5
|
+
ul.nav.navbar-nav
|
6
|
+
li.nav-item.active: a.nav-link href="#"
|
7
|
+
' Home
|
8
|
+
span.sr-only (current)
|
9
|
+
li.nav-item: a.nav-link href="#" Link
|
10
|
+
li.nav-item.dropdown
|
11
|
+
a.nav-link.dropdown-toggle href="#" data-toggle="dropdown" role="button" aria-expanded="false"
|
12
|
+
' Dropdown
|
13
|
+
span.caret
|
14
|
+
.dropdown-menu role="menu"
|
15
|
+
a.dropdown-item href="#" Action
|
16
|
+
a.dropdown-item href="#" Another action
|
17
|
+
a.dropdown-item href="#" Something else here
|
18
|
+
a.dropdown-divider
|
19
|
+
a.dropdown-item href="#" Separated ank
|
20
|
+
a.dropdown-divider
|
21
|
+
a.dropdown-item href="#" One more separated link
|
22
|
+
|
23
|
+
.container
|
24
|
+
.card
|
25
|
+
.card-header: h3 Dummy App
|
26
|
+
.card-block: .row
|
27
|
+
.col-sm-3
|
28
|
+
h2 3 columns
|
29
|
+
.list-group
|
30
|
+
a.list-group-item href='#one' One
|
31
|
+
a.list-group-item href='#two' Two
|
32
|
+
a.list-group-item href='#three' Three
|
33
|
+
.col-sm-3
|
34
|
+
h2 3 columns
|
35
|
+
.btn-group
|
36
|
+
button.btn.btn-primary type='button' Button
|
37
|
+
button.btn.btn-primary type='button' Button
|
38
|
+
table.table
|
39
|
+
caption Table
|
40
|
+
tr
|
41
|
+
td.table-danger Danger!
|
42
|
+
td.table-success Success!
|
43
|
+
.col-sm-6
|
44
|
+
h2 6 columns
|
45
|
+
.row
|
46
|
+
.col-xs-4.col-xs-push-4: .card: .card-block
|
47
|
+
.card-text data-toggle="tooltip" title="hi"
|
48
|
+
h6 This is col-xs-4 col-xs-push-4.<br><small>Hover for tooltip.</small>
|
49
|
+
|
50
|
+
.card: .card-block: form.form-inline
|
51
|
+
.form-group
|
52
|
+
label.sr-only for="exampleInputEmail2" Email address
|
53
|
+
input.form-control#exampleInputEmail2 type="email" placeholder="Enter email"
|
54
|
+
.checkbox
|
55
|
+
label
|
56
|
+
input type="checkbox"
|
57
|
+
| Remember me
|
58
|
+
button.btn.btn-default type="submit" Sign in
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails'
|
4
|
+
|
5
|
+
%w(
|
6
|
+
action_controller
|
7
|
+
action_view
|
8
|
+
sprockets
|
9
|
+
).each do |framework|
|
10
|
+
require "#{framework}/railtie"
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'autoprefixer-rails'
|
14
|
+
require 'slim-rails'
|
15
|
+
require 'uglifier'
|
16
|
+
|
17
|
+
require 'bootstrap'
|
18
|
+
require 'jquery-rails'
|
19
|
+
|
20
|
+
module Dummy
|
21
|
+
class Application < Rails::Application
|
22
|
+
config.assets.enabled = true if config.assets.respond_to?(:enabled)
|
23
|
+
if Rails::VERSION::MAJOR > 4
|
24
|
+
# Rails 4 precompiles application.css|js by default, but future version of Rails do not.
|
25
|
+
config.assets.precompile += %w( application.css application.js )
|
26
|
+
end
|
27
|
+
config.to_prepare do
|
28
|
+
if ENV['VERBOSE']
|
29
|
+
STDERR.puts "Loaded Rails #{Rails::VERSION::STRING}, Sprockets #{Sprockets::VERSION}",
|
30
|
+
"Asset paths: #{Rails.application.config.assets.paths}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports and disable caching.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Print deprecation notices to the Rails logger.
|
17
|
+
config.active_support.deprecation = :log
|
18
|
+
|
19
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
20
|
+
# This option may cause significant delays in view rendering with a large
|
21
|
+
# number of complex assets.
|
22
|
+
config.assets.debug = true
|
23
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# Code is not reloaded between requests.
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both thread web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
14
|
+
config.consider_all_requests_local = false
|
15
|
+
config.action_controller.perform_caching = true
|
16
|
+
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
20
|
+
# config.action_dispatch.rack_cache = true
|
21
|
+
|
22
|
+
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
+
if config.respond_to?(:serve_static_files)
|
24
|
+
# rails >= 4.2
|
25
|
+
config.serve_static_files = true
|
26
|
+
elsif config.respond_to?(:serve_static_assets)
|
27
|
+
# rails < 4.2
|
28
|
+
config.serve_static_assets = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# Compress JavaScripts and CSS.
|
32
|
+
config.assets.js_compressor = :uglifier
|
33
|
+
# config.assets.css_compressor = :sass
|
34
|
+
|
35
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
36
|
+
config.assets.compile = false
|
37
|
+
|
38
|
+
# Generate digests for assets URLs.
|
39
|
+
config.assets.digest = true
|
40
|
+
|
41
|
+
# Version of your assets, change this if you want to expire all your assets.
|
42
|
+
config.assets.version = '1.0'
|
43
|
+
|
44
|
+
# Specifies the header that your server uses for sending files.
|
45
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
46
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
47
|
+
|
48
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
49
|
+
# config.force_ssl = true
|
50
|
+
|
51
|
+
# Set to :debug to see everything in the log.
|
52
|
+
config.log_level = :info
|
53
|
+
|
54
|
+
# Prepend all log lines with the following tags.
|
55
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
56
|
+
|
57
|
+
# Use a different logger for distributed setups.
|
58
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
59
|
+
|
60
|
+
# Use a different cache store in production.
|
61
|
+
# config.cache_store = :mem_cache_store
|
62
|
+
|
63
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
64
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
65
|
+
|
66
|
+
# Precompile additional assets.
|
67
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
68
|
+
# config.assets.precompile += %w( search.js )
|
69
|
+
|
70
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
71
|
+
# the I18n.default_locale when a translation can not be found).
|
72
|
+
config.i18n.fallbacks = true
|
73
|
+
|
74
|
+
# Send deprecation notices to registered listeners.
|
75
|
+
config.active_support.deprecation = :notify
|
76
|
+
|
77
|
+
# Disable automatic flushing of the log to improve performance.
|
78
|
+
# config.autoflush_log = false
|
79
|
+
|
80
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
81
|
+
config.log_formatter = ::Logger::Formatter.new
|
82
|
+
end
|