amp-html 0.7.18 → 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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +82 -77
- data/README.md +61 -75
- data/app/helpers/amp_html/asset_helper.rb +11 -0
- data/app/helpers/amp_html/base_helper.rb +14 -0
- data/app/helpers/amp_html/dynamic_content_helper.rb +14 -0
- data/app/helpers/amp_html/layouts_helper.rb +11 -0
- data/app/helpers/amp_html/media_helper.rb +15 -0
- data/app/views/mozaic/amp/_amp-link.html.erb +1 -0
- data/app/views/mozaic/amp/_audio.html.erb +11 -0
- data/app/views/mozaic/amp/_canonical-link.html.erb +1 -0
- data/app/views/mozaic/amp/_components.html.erb +6 -0
- data/app/views/mozaic/amp/_doctype.html.erb +4 -0
- data/app/views/mozaic/amp/_font.html.erb +2 -0
- data/app/views/mozaic/amp/_form-response.html.erb +5 -0
- data/app/views/mozaic/amp/_form.html.erb +3 -0
- data/app/views/mozaic/amp/_head.html.erb +13 -0
- data/app/views/mozaic/amp/_img.html.erb +1 -0
- data/app/views/mozaic/amp/_input.html.erb +1 -0
- data/app/views/mozaic/amp/_mustache.html.erb +3 -0
- data/app/views/mozaic/amp/_selector.html.erb +3 -0
- data/app/views/mozaic/amp/_video.html.erb +11 -0
- data/lib/amp-html.rb +4 -20
- data/lib/amp-html/configuration.rb +13 -158
- data/lib/amp-html/engine.rb +6 -0
- data/lib/amp-html/railtie.rb +109 -0
- data/lib/amp-html/version.rb +1 -9
- data/lib/generators/amp_html_generator.rb +27 -0
- data/lib/generators/templates/{assets/stylesheets/application.scss → application.css} +1 -1
- data/lib/generators/templates/initializer.rb +14 -0
- data/lib/generators/templates/layout.html.erb +15 -0
- metadata +53 -204
- data/.github/issue_template.md +0 -16
- data/.github/pull_request_template.md +0 -21
- data/.gitignore +0 -13
- data/.travis.yml +0 -4
- data/CODE_OF_CONDUCT.md +0 -46
- data/CONTRIBUTING.md +0 -1
- data/DEPRECATIONS.md +0 -9
- data/Gemfile +0 -12
- data/Gemfile.lock +0 -164
- data/INSTALL.md +0 -2
- data/OWNERS.yaml +0 -1
- data/Rakefile +0 -6
- data/amp-html.gemspec +0 -30
- data/bin/amp-html +0 -4
- data/lib/amp-html/cli.rb +0 -113
- data/lib/amp-html/components/docs/README.md +0 -101
- data/lib/amp-html/components/docs/ad.md +0 -83
- data/lib/amp-html/components/docs/analytics.md +0 -131
- data/lib/amp-html/components/docs/anim.md +0 -66
- data/lib/amp-html/components/docs/fonts.md +0 -63
- data/lib/amp-html/components/docs/forms.md +0 -79
- data/lib/amp-html/components/docs/iframe.md +0 -62
- data/lib/amp-html/components/docs/javascript.md +0 -71
- data/lib/amp-html/components/docs/lists.md +0 -168
- data/lib/amp-html/components/docs/media.md +0 -52
- data/lib/amp-html/components/docs/mustache.md +0 -46
- data/lib/amp-html/components/docs/notifications.md +0 -0
- data/lib/amp-html/components/docs/schema.md +0 -80
- data/lib/amp-html/components/docs/service_worker.md +0 -60
- data/lib/amp-html/components/docs/social.md +0 -130
- data/lib/amp-html/components/docs/stylesheets.md +0 -50
- data/lib/amp-html/components/help.rb +0 -19
- data/lib/amp-html/components/install.rb +0 -34
- data/lib/amp-html/components/templates/ERROR.md +0 -5
- data/lib/amp-html/components/templates/README.md +0 -12
- data/lib/amp-html/configuration/docs/README.md +0 -0
- data/lib/amp-html/configuration/help.rb +0 -11
- data/lib/amp-html/helpers/docs/README.md +0 -98
- data/lib/amp-html/helpers/docs/amp.md +0 -0
- data/lib/amp-html/helpers/docs/amp_ad.md +0 -86
- data/lib/amp-html/helpers/docs/amp_analytics.md +0 -76
- data/lib/amp-html/helpers/docs/amp_anim.md +0 -68
- data/lib/amp-html/helpers/docs/amp_audio.md +0 -54
- data/lib/amp-html/helpers/docs/amp_auto_ads.md +0 -43
- data/lib/amp-html/helpers/docs/amp_close_user_notification_button.md +0 -0
- data/lib/amp-html/helpers/docs/amp_css.md +0 -37
- data/lib/amp-html/helpers/docs/amp_css_link.md +0 -0
- data/lib/amp-html/helpers/docs/amp_custom_ad.md +0 -0
- data/lib/amp-html/helpers/docs/amp_document_link.md +0 -0
- data/lib/amp-html/helpers/docs/amp_embed.md +0 -86
- data/lib/amp-html/helpers/docs/amp_facebook.md +0 -70
- data/lib/amp-html/helpers/docs/amp_fallback.md +0 -47
- data/lib/amp-html/helpers/docs/amp_font.md +0 -0
- data/lib/amp-html/helpers/docs/amp_font_link.md +0 -0
- data/lib/amp-html/helpers/docs/amp_form.md +0 -0
- data/lib/amp-html/helpers/docs/amp_form_response.md +0 -0
- data/lib/amp-html/helpers/docs/amp_gfycat.md +0 -0
- data/lib/amp-html/helpers/docs/amp_global_css.md +0 -0
- data/lib/amp-html/helpers/docs/amp_google_analytics.md +0 -0
- data/lib/amp-html/helpers/docs/amp_google_font.md +0 -0
- data/lib/amp-html/helpers/docs/amp_head.md +0 -0
- data/lib/amp-html/helpers/docs/amp_html_doctype.md +0 -0
- data/lib/amp-html/helpers/docs/amp_iframe.md +0 -0
- data/lib/amp-html/helpers/docs/amp_image.md +0 -0
- data/lib/amp-html/helpers/docs/amp_input.md +0 -0
- data/lib/amp-html/helpers/docs/amp_instagram.md +0 -0
- data/lib/amp-html/helpers/docs/amp_js.md +0 -0
- data/lib/amp-html/helpers/docs/amp_link.md +0 -0
- data/lib/amp-html/helpers/docs/amp_list.md +0 -0
- data/lib/amp-html/helpers/docs/amp_live_list.md +0 -0
- data/lib/amp-html/helpers/docs/amp_live_list_items.md +0 -0
- data/lib/amp-html/helpers/docs/amp_live_list_pagination.md +0 -0
- data/lib/amp-html/helpers/docs/amp_live_list_update.md +0 -0
- data/lib/amp-html/helpers/docs/amp_mustache.md +0 -0
- data/lib/amp-html/helpers/docs/amp_pin_it.md +0 -0
- data/lib/amp-html/helpers/docs/amp_pin_widget.md +0 -0
- data/lib/amp-html/helpers/docs/amp_pinterest_follow.md +0 -0
- data/lib/amp-html/helpers/docs/amp_pixel.md +0 -0
- data/lib/amp-html/helpers/docs/amp_placeholder.md +0 -0
- data/lib/amp-html/helpers/docs/amp_reddit.md +0 -0
- data/lib/amp-html/helpers/docs/amp_resources.md +0 -0
- data/lib/amp-html/helpers/docs/amp_selector.md +0 -0
- data/lib/amp-html/helpers/docs/amp_serviceworker.md +0 -0
- data/lib/amp-html/helpers/docs/amp_social_share.md +0 -0
- data/lib/amp-html/helpers/docs/amp_soundcloud.md +0 -0
- data/lib/amp-html/helpers/docs/amp_twitter.md +0 -0
- data/lib/amp-html/helpers/docs/amp_user_notification.md +0 -0
- data/lib/amp-html/helpers/docs/amp_video.md +0 -0
- data/lib/amp-html/helpers/docs/amp_video_ad.md +0 -0
- data/lib/amp-html/helpers/docs/amp_vine.md +0 -0
- data/lib/amp-html/helpers/docs/amp_youtube.md +0 -0
- data/lib/amp-html/helpers/docs/audio_tag.md +0 -0
- data/lib/amp-html/helpers/docs/canonical_document_link.md +0 -0
- data/lib/amp-html/helpers/docs/form_tag.md +0 -0
- data/lib/amp-html/helpers/docs/image_tag.md +0 -0
- data/lib/amp-html/helpers/docs/input_tag.md +0 -0
- data/lib/amp-html/helpers/docs/javascript_include_tag.md +0 -0
- data/lib/amp-html/helpers/docs/noscript_tag.md +0 -0
- data/lib/amp-html/helpers/docs/schema_tag.md +0 -0
- data/lib/amp-html/helpers/docs/stylesheet_link_tag.md +0 -0
- data/lib/amp-html/helpers/docs/video_tag.md +0 -0
- data/lib/amp-html/helpers/help.rb +0 -23
- data/lib/amp-html/root.rb +0 -7
- data/lib/amp-html/test.rb +0 -169
- data/lib/amp-html/test/help.rb +0 -11
- data/lib/amp-html/test/templates/README.md +0 -43
- data/lib/amp-html/test/templates/css/!important.md +0 -1
- data/lib/amp-html/test/templates/css/-amp-.md +0 -1
- data/lib/amp-html/test/templates/css/-moz-binding.md +0 -1
- data/lib/amp-html/test/templates/css/@import.md +0 -1
- data/lib/amp-html/test/templates/css/behavior.md +0 -1
- data/lib/amp-html/test/templates/css/filter.md +0 -1
- data/lib/amp-html/test/templates/css/i-amp-.md +0 -1
- data/lib/amp-html/test/templates/css/overflow.md +0 -1
- data/lib/amp-html/test/templates/html/applet.md +0 -1
- data/lib/amp-html/test/templates/html/audio.md +0 -1
- data/lib/amp-html/test/templates/html/base.md +0 -1
- data/lib/amp-html/test/templates/html/embed.md +0 -1
- data/lib/amp-html/test/templates/html/frame.md +0 -1
- data/lib/amp-html/test/templates/html/frameset.md +0 -1
- data/lib/amp-html/test/templates/html/http-equiv.md +0 -1
- data/lib/amp-html/test/templates/html/iframe.md +0 -1
- data/lib/amp-html/test/templates/html/img.md +0 -1
- data/lib/amp-html/test/templates/html/javascript_include_tag.md +0 -1
- data/lib/amp-html/test/templates/html/object.md +0 -1
- data/lib/amp-html/test/templates/html/onclick.md +0 -1
- data/lib/amp-html/test/templates/html/onmousehover.md +0 -1
- data/lib/amp-html/test/templates/html/param.md +0 -1
- data/lib/amp-html/test/templates/html/stylesheet_link_tag.md +0 -1
- data/lib/amp-html/test/templates/html/video.md +0 -1
- data/lib/amp-html/test/templates/markup/!doctype.md +0 -1
- data/lib/amp-html/test/templates/markup/amp_document_link.md +0 -1
- data/lib/amp-html/test/templates/markup/amp_head.md +0 -1
- data/lib/amp-html/test/templates/markup/amp_html_doctype.md +0 -1
- data/lib/amp-html/test/templates/markup/canonical_document_link.md +0 -1
- data/lib/amp-html/test/templates/markup/head_body.md +0 -1
- data/lib/amp-html/test/templates/markup/html.md +0 -1
- data/lib/amp-html/test/templates/markup/meta_viewport.md +0 -1
- data/lib/amp-html/validate.rb +0 -46
- data/lib/amp-html/validate/help.rb +0 -11
- data/lib/amp-html/validate/templates/README.md +0 -32
- data/lib/generators/amp_html/assets_generator.rb +0 -31
- data/lib/generators/amp_html/bundle_generator.rb +0 -50
- data/lib/generators/amp_html/components_generator.rb +0 -84
- data/lib/generators/amp_html/helpers_generator.rb +0 -32
- data/lib/generators/amp_html/install_generator.rb +0 -53
- data/lib/generators/amp_html/views_generator.rb +0 -62
- data/lib/generators/templates/assets/README.md +0 -0
- data/lib/generators/templates/components/README.md +0 -0
- data/lib/generators/templates/components/views/_components.html.erb +0 -141
- data/lib/generators/templates/components/views/_google_analytics.html.erb +0 -23
- data/lib/generators/templates/helpers/README.md +0 -0
- data/lib/generators/templates/helpers/amp/fallback_tag_helper.rb +0 -16
- data/lib/generators/templates/helpers/amp/font_tag_helper.rb +0 -37
- data/lib/generators/templates/helpers/amp/link_tag_helper.rb +0 -11
- data/lib/generators/templates/helpers/amp/mustache_tag_helper.rb +0 -13
- data/lib/generators/templates/helpers/amp/noscript_tag_helper.rb +0 -13
- data/lib/generators/templates/helpers/amp/placeholder_tag_helper.rb +0 -16
- data/lib/generators/templates/helpers/amp/schema_tag_helper.rb +0 -16
- data/lib/generators/templates/helpers/amp/stylesheets_tag_helper.rb +0 -21
- data/lib/generators/templates/helpers/amp_tag_helper.rb.erb +0 -65
- data/lib/generators/templates/helpers/asset_tag_helper.rb.erb +0 -119
- data/lib/generators/templates/helpers/form_tag_helper.rb.erb +0 -79
- data/lib/generators/templates/install/README.md +0 -0
- data/lib/generators/templates/install/amp-html.rb.erb +0 -19
- data/lib/generators/templates/install/amp-html.yml.erb +0 -189
- data/lib/generators/templates/views/README.md +0 -0
- data/lib/generators/templates/views/application.html.erb +0 -71
- data/lib/generators/templates/views/application/_head.html.erb +0 -47
- data/lib/generators/templates/views/application/_resources.html.erb +0 -16
- data/lib/generators/templates/views/application/_schema.html.erb +0 -6
- data/lib/generators/templates/views/config/mime_types.rb +0 -8
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: HTML ERROR (AMP): `<frame>` is prohibited by AMP
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: HTML ERROR (AMP): `<frameset>` is prohibited by AMP
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: HTML ERROR (AMP): `http-equiv` attribute of `meta` tags is banned in an AMP document
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: HTML ERROR (AMP): `<iframe>` is prohibited by AMP. `amp_iframe` helper is available with the "iframe" component. Run `amp-html install iframe` to install.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: HTML ERROR (AMP): `<img>` is prohibited by AMP use `amp_img` helper instead
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: HTML ERROR (AMP): External and internal scripts are not allowed in an AMP document
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: HTML ERROR (AMP): `<object>` is prohibited by AMP
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: HTML ERROR (AMP): `onclick` as attribute name is disallowed in AMP
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: HTML ERROR (AMP): `onmousehover` as attribute name is disallowed in AMP
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: HTML ERROR (AMP): `<param>` is prohibited by AMP
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: HTML ERROR (AMP): External and internal stylesheets are not allowed in an AMP document
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: HTML ERROR (AMP): `<video>` is prohibited by AMP use `amp_video` helper instead
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: MARKUP ERROR (AMP): `amp_html_doctype` helper must be used instead of `<!doctype html>` and `<html></html>`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: MARKUP ERROR (AMP): A `amp_document_link` helper must be used in `head` to link to a AMP version of the document
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: MARKUP ERROR (AMP): `amp_head` helper must be included as first child of `head` tag
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: MARKUP ERROR (AMP): `amp_html_doctype` helper must be used instead of `<!doctype html>` and `<html></html>`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: MARKUP ERROR (AMP): A `canonical_document_link` helper must be used in `head` to either link to a non AMP version of the document or itself
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: MARKUP ERROR (AMP): `head` and `body` tags must exist in an AMP document
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: MARKUP ERROR (AMP): `amp_html_doctype` helper must be used instead of `<!doctype html>` and `<html></html>`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
AMP-HTML TEST: MARKUP ERROR (AMP): A `<meta name="viewport" content="width=device-width,minimum-scale=1>` tag must exist in `head` of any AMP document
|
data/lib/amp-html/validate.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
module AmpHtml
|
|
2
|
-
class Validate
|
|
3
|
-
|
|
4
|
-
require 'highline'
|
|
5
|
-
require 'launchy'
|
|
6
|
-
|
|
7
|
-
def self.validate url, server_running
|
|
8
|
-
|
|
9
|
-
unless server_running
|
|
10
|
-
cli = HighLine.new
|
|
11
|
-
answer = cli.ask 'Is your rails server running? [y/n]'
|
|
12
|
-
unless answer == 'y'
|
|
13
|
-
warn 'Rerun `amp-html validate URL` while your server is running'
|
|
14
|
-
puts 'Starting your rails server ...'
|
|
15
|
-
exec 'rails s'
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
validation_url = url + '#development=1'
|
|
20
|
-
root_validation_url = 'http://localhost:3000' + '#development=1'
|
|
21
|
-
|
|
22
|
-
if url.present? && url != 'root'
|
|
23
|
-
Launchy.open( validation_url ) do |exception|
|
|
24
|
-
warn "Attempted to open #{url} and failed because of: #{exception}. Open #{validation_url} in your browser instead."
|
|
25
|
-
exit
|
|
26
|
-
end
|
|
27
|
-
else
|
|
28
|
-
if Rails.env.development?
|
|
29
|
-
Launchy.open( root_validation_url ) do |exception|
|
|
30
|
-
warn "Attempted to open #{url} and failed because of: #{exception}. Open #{root_validation_url} in your browser instead."
|
|
31
|
-
exit
|
|
32
|
-
end
|
|
33
|
-
else
|
|
34
|
-
warn 'If you are not in the development environment, you need to specify the exact uri for the site you want to validate.'
|
|
35
|
-
exit
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
puts '=> Open the Developer Console and check for validation errors.'
|
|
40
|
-
|
|
41
|
-
exit
|
|
42
|
-
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
end
|
|
46
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# AMP-HTML Validate
|
|
3
|
-
|
|
4
|
-
Validate your views using the AMP validator and a browser.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
|
|
9
|
-
amp-html validate URL
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## Options
|
|
13
|
-
|
|
14
|
-
`--server_running` or `-r`: Pass this option if your server is already running.
|
|
15
|
-
|
|
16
|
-
`--help` or `-h`: Run tests with `help` to get additional information on AMP-HTML tests.
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## Arguments
|
|
21
|
-
|
|
22
|
-
### root
|
|
23
|
-
Validates the app root.
|
|
24
|
-
**Note:** This argument is only available in development environment
|
|
25
|
-
|
|
26
|
-
amp-html validate root
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
### URL
|
|
30
|
-
Pass a specific URL to validate any view of your application.
|
|
31
|
-
|
|
32
|
-
amp-html validate https://railsamp.com
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require 'rails/generators/base'
|
|
2
|
-
require 'thor'
|
|
3
|
-
|
|
4
|
-
module AmpHtml
|
|
5
|
-
module Generators
|
|
6
|
-
|
|
7
|
-
class AssetsGenerator < Rails::Generators::Base
|
|
8
|
-
|
|
9
|
-
source_root File.expand_path '../../templates/assets', __FILE__
|
|
10
|
-
desc 'Generate assets to allow for use of the asset pipeline.'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# ASSETS
|
|
14
|
-
class_option :stylesheets, desc: 'Generate stylesheet assets', type: :boolean, default: false, aliases: '-st'
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def create_stylesheet_assets
|
|
19
|
-
if options.size < 0 || options[:stylesheets]
|
|
20
|
-
template 'stylesheets/application.scss', 'app/assets/stylesheets/amp/application.scss'
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def show_readme
|
|
25
|
-
readme 'README.md'
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
require 'rails/generators/base'
|
|
2
|
-
require 'thor'
|
|
3
|
-
|
|
4
|
-
module AmpHtml
|
|
5
|
-
module Generators
|
|
6
|
-
|
|
7
|
-
class BundleGenerator < Rails::Generators::Base
|
|
8
|
-
|
|
9
|
-
desc 'Bundle all amp-html generators.'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class_option :split, desc: 'Keep an application layout without AMP', type: :boolean, default: false, aliases: '-s'
|
|
13
|
-
class_option :format, desc: 'Set the views format. Defaults to `html`', type: :string, aliases: '-f'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# CONFIGURATION
|
|
17
|
-
class_option :name, desc: 'Set the name of your app', type: :string, default: "Hello AMP", aliases: '-n'
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# ASSETS
|
|
21
|
-
class_option :stylesheets, desc: 'Generate stylesheet assets', type: :boolean, default: false, aliases: '-st'
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# COMPONENTS
|
|
25
|
-
class_option :all, desc: 'Install all AMP-HTML components', type: :boolean, default: false, aliases: '-a'
|
|
26
|
-
|
|
27
|
-
class_option :analytics, desc: 'Install the AMP-HTML Analytics Component', type: :boolean, default: false
|
|
28
|
-
class_option :iframe, desc: 'Install the AMP-HTML Iframe Component', type: :boolean, default: false
|
|
29
|
-
class_option :notifications, desc: 'Install the AMP-HTML Notifications Component', type: :boolean, default: false
|
|
30
|
-
class_option :anim, desc: 'Install the AMP-HTML Animated Images Component', type: :boolean, default: false
|
|
31
|
-
class_option :ad, desc: 'Install the AMP-HTML Advertisements Component', type: :boolean, default: false
|
|
32
|
-
class_option :social, desc: 'Install the AMP-HTML Social Component', type: :boolean, default: false
|
|
33
|
-
class_option :javascript, desc: 'Install the AMP-HTML Javascript Component', type: :boolean, default: false
|
|
34
|
-
class_option :service_worker, desc: 'Install the AMP-HTML Service Worker Component', type: :boolean, default: false
|
|
35
|
-
class_option :lists, desc: 'Install the AMP-HTML Lists Component', type: :boolean, default: false
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def run_generators
|
|
40
|
-
generate "amp_html:install#{ ' -s' if options[:split] }#{ ' -f ' + options[:format] if options[:format] }#{ ' -n ' if options[:name] }'#{ options[:name] if options[:name] }'#{ ' -a' if options[:all] }#{ ' --anim' if options[:anim] }#{ ' --ad' if options[:ad] }#{ ' --iframe' if options[:iframe] }#{ ' --analytics' if options[:analytics] }#{ ' --notifications' if options[:notifications] }#{ ' --social' if options[:social] }"
|
|
41
|
-
generate "amp_html:helpers#{ ' -s' if options[:split] }"
|
|
42
|
-
generate "amp_html:views#{ ' -s' if options[:split] }#{ ' -f ' + options[:format] if options[:format] }#{ ' -a' if options[:all] }#{ ' --analytics' if options[:analytics] }"
|
|
43
|
-
generate "amp_html:assets#{ ' -st' if options[:stylesheets] }"
|
|
44
|
-
generate "amp_html:components#{ ' -s' if options[:split] }#{ ' -f ' + options[:format] if options[:format] }#{ ' -a' if options[:all] }#{ ' --anim' if options[:anim] }#{ ' --ad' if options[:ad] }#{ ' --iframe' if options[:iframe] }#{ ' --analytics' if options[:analytics] }#{ ' --notifications' if options[:notifications] }#{ ' --social' if options[:social] }#{ ' --javascript' if options[:javascript] }"
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
require 'rails/generators/base'
|
|
2
|
-
require 'thor'
|
|
3
|
-
|
|
4
|
-
module AmpHtml
|
|
5
|
-
module Generators
|
|
6
|
-
|
|
7
|
-
class ComponentsGenerator < Rails::Generators::Base
|
|
8
|
-
|
|
9
|
-
source_root File.expand_path '../../templates/components', __FILE__
|
|
10
|
-
desc 'Install AMP-HTML components.'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class_option :split, desc: 'Keep an application layout without AMP', type: :boolean, default: false, aliases: '-s'
|
|
14
|
-
class_option :format, desc: 'Set the views format. Defaults to `html`', type: :string, aliases: '-f'
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
# COMPONENTS
|
|
18
|
-
class_option :all, desc: 'Install all AMP-HTML components', type: :boolean, default: false, aliases: '-a'
|
|
19
|
-
|
|
20
|
-
class_option :analytics, desc: 'Install the AMP-HTML Analytics Component', type: :boolean, default: false
|
|
21
|
-
class_option :iframe, desc: 'Install the AMP-HTML Iframe Component', type: :boolean, default: false
|
|
22
|
-
class_option :notifications, desc: 'Install the AMP-HTML Notifications Component', type: :boolean, default: false
|
|
23
|
-
class_option :anim, desc: 'Install the AMP-HTML Animated Images Component', type: :boolean, default: false
|
|
24
|
-
class_option :ad, desc: 'Install the AMP-HTML Advertisements Component', type: :boolean, default: false
|
|
25
|
-
class_option :social, desc: 'Install the AMP-HTML Social Component', type: :boolean, default: false
|
|
26
|
-
class_option :javascript, desc: 'Install the AMP-HTML Javascript Component', type: :boolean, default: false
|
|
27
|
-
class_option :service_worker, desc: 'Install the AMP-HTML Service Worker Component', type: :boolean, default: false
|
|
28
|
-
class_option :lists, desc: 'Install the AMP-HTML Lists Component', type: :boolean, default: false
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def create_views
|
|
34
|
-
template 'views/_components.html.erb', "app/views/application/amp/_components.#{pick_format}.erb"
|
|
35
|
-
|
|
36
|
-
FileUtils.rm_rf 'app/views/application/amp/components'
|
|
37
|
-
template 'views/_google_analytics.html.erb', "app/views/application/amp/components/_google_analytics.#{pick_format}.erb" if options[:all] || options[:analytics] || options[:notifications]
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def create_helpers
|
|
41
|
-
FileUtils.rm_rf 'app/helpers/amp/components'
|
|
42
|
-
template 'helpers/analytics_tag_helper.rb', "app/helpers/amp/components/analytics_tag_helper.rb" if options[:all] || options[:analytics] || options[:notifications]
|
|
43
|
-
template 'helpers/iframe_tag_helper.rb', "app/helpers/amp/components/iframe_tag_helper.rb" if options[:all] || options[:iframe] || options[:javascript] || options[:service_worker]
|
|
44
|
-
template 'helpers/notification_tag_helper.rb', "app/helpers/amp/components/notification_tag_helper.rb" if options[:all] || options[:notifications]
|
|
45
|
-
template 'helpers/anim_tag_helper.rb', "app/helpers/amp/components/anim_tag_helper.rb" if options[:all] || options[:anim]
|
|
46
|
-
template 'helpers/ad_tag_helper.rb', "app/helpers/amp/components/ad_tag_helper.rb" if options[:all] || options[:ad]
|
|
47
|
-
template 'helpers/social_tag_helper.rb', "app/helpers/amp/components/social_tag_helper.rb" if options[:all] || options[:social]
|
|
48
|
-
template 'helpers/javascript_tag_helper.rb', "app/helpers/amp/components/javascript_tag_helper.rb" if options[:all] || options[:javascript]
|
|
49
|
-
template 'helpers/serviceworker_tag_helper.rb', "app/helpers/amp/components/serviceworker_tag_helper.rb" if options[:all] || options[:service_worker]
|
|
50
|
-
template 'helpers/lists_tag_helper.rb', "app/helpers/amp/components/lists_tag_helper.rb" if options[:all] || options[:lists]
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def create_assets
|
|
54
|
-
template 'assets/javascripts/application.js', 'app/assets/javascripts/amp/application.js' if options[:all] || options[:javascript]
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def create_files
|
|
58
|
-
template 'public/remote.html', 'public/remote.html' if options[:all] || options[:ad]
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def show_readme
|
|
62
|
-
readme 'README.md'
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
private
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def pick_format
|
|
70
|
-
if options[:format]
|
|
71
|
-
options[:format]
|
|
72
|
-
else
|
|
73
|
-
if options[:split]
|
|
74
|
-
'amp'
|
|
75
|
-
else
|
|
76
|
-
'html'
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
require 'rails/generators/base'
|
|
2
|
-
require 'thor'
|
|
3
|
-
|
|
4
|
-
module AmpHtml
|
|
5
|
-
module Generators
|
|
6
|
-
|
|
7
|
-
class HelpersGenerator < Rails::Generators::Base
|
|
8
|
-
|
|
9
|
-
source_root File.expand_path '../../templates/helpers', __FILE__
|
|
10
|
-
desc 'Generate AMP Tag Helpers. Run with --split to keep a version without AMP.'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class_option :split, desc: 'Keep an application layout without AMP', type: :boolean, default: false, aliases: '-s'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def create_helpers
|
|
18
|
-
template 'asset_tag_helper.rb.erb', 'app/helpers/asset_tag_helper.rb'
|
|
19
|
-
template 'form_tag_helper.rb.erb', 'app/helpers/form_tag_helper.rb'
|
|
20
|
-
|
|
21
|
-
directory 'amp', 'app/helpers/amp'
|
|
22
|
-
template 'amp_tag_helper.rb.erb', 'app/helpers/amp/amp_tag_helper.rb'
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def show_readme
|
|
26
|
-
readme 'README.md'
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
require 'rails/generators/base'
|
|
2
|
-
require 'thor'
|
|
3
|
-
|
|
4
|
-
module AmpHtml
|
|
5
|
-
module Generators
|
|
6
|
-
|
|
7
|
-
class InstallGenerator < Rails::Generators::Base
|
|
8
|
-
|
|
9
|
-
source_root File.expand_path '../../templates/install', __FILE__
|
|
10
|
-
desc 'Install AMP-HTML. Run with --split to keep a version without AMP.'
|
|
11
|
-
|
|
12
|
-
class_option :only_initializer, desc: 'Only generate initializer', type: :boolean, default: false
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class_option :split, desc: 'Keep an application layout without AMP', type: :boolean, default: false, aliases: '-s'
|
|
16
|
-
class_option :format, desc: 'Set the views format. Defaults to `html`', type: :string, aliases: '-f'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
# CONFIGURATION
|
|
20
|
-
class_option :name, desc: 'Set the name of your app', type: :string, default: 'Hello AMP', aliases: '-n'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# COMPONENTS
|
|
24
|
-
class_option :all, desc: 'Install all AMP-HTML components', type: :boolean, default: false, aliases: '-a'
|
|
25
|
-
|
|
26
|
-
class_option :analytics, desc: 'Install the AMP-HTML Analytics Component', type: :boolean, default: false
|
|
27
|
-
class_option :iframe, desc: 'Install the AMP-HTML Iframe Component', type: :boolean, default: false
|
|
28
|
-
class_option :notifications, desc: 'Install the AMP-HTML Notifications Component', type: :boolean, default: false
|
|
29
|
-
class_option :anim, desc: 'Install the AMP-HTML Animated Images Component', type: :boolean, default: false
|
|
30
|
-
class_option :ad, desc: 'Install the AMP-HTML Advertisements Component', type: :boolean, default: false
|
|
31
|
-
class_option :social, desc: 'Install the AMP-HTML Social Component', type: :boolean, default: false
|
|
32
|
-
class_option :javascript, desc: 'Install the AMP-HTML Javascript Component', type: :boolean, default: false
|
|
33
|
-
class_option :service_worker, desc: 'Install the AMP-HTML Service Worker Component', type: :boolean, default: false
|
|
34
|
-
class_option :lists, desc: 'Install the AMP-HTML Lists Component', type: :boolean, default: false
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def create_configuration
|
|
39
|
-
template 'amp-html.yml.erb', 'config/amp-html.yml' unless options[:only_initializer]
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def create_initializer
|
|
43
|
-
template 'amp-html.rb.erb', 'config/initializers/amp-html.rb'
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def show_readme
|
|
47
|
-
readme 'README.md'
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
require 'rails/generators/base'
|
|
2
|
-
require 'thor'
|
|
3
|
-
|
|
4
|
-
module AmpHtml
|
|
5
|
-
module Generators
|
|
6
|
-
|
|
7
|
-
class ViewsGenerator < Rails::Generators::Base
|
|
8
|
-
|
|
9
|
-
source_root File.expand_path '../../templates/views', __FILE__
|
|
10
|
-
desc 'Updates views to ensure compatibility with AMP. Run with --split to keep a version without AMP.'
|
|
11
|
-
|
|
12
|
-
class_option :only_resources, desc: 'Only generate resources', type: :boolean, default: false
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class_option :split, desc: 'Keep an application layout without AMP', type: :boolean, default: false, aliases: '-s'
|
|
16
|
-
class_option :format, desc: 'Set the views format. Defaults to `html`', type: :string, aliases: '-f'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
# DEEP INTEGRATION COMPONENTS
|
|
20
|
-
class_option :all, desc: 'Install all AMP-HTML components', type: :boolean, default: false, aliases: '-a'
|
|
21
|
-
|
|
22
|
-
class_option :analytics, desc: 'Install the AMP-HTML Analytics Component', type: :boolean, default: false
|
|
23
|
-
class_option :javascript, desc: 'Install the AMP-HTML Javascript Component', type: :boolean, default: false
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def create_views
|
|
29
|
-
template 'application/_resources.html.erb', "app/views/application/amp/_resources.#{pick_format}.erb"
|
|
30
|
-
template 'application/_head.html.erb', "app/views/application/amp/_head.#{pick_format}.erb" unless options[:only_resources]
|
|
31
|
-
template 'application/_schema.html.erb', "app/views/application/amp/_schema.#{pick_format}.erb" unless options[:only_resources]
|
|
32
|
-
template 'application.html.erb', "app/views/layouts/application.#{pick_format}.erb" unless options[:only_resources]
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def create_mime_types
|
|
36
|
-
template 'config/mime_types.rb', 'config/initializers/mime_types.rb' unless options[:only_resources]
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def show_readme
|
|
40
|
-
readme 'README.md'
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
private
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def pick_format
|
|
48
|
-
if options[:format]
|
|
49
|
-
options[:format]
|
|
50
|
-
else
|
|
51
|
-
if options[:split]
|
|
52
|
-
'amp'
|
|
53
|
-
else
|
|
54
|
-
'html'
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
end
|