stylish 0.0.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +3 -7
- data/ROADMAP.md +2 -0
- data/Rakefile +22 -19
- data/bin/stylish +10 -28
- data/lib/assets/javascripts/stylish/index.js +5 -0
- data/lib/assets/javascripts/stylish/test.coffee +1 -0
- data/lib/assets/stylesheets/stylish/index.css +3 -0
- data/lib/stylish.rb +62 -30
- data/lib/stylish/api.rb +10 -0
- data/lib/stylish/api.ru +7 -0
- data/lib/stylish/api/asset_browser.rb +39 -0
- data/lib/stylish/api/server_info.rb +17 -0
- data/lib/stylish/asset.rb +18 -0
- data/lib/stylish/cli.rb +26 -0
- data/lib/stylish/cli/console.rb +10 -0
- data/lib/stylish/cli/generate.rb +69 -0
- data/lib/stylish/cli/import.rb +97 -0
- data/lib/stylish/cli/server.rb +31 -0
- data/lib/stylish/configuration.rb +24 -18
- data/lib/stylish/core_ext.rb +39 -2
- data/lib/stylish/engine.rb +0 -8
- data/lib/stylish/middleman_extension.rb +33 -0
- data/lib/stylish/rails/view_helpers.rb +42 -0
- data/lib/stylish/theme.rb +42 -0
- data/lib/stylish/theme/component.rb +4 -0
- data/lib/stylish/theme/exporter.rb +15 -0
- data/lib/stylish/theme/exporters/middleman.rb +7 -0
- data/lib/stylish/theme/importer.rb +175 -0
- data/lib/stylish/theme/importers/startup_framework.rb +266 -0
- data/lib/stylish/theme/layout.rb +5 -0
- data/lib/stylish/theme/manifest.rb +13 -0
- data/lib/stylish/theme/page.rb +4 -0
- data/lib/stylish/version.rb +1 -1
- data/spec/acceptance/model_creation_spec.rb +1 -5
- data/spec/interface/browsing_assets_spec.rb +21 -0
- data/stylish.gemspec +10 -11
- metadata +68 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c22798835a744816b6894cf715deac2aacead4c1
|
4
|
+
data.tar.gz: a8e82d25940608c53eea1cf81f672f10f7f495da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 636f0e21236f2440eaae6847461adebb5b298ebf29361a5b93439b3ccf8c8bc9cd86bdbfc6b633356321212a510c6802aa625d029216f7ae53815c791a666e6e
|
7
|
+
data.tar.gz: c538902fc3e930d3e26481a6730050e65d5d035882ce6a15f009c6da909331081efe4ac410712787428ee8b50dbbb89df11596424b1c2c9f6c25608ba30f7390
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in stylish.gemspec
|
4
3
|
gemspec
|
5
4
|
|
6
|
-
group :
|
7
|
-
gem '
|
8
|
-
gem 'sass-rails'
|
9
|
-
gem 'spawnling'
|
10
|
-
gem 'faye'
|
11
|
-
gem 'listen'
|
5
|
+
group :development do
|
6
|
+
gem 'smooth', :path => File.join(ENV['HOME'],'Gems','smooth')
|
12
7
|
end
|
8
|
+
|
data/ROADMAP.md
ADDED
data/Rakefile
CHANGED
@@ -1,25 +1,28 @@
|
|
1
|
-
|
1
|
+
Dir[File.join(Dir.pwd, 'tasks', '**', '*.rb')].each { |f| require f }
|
2
|
+
Dir[File.join(Dir.pwd, 'tasks', '*.rake')].each { |f| load f }
|
2
3
|
|
3
4
|
require "bundler/gem_tasks"
|
4
|
-
|
5
|
-
begin
|
6
|
-
require 'bundler/setup'
|
7
|
-
rescue LoadError
|
8
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
9
|
-
end
|
10
|
-
|
11
|
-
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
12
|
-
load 'rails/tasks/engine.rake'
|
13
|
-
|
14
|
-
Bundler::GemHelper.install_tasks
|
15
|
-
|
16
|
-
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
17
|
-
|
18
|
-
require 'rspec/core'
|
19
5
|
require 'rspec/core/rake_task'
|
20
6
|
|
21
|
-
|
22
|
-
|
23
|
-
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
#Distribution.configure do |config|
|
10
|
+
# config.package_name = 'brief'
|
11
|
+
# config.version = Brief::VERSION
|
12
|
+
# config.rb_version = '20150210-2.1.5'
|
13
|
+
# config.packaging_dir = File.expand_path 'packaging'
|
14
|
+
# config.native_extensions = [
|
15
|
+
# 'github-markdown-0.6.8',
|
16
|
+
# 'escape_utils-1.0.1',
|
17
|
+
# #'charlock_holmes-0.7.3',
|
18
|
+
# #'posix-spawn-0.3.9',
|
19
|
+
# #'nokogumbo-1.3.0',
|
20
|
+
# #'rugged-0.21.4',
|
21
|
+
# 'nokogiri-1.6.5',
|
22
|
+
# 'eventmachine-1.0.6',
|
23
|
+
# 'thin-1.6.3',
|
24
|
+
# 'unf_ext-0.0.6'
|
25
|
+
# ]
|
26
|
+
#end
|
24
27
|
|
25
28
|
task :default => :spec
|
data/bin/stylish
CHANGED
@@ -1,33 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
require
|
6
|
-
|
7
|
-
require '
|
8
|
-
require 'faye'
|
9
|
-
require 'spawnling'
|
10
|
-
require 'stylish'
|
11
|
-
|
12
|
-
if ARGV.include?("console")
|
13
|
-
Pry.start
|
14
|
-
else
|
15
|
-
require 'commander/import'
|
16
|
-
|
17
|
-
program :name, "Stylish"
|
18
|
-
program :description, "Stylish Development Server"
|
19
|
-
program :version, "0.0.1"
|
20
|
-
|
21
|
-
command :start do |c|
|
22
|
-
c.syntax = 'stylish start [options]'
|
23
|
-
c.description = 'manually start the watcher process'
|
24
|
-
|
25
|
-
c.option '--library-root PATH', 'Specify the library root path'
|
26
|
-
|
27
|
-
c.action do |args, options|
|
28
|
-
Stylish::Developer::Environment.start(library_root: options.library_root)
|
29
|
-
end
|
30
|
-
end
|
3
|
+
begin
|
4
|
+
require 'bundler'
|
5
|
+
Bundler.require
|
6
|
+
rescue
|
7
|
+
require 'rubygems'
|
31
8
|
end
|
32
9
|
|
10
|
+
require 'stylish'
|
11
|
+
require 'stylish/cli'
|
12
|
+
require 'pry'
|
33
13
|
|
14
|
+
$terminal.wrap_at=160 rescue nil
|
15
|
+
Stylish::Cli.new.run
|
@@ -0,0 +1 @@
|
|
1
|
+
window.Test = "whatup"
|
data/lib/stylish.rb
CHANGED
@@ -1,40 +1,72 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require '
|
8
|
-
|
9
|
-
require "stylish/version"
|
10
|
-
require "stylish/configuration"
|
11
|
-
|
12
|
-
require "stylish/developer"
|
13
|
-
require 'stylish/developer/server'
|
14
|
-
require 'stylish/developer/route'
|
15
|
-
require 'stylish/developer/path'
|
16
|
-
require 'stylish/developer/listing'
|
17
|
-
require 'stylish/developer/modification'
|
18
|
-
require 'stylish/developer/model_delegator'
|
19
|
-
|
20
|
-
require 'stylish/developer/config'
|
21
|
-
require 'stylish/developer/environment'
|
22
|
-
|
23
|
-
require "stylish/manifest"
|
24
|
-
require "stylish/fs"
|
25
|
-
require "stylish/models"
|
26
|
-
require "stylish/util"
|
1
|
+
require 'pathname'
|
2
|
+
require 'hike'
|
3
|
+
require 'hashie'
|
4
|
+
require 'singleton'
|
5
|
+
require 'json'
|
6
|
+
require 'active_support'
|
7
|
+
require 'active_support/core_ext/string'
|
27
8
|
|
28
9
|
module Stylish
|
29
|
-
|
10
|
+
def self.pwd
|
11
|
+
Pathname(ENV.fetch('STYLISH_PWD') { Dir.pwd })
|
12
|
+
end
|
30
13
|
|
31
|
-
def self.
|
32
|
-
Stylish
|
14
|
+
def self.root
|
15
|
+
Pathname(ENV.fetch('STYLISH_ROOT') { Stylish.pwd })
|
33
16
|
end
|
34
17
|
|
35
18
|
def self.config
|
36
19
|
Stylish::Configuration.instance
|
37
20
|
end
|
21
|
+
|
22
|
+
def self.api
|
23
|
+
@api ||= begin
|
24
|
+
require 'sinatra/base'
|
25
|
+
require 'stylish/api'
|
26
|
+
|
27
|
+
Stylish::Api.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.sprockets
|
32
|
+
return @sprockets if @sprockets
|
33
|
+
|
34
|
+
require 'sprockets' unless defined?(::Sprockets)
|
35
|
+
|
36
|
+
env = case
|
37
|
+
when defined?(::Rails)
|
38
|
+
::Rails.application.assets
|
39
|
+
when defined?(::Middleman::Application)
|
40
|
+
middleman_app = ObjectSpace.each_object.detect {|obj| obj.class.to_s.match(/Middleman::Application/) }
|
41
|
+
middleman_app && middleman_app.sprockets
|
42
|
+
else
|
43
|
+
::Sprockets::Environment.new(root)
|
44
|
+
end
|
45
|
+
|
46
|
+
library_path = Stylish.config.public
|
47
|
+
|
48
|
+
env.append_path(library_path) if library_path.exist?
|
49
|
+
|
50
|
+
# append the stylish library paths
|
51
|
+
env.append_path lib_root.join("assets/javascripts")
|
52
|
+
env.append_path lib_root.join("assets/stylesheets")
|
53
|
+
|
54
|
+
@sprockets = env
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.lib_root
|
58
|
+
Pathname(File.dirname(__FILE__))
|
59
|
+
end
|
38
60
|
end
|
39
61
|
|
40
|
-
|
62
|
+
require 'stylish/version'
|
63
|
+
require 'stylish/core_ext'
|
64
|
+
require 'stylish/configuration'
|
65
|
+
require 'stylish/asset'
|
66
|
+
require 'stylish/theme'
|
67
|
+
require 'stylish/engine' if defined?(::Rails)
|
68
|
+
|
69
|
+
if defined?(::Middleman)
|
70
|
+
require 'stylish/middleman_extension'
|
71
|
+
Stylish::MiddlemanExtension.activate_stylish_extension()
|
72
|
+
end
|
data/lib/stylish/api.rb
ADDED
data/lib/stylish/api.ru
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Stylish
|
2
|
+
module AssetBrowser
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
get "/browse/assets" do
|
7
|
+
{
|
8
|
+
path: path,
|
9
|
+
action: "browse/assets",
|
10
|
+
entries: []
|
11
|
+
}.to_json
|
12
|
+
end
|
13
|
+
|
14
|
+
get "/browse/assets/*" do |path|
|
15
|
+
asset = Stylish.sprockets.find_asset(path) rescue nil
|
16
|
+
|
17
|
+
response = if asset
|
18
|
+
{
|
19
|
+
realpath: asset.pathname.expand_path.to_s,
|
20
|
+
content: asset.pathname.read,
|
21
|
+
rendered: asset.to_s,
|
22
|
+
logical_path: asset.logical_path,
|
23
|
+
digest: asset.digest,
|
24
|
+
id: Digest::MD5.hexdigest(asset.pathname.to_s)
|
25
|
+
}
|
26
|
+
else
|
27
|
+
{
|
28
|
+
path: path,
|
29
|
+
action: "browse/assets",
|
30
|
+
entries: []
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
response.to_json
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Stylish
|
2
|
+
module ServerInfo
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
get "/server/info" do
|
7
|
+
{
|
8
|
+
configuration: Stylish.config.public,
|
9
|
+
sprockets: {
|
10
|
+
paths: Stylish.sprockets.paths
|
11
|
+
}
|
12
|
+
}.to_json
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# An Asset is a wrapper around anything sprockets can compile
|
2
|
+
module Stylish
|
3
|
+
class Asset < Hashie::Dash
|
4
|
+
property :logical_path
|
5
|
+
|
6
|
+
def asset
|
7
|
+
Stylish.sprockets.find_asset(logical_path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def contents
|
11
|
+
asset.pathname.read
|
12
|
+
end
|
13
|
+
|
14
|
+
def compiled
|
15
|
+
asset.to_s
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/stylish/cli.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'commander'
|
2
|
+
|
3
|
+
module Stylish
|
4
|
+
class Cli
|
5
|
+
include Commander::Methods
|
6
|
+
|
7
|
+
def run
|
8
|
+
program :name, 'Stylish CLI'
|
9
|
+
program :version, Stylish::VERSION
|
10
|
+
program :description, 'Interface for the Stylish gem'
|
11
|
+
|
12
|
+
$terminal.wrap_at=160 rescue nil
|
13
|
+
|
14
|
+
commands = Dir[Stylish.lib_root.join('stylish','cli','**/*.rb')]
|
15
|
+
|
16
|
+
cli = self
|
17
|
+
|
18
|
+
commands.each do |file|
|
19
|
+
file = Pathname(file)
|
20
|
+
cli.instance_eval(file.read)
|
21
|
+
end
|
22
|
+
|
23
|
+
run!
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
command "combine components" do |c|
|
2
|
+
c.syntax = "stylish combine components THEME_NAME COMPONENT_LIST"
|
3
|
+
c.description = "combine component content"
|
4
|
+
|
5
|
+
c.option '--theme-root PATH', String, 'Path to the theme'
|
6
|
+
c.option '--partial-directory PATH', String, 'Path to the partials directory'
|
7
|
+
c.option '--use-partials', nil, 'Put the components in partials instead of concatenating them'
|
8
|
+
c.option '--extension NAME', String, 'Which extension are the components in?'
|
9
|
+
|
10
|
+
|
11
|
+
c.action do |args, options|
|
12
|
+
theme_name = args.shift
|
13
|
+
component_list = args
|
14
|
+
|
15
|
+
options.default(extension:"html.erb")
|
16
|
+
|
17
|
+
theme_root = Pathname(Dir.pwd).join('vendor',theme_name)
|
18
|
+
theme = Stylish::Theme.new(theme_root)
|
19
|
+
|
20
|
+
component_root = theme.root.join('views','components')
|
21
|
+
requested = component_list.map {|f| component_root.join("#{f}.#{options.extension}") }
|
22
|
+
matched = requested.select(&:exist?)
|
23
|
+
|
24
|
+
if requested.size != matched.size
|
25
|
+
puts "Asked for #{ requested.size } partials, only found #{ matched.size }"
|
26
|
+
else
|
27
|
+
if options.use_partials
|
28
|
+
if options.partial_directory.to_s.length == 0
|
29
|
+
if Pathname(Dir.pwd).join('source/partials').exist?
|
30
|
+
partials_folder = Pathname(Dir.pwd).join("source/partials")
|
31
|
+
elsif Pathname(Dir.pwd).join("app","views","partials").exist?
|
32
|
+
partials_folder = Pathname(Dir.pwd).join("app","views","partials")
|
33
|
+
end
|
34
|
+
|
35
|
+
raise 'You indicated that you would like to use partials, but did not supply a partials directory and we could not guess'
|
36
|
+
else
|
37
|
+
partials_folder = Pathname(options.partial_directory)
|
38
|
+
end
|
39
|
+
|
40
|
+
raise 'Partials folder does not exist' unless partials_folder.exist?
|
41
|
+
|
42
|
+
content_lines = []
|
43
|
+
|
44
|
+
matched.each do |component|
|
45
|
+
partial_folder = partials_folder.join(component.parent.basename.to_s)
|
46
|
+
FileUtils.mkdir_p(partial_folder)
|
47
|
+
|
48
|
+
partial_path = partial_folder.join("_#{component.basename}")
|
49
|
+
|
50
|
+
partial_path.open("w+") do |fh|
|
51
|
+
fh.write(component.read)
|
52
|
+
end
|
53
|
+
|
54
|
+
partial_tag = "partials/#{ partial_folder.basename }/#{ File.basename(partial_path, '.*') }"
|
55
|
+
|
56
|
+
partial_tag.sub!(/\/_/,'/')
|
57
|
+
partial_tag.gsub!(/\.html/,'')
|
58
|
+
|
59
|
+
content_lines << "<%= partial('#{partial_tag}') %>"
|
60
|
+
end
|
61
|
+
else
|
62
|
+
content_lines = matched.map {|path| path.read }
|
63
|
+
end
|
64
|
+
|
65
|
+
puts content_lines.join("\n")
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|