amp-html 1.1.0 → 1.2.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 +10 -0
- data/README.md +1 -7
- data/app/helpers/amp_html/base_helper.rb +14 -9
- data/app/views/mozaic/amp/_doctype.html.erb +2 -2
- data/app/views/mozaic/amp/_head.html.erb +1 -2
- data/lib/amp-html/configuration.rb +0 -2
- data/lib/amp-html/railtie.rb +24 -12
- data/lib/amp-html/version.rb +1 -1
- data/lib/generators/amp_html_generator.rb +2 -1
- data/lib/generators/templates/application.sass +6 -0
- data/lib/generators/templates/initializer.rb +0 -4
- data/lib/generators/templates/layout.html.erb +1 -1
- metadata +17 -3
- data/lib/generators/templates/application.css +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3cad4f6ae213a043323c0f759a63c934c836a157c3361f422f0ca4b698f9a36
|
4
|
+
data.tar.gz: 3219480ff79226a0da61cdabb800846017090b90cab5d09f2a3daf8eebe926d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5f1334e1f4525199c2746c47103580233fd54f6f399b5023f70a69a8292aa756541b9ab1ea7ff1581412c8e39fd33e64e96eefbbfd7b7f343bf546b04552874
|
7
|
+
data.tar.gz: 4a65426b0516f365392743accde3bb60823340ec50ca324f00efe46529c7525dadb53ac5988dd676d6183a0aa7326a61f0403ff80e0f6e662360bf2a1b43c61c
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@
|
|
4
4
|
|
5
5
|
* nothing yet
|
6
6
|
|
7
|
+
### 1.2.0 - 2018/01/30
|
8
|
+
|
9
|
+
* features
|
10
|
+
* automatically load controller action specific stylesheets
|
11
|
+
* enhancements
|
12
|
+
* allow options to be passed to the `amp/doctype` component
|
13
|
+
* bugfixes
|
14
|
+
* fix `amp/canonical-link` component for apps without SplitView
|
15
|
+
* fix media components
|
16
|
+
|
7
17
|
### 1.1.0 - 2018/01/17
|
8
18
|
|
9
19
|
* features
|
data/README.md
CHANGED
@@ -30,11 +30,6 @@ Use the powerful features of AMP to make your Rails app consistently fast, beaut
|
|
30
30
|
* [Controllers](#controllers)
|
31
31
|
* [SplitView](#splitview)
|
32
32
|
* [Guides](#guides)
|
33
|
-
* [Getting started](#getting-started)
|
34
|
-
* [Utilizing features](#utilizing-features)
|
35
|
-
* [Essentials](#essentials)
|
36
|
-
* [Powerful features](#powerful-features)
|
37
|
-
* [Testing](#testing)
|
38
33
|
* [Components](#components)
|
39
34
|
* [Configuration](#configuration)
|
40
35
|
* [To Do](#to-do)
|
@@ -207,11 +202,10 @@ You can configure amp-html by passing a block to `configure`. This can be done i
|
|
207
202
|
|
208
203
|
```ruby
|
209
204
|
AmpHtml.configure do |config|
|
210
|
-
config.
|
205
|
+
config.split_view = false
|
211
206
|
end
|
212
207
|
```
|
213
208
|
|
214
|
-
* `inherit_stylesheets` Use your regular stylesheets bundled with `app/assets/stylesheets/application.css` in your AMP views. Takes a boolean. Defaults to `false`.
|
215
209
|
* `split_view` Enable SplitView to allow for AMP enabled and AMP disabled versions of your views. Takes a boolean. Defaults to `false`.
|
216
210
|
* `split_view_default` The default view version if no `amp` param is present in the request. Must be either `'amp'` or `'html'`. Defaults to `'amp'`.
|
217
211
|
|
@@ -10,15 +10,20 @@ module AmpHtml
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
def amp_packaged_css
|
14
|
+
global = Rails.application.assets.find_asset('amp/application.css').to_s
|
15
|
+
package = Rails.application.assets.find_asset("amp/packages/#{params[:controller]}/#{action_name}.css").to_s
|
16
|
+
# if Rails.env.development?
|
17
|
+
# ::Sass::Engine.new(global + package, {
|
18
|
+
# syntax: :scss,
|
19
|
+
# cache: false,
|
20
|
+
# read_cache: false,
|
21
|
+
# style: :compressed
|
22
|
+
# }).render
|
23
|
+
# else
|
24
|
+
# global + package
|
25
|
+
# end
|
26
|
+
global + package
|
22
27
|
end
|
23
28
|
|
24
29
|
def amp= value = true
|
@@ -7,7 +7,6 @@
|
|
7
7
|
|
8
8
|
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
|
9
9
|
<style amp-custom>
|
10
|
-
<%=
|
11
|
-
<%= get_asset 'amp/application.css' %>
|
10
|
+
<%= amp_packaged_css %>
|
12
11
|
<%= area :css %>
|
13
12
|
</style>
|
@@ -11,12 +11,10 @@ module AmpHtml
|
|
11
11
|
|
12
12
|
class Configuration
|
13
13
|
|
14
|
-
attr_accessor :inherit_stylesheets
|
15
14
|
attr_accessor :split_view
|
16
15
|
attr_accessor :split_view_default
|
17
16
|
|
18
17
|
def initialize
|
19
|
-
@inherit_stylesheets = false
|
20
18
|
@split_view = false
|
21
19
|
@split_view_default = 'amp'
|
22
20
|
end
|
data/lib/amp-html/railtie.rb
CHANGED
@@ -3,29 +3,35 @@ require 'rails/railtie'
|
|
3
3
|
module AmpHtml
|
4
4
|
class Railtie < ::Rails::Railtie
|
5
5
|
|
6
|
+
include ActionView::Helpers::AssetUrlHelper
|
7
|
+
|
6
8
|
initializer 'amp-html.mozaic' do
|
7
9
|
Mozaic.configure do |config|
|
8
10
|
|
9
11
|
|
10
12
|
### Base
|
11
13
|
|
12
|
-
config.define_component 'amp/doctype'
|
14
|
+
config.define_component 'amp/doctype', '⚡': ''
|
13
15
|
config.define_component 'amp/amp-link', rel: 'amphtml' do |options|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
if AmpHtml.configuration.split_view
|
17
|
+
href = options[:href].split('?').first
|
18
|
+
unless AmpHtml.configuration.split_view_default == 'amp'
|
19
|
+
options[:href] ||= "#{href}?#{{ amp: true }.to_query}"
|
20
|
+
else
|
21
|
+
options[:href] ||= href
|
22
|
+
end
|
18
23
|
else
|
19
|
-
|
24
|
+
false
|
20
25
|
end
|
21
26
|
end
|
22
27
|
config.define_component 'amp/canonical-link', rel: 'canonical' do |options|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
if AmpHtml.configuration.split_view
|
29
|
+
href = options[:href].split('?').first
|
30
|
+
if AmpHtml.configuration.split_view_default == 'amp'
|
31
|
+
options[:href] ||= "#{href}?#{{ amp: false }.to_query}"
|
32
|
+
else
|
33
|
+
options[:href] ||= href
|
34
|
+
end
|
29
35
|
end
|
30
36
|
end
|
31
37
|
config.define_component 'amp/head'
|
@@ -101,6 +107,12 @@ module AmpHtml
|
|
101
107
|
|
102
108
|
initializer 'amp-html.assets' do
|
103
109
|
Rails.application.config.assets.precompile += ['amp/application.css']
|
110
|
+
Dir.glob Rails.root.join('app', 'assets', 'stylesheets', 'amp', 'packages', '**', '*') do |path|
|
111
|
+
next if File.directory? path
|
112
|
+
path = path.split('stylesheets').last
|
113
|
+
path.slice! 0
|
114
|
+
Rails.application.config.assets.precompile += [path]
|
115
|
+
end
|
104
116
|
end
|
105
117
|
|
106
118
|
initializer 'amp-html.action_controller' do
|
data/lib/amp-html/version.rb
CHANGED
@@ -14,7 +14,8 @@ module AmpHtml
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def create_assets
|
17
|
-
template 'application.
|
17
|
+
template 'application.sass', 'app/assets/stylesheets/amp/application.sass'
|
18
|
+
template '.keep-file', 'app/assets/stylesheets/amp/packages/.keep'
|
18
19
|
end
|
19
20
|
|
20
21
|
def create_initializer
|
@@ -0,0 +1,6 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into amp/application.css, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// This manifest is only used for application wide styles. Add view specific files to the /packages subfolder.
|
5
|
+
//
|
6
|
+
// Don't use `require_tree .` in this file, as that would include all view specific files in this manifest.
|
@@ -1,9 +1,5 @@
|
|
1
1
|
AmpHtml.configure do |config|
|
2
2
|
|
3
|
-
# Use your regular stylesheets bundled with `app/assets/stylesheets/application.css` in your AMP views. Takes a boolean.
|
4
|
-
# config.inherit_stylesheets = false
|
5
|
-
|
6
|
-
|
7
3
|
### SplitView
|
8
4
|
|
9
5
|
# Enable SplitView to allow for AMP enabled and AMP disabled versions of your views. Takes a boolean.
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<head>
|
3
3
|
<%%= component 'amp/head' %>
|
4
4
|
<title>Hello AMP world</title>
|
5
|
-
|
5
|
+
<%%= component 'amp/canonical-link', href: request.original_url %>
|
6
6
|
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
|
7
7
|
<%%= csrf_meta_tags %>
|
8
8
|
</head>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amp-html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sass-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: mozaic
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,7 +147,7 @@ files:
|
|
133
147
|
- lib/amp-html/railtie.rb
|
134
148
|
- lib/amp-html/version.rb
|
135
149
|
- lib/generators/amp_html_generator.rb
|
136
|
-
- lib/generators/templates/application.
|
150
|
+
- lib/generators/templates/application.sass
|
137
151
|
- lib/generators/templates/components/assets/javascripts/application.js
|
138
152
|
- lib/generators/templates/components/helpers/ad_tag_helper.rb
|
139
153
|
- lib/generators/templates/components/helpers/analytics_tag_helper.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into amp/application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
6
|
-
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
-
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
-
* It is generally better to create a new file per style scope.
|
12
|
-
*
|
13
|
-
*= require_tree .
|
14
|
-
*= require_self
|
15
|
-
*/
|