spark_engine 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.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/CODE_OF_CONDUCT.md +49 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +34 -0
  7. data/Rakefile +2 -0
  8. data/bin/spark +99 -0
  9. data/lib/spark_engine/assets.rb +8 -0
  10. data/lib/spark_engine/command/help.rb +86 -0
  11. data/lib/spark_engine/command/npm.rb +62 -0
  12. data/lib/spark_engine/command.rb +156 -0
  13. data/lib/spark_engine/config_data.rb +29 -0
  14. data/lib/spark_engine/helpers/asset_helpers.rb +66 -0
  15. data/lib/spark_engine/helpers/layout_helpers.rb +21 -0
  16. data/lib/spark_engine/middleware.rb +72 -0
  17. data/lib/spark_engine/plugin/assets/asset.rb +163 -0
  18. data/lib/spark_engine/plugin/assets/javascripts.rb +83 -0
  19. data/lib/spark_engine/plugin/assets/stylesheets.rb +88 -0
  20. data/lib/spark_engine/plugin/assets/svgs.rb +79 -0
  21. data/lib/spark_engine/plugin.rb +191 -0
  22. data/lib/spark_engine/sass/engine.rb +21 -0
  23. data/lib/spark_engine/sass/importer.rb +103 -0
  24. data/lib/spark_engine/scaffold/gem/.gitignore +18 -0
  25. data/lib/spark_engine/scaffold/gem/app/assets/images/namespace/.keep +0 -0
  26. data/lib/spark_engine/scaffold/gem/app/assets/javascripts/namespace/engine.js +3 -0
  27. data/lib/spark_engine/scaffold/gem/app/assets/stylesheets/namespace/_index.scss +1 -0
  28. data/lib/spark_engine/scaffold/gem/app/assets/svgs/namespace/.keep +0 -0
  29. data/lib/spark_engine/scaffold/gem/app/helpers/namespace/application_helper.rb +4 -0
  30. data/lib/spark_engine/scaffold/gem/app/views/layouts/namespace/default.html.erb +18 -0
  31. data/lib/spark_engine/scaffold/gem/gem.gemspec +24 -0
  32. data/lib/spark_engine/scaffold/gem/lib/gem.rb +12 -0
  33. data/lib/spark_engine/scaffold/gem/site/app/assets/javascripts/application.js +1 -0
  34. data/lib/spark_engine/scaffold/gem/site/app/assets/stylesheets/application.scss +2 -0
  35. data/lib/spark_engine/scaffold/gem/site/app/controllers/docs_controller.rb +19 -0
  36. data/lib/spark_engine/scaffold/gem/site/app/views/docs/index.html.erb +1 -0
  37. data/lib/spark_engine/scaffold/gem/site/app/views/layouts/application.html.erb +4 -0
  38. data/lib/spark_engine/scaffold/gem/site/config/application.rb +18 -0
  39. data/lib/spark_engine/scaffold/gem/site/config/environments/development.rb +13 -0
  40. data/lib/spark_engine/scaffold/gem/site/config/routes.rb +3 -0
  41. data/lib/spark_engine/scaffold.rb +191 -0
  42. data/lib/spark_engine/version.rb +3 -0
  43. data/lib/spark_engine.rb +106 -0
  44. data/spark_engine.gemspec +31 -0
  45. metadata +234 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e14e3ea9f6106b145bd3c3a68525a2bf4bc20682aecf4c23844ecf6b2d2db7a1
