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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ce9345eb8420e741a9234f720105fe1ce83c10c
4
- data.tar.gz: 37ef0f869a327e87b03b6f11d735ea27d2d30da4
3
+ metadata.gz: c22798835a744816b6894cf715deac2aacead4c1
4
+ data.tar.gz: a8e82d25940608c53eea1cf81f672f10f7f495da
5
5
  SHA512:
6
- metadata.gz: 4b7966532e811492008ac7211eb8ed9047007a9616212d9863fd27a384cbd744f022619f27ce3b4e470835791004c7a4e2240b0d6e9a84bd01457637ac6069e1
7
- data.tar.gz: e14948bd5828e140f797b2bd4d741eba19b33cb3d92e90f085b88c7b30b7c83308e963ab3623884f0aca29890b4e4f5be5cf32b2c3bcd0d6a403df3b5f0b6c02
6
+ metadata.gz: 636f0e21236f2440eaae6847461adebb5b298ebf29361a5b93439b3ccf8c8bc9cd86bdbfc6b633356321212a510c6802aa625d029216f7ae53815c791a666e6e
7
+ data.tar.gz: c538902fc3e930d3e26481a6730050e65d5d035882ce6a15f009c6da909331081efe4ac410712787428ee8b50dbbb89df11596424b1c2c9f6c25608ba30f7390
data/.gitignore CHANGED
@@ -12,3 +12,4 @@ spec/dummy/tmp
12
12
  bower_components/
13
13
  node_modules/
14
14
  front-end/
15
+ vendor/themes
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 :test, :development do
7
- gem 'coffee-rails'
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
+
@@ -0,0 +1,2 @@
1
+ - Theme Importer
2
+ - annotate elements which need to be replaced with asset_path helpers
data/Rakefile CHANGED
@@ -1,25 +1,28 @@
1
- #!/usr/bin/env rake
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
- desc "Run all specs in spec directory (excluding plugin specs)"
22
-
23
- RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
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
@@ -1,33 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift File.join(File.dirname(__FILE__),'..','lib')
4
-
5
- require 'rubygems'
6
- require 'pry'
7
- require 'listen'
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,5 @@
1
+ //= require_self
2
+ //= require ./test
3
+ (function(){
4
+ window.Stylish = window.Stylish || {};
5
+ })()
@@ -0,0 +1 @@
1
+ window.Test = "whatup"
@@ -0,0 +1,3 @@
1
+ .stylish {
2
+ color: pink;
3
+ }
@@ -1,40 +1,72 @@
1
- require "hashie"
2
- require "singleton"
3
- require "set"
4
- require "active_support/core_ext"
5
- require "stylish/core_ext"
6
- require "github-fs"
7
- require 'rack'
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
- require 'stylish/engine' if defined?(::Rails)
10
+ def self.pwd
11
+ Pathname(ENV.fetch('STYLISH_PWD') { Dir.pwd })
12
+ end
30
13
 
31
- def self.util
32
- Stylish::Util
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
- Stylish::Models.load_all()
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
@@ -0,0 +1,10 @@
1
+ require 'stylish/api/asset_browser'
2
+ require 'stylish/api/server_info'
3
+
4
+ module Stylish
5
+ class Api < Sinatra::Base
6
+ include Stylish::ServerInfo
7
+ include Stylish::AssetBrowser
8
+ end
9
+ end
10
+
@@ -0,0 +1,7 @@
1
+ map '/assets' do
2
+ run Stylish.sprockets
3
+ end
4
+
5
+ map "/" do
6
+ run Stylish.api
7
+ end
@@ -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
@@ -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,10 @@
1
+ command "console" do |c|
2
+ c.syntax = "stylish console [OPTIONS]"
3
+ c.description = "start a console session in the context of this stylish environment"
4
+
5
+ c.action do |args, options|
6
+ require 'pry'
7
+ Pry.start
8
+ end
9
+ end
10
+
@@ -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