happo 2.3.0 → 2.4.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/lib/happo.rb +1 -0
- data/lib/happo/public/HappoDiffs.jsx +91 -0
- data/lib/happo/public/happo-styles.css +1 -0
- data/lib/happo/uploader.rb +1 -0
- data/lib/happo/utils.rb +4 -13
- data/lib/happo/version.rb +1 -1
- data/lib/happo/views/debug.erb +1 -0
- data/lib/happo/views/diffs.erb +22 -44
- data/lib/happo/views/index.erb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8151e36e534eae38fab096a18a81ae2cb6e61cf0
|
4
|
+
data.tar.gz: f28280aea360ccf7e2a413bb9e83889e404928df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5583155f820c9c67ca92c94f2f88a659f00f7c54c53873c9b370fd85351bacaea54aa729f318ad6794e25e7f2387e39212eaa196611e3ffaee260169ec09ef78
|
7
|
+
data.tar.gz: 8d39502a92d286e08cd85f3013f8419e7601f73c662ba06b99e57dbd57c5c197ded39edfbe40c255ae46f985341e45c4874536ff5bcda35b3188614708bfd909
|
data/lib/happo.rb
CHANGED
@@ -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
|
+
});
|
data/lib/happo/uploader.rb
CHANGED
data/lib/happo/utils.rb
CHANGED
@@ -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
|
data/lib/happo/version.rb
CHANGED
data/lib/happo/views/debug.erb
CHANGED
data/lib/happo/views/diffs.erb
CHANGED
@@ -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
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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>
|
data/lib/happo/views/index.erb
CHANGED
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.
|
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
|