4
+ data.tar.gz: c10f52044b61ee93dafb647fdd80ed18291fbe3d7f5d5110b662fde42d7bab52
5
+ SHA512:
6
+ metadata.gz: 4d35cd50784a6fca125005939335ee5359f3adb6929db9cb63cb61248fb90be2d526b9b4334348aef63086627cd1ec931d35fbafef0ee4e955313e048c85e323
7
+ data.tar.gz: 2821d2dc7ce2d36d9f354768243e195e62b9f1f7e55dc26806dd3e472a604d67bdeef2d1631163cb61dc4c8522efe3c1fb32f3fb14689aa14ff95c61f4b2f79e
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /test/
11
+ .DS_Store
12
+ node_modules
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at brandon@imathis.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in megatron.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Brandon Mathis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Spark
2
+
3
+ A design systems framework for Rails.
4
+
5
+
6
+ ## Installation
7
+
8
+ First install the gem.
9
+
10
+ ```sh
11
+ gem install spark_engine
12
+ ```
13
+
14
+ Generate a new engine with Spark.
15
+
16
+ ```sh
17
+ spark new your_plugin
18
+ ```
19
+
20
+ This will create a new gem and generate the scaffolding for a Spark Rails Engine.
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/imathis/spark. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
29
+
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
34
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/spark ADDED
@@ -0,0 +1,99 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
4
+
5
+ require 'optparse'
6
+ require 'spark_engine'
7
+ require 'spark_engine/command'
8
+ require "spark_engine/command/help"
9
+
10
+ options = {
11
+ path: '.'
12
+ }
13
+
14
+ def next_arg
15
+ if ARGV.first && !ARGV.first.match(/^-/)
16
+ ARGV.shift
17
+ end
18
+ end
19
+
20
+ OptionParser.new do |opts|
21
+
22
+ options[:help] = ARGV.shift if %w(help h).include?(ARGV.first)
23
+
24
+ if ARGV.empty?
25
+ options[:help] = true
26
+ else
27
+ options[:command] = next_arg
28
+ end
29
+
30
+ opts.banner = SparkEngine::Help.banner(options[:command])
31
+
32
+ if %w(n new).include? options[:command]
33
+ options[:name] = next_arg
34
+
35
+ opts.on("-e", "--engine ENGINE_NAME", String, "Name the engine (defaults to gem name)") do |engine|
36
+ options[:engine] = engine
37
+ end
38
+
39
+ opts.on("-f", "--force", "overwrite existing files") do |val|
40
+ options[:force] = true
41
+ end
42
+ end
43
+
44
+ if %w(s server).include? options[:command]
45
+ opts.on("-w", "--watch", "Watch assets") do |val|
46
+ options[:watch] = true
47
+ end
48
+ end
49
+
50
+ if %w(b w s build watch server).include? options[:command]
51
+ opts.on("-j", "--js", "Build javascripts.") do |val|
52
+ options[:select_assets] = true
53
+ options[:js] = true
54
+ end
55
+
56
+ opts.on("-c", "--css", "Build css.") do |val|
57
+ options[:select_assets] = true
58
+ options[:css] = true
59
+ end
60
+
61
+ opts.on("-s", "--svg", "Build svgs.") do |val|
62
+ options[:select_assets] = true
63
+ options[:svg] = true
64
+ end
65
+
66
+ opts.on("-P", "--production", "Build assets as with production mode.") do |val|
67
+ ENV['RAILS_ENV'] = 'production'
68
+ options[:production] = true
69
+ end
70
+
71
+ opts.on("-C", "--clean", "Remove cache files before build.") do |val|
72
+ options[:clean] = true
73
+ end
74
+ end
75
+
76
+ if %w(s server).include? options[:command]
77
+ opts.on("-p", "--port PORT", String, "serve site at port") do |val|
78
+ options[:port] = val
79
+ end
80
+
81
+ opts.on("-b", "--bind HOST", String, "Bind to a specific host, e.g. 0.0.0.0") do |val|
82
+ options[:host] = val
83
+ end
84
+ end
85
+
86
+ opts.on("-v", "--version", "Print version") do |version|
87
+ options[:command] = 'version'
88
+ end
89
+
90
+ opts.on("-h", "--help", "Print this message") do |version|
91
+ options[:help] = opts
92
+ end
93
+
94
+ if options[:help]
95
+ options[:help] = opts
96
+ end
97
+ end.parse!
98
+
99
+ SparkEngine::Command.run(options)
@@ -0,0 +1,8 @@
1
+ module SparkEngine
2
+ module Assets
3
+ autoload :AssetType, 'spark_engine/plugin/assets/asset'
4
+ autoload :Stylesheets, 'spark_engine/plugin/assets/stylesheets'
5
+ autoload :Javascripts, 'spark_engine/plugin/assets/javascripts'
6
+ autoload :Svgs, 'spark_engine/plugin/assets/svgs'
7
+ end
8
+ end
@@ -0,0 +1,86 @@
1
+ module SparkEngine
2
+ module Help
3
+ extend self
4
+
5
+ def banner(command=nil)
6
+ if command.nil?
7
+ <<-HERE
8
+ General Commands (run from anywhere):
9
+ #{spark_commands.map{|c| commands(c) }.join("\n ")}
10
+
11
+ Engine Commands (run these from your project's directory)
12
+ #{engine_commands.map{|c| commands(c) }.join("\n ")}
13
+
14
+ For help with a specific command, run `spark help command`
15
+
16
+ Options:
17
+ HERE
18
+ elsif commands(command)
19
+ "\nUsage:\n spark #{commands(command)}\n\nOptions:\n"
20
+ end
21
+ end
22
+
23
+ def engine_commands
24
+ %w(help build watch server help gem:build gem:install gem:release)
25
+ end
26
+
27
+ def spark_commands
28
+ %w(new help)
29
+ end
30
+
31
+ def commands(command)
32
+ case command
33
+ when 'new', 'n'; new
34
+ when 'help', 'h'; help
35
+ when 'build', 'b'; build
36
+ when 'watch', 'w'; watch
37
+ when 'server', 's'; server
38
+ when 'clean', 'c'; clean
39
+ when 'help', 'h'; help
40
+ when 'gem:build'; gem_build
41
+ when 'gem:install'; gem_install
42
+ when 'gem:release'; gem_release
43
+ end
44
+ end
45
+
46
+ def new
47
+ "new name [options] # Create a new Spark framework engine"
48
+ end
49
+
50
+ def help
51
+ "help [command] # Show help for a specific command"
52
+ end
53
+
54
+ def build
55
+ "build [options] # Build assets"
56
+ end
57
+
58
+ def watch
59
+ "watch [options] # Build assets when files change"
60
+ end
61
+
62
+ def server
63
+ "server [options] # Serve documentation site"
64
+ end
65
+
66
+ def clean
67
+ "clean # Remove cache files"
68
+ end
69
+
70
+ def help
71
+ "help [command] # Show help for a specific command"
72
+ end
73
+
74
+ def gem_build
75
+ "gem:build # Build assets for production and build gem"
76
+ end
77
+
78
+ def gem_install
79
+ "gem:install # Build assets for production, build, and install gem"
80
+ end
81
+
82
+ def gem_release
83
+ "gem:release # Build assets for production, build, and release gem to rubygems.org"
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,62 @@
1
+ module SparkEngine
2
+ module NPM
3
+ extend self
4
+
5
+ require "yaml"
6
+
7
+ DEPENDENCIES = YAML.load %Q{
8
+ private: true
9
+ devDependencies:
10
+ browserify: ^16.2.1
11
+ browserify-incremental: ^3.1.1
12
+ svgo: ^1.0.5
13
+ }
14
+
15
+ def setup
16
+ puts "\nAdding npm dependencies…".bold
17
+
18
+ if File.exist?(package_path)
19
+ update_package_json
20
+ else
21
+ write_package_json(DEPENDENCIES)
22
+ end
23
+ end
24
+
25
+ def package_path
26
+ File.join(Dir.pwd, 'package.json')
27
+ end
28
+
29
+ def write_package_json(contents)
30
+ File.open(package_path, 'w') do |io|
31
+ io.write(JSON.pretty_generate(contents))
32
+ end
33
+
34
+ puts "create".rjust(12).colorize(:green).bold + " #{package_path}"
35
+ end
36
+
37
+ def read_package_json
38
+ JSON.parse File.read(package_path)
39
+ end
40
+
41
+ def update_package_json
42
+ package = read_package_json
43
+ package['dependencies'] ||= {}
44
+ package['devDependencies'] ||= {}
45
+
46
+ deps = DEPENDENCIES['devDependencies']
47
+
48
+ deps.keys.each do |dep|
49
+ d = deps[dep]
50
+
51
+ if package['devDependencies'][dep].nil? && package['dependencies'][dep].nil?
52
+ package['devDependencies'][dep] = d
53
+ end
54
+ end
55
+
56
+ package.delete('dependencies') if package['dependencies'].empty?
57
+
58
+ write_package_json(package)
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,156 @@
1
+ module SparkEngine
2
+ module Command
3
+ extend self
4
+
5
+ def run(options)
6
+ @production = options[:production]
7
+
8
+ if options[:help]
9
+ version
10
+ puts options[:help]
11
+ return
12
+ end
13
+
14
+ case options[:command]
15
+ when 'new', 'n'
16
+ require "spark_engine/scaffold"
17
+ Scaffold.new(options)
18
+ when 'build', 'b'
19
+ from_root { dispatch(:build, options) }
20
+ when 'watch', 'w'
21
+ from_root { dispatch(:watch, options) }
22
+ when 'server', 's'
23
+ from_root { dispatch(:server, options) }
24
+ when 'clean', 'c'
25
+ from_root { clean }
26
+ when 'version'
27
+ version
28
+ when 'gem:build'
29
+ from_root { gem_build }
30
+ when 'gem:install'
31
+ from_root { gem_install }
32
+ when 'gem:release'
33
+ from_root { gem_release }
34
+ when 'gem:tag'
35
+ from_root { gem_tag }
36
+ else
37
+ puts "Command `#{options[:command]}` not recognized"
38
+ end
39
+ end
40
+
41
+ def version
42
+ spec = SparkEngine.plugin_spec
43
+ puts "spark_engine v #{SparkEngine::VERSION}"
44
+ puts " - #{spec.name} v #{spec.version}\n" if spec
45
+ puts ""
46
+ end
47
+
48
+ def production?
49
+ @production == true
50
+ end
51
+
52
+ def gem_build
53
+ @production = true
54
+ FileUtils.rm_rf('public')
55
+ dispatch(:build)
56
+ system "bundle exec rake build"
57
+ end
58
+
59
+ def gem_install
60
+ @production = true
61
+ FileUtils.rm_rf('public')
62
+ dispatch(:build)
63
+ system "bundle exec rake install"
64
+ end
65
+
66
+ def gem_release
67
+ @production = true
68
+ gem_build
69
+ spec = SparkEngine.plugin_spec
70
+ gem_file = "./pkg/#{spec.gem}-#{spec.version}.gem"
71
+
72
+ if File.exists?(gem_file)
73
+ system "git commit -m v#{spec.version}"
74
+ system "git tag v#{spec.version}"
75
+ system "git push origin $(git rev-parse --abbrev-ref HEAD) --tag"
76
+
77
+ if key = ENV['RUBYGEMS_API_KEY']
78
+ gem = "#{spec.name}-#{spec.version}.gem"
79
+ system "bundle exec rake build"
80
+ system "curl --data-binary @./pkg/#{gem} -H 'Authorization:#{key}' https://rubygems.org/api/v1/gems"
81
+ else
82
+ system "gem push #{gem_file}"
83
+ system "rm ./public/*.gz"
84
+ end
85
+ end
86
+ end
87
+
88
+ def gem_tag
89
+ system "git tag v#{SparkEngine.plugin_spec.version}"
90
+ end
91
+
92
+ def require_rails
93
+ require File.join(Dir.pwd, SparkEngine.rails_path('config/application'))
94
+ end
95
+
96
+ def clean
97
+ FileUtils.rm_rf('public')
98
+ FileUtils.rm_rf(SparkEngine.rails_path('tmp/cache/'))
99
+ FileUtils.rm_rf('.sass-cache')
100
+ FileUtils.rm_rf(SparkEngine.rails_path('.sass-cache'))
101
+ end
102
+
103
+ # Handles running threaded commands
104
+ #
105
+ def dispatch(command, *args)
106
+ @threads = []
107
+ send command, *args
108
+ @threads.each { |thr| thr.join }
109
+ end
110
+
111
+ # Build assets
112
+ def build(options={})
113
+ puts SparkEngine.production? ? 'Building for production…' : 'Building…'
114
+ require_rails
115
+ clean if SparkEngine.production?
116
+ SparkEngine.plugin.build(options)
117
+ end
118
+
119
+ # Watch assets for changes and build
120
+ def watch(options={})
121
+ build(options)
122
+ require 'listen'
123
+
124
+ trap("SIGINT") {
125
+ puts "\nspark_engine watcher stopped. Have a nice day!"
126
+ exit!
127
+ }
128
+
129
+ @threads.concat SparkEngine.load_plugin.watch(options)
130
+ end
131
+
132
+ # Run rails server and watch assets
133
+ def server(options={})
134
+ options[:port] ||= 3000
135
+ @threads << Thread.new { system "#{SparkEngine.rails_path('bin/rails')} server -p #{options[:port]}" }
136
+ watch(options) if options[:watch]
137
+ end
138
+
139
+ def from_root(command=nil, &blk)
140
+ unless SparkEngine.gem_path
141
+ abort "Command must be run from the root of an engine (adjacent to the gemspec)."
142
+ end
143
+
144
+ Dir.chdir(SparkEngine.gem_path) do
145
+ if command
146
+ system command
147
+ else
148
+ blk.call
149
+ end
150
+ end
151
+ end
152
+
153
+ end
154
+ end
155
+
156
+
@@ -0,0 +1,29 @@
1
+ module SparkEngine
2
+ module ConfigData
3
+ extend self
4
+ def read(*roots)
5
+ @data ||= {}
6
+
7
+ data_files(*roots).each do |path|
8
+ name = File.basename(path, '.*')
9
+ case File.extname(path)
10
+ when '.json'
11
+ @data[name] = JSON.parse(File.read(path))
12
+ when '.yml'
13
+ @data[name] = YAML.load_file(path)
14
+ end
15
+ end
16
+
17
+ @data
18
+ end
19
+
20
+ def data_files(*roots)
21
+ files = []
22
+ [roots].flatten.each do |root|
23
+ files.concat Dir[File.join(root, 'config/data/**/*.json')]
24
+ files.concat Dir[File.join(root, 'config/data/**/*.yml')]
25
+ end
26
+ files.flatten.compact.uniq
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,66 @@
1
+ module SparkEngine
2
+ module Helpers
3
+ module AssetsHelper
4
+
5
+ def spark_asset_url(file)
6
+ SparkEngine.plugin.asset_url(file)
7
+ end
8
+
9
+ def stylesheet_tag(*args)
10
+ options = args.last.is_a?(Hash) ? args.pop : {}
11
+ tags = ''
12
+
13
+ stylesheet_url(args).each do |url|
14
+ tags += stylesheet_link_tag url, options
15
+ end
16
+
17
+ tags.html_safe
18
+ end
19
+
20
+ def javascript_tag(*args)
21
+ options = args.last.is_a?(Hash) ? args.pop : {}
22
+ tags = ''
23
+
24
+ javascript_url(args).each do |url|
25
+ tags += javascript_include_tag url, options
26
+ end
27
+
28
+ tags.html_safe
29
+ end
30
+
31
+ def stylesheet_url(*args)
32
+ SparkEngine.plugin.stylesheets.urls(args)
33
+ end
34
+
35
+ def javascript_url(*args)
36
+ SparkEngine.plugin.javascripts.urls(args)
37
+ end
38
+
39
+ def asset_tags
40
+ stylesheet_tag + javascript_tag
41
+ end
42
+
43
+ def pin_tab_icon_tag(path, color="black")
44
+ %Q{<link rel="mask-icon" mask href="#{spark_asset_url(path)}" color="#{color}">}.html_safe
45
+ end
46
+
47
+ def favicon_tag(*args)
48
+ options = args.last.is_a?(Hash) ? args.pop : {}
49
+ source = args.first || 'favicon.ico'
50
+ tag('link', {
51
+ :rel => 'shortcut icon',
52
+ :type => 'image/x-icon',
53
+ :href => spark_asset_url(source)
54
+ }.merge!(options.symbolize_keys))
55
+ end
56
+
57
+ def sass_data(key=nil)
58
+ if key
59
+ SparkEngine.plugin.stylesheets.data[key]
60
+ else
61
+ SparkEngine.plugin.stylesheets.data
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,21 @@
1
+ module SparkEngine
2
+ module Helpers
3
+ module LayoutHelper
4
+ def render_layout(*args, &block)
5
+ options = args.last.is_a?(Hash) ? args.pop : {}
6
+ layout = args.first || 'default'
7
+ options[:template] = "layouts/#{layout}"
8
+ yield if block_given?
9
+ render options
10
+ end
11
+
12
+ def javascripts(&block)
13
+ content_for :javascripts, &block
14
+ end
15
+
16
+ def stylesheets(&block)
17
+ content_for :stylesheets, &block
18
+ end
19
+ end
20
+ end
21
+ end