happo 2.3.0 → 2.4.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: 88d89187e77ba6225483b0018803b72cb3226fc3
4
- data.tar.gz: 0dad6cf7d66a3df8b2403c78ff881a065b15dacd
3
+ metadata.gz: 8151e36e534eae38fab096a18a81ae2cb6e61cf0
4
+ data.tar.gz: f28280aea360ccf7e2a413bb9e83889e404928df
5
5
  SHA512:
6
- metadata.gz: e377214d9a7d2a1f01cd2b91f5d3b6f89f55c9755f13105b8ac9bf233ec27c690642faf3343e23bdc20b31c7e2e478a0a01660ce140c60dd8d8413c9cc9efd9b
7
- data.tar.gz: 5b6ae122c2553cb4e30eee81af44410f76770d4fe7d4d460734e48b33cf95a503661e9ada714c04bcbc455b7284cd462a26605ab5bf45d4d72adc0827d18c48e
6
+ metadata.gz: 5583155f820c9c67ca92c94f2f88a659f00f7c54c53873c9b370fd85351bacaea54aa729f318ad6794e25e7f2387e39212eaa196611e3ffaee260169ec09ef78
7
+ data.tar.gz: 8d39502a92d286e08cd85f3013f8419e7601f73c662ba06b99e57dbd57c5c197ded39edfbe40c255ae46f985341e45c4874536ff5bcda35b3188614708bfd909
@@ -1,3 +1,4 @@
1
+ require 'json'
1
2
  require 'happo/utils'
2
3
  require 'happo/uploader'
3
4
  require 'happo/version'
@@ -0,0 +1,91 @@
1
+ const PropTypes = React.PropTypes;
2
+
3
+ const imageObjectStructure = {
4
+ description: PropTypes.string.isRequired,
5
+ viewport: PropTypes.string.isRequired,
6
+ url: PropTypes.string.isRequired,
7
+ };
8
+
9
+ function imageSlug(image) {
10
+ return btoa(image.description + image.viewport);
11
+ }
12
+
13
+ function renderImage(image) {
14
+ return (
15
+ <div>
16
+ <h3 id={imageSlug(image)}>
17
+ <a className='anchored' href={`#${imageSlug(image)}`}>
18
+ {image.description}
19
+ {' @ '}
20
+ {image.viewport}
21
+ </a>
22
+ </h3>
23
+ <img src={image.url} />
24
+ </div>
25
+ );
26
+ }
27
+
28
+ function renderDiffImages(diffImages) {
29
+ if (!diffImages.length) {
30
+ return null;
31
+ }
32
+
33
+ return (
34
+ <div>
35
+ <h2 id='diffs'>
36
+ <a className='anchored' href='#diffs'>
37
+ Diffs ({ diffImages.length })
38
+ </a>
39
+ </h2>
40
+
41
+ {diffImages.map(renderImage)}
42
+ </div>
43
+ );
44
+ }
45
+
46
+ function renderNewImages(newImages) {
47
+ if (!newImages.length) {
48
+ return null;
49
+ }
50
+
51
+ return (
52
+ <div>
53
+ <h2 id='new'>
54
+ <a className='anchored' href='#new'>
55
+ New examples ({ newImages.length })
56
+ </a>
57
+ </h2>
58
+
59
+ {newImages.map(renderImage)}
60
+ </div>
61
+ );
62
+ }
63
+
64
+ window.HappoDiffs = React.createClass({
65
+ propTypes: {
66
+ pageTitle: PropTypes.string.isRequired,
67
+ diffImages: PropTypes.arrayOf(imageObjectStructure).isRequired,
68
+ newImages: PropTypes.arrayOf(imageObjectStructure).isRequired,
69
+ generatedAt: PropTypes.string.isRequired,
70
+ },
71
+
72
+ render() {
73
+ return (
74
+ <div>
75
+ <header className='header'>
76
+ <h1 className='header_title'>
77
+ {this.props.pageTitle}
78
+ </h1>
79
+ <div className='header__time'>
80
+ Generated: {this.props.generatedAt}
81
+ </div>
82
+ </header>
83
+
84
+ <main className='main'>
85
+ {renderDiffImages(this.props.diffImages)}
86
+ {renderNewImages(this.props.newImages)}
87
+ </main>
88
+ </div>
89
+ );
90
+ }
91
+ });
@@ -38,6 +38,7 @@ body {
38
38
  opacity: .2;
39
39
  vertical-align: middle;
40
40
  width: 24px;
41
+ margin-left: 5px;
41
42
  }
42
43
 
