breakfast 0.2.1 → 0.3.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 +4 -4
- data/CHANGELOG.md +42 -0
- data/README.md +38 -0
- data/breakfast.gemspec +2 -2
- data/lib/breakfast.rb +2 -0
- data/lib/breakfast/brunch_watcher.rb +1 -3
- data/lib/breakfast/capistrano/tasks/breakfast.rake +2 -1
- data/lib/breakfast/compilation_listener.rb +40 -11
- data/lib/breakfast/railtie.rb +3 -2
- data/lib/breakfast/version.rb +1 -1
- data/lib/breakfast/view_helper.rb +3 -2
- data/lib/generators/breakfast/install_generator.rb +10 -4
- data/lib/generators/breakfast/templates/package.json +1 -1
- data/node_package/package.json +1 -1
- data/node_package/src/breakfast-rails.js +5 -4
- data/node_package/src/live-reload.js +40 -8
- data/node_package/src/settings.js +48 -0
- data/node_package/src/status-bar.js +218 -40
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b12b97396b07486556ec5d2332c17d328794d430
|
4
|
+
data.tar.gz: 61fd4a2a085594668a2e4e7922c15271ad612f20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1567fbd110b9e21807a61302acf9fdd2f8a49b4de5063ee1c1ffab0a2df4f907727102873afee5542f0ede6dc983a5a48675fa9bc517042606cc3556c761f9e1
|
7
|
+
data.tar.gz: 15c45fba85e50e330f733fc4a0165d2653cc8694cd0ca4d148b43fd1d7248962f87ac0e8c00ab7a4847b497d12a9c1d9a1adeae638a8b29e60db544462f50f0d
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# CHANGE LOG
|
2
|
+
|
3
|
+
## 0.3.0 - 2016-09-28
|
4
|
+
|
5
|
+
### Upgrading from `0.2.0`
|
6
|
+
- Update gem with `bundle update breakfast`
|
7
|
+
- Bump the `breakfast-rails` version in `package.json` to `0.3.1`
|
8
|
+
- Run `npm install`
|
9
|
+
- If you have modified the `config.breakfast.view_folders` option you will need
|
10
|
+
to replace it. The new option is `config.breakfast.source_code_folders` and it
|
11
|
+
defaults to `[Rails.root.join("app")]`. If you have view or Ruby files that
|
12
|
+
you would like to trigger reloads outside of the `app` folder then append
|
13
|
+
those paths by adding:
|
14
|
+
|
15
|
+
```
|
16
|
+
config.breakfast.source_code_folders << Rails.root.join("lib")
|
17
|
+
```
|
18
|
+
|
19
|
+
To which ever environment you want `Breakfast` to run in
|
20
|
+
(probably `config/environments/development.rb`).
|
21
|
+
|
22
|
+
### Added
|
23
|
+
- New status bar that allows the user to switch reload strategies on the fly
|
24
|
+
- Support for Haml & Slim files (without .html extension)
|
25
|
+
- Reloading on ruby file changes.
|
26
|
+
- Specify minimum Node & NPM versions when installing (avoid awkward and none
|
27
|
+
descriptive error messages)
|
28
|
+
- NPM binary path for Capistrano
|
29
|
+
|
30
|
+
### Changes
|
31
|
+
- config.breakfast.view_folders change to config.breakfast.source_code_folders.
|
32
|
+
Change brought about by need to trigger reloads when Ruby source code changes.
|
33
|
+
|
34
|
+
### Removed
|
35
|
+
- config.breakfast.view_folders is no longer supported. Deprecated in favor of
|
36
|
+
source_code_folders option.
|
37
|
+
|
38
|
+
#### Contributors
|
39
|
+
Many many thanks to the contributors for this release!
|
40
|
+
|
41
|
+
- [@patkoperwas](https://github.com/patkoperwas)
|
42
|
+
- [@josh-rosen](https://github.com/Josh-Rosen)
|
data/README.md
CHANGED
@@ -13,6 +13,44 @@ support. Be up and running on the latest frontend framework in minutes.
|
|
13
13
|
See the official docs at
|
14
14
|
[http://breakfast.devlocker.io](http://breakfast.devlocker.io).
|
15
15
|
|
16
|
+
View updates in the [CHANGELOG](https://github.com/devlocker/breakfast/blob/master/CHANGELOG.md)
|
17
|
+
|
18
|
+
### Latest Release `0.3.0`
|
19
|
+
#### Added
|
20
|
+
- New status bar that allows the user to switch reload strategies on the fly
|
21
|
+
- Support for Haml & Slim files (without .html extension)
|
22
|
+
- Reloading on ruby file changes.
|
23
|
+
- Specify minimum Node & NPM versions when installing (avoid awkward and none
|
24
|
+
descriptive error messages)
|
25
|
+
- NPM binary path for Capistrano
|
26
|
+
|
27
|
+
#### Changes
|
28
|
+
- config.breakfast.view_folders change to config.breakfast.source_code_folders.
|
29
|
+
Change brought about by need to trigger reloads when Ruby source code changes.
|
30
|
+
|
31
|
+
#### Removed
|
32
|
+
- config.breakfast.view_folders is no longer supported. Deprecated in favor of
|
33
|
+
source_code_folders option.
|
34
|
+
|
35
|
+
|
36
|
+
### Upgrading
|
37
|
+
#### Upgrading to `0.3.0` from `0.2.0`
|
38
|
+
- Update gem with `bundle update breakfast`
|
39
|
+
- Bump the `breakfast-rails` version in `package.json` to `0.3.1`
|
40
|
+
- Run `npm install`
|
41
|
+
- If you have modified the `config.breakfast.view_folders` option you will need
|
42
|
+
to replace it. The new option is `config.breakfast.source_code_folders` and it
|
43
|
+
defaults to `[Rails.root.join("app")]`. If you have view or Ruby files that
|
44
|
+
you would like to trigger reloads outside of the `app` folder then append
|
45
|
+
those paths by adding:
|
46
|
+
|
47
|
+
```
|
48
|
+
config.breakfast.source_code_folders << Rails.root.join("lib")
|
49
|
+
```
|
50
|
+
|
51
|
+
To which ever environment you want `Breakfast` to run in
|
52
|
+
(probably `config/environments/development.rb`).
|
53
|
+
|
16
54
|
|
17
55
|
### Contributing
|
18
56
|
Bug reports and pull requests are welcome on GitHub at
|
data/breakfast.gemspec
CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
25
|
spec.add_dependency "rails", "~> 5.0"
|
26
|
-
spec.add_dependency "actioncable"
|
27
|
-
spec.add_dependency "listen"
|
26
|
+
spec.add_dependency "actioncable", "~> 5.0"
|
27
|
+
spec.add_dependency "listen", "~> 3.1"
|
28
28
|
end
|
data/lib/breakfast.rb
CHANGED
@@ -2,7 +2,6 @@ require "pty"
|
|
2
2
|
|
3
3
|
module Breakfast
|
4
4
|
class BrunchWatcher
|
5
|
-
CHANNEL = "breakfast_status".freeze
|
6
5
|
BRUNCH_COMMAND = "./node_modules/brunch/bin/brunch watch".freeze
|
7
6
|
|
8
7
|
def self.spawn(log:)
|
@@ -26,7 +25,6 @@ module Breakfast
|
|
26
25
|
log.debug output
|
27
26
|
|
28
27
|
output = output.gsub(/\e\[([;\d]+)?m/, '')
|
29
|
-
|
30
28
|
case output
|
31
29
|
when /compiled/
|
32
30
|
broadcast(status: "success", message: output.split("info: ").last)
|
@@ -46,7 +44,7 @@ module Breakfast
|
|
46
44
|
private
|
47
45
|
|
48
46
|
def broadcast(status:, message:)
|
49
|
-
ActionCable.server.broadcast(
|
47
|
+
ActionCable.server.broadcast(STATUS_CHANNEL, {
|
50
48
|
status: status,
|
51
49
|
message: message
|
52
50
|
})
|
@@ -3,7 +3,7 @@ namespace :breakfast do
|
|
3
3
|
task :compile do
|
4
4
|
on roles fetch(:breakfast_roles) do |host|
|
5
5
|
within release_path do
|
6
|
-
execute :
|
6
|
+
execute fetch(:breakfast_npm_path).to_sym, "install"
|
7
7
|
execute "node_modules/brunch/bin/brunch", "build --production"
|
8
8
|
end
|
9
9
|
end
|
@@ -16,5 +16,6 @@ end
|
|
16
16
|
namespace :load do
|
17
17
|
task :defaults do
|
18
18
|
set :breakfast_roles, -> { :web }
|
19
|
+
set :breakfast_npm_path, "/usr/bin/npm"
|
19
20
|
end
|
20
21
|
end
|
@@ -1,22 +1,51 @@
|
|
1
1
|
module Breakfast
|
2
2
|
class CompilationListener
|
3
|
-
|
4
|
-
|
3
|
+
ASSET_EXTENSIONS = ["css", "js"].freeze
|
4
|
+
SOURCE_CODE_EXTENSIONS = ["rb", "html", "haml", "slim"].freeze
|
5
5
|
|
6
|
-
def self.start(asset_output_folders:,
|
7
|
-
|
6
|
+
def self.start(asset_output_folders:, source_code_folders:)
|
7
|
+
asset_listener =
|
8
|
+
::Listen.to(*asset_output_folders) do |modified, added, removed|
|
9
|
+
files = modified + added + removed
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
+
ASSET_EXTENSIONS.each do |extension|
|
12
|
+
if files.any? { |file| file.match(/\.#{extension}/) }
|
13
|
+
ActionCable.server.broadcast(
|
14
|
+
Breakfast::RELOAD_CHANNEL,
|
15
|
+
{ extension: extension }
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
rails_listener =
|
22
|
+
::Listen.to(*source_code_folders) do |modified, added, removed|
|
23
|
+
files = modified + added + removed
|
24
|
+
|
25
|
+
SOURCE_CODE_EXTENSIONS.each do |extension|
|
26
|
+
matched = files.select { |file| file.match(/\.#{extension}/) }
|
27
|
+
if matched.present?
|
28
|
+
ActionCable.server.broadcast(
|
29
|
+
Breakfast::RELOAD_CHANNEL,
|
30
|
+
{ extension: extension }
|
31
|
+
)
|
32
|
+
|
33
|
+
file_names = matched
|
34
|
+
.map { |file| file.split("/").last }
|
35
|
+
.join(", ")
|
36
|
+
.truncate(60)
|
11
37
|
|
12
|
-
|
13
|
-
|
14
|
-
|
38
|
+
ActionCable.server.broadcast(Breakfast::STATUS_CHANNEL, {
|
39
|
+
status: "success",
|
40
|
+
message: "saved: #{file_names}",
|
41
|
+
extension: extension
|
42
|
+
})
|
43
|
+
end
|
15
44
|
end
|
16
45
|
end
|
17
|
-
end
|
18
46
|
|
19
|
-
|
47
|
+
asset_listener.start
|
48
|
+
rails_listener.start
|
20
49
|
end
|
21
50
|
end
|
22
51
|
end
|
data/lib/breakfast/railtie.rb
CHANGED
@@ -9,9 +9,10 @@ module BrunchRails
|
|
9
9
|
config.breakfast.html_reload_strategy = :turbolinks
|
10
10
|
config.breakfast.js_reload_strategy = :page
|
11
11
|
config.breakfast.css_reload_strategy = :hot
|
12
|
+
config.breakfast.ruby_reload_strategy = :off
|
12
13
|
|
13
14
|
config.breakfast.asset_output_folders = [Rails.root.join("public")]
|
14
|
-
config.breakfast.
|
15
|
+
config.breakfast.source_code_folders = [Rails.root.join("app")]
|
15
16
|
config.breakfast.environments = %w(development)
|
16
17
|
config.breakfast.status_bar_location = :bottom
|
17
18
|
end
|
@@ -30,7 +31,7 @@ module BrunchRails
|
|
30
31
|
|
31
32
|
Breakfast::CompilationListener.start(
|
32
33
|
asset_output_folders: config.breakfast.asset_output_folders,
|
33
|
-
|
34
|
+
source_code_folders: config.breakfast.source_code_folders
|
34
35
|
)
|
35
36
|
end
|
36
37
|
end
|
data/lib/breakfast/version.rb
CHANGED
@@ -7,10 +7,11 @@ module Breakfast
|
|
7
7
|
require("breakfast-rails").init({
|
8
8
|
host: "#{request.host}",
|
9
9
|
port: #{request.port},
|
10
|
-
|
10
|
+
strategies: {
|
11
11
|
js: "#{Rails.configuration.breakfast.js_reload_strategy}",
|
12
12
|
css: "#{Rails.configuration.breakfast.css_reload_strategy}",
|
13
|
-
html: "#{Rails.configuration.breakfast.html_reload_strategy}"
|
13
|
+
html: "#{Rails.configuration.breakfast.html_reload_strategy}",
|
14
|
+
rb: "#{Rails.configuration.breakfast.ruby_reload_strategy}"
|
14
15
|
},
|
15
16
|
statusBarLocation: "#{Rails.configuration.breakfast.status_bar_location}"
|
16
17
|
});
|
@@ -4,9 +4,11 @@ module Breakfast
|
|
4
4
|
module Generators
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
6
6
|
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
NODE_VERSION = 'v4.1.1'
|
8
|
+
NPM_VERSION = '3.10.6'
|
7
9
|
|
8
10
|
def install
|
9
|
-
if
|
11
|
+
if node_prerequisites_installed?
|
10
12
|
create_brunch_config
|
11
13
|
create_package_json
|
12
14
|
create_directory_structure
|
@@ -27,7 +29,7 @@ module Breakfast
|
|
27
29
|
|
28
30
|
---> ERROR - MISSING NODE & NPM
|
29
31
|
|
30
|
-
---> Node & npm are required to run Breakfast.
|
32
|
+
---> Node version >= #{NODE_VERSION} & npm version >= #{NPM_VERSION} are required to run Breakfast.
|
31
33
|
---> Please install them before attempting to continue.
|
32
34
|
---> https://nodejs.org
|
33
35
|
---> https://npmjs.org
|
@@ -38,8 +40,12 @@ module Breakfast
|
|
38
40
|
|
39
41
|
private
|
40
42
|
|
41
|
-
def
|
42
|
-
`which node`.present? && `which npm`.present?
|
43
|
+
def node_prerequisites_installed?
|
44
|
+
`which node`.present? && `which npm`.present? && node_versions_are_satisfactory?
|
45
|
+
end
|
46
|
+
|
47
|
+
def node_versions_are_satisfactory?
|
48
|
+
`node -v` >= NODE_VERSION && `npm -v` >= NPM_VERSION
|
43
49
|
end
|
44
50
|
|
45
51
|
def create_brunch_config
|
data/node_package/package.json
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
const LiveReloader = require('./live-reload');
|
2
2
|
const StatusBar = require('./status-bar');
|
3
|
-
const
|
3
|
+
const Settings = require('./settings');
|
4
4
|
|
5
5
|
const BreakfastRails = {
|
6
6
|
init(options = {}) {
|
7
|
-
|
7
|
+
window.Breakfast = (window.Breakfast || {});
|
8
8
|
|
9
|
-
const
|
10
|
-
const
|
9
|
+
const settings = new Settings(options);
|
10
|
+
const liveReloader = new LiveReloader(settings);
|
11
|
+
const statusBar = new StatusBar(settings);
|
11
12
|
|
12
13
|
liveReloader.init();
|
13
14
|
statusBar.init();
|
@@ -1,6 +1,8 @@
|
|
1
|
+
const RELOAD_CHANNEL = 'Breakfast::LiveReloadChannel';
|
2
|
+
|
1
3
|
class LiveReloader {
|
2
|
-
constructor(
|
3
|
-
this.
|
4
|
+
constructor(settings) {
|
5
|
+
this.settings = settings;
|
4
6
|
}
|
5
7
|
|
6
8
|
buildFreshUrl(url) {
|
@@ -52,7 +54,26 @@ class LiveReloader {
|
|
52
54
|
case 'turbolinks':
|
53
55
|
const location = window.top.location;
|
54
56
|
|
55
|
-
if (
|
57
|
+
if (this.turbolinksAvailable() && !this.onErrorPage()) {
|
58
|
+
Turbolinks.visit(location);
|
59
|
+
} else {
|
60
|
+
location.reload();
|
61
|
+
}
|
62
|
+
break;
|
63
|
+
case 'page':
|
64
|
+
window.top.location.reload();
|
65
|
+
break;
|
66
|
+
case 'off':
|
67
|
+
break;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
rubyReload(strategy) {
|
72
|
+
switch (strategy) {
|
73
|
+
case 'turbolinks':
|
74
|
+
const location = window.top.location;
|
75
|
+
|
76
|
+
if (this.turbolinksAvailable() && !this.onErrorPage()) {
|
56
77
|
Turbolinks.visit(location);
|
57
78
|
} else {
|
58
79
|
location.reload();
|
@@ -66,20 +87,31 @@ class LiveReloader {
|
|
66
87
|
}
|
67
88
|
}
|
68
89
|
|
90
|
+
turbolinksAvailable() {
|
91
|
+
return (typeof Turbolinks !== 'undefined');
|
92
|
+
}
|
93
|
+
// If user is on an error page and they fix the error and re-render using
|
94
|
+
// turbolinks than the CSS from the Rails error page will hang around. Will
|
95
|
+
// initiate a full refresh to get rid of it.
|
96
|
+
onErrorPage() {
|
97
|
+
return (document.title.indexOf('Exception caught') !== -1);
|
98
|
+
}
|
99
|
+
|
69
100
|
init() {
|
70
101
|
const reloaders = {
|
71
102
|
js: this.jsReload.bind(this),
|
72
103
|
css: this.cssReload.bind(this),
|
73
|
-
html: this.htmlReload.bind(this)
|
104
|
+
html: this.htmlReload.bind(this),
|
105
|
+
slim: this.htmlReload.bind(this),
|
106
|
+
haml: this.htmlReload.bind(this),
|
107
|
+
rb: this.rubyReload.bind(this)
|
74
108
|
};
|
75
109
|
|
76
110
|
document.addEventListener('DOMContentLoaded', () => {
|
77
|
-
|
78
|
-
|
79
|
-
this.options.cable.subscriptions.create(reloadChannel, {
|
111
|
+
this.settings.cable.subscriptions.create(RELOAD_CHANNEL, {
|
80
112
|
received: (data) => {
|
81
113
|
const reloader = reloaders[data.extension];
|
82
|
-
reloader(this.
|
114
|
+
reloader(this.settings.strategies[data.extension]);
|
83
115
|
}
|
84
116
|
});
|
85
117
|
});
|
@@ -0,0 +1,48 @@
|
|
1
|
+
const LOCAL_STORAGE_KEY = 'breakfast-rails-settings';
|
2
|
+
const ActionCable = require('actioncable');
|
3
|
+
|
4
|
+
class Settings {
|
5
|
+
constructor(options = {}) {
|
6
|
+
this.options = options;
|
7
|
+
this.host = options.host;
|
8
|
+
this.port = options.port;
|
9
|
+
this.strategies = this.determineStrategies();
|
10
|
+
this.statusBarLocation = options.statusBarLocation;
|
11
|
+
this.cable = ActionCable.createConsumer(`ws://${this.host}:${this.port}/cable`);
|
12
|
+
this.log = (this.storedSettings().log || {});
|
13
|
+
|
14
|
+
this.save();
|
15
|
+
}
|
16
|
+
|
17
|
+
save() {
|
18
|
+
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify({
|
19
|
+
host: this.host,
|
20
|
+
port: this.port,
|
21
|
+
strategies: this.strategies,
|
22
|
+
log: this.log
|
23
|
+
}));
|
24
|
+
}
|
25
|
+
|
26
|
+
determineStrategies() {
|
27
|
+
const defaults = this.options.strategies || {};
|
28
|
+
const existing = this.storedSettings().strategies || {};
|
29
|
+
|
30
|
+
return (Object.assign(defaults, existing));
|
31
|
+
}
|
32
|
+
|
33
|
+
updateStrategies(strategy) {
|
34
|
+
this.strategies = Object.assign(this.strategies, strategy);
|
35
|
+
this.save();
|
36
|
+
}
|
37
|
+
|
38
|
+
updateLog(log) {
|
39
|
+
this.log = log;
|
40
|
+
this.save();
|
41
|
+
}
|
42
|
+
|
43
|
+
storedSettings() {
|
44
|
+
return (JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY)) || {});
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
module.exports = Settings;
|
@@ -1,52 +1,230 @@
|
|
1
|
-
const LOCAL_STORAGE_KEY = 'breakfast-last-log';
|
2
1
|
const STATUS_CHANNEL = 'Breakfast::StatusChannel';
|
3
2
|
|
4
3
|
class StatusBar {
|
5
|
-
constructor(
|
6
|
-
this.
|
4
|
+
constructor(settings = {}) {
|
5
|
+
this.settings = settings;
|
6
|
+
|
7
|
+
this.settings.cable.subscriptions.create(STATUS_CHANNEL, {
|
8
|
+
connected: () => {
|
9
|
+
this.write(this.settings.log.message, this.settings.log.status);
|
10
|
+
},
|
11
|
+
received: (log) => {
|
12
|
+
if (this.settings.strategies[log.extension] !== 'off') {
|
13
|
+
this.settings.updateLog(log);
|
14
|
+
this.write(log.message, log.status);
|
15
|
+
}
|
16
|
+
},
|
17
|
+
disconnected: () => {
|
18
|
+
this.write('Disconnected from server...', 'error');
|
19
|
+
}
|
20
|
+
});
|
7
21
|
}
|
8
22
|
|
9
23
|
init() {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
);
|
23
|
-
}
|
24
|
-
|
25
|
-
drawStatusBar(statusData = {}) {
|
26
|
-
const statusBar = document.getElementById('breakfast-status-bar');
|
24
|
+
let eventName;
|
25
|
+
|
26
|
+
if (typeof Turbolinks !== 'undefined') {
|
27
|
+
eventName = 'turbolinks:load';
|
28
|
+
} else {
|
29
|
+
eventName = 'DOMContentLoaded';
|
30
|
+
}
|
31
|
+
|
32
|
+
document.addEventListener(eventName, () => {
|
33
|
+
this.render();
|
34
|
+
this.write(this.settings.log.message, this.settings.log.status);
|
35
|
+
});
|
27
36
|
|
28
|
-
|
29
|
-
|
37
|
+
window.Breakfast.StatusBar = this;
|
38
|
+
}
|
39
|
+
|
40
|
+
write(message, status) {
|
41
|
+
const log = document.getElementById('breakfast-message-log');
|
42
|
+
if (log) {
|
43
|
+
log.innerHTML = message;
|
44
|
+
log.className = `breakfast-message-log-${ status }`;
|
30
45
|
}
|
46
|
+
}
|
47
|
+
|
48
|
+
handleClick(option) {
|
49
|
+
this.settings.updateStrategies(option);
|
50
|
+
const reloaders = document.getElementById('breakfast-reloaders');
|
51
|
+
reloaders.innerHTML = this.renderReloaders();
|
52
|
+
}
|
53
|
+
|
54
|
+
render() {
|
55
|
+
const statusBar = document.getElementById('breakfast-status-bar');
|
56
|
+
|
57
|
+
if (statusBar) { document.body.removeChild(statusBar); }
|
58
|
+
|
59
|
+
const sb = document.createElement('DIV');
|
60
|
+
sb.setAttribute('class', 'breakfast-status-bar');
|
61
|
+
sb.setAttribute('id', 'breakfast-status-bar');
|
62
|
+
|
63
|
+
sb.innerHTML = `
|
64
|
+
${ this.stylesheet() }
|
65
|
+
<div id="breakfast-reloaders" class="breakfast-reloaders">
|
66
|
+
${ this.renderReloaders() }
|
67
|
+
</div>
|
68
|
+
<div id="breakfast-message-log">
|
69
|
+
</div>
|
70
|
+
`;
|
71
|
+
|
72
|
+
document.body.appendChild(sb);
|
73
|
+
}
|
74
|
+
|
75
|
+
renderReloaders() {
|
76
|
+
return (`
|
77
|
+
<div class="breakfast-reloader">
|
78
|
+
<span>js: </span><span class="breakfast-type">${ this.settings.strategies.js }</span>
|
79
|
+
<div class="breakfast-menu">
|
80
|
+
${ this.renderLink('js', 'page', 'Page Reload') }
|
81
|
+
${ this.renderLink('js', 'off', 'Off') }
|
82
|
+
</div>
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div class="breakfast-reloader">
|
86
|
+
<span>css: </span><span class="breakfast-type">${ this.settings.strategies.css }</span>
|
87
|
+
<div class="breakfast-menu">
|
88
|
+
${ this.renderLink('css', 'page', 'Page Reload') }
|
89
|
+
${ this.renderLink('css', 'hot', 'Hot Reload') }
|
90
|
+
${ this.renderLink('css', 'off', 'Off') }
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
<div class="breakfast-reloader">
|
94
|
+
<span>html: </span><span class="breakfast-type">${ this.settings.strategies.html }</span>
|
95
|
+
<div class="breakfast-menu">
|
96
|
+
${ this.renderLink('html', 'page', 'Page Reload') }
|
97
|
+
${ this.renderLink('html', 'turbolinks', 'Turbolinks Reload') }
|
98
|
+
${ this.renderLink('html', 'off', 'Off') }
|
99
|
+
</div>
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<div class="breakfast-reloader">
|
103
|
+
<span>ruby: </span><span class="breakfast-type">${ this.settings.strategies.rb }</span>
|
104
|
+
<div class="breakfast-menu">
|
105
|
+
${ this.renderLink('rb', 'page', 'Page Reload') }
|
106
|
+
${ this.renderLink('rb', 'turbolinks', 'Turbolinks Reload') }
|
107
|
+
${ this.renderLink('rb', 'off', 'Off') }
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
`);
|
111
|
+
}
|
112
|
+
|
113
|
+
renderLink(type, strategy, text) {
|
114
|
+
const active = this.settings.strategies[type] === strategy;
|
115
|
+
|
116
|
+
return (`
|
117
|
+
<a
|
118
|
+
class="breakfast-menu-option ${ active ? 'breakfast-active' : '' }"
|
119
|
+
onclick="Breakfast.StatusBar.handleClick({'${ type }': '${ strategy }'}); return false;"
|
120
|
+
href="#"
|
121
|
+
>
|
122
|
+
<div class="breakfast-toggle"></div><div>${ text }</div>
|
123
|
+
</a>
|
124
|
+
`);
|
125
|
+
}
|
126
|
+
|
127
|
+
stylesheet() {
|
128
|
+
return (`
|
129
|
+
<style>
|
130
|
+
.breakfast-status-bar {
|
131
|
+
align-items: center;
|
132
|
+
background-color: #1f1f1f;
|
133
|
+
${this.settings.statusBarLocation}: 0;
|
134
|
+
color: #999;
|
135
|
+
font-family: monospace;
|
136
|
+
font-size: 12px;
|
137
|
+
display: flex;
|
138
|
+
height: 30px;
|
139
|
+
position: fixed;
|
140
|
+
width: 100%;
|
141
|
+
}
|
142
|
+
|
143
|
+
.breakfast-status-bar .breakfast-reloaders {
|
144
|
+
align-items: center;
|
145
|
+
display: flex;
|
146
|
+
}
|
147
|
+
|
148
|
+
.breakfast-status-bar .breakfast-reloader {
|
149
|
+
border-left: 1px solid #444;
|
150
|
+
padding: 4px 8px;
|
151
|
+
position: relative;
|
152
|
+
}
|
153
|
+
|
154
|
+
.breakfast-status-bar .breakfast-reloader:hover {
|
155
|
+
cursor: pointer;
|
156
|
+
}
|
157
|
+
|
158
|
+
.breakfast-status-bar .breakfast-reloader:hover .breakfast-menu {
|
159
|
+
display: block;
|
160
|
+
}
|
161
|
+
|
162
|
+
.breakfast-status-bar .breakfast-type {
|
163
|
+
color: #eee;
|
164
|
+
}
|
165
|
+
|
166
|
+
.breakfast-status-bar .breakfast-menu {
|
167
|
+
background-color: #1f1f1f;
|
168
|
+
border-radius: 2px;
|
169
|
+
${this.settings.statusBarLocation}: 22px;
|
170
|
+
display: none;
|
171
|
+
left: 0;
|
172
|
+
position: absolute;
|
173
|
+
width: 225px;
|
174
|
+
}
|
175
|
+
|
176
|
+
.breakfast-status-bar .breakfast-menu-option {
|
177
|
+
align-items: center;
|
178
|
+
border-bottom: 1px solid #000;
|
179
|
+
border-top: 1px solid #333;
|
180
|
+
color: #999;
|
181
|
+
display: flex;
|
182
|
+
padding: 6px 15px;
|
183
|
+
z-index: 1000;
|
184
|
+
}
|
185
|
+
|
186
|
+
.breakfast-status-bar .breakfast-menu-option:hover {
|
187
|
+
background-color: #333;
|
188
|
+
text-decoration: none;
|
189
|
+
}
|
190
|
+
|
191
|
+
.breakfast-status-bar .breakfast-active {
|
192
|
+
color: #eee;
|
193
|
+
}
|
194
|
+
|
195
|
+
.breakfast-status-bar .breakfast-active .breakfast-toggle {
|
196
|
+
background-color: #539417;
|
197
|
+
}
|
198
|
+
|
199
|
+
.breakfast-status-bar .breakfast-toggle {
|
200
|
+
background-color: #000;
|
201
|
+
border-radius: 50%;
|
202
|
+
height: 8px;
|
203
|
+
margin-right: 8px;
|
204
|
+
width: 8px;
|
205
|
+
}
|
206
|
+
|
207
|
+
.breakfast-status-bar .breakfast-message-log-success {
|
208
|
+
align-items: center;
|
209
|
+
background-color: #539417;
|
210
|
+
color: #fff;
|
211
|
+
display: flex;
|
212
|
+
flex-grow: 1;
|
213
|
+
height: 30px;
|
214
|
+
padding: 8px;
|
215
|
+
}
|
31
216
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
padding: 6px;
|
44
|
-
background: ${colors[statusData.status]};
|
45
|
-
color: #fff;
|
46
|
-
white-space: pre-wrap;
|
47
|
-
${this.options.statusBarLocation}: 0;"
|
48
|
-
>Breakfast: ${ statusData.message }</div>
|
49
|
-
`;
|
217
|
+
.breakfast-status-bar .breakfast-message-log-error {
|
218
|
+
align-self: ${ this.settings.statusBarLocation === 'bottom' ? 'flex-end' : 'flex-start' };
|
219
|
+
background-color: #a93131;
|
220
|
+
color: #fff;
|
221
|
+
flex-grow: 1;
|
222
|
+
min-height: 30px;
|
223
|
+
padding: 5px 8px;
|
224
|
+
white-space: pre-wrap;
|
225
|
+
}
|
226
|
+
</style>
|
227
|
+
`);
|
50
228
|
}
|
51
229
|
}
|
52
230
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breakfast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Koperwas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,30 +70,30 @@ dependencies:
|
|
70
70
|
name: actioncable
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
75
|
+
version: '5.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
82
|
+
version: '5.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: listen
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '3.1'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '3.1'
|
97
97
|
description: Replace the asset pipeline with Brunch. Get CSS, JS and HTML live-reloading
|
98
98
|
out of the box. Full ES6 support with require.
|
99
99
|
email:
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- ".gitignore"
|
106
106
|
- ".rspec"
|
107
107
|
- ".travis.yml"
|
108
|
+
- CHANGELOG.md
|
108
109
|
- Gemfile
|
109
110
|
- LICENSE.txt
|
110
111
|
- README.md
|
@@ -132,6 +133,7 @@ files:
|
|
132
133
|
- node_package/package.json
|
133
134
|
- node_package/src/breakfast-rails.js
|
134
135
|
- node_package/src/live-reload.js
|
136
|
+
- node_package/src/settings.js
|
135
137
|
- node_package/src/status-bar.js
|
136
138
|
homepage: https://github.com/devlocker/breakfast
|
137
139
|
licenses:
|