toolbox_esten 1.0.0
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +0 -0
- data/CONTRIBUTING.md +0 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +165 -0
- data/LICENSE.txt +22 -0
- data/README.md +0 -0
- data/Rakefile +8 -0
- data/assets/javascripts/simpleLoader/simpleLoader.js +122 -0
- data/assets/javascripts/simpleLoader/simpleLoader.min.js +1 -0
- data/assets/javascripts/simpleMenu/simpleMenu.js +53 -0
- data/assets/javascripts/simpleMenu/simpleMenu.min.js +1 -0
- data/assets/javascripts/simpleSelection/simpleSelect.js +60 -0
- data/assets/javascripts/simpleTextfield/simpleTextfield.js +94 -0
- data/assets/javascripts/simpleTooltip/simpleTooltip.js +166 -0
- data/assets/javascripts/simpleTooltip/simpleTooltip.min.js +1 -0
- data/assets/stylesheets/_jquery_ui.scss +1 -0
- data/assets/stylesheets/_simpleloader.scss +2 -0
- data/assets/stylesheets/_simpleselection.scss +1 -0
- data/assets/stylesheets/_simpletextfield.scss +1 -0
- data/assets/stylesheets/_simpletooltip.scss +1 -0
- data/assets/stylesheets/_toolbox_esten.scss +18 -0
- data/assets/stylesheets/jquery_ui/uidialog.scss +39 -0
- data/assets/stylesheets/simpleLoader/keyframes.scss +325 -0
- data/assets/stylesheets/simpleLoader/simpleLoader.scss +367 -0
- data/assets/stylesheets/simpleSelection/simpleSelection.scss +15 -0
- data/assets/stylesheets/simpleTextfield/simpleTextfield.scss +54 -0
- data/assets/stylesheets/simpleTooltip/simpleTooltip.scss +21 -0
- data/assets/stylesheets/toolbox_esten/base.scss +27 -0
- data/assets/stylesheets/toolbox_esten/buttons.scss +162 -0
- data/assets/stylesheets/toolbox_esten/datatables.scss +113 -0
- data/assets/stylesheets/toolbox_esten/detail.scss +22 -0
- data/assets/stylesheets/toolbox_esten/flex.scss +32 -0
- data/assets/stylesheets/toolbox_esten/form.scss +35 -0
- data/assets/stylesheets/toolbox_esten/grid.scss +34 -0
- data/assets/stylesheets/toolbox_esten/helper.scss +42 -0
- data/assets/stylesheets/toolbox_esten/mixins.scss +179 -0
- data/assets/stylesheets/toolbox_esten/notification.scss +109 -0
- data/assets/stylesheets/toolbox_esten/reset.scss +38 -0
- data/assets/stylesheets/toolbox_esten/section.scss +53 -0
- data/assets/stylesheets/toolbox_esten/tables.scss +72 -0
- data/assets/stylesheets/toolbox_esten/tabs.scss +42 -0
- data/assets/stylesheets/toolbox_esten/textfield.scss +43 -0
- data/assets/stylesheets/toolbox_esten/top_bar.scss +80 -0
- data/assets/stylesheets/toolbox_esten/variables.scss +260 -0
- data/bower.json +26 -0
- data/composer.json +20 -0
- data/lib/toolbox_esten.rb +84 -0
- data/lib/toolbox_esten/engine.rb +11 -0
- data/lib/toolbox_esten/version.rb +3 -0
- data/sache.json +5 -0
- data/tasks/bower.rake +29 -0
- data/tasks/converter.rb +62 -0
- data/tasks/converter/char_string_scanner.rb +38 -0
- data/tasks/converter/logger.rb +57 -0
- data/tasks/converter/network.rb +100 -0
- data/tasks/install.rake +20 -0
- data/templates/.travis.yml +19 -0
- data/templates/project/styles.sass +2 -0
- data/toolbox_esten.gemspec +43 -0
- metadata +317 -0
data/composer.json
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"name": "twbs/toolbox_esten",
|
3
|
+
"description": "",
|
4
|
+
"keywords": ["toolbox_esten", "css", "sass"],
|
5
|
+
"homepage": "https://github.com/shaunshang2010/toolbox_esten",
|
6
|
+
"authors": [
|
7
|
+
{
|
8
|
+
"name": "Shang Chuan Chuan"
|
9
|
+
}
|
10
|
+
],
|
11
|
+
"support": {
|
12
|
+
"issues": "https://github.com/shaunshang2010/toolbox_esten/issues"
|
13
|
+
},
|
14
|
+
"license": "MIT",
|
15
|
+
"extra": {
|
16
|
+
"branch-alias": {
|
17
|
+
"dev-master": "3.3.x-dev"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'toolbox_esten/version'
|
2
|
+
module ToolboxEsten
|
3
|
+
class << self
|
4
|
+
# Inspired by Kaminari
|
5
|
+
def load!
|
6
|
+
register_compass_extension if compass?
|
7
|
+
|
8
|
+
if rails?
|
9
|
+
register_rails_engine
|
10
|
+
elsif sprockets?
|
11
|
+
register_sprockets
|
12
|
+
end
|
13
|
+
|
14
|
+
configure_sass
|
15
|
+
end
|
16
|
+
|
17
|
+
# Paths
|
18
|
+
def gem_path
|
19
|
+
@gem_path ||= File.expand_path '..', File.dirname(__FILE__)
|
20
|
+
end
|
21
|
+
|
22
|
+
def stylesheets_path
|
23
|
+
File.join assets_path, 'stylesheets'
|
24
|
+
end
|
25
|
+
|
26
|
+
def fonts_path
|
27
|
+
File.join assets_path, 'fonts'
|
28
|
+
end
|
29
|
+
|
30
|
+
def javascripts_path
|
31
|
+
File.join assets_path, 'javascripts'
|
32
|
+
end
|
33
|
+
|
34
|
+
def assets_path
|
35
|
+
@assets_path ||= File.join gem_path, 'assets'
|
36
|
+
end
|
37
|
+
|
38
|
+
# Environment detection helpers
|
39
|
+
def sprockets?
|
40
|
+
defined?(::Sprockets)
|
41
|
+
end
|
42
|
+
|
43
|
+
def compass?
|
44
|
+
defined?(::Compass::Frameworks)
|
45
|
+
end
|
46
|
+
|
47
|
+
def rails?
|
48
|
+
defined?(::Rails)
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def configure_sass
|
54
|
+
require 'sass'
|
55
|
+
|
56
|
+
::Sass.load_paths << stylesheets_path
|
57
|
+
|
58
|
+
# ToolboxEsten requires minimum precision of 8, see https://github.com/shaunshang2010/toolbox_esten/issues/409
|
59
|
+
::Sass::Script::Number.precision = [8, ::Sass::Script::Number.precision].max
|
60
|
+
end
|
61
|
+
|
62
|
+
def register_compass_extension
|
63
|
+
::Compass::Frameworks.register(
|
64
|
+
'toolbox_esten',
|
65
|
+
:version => ToolboxEsten::VERSION,
|
66
|
+
:path => gem_path,
|
67
|
+
:stylesheets_directory => stylesheets_path,
|
68
|
+
:templates_directory => File.join(gem_path, 'templates')
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
def register_rails_engine
|
73
|
+
require 'toolbox_esten/engine'
|
74
|
+
end
|
75
|
+
|
76
|
+
def register_sprockets
|
77
|
+
Sprockets.append_path(stylesheets_path)
|
78
|
+
Sprockets.append_path(fonts_path)
|
79
|
+
Sprockets.append_path(javascripts_path)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
ToolboxEsten.load!
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module ToolboxEsten
|
2
|
+
module Rails
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
initializer 'toolbox_esten.assets.precompile' do |app|
|
5
|
+
%w(stylesheets javascripts).each do |sub|
|
6
|
+
app.config.assets.paths << root.join('assets', sub).to_s
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/sache.json
ADDED
data/tasks/bower.rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'find'
|
2
|
+
require 'json'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
namespace :bower do
|
6
|
+
|
7
|
+
find_files = ->(path) {
|
8
|
+
Find.find(Pathname.new(path).relative_path_from(Pathname.new Dir.pwd).to_s).map do |path|
|
9
|
+
path if File.file?(path)
|
10
|
+
end.compact
|
11
|
+
}
|
12
|
+
|
13
|
+
desc 'update main and version in bower.json'
|
14
|
+
task :generate do
|
15
|
+
require 'toolbox_esten'
|
16
|
+
Dir.chdir ToolboxEsten.gem_path do
|
17
|
+
spec = JSON.parse(File.read 'bower.json')
|
18
|
+
|
19
|
+
spec['main'] =
|
20
|
+
find_files.(File.join(ToolboxEsten.stylesheets_path, '_toolbox_esten.scss'))
|
21
|
+
|
22
|
+
spec['version'] = ToolboxEsten::VERSION
|
23
|
+
|
24
|
+
File.open('bower.json', 'w') do |f|
|
25
|
+
f.puts JSON.pretty_generate(spec)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/tasks/converter.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# Based on convert script from vwall/compass-twitter-bootstrap gem.
|
3
|
+
# https://github.com/vwall/compass-twitter-bootstrap/blob/master/build/convert.rb
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this work except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License in the LICENSE file, or at:
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'open-uri'
|
18
|
+
require 'json'
|
19
|
+
require 'strscan'
|
20
|
+
require 'forwardable'
|
21
|
+
require 'term/ansicolor'
|
22
|
+
require 'fileutils'
|
23
|
+
|
24
|
+
require_relative 'converter/logger'
|
25
|
+
require_relative 'converter/network'
|
26
|
+
|
27
|
+
class Converter
|
28
|
+
extend Forwardable
|
29
|
+
include Network
|
30
|
+
|
31
|
+
def initialize(repo: 'twbs/toolbox_esten', branch: 'master', save_to: {}, cache_path: 'tmp/converter-cache-toolbox_esten')
|
32
|
+
@logger = Logger.new
|
33
|
+
@repo = repo
|
34
|
+
@branch = branch || 'master'
|
35
|
+
@branch_sha = get_branch_sha
|
36
|
+
@cache_path = cache_path
|
37
|
+
# @repo_url = "https://github.com/#@repo"
|
38
|
+
@repo_url = ""
|
39
|
+
@save_to = {scss: 'assets/stylesheets/toolbox_esten'}.merge(save_to)
|
40
|
+
end
|
41
|
+
|
42
|
+
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
|
43
|
+
|
44
|
+
def process_toolbox_esten
|
45
|
+
log_status "Convert toolbox_esten LESS to Sass"
|
46
|
+
puts " repo : #@repo_url"
|
47
|
+
puts " branch : #@branch_sha #@repo_url/tree/#@branch"
|
48
|
+
puts " save to: #{@save_to.to_json}"
|
49
|
+
puts " twbs cache: #{@cache_path}"
|
50
|
+
puts '-' * 60
|
51
|
+
|
52
|
+
@save_to.each { |_, v| FileUtils.mkdir_p(v) }
|
53
|
+
|
54
|
+
process_stylesheet_assets
|
55
|
+
end
|
56
|
+
|
57
|
+
def save_file(path, content, mode='w')
|
58
|
+
dir = File.dirname(path)
|
59
|
+
FileUtils.mkdir_p(dir) unless File.directory?(dir)
|
60
|
+
File.open(path, mode) { |file| file.write(content) }
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# regular string scanner works with bytes
|
2
|
+
# this one works with chars and provides #scan_next
|
3
|
+
class Converter
|
4
|
+
class CharStringScanner
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def initialize(*args)
|
8
|
+
@s = StringScanner.new(*args)
|
9
|
+
end
|
10
|
+
|
11
|
+
def_delegators :@s, :scan_until, :skip_until, :string
|
12
|
+
|
13
|
+
# advance scanner to pos after the next match of pattern and return the match
|
14
|
+
def scan_next(pattern)
|
15
|
+
return unless @s.scan_until(pattern)
|
16
|
+
@s.matched
|
17
|
+
end
|
18
|
+
|
19
|
+
def pos
|
20
|
+
byte_to_str_pos @s.pos
|
21
|
+
end
|
22
|
+
|
23
|
+
def pos=(i)
|
24
|
+
@s.pos = str_to_byte_pos i
|
25
|
+
i
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def byte_to_str_pos(pos)
|
31
|
+
@s.string.byteslice(0, pos).length
|
32
|
+
end
|
33
|
+
|
34
|
+
def str_to_byte_pos(pos)
|
35
|
+
@s.string.slice(0, pos).bytesize
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class Converter
|
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,100 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
class Converter
|
3
|
+
module Network
|
4
|
+
protected
|
5
|
+
|
6
|
+
def get_paths_by_type(dir, file_re, recursive = true)
|
7
|
+
get_file_paths(dir, recursive).select { |path| path =~ file_re }
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_file_paths(dir, recursive = true)
|
11
|
+
get_tree(get_tree_sha(dir), recursive)['tree'].select { |f| f['type'] == 'blob' }.map { |f| f['path'] }
|
12
|
+
end
|
13
|
+
|
14
|
+
def read_files(path, files)
|
15
|
+
# full_path = "https://raw.githubusercontent.com/#@repo/#@branch_sha/#{path}"
|
16
|
+
full_path = ""
|
17
|
+
contents = read_cached_files(path, files)
|
18
|
+
log_http_get_files contents.keys, full_path, true if contents.keys
|
19
|
+
files -= contents.keys
|
20
|
+
log_http_get_files files, full_path, false
|
21
|
+
files.map do |name|
|
22
|
+
Thread.start {
|
23
|
+
contents[name] = open("#{full_path}/#{name}").read
|
24
|
+
Thread.exclusive { write_cached_files path, name => contents[name] }
|
25
|
+
}
|
26
|
+
end.each(&:join)
|
27
|
+
contents
|
28
|
+
end
|
29
|
+
|
30
|
+
def read_cached_files(path, files)
|
31
|
+
full_path = "#@cache_path/#@branch_sha/#{path}"
|
32
|
+
contents = {}
|
33
|
+
if File.directory?(full_path)
|
34
|
+
files.each do |name|
|
35
|
+
path = "#{full_path}/#{name}"
|
36
|
+
contents[name] = File.read(path, mode: 'rb') if File.exists?(path)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
contents
|
40
|
+
end
|
41
|
+
|
42
|
+
def write_cached_files(path, files)
|
43
|
+
full_path = "./#@cache_path/#@branch_sha/#{path}"
|
44
|
+
files.each do |name, content|
|
45
|
+
FileUtils.mkdir_p File.dirname(File.join(full_path, name))
|
46
|
+
File.open("#{full_path}/#{name}", 'wb') { |f| f.write content }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def get_file(url)
|
52
|
+
uri = URI(url)
|
53
|
+
cache_path = "./#@cache_path#{uri.path}#{uri.query.tr('?&=', '-') if uri.query}"
|
54
|
+
FileUtils.mkdir_p File.dirname(cache_path)
|
55
|
+
if File.exists?(cache_path)
|
56
|
+
log_http_get_file url, true
|
57
|
+
File.read(cache_path, mode: 'rb')
|
58
|
+
else
|
59
|
+
log_http_get_file url, false
|
60
|
+
content = open(url).read
|
61
|
+
File.open(cache_path, 'wb') { |f| f.write content }
|
62
|
+
content
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# get sha of the branch (= the latest commit)
|
67
|
+
def get_branch_sha
|
68
|
+
@branch_sha ||= begin
|
69
|
+
if @branch + "\n" == %x[git rev-parse #@branch]
|
70
|
+
@branch
|
71
|
+
else
|
72
|
+
# cmd = "git ls-remote #{Shellwords.escape "https://github.com/#@repo"} #@branch"
|
73
|
+
cmd = ""
|
74
|
+
log cmd
|
75
|
+
result = %x[#{cmd}]
|
76
|
+
raise 'Could not get branch sha!' unless $?.success? && !result.empty?
|
77
|
+
result.split(/\s+/).first
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Get the sha of a dir
|
83
|
+
def get_tree_sha(dir, tree = get_trees)
|
84
|
+
tree['tree'].find { |t| t['path'] == dir }['sha']
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_trees
|
88
|
+
@trees ||= get_tree(@branch_sha)
|
89
|
+
end
|
90
|
+
|
91
|
+
def get_tree(sha, recursive = true)
|
92
|
+
# get_json("https://api.github.com/repos/#@repo/git/trees/#{sha}#{'?recursive=1' if recursive}")
|
93
|
+
get_json("")
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_json(url)
|
97
|
+
JSON.parse get_file(url)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/tasks/install.rake
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Needed for pre-3.1.
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
require "find"
|
5
|
+
|
6
|
+
namespace :toolbox_esten do
|
7
|
+
desc "Move files to the Rails assets directory."
|
8
|
+
task :install, [:sass_path] do |t, args|
|
9
|
+
args.with_defaults(:sass_path => 'public/stylesheets/sass')
|
10
|
+
source_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
11
|
+
FileUtils.mkdir_p("#{Rails.root}/#{args.sass_path}/toolbox_esten")
|
12
|
+
FileUtils.cp_r("#{source_root}/app/assets/stylesheets/.", "#{Rails.root}/#{args.sass_path}/toolbox_esten", { :preserve => true })
|
13
|
+
Find.find("#{Rails.root}/#{args.sass_path}/toolbox_esten") do |path|
|
14
|
+
if path.end_with?(".scss")
|
15
|
+
path_without_css_extension = path.gsub(/\.css\.scss$/, ".scss")
|
16
|
+
FileUtils.mv(path, path_without_css_extension)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|