43
44
  .anchored:hover::after {
@@ -52,6 +52,7 @@ module Happo
52
52
  path = File.expand_path(
53
53
  File.join(File.dirname(__FILE__), 'views', 'diffs.erb'))
54
54
  html.content = ERB.new(File.read(path)).result(binding)
55
+ html.content_encoding = 'utf-8'
55
56
  html.content_type = 'text/html'
56
57
  html.save
57
58
  html.url
@@ -90,22 +90,13 @@ module Happo
90
90
  File.read(File.expand_path('../public/happo-styles.css', __FILE__))
91
91
  end
92
92
 
93
+ def self.jsx_code
94
+ File.read(File.expand_path('../public/HappoDiffs.jsx', __FILE__))
95
+ end
96
+
93
97
  def self.last_result_summary
94
98
  YAML.load(File.read(File.join(
95
99
  self.config['snapshots_folder'], 'result_summary.yaml')))
96
100
  end
97
-
98
- def self.to_inline_slug(string)
99
- value = string.gsub(/[^\x00-\x7F]/n, '').to_s
100
- value.gsub!(/[']+/, '')
101
- value.gsub!(/\W+/, ' ')
102
- value.strip!
103
- value.tr!(' ', '-')
104
- URI.escape(value)
105
- end
106
-
107
- def self.image_slug(diff_image)
108
- to_inline_slug("#{diff_image[:description]} #{diff_image[:viewport]}")
109
- end
110
101
  end
111
102
  end
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module Happo
3
- VERSION = '2.3.0'
3
+ VERSION = '2.4.0'
4
4
  end
@@ -1,6 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
+ <meta charset="utf-8" />
4
5
  <title>Happo Debug Tool</title>
5
6
 
6
7
  <link rel="shortcut icon" href="<%= Happo::Utils.favicon_as_base64 %>" />
@@ -3,6 +3,7 @@
3
3
  <!DOCTYPE html>
4
4
  <html>
5
5
  <head>
6
+ <meta charset="utf-8" />
6
7
  <title><%= Happo::Utils.page_title(diff_images, new_images) %></title>
7
8
 
8
9
  <link rel="shortcut icon" href="<%= Happo::Utils.favicon_as_base64 %>" />
@@ -10,52 +11,29 @@
10
11
  <style>
11
12
  <%= Happo::Utils.css_styles %>
12
13
  </style>
13
- </head>
14
-
15
- <body>
16
- <header class="header">
17
- <h1 class="header_title">
18
- <%= Happo::Utils.page_title(diff_images, new_images) %>
19
- </h1>
20
- <div class="header__time">Generated: <%= Time.now %></div>
21
- </header>
22
-
23
- <main class="main">
24
- <% if diff_images.count > 0%>
25
- <h2 id="diffs">
26
- <a class="anchored" href="#diffs">
27
- Diffs (<%= diff_images.count %>)
28
- </a>
29
- </h2>
30
14
 
31
- <% diff_images.each do |image| %>
32
- <h3 id="<%= Happo::Utils.image_slug(image) %>">
33
- <a class="anchored" href="#<%= Happo::Utils.image_slug(image) %>">
34
- <%= Rack::Utils.escape_html(image[:description]) %> @ <%= image[:viewport] %>
35
- </a>
36
- </h3>
15
+ <script src="https://npmcdn.com/react@15.3.1/dist/react.min.js"></script>
16
+ <script src="https://npmcdn.com/react-dom@15.3.1/dist/react-dom.min.js"></script>
17
+ <script src="https://npmcdn.com/babel-core@5.8.38/browser.min.js"></script>
37
18
 
38
- <img src="<%= image[:url] %>">
39
- <% end %>
40
- <% end %>
41
-
42
- <% if new_images.count > 0%>
43
- <h2 id="new">
44
- <a class="anchored" href="#new">
45
- New examples (<%= new_images.count %>)
46
- </a>
47
- </h2>
48
-
49
- <% new_images.each do |image| %>
50
- <h3 id="<%= Happo::Utils.image_slug(image) %>">
51
- <a class="anchored" href="#<%= Happo::Utils.image_slug(image) %>">
52
- <%= Rack::Utils.escape_html(image[:description]) %> @ <%= image[:viewport] %>
53
- </a>
54
- </h3>
19
+ <script type="text/babel">
20
+ <%= Happo::Utils.jsx_code %>
21
+ </script>
22
+ </head>
55
23
 
56
- <img src="<%= image[:url] %>">
57
- <% end %>
58
- <% end %>
59
- </main>
24
+ <body>
25
+ <div id="react-root"></div>
26
+
27
+ <script type="text/babel">
28
+ ReactDOM.render(
29
+ <HappoDiffs
30
+ newImages={<%= new_images.to_json %>}
31
+ diffImages={<%= diff_images.to_json %>}
32
+ pageTitle={<%= Happo::Utils.page_title(diff_images, new_images).to_json %>}
33
+ generatedAt={<%= Time.now.to_s.to_json %>}
34
+ />,
35
+ document.getElementById('react-root')
36
+ );
37
+ </script>
60
38
  </body>
61
39
  </html>
@@ -1,6 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
+ <meta charset="utf-8" />
4
5
  <title>Happo</title>
5
6
 
6
7
  <link rel="shortcut icon" href="<%= Happo::Utils.favicon_as_base64 %>" />
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henric Trotzig
@@ -145,6 +145,7 @@ files:
145
145
  - bin/happo
146
146
  - lib/happo.rb
147
147
  - lib/happo/logger.rb
148
+ - lib/happo/public/HappoDiffs.jsx
148
149
  - lib/happo/public/favicon.ico
149
150
  - lib/happo/public/happo-runner.js
150
151
  - lib/happo/public/happo-styles.css