amp-html 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +7 -0
  2. data/.github/issue_template.md +16 -0
  3. data/.github/pull_request_template.md +21 -0
  4. data/.gitignore +13 -0
  5. data/.travis.yml +4 -0
  6. data/CHANGELOG.md +302 -0
  7. data/CONTRIBUTING.md +1 -0
  8. data/DEPRECATIONS.md +9 -0
  9. data/Gemfile +12 -0
  10. data/Gemfile.lock +162 -0
  11. data/INSTALL.md +1 -0
  12. data/LICENSE +21 -0
  13. data/OWNERS.yaml +1 -0
  14. data/README.md +192 -0
  15. data/Rakefile +6 -0
  16. data/amp-html.gemspec +29 -0
  17. data/bin/amp-html +4 -0
  18. data/lib/amp_html.rb +27 -0
  19. data/lib/amp_html/cli.rb +113 -0
  20. data/lib/amp_html/components/docs/README.md +101 -0
  21. data/lib/amp_html/components/docs/ad.md +83 -0
  22. data/lib/amp_html/components/docs/analytics.md +131 -0
  23. data/lib/amp_html/components/docs/anim.md +66 -0
  24. data/lib/amp_html/components/docs/fonts.md +63 -0
  25. data/lib/amp_html/components/docs/forms.md +79 -0
  26. data/lib/amp_html/components/docs/iframe.md +62 -0
  27. data/lib/amp_html/components/docs/javascript.md +71 -0
  28. data/lib/amp_html/components/docs/lists.md +168 -0
  29. data/lib/amp_html/components/docs/media.md +52 -0
  30. data/lib/amp_html/components/docs/mustache.md +46 -0
  31. data/lib/amp_html/components/docs/notifications.md +0 -0
  32. data/lib/amp_html/components/docs/schema.md +80 -0
  33. data/lib/amp_html/components/docs/service_worker.md +60 -0
  34. data/lib/amp_html/components/docs/social.md +130 -0
  35. data/lib/amp_html/components/docs/stylesheets.md +50 -0
  36. data/lib/amp_html/components/help.rb +19 -0
  37. data/lib/amp_html/components/install.rb +34 -0
  38. data/lib/amp_html/components/templates/ERROR.md +5 -0
  39. data/lib/amp_html/components/templates/README.md +12 -0
  40. data/lib/amp_html/configuration.rb +170 -0
  41. data/lib/amp_html/configuration/docs/README.md +0 -0
  42. data/lib/amp_html/configuration/help.rb +11 -0
  43. data/lib/amp_html/helpers/docs/README.md +98 -0
  44. data/lib/amp_html/helpers/docs/amp.md +0 -0
  45. data/lib/amp_html/helpers/docs/amp_ad.md +86 -0
  46. data/lib/amp_html/helpers/docs/amp_analytics.md +76 -0
  47. data/lib/amp_html/helpers/docs/amp_anim.md +68 -0
  48. data/lib/amp_html/helpers/docs/amp_audio.md +54 -0
  49. data/lib/amp_html/helpers/docs/amp_auto_ads.md +43 -0
  50. data/lib/amp_html/helpers/docs/amp_close_user_notification_button.md +0 -0
  51. data/lib/amp_html/helpers/docs/amp_css.md +37 -0
  52. data/lib/amp_html/helpers/docs/amp_css_link.md +0 -0
  53. data/lib/amp_html/helpers/docs/amp_custom_ad.md +0 -0
  54. data/lib/amp_html/helpers/docs/amp_document_link.md +0 -0
  55. data/lib/amp_html/helpers/docs/amp_embed.md +86 -0
  56. data/lib/amp_html/helpers/docs/amp_facebook.md +70 -0
  57. data/lib/amp_html/helpers/docs/amp_fallback.md +47 -0
  58. data/lib/amp_html/helpers/docs/amp_font.md +0 -0
  59. data/lib/amp_html/helpers/docs/amp_font_link.md +0 -0
  60. data/lib/amp_html/helpers/docs/amp_form.md +0 -0
  61. data/lib/amp_html/helpers/docs/amp_form_response.md +0 -0
  62. data/lib/amp_html/helpers/docs/amp_gfycat.md +0 -0
  63. data/lib/amp_html/helpers/docs/amp_global_css.md +0 -0
  64. data/lib/amp_html/helpers/docs/amp_google_analytics.md +0 -0
  65. data/lib/amp_html/helpers/docs/amp_google_font.md +0 -0
  66. data/lib/amp_html/helpers/docs/amp_head.md +0 -0
  67. data/lib/amp_html/helpers/docs/amp_html_doctype.md +0 -0
  68. data/lib/amp_html/helpers/docs/amp_iframe.md +0 -0
  69. data/lib/amp_html/helpers/docs/amp_image.md +0 -0
  70. data/lib/amp_html/helpers/docs/amp_input.md +0 -0
  71. data/lib/amp_html/helpers/docs/amp_instagram.md +0 -0
  72. data/lib/amp_html/helpers/docs/amp_js.md +0 -0
  73. data/lib/amp_html/helpers/docs/amp_link.md +0 -0
  74. data/lib/amp_html/helpers/docs/amp_list.md +0 -0
  75. data/lib/amp_html/helpers/docs/amp_live_list.md +0 -0
  76. data/lib/amp_html/helpers/docs/amp_live_list_items.md +0 -0
  77. data/lib/amp_html/helpers/docs/amp_live_list_pagination.md +0 -0
  78. data/lib/amp_html/helpers/docs/amp_live_list_update.md +0 -0
  79. data/lib/amp_html/helpers/docs/amp_mustache.md +0 -0
  80. data/lib/amp_html/helpers/docs/amp_pin_it.md +0 -0
  81. data/lib/amp_html/helpers/docs/amp_pin_widget.md +0 -0
  82. data/lib/amp_html/helpers/docs/amp_pinterest_follow.md +0 -0
  83. data/lib/amp_html/helpers/docs/amp_pixel.md +0 -0
  84. data/lib/amp_html/helpers/docs/amp_placeholder.md +0 -0
  85. data/lib/amp_html/helpers/docs/amp_reddit.md +0 -0
  86. data/lib/amp_html/helpers/docs/amp_resources.md +0 -0
  87. data/lib/amp_html/helpers/docs/amp_selector.md +0 -0
  88. data/lib/amp_html/helpers/docs/amp_serviceworker.md +0 -0
  89. data/lib/amp_html/helpers/docs/amp_social_share.md +0 -0
  90. data/lib/amp_html/helpers/docs/amp_soundcloud.md +0 -0
  91. data/lib/amp_html/helpers/docs/amp_twitter.md +0 -0
  92. data/lib/amp_html/helpers/docs/amp_user_notification.md +0 -0
  93. data/lib/amp_html/helpers/docs/amp_video.md +0 -0
  94. data/lib/amp_html/helpers/docs/amp_video_ad.md +0 -0
  95. data/lib/amp_html/helpers/docs/amp_vine.md +0 -0
  96. data/lib/amp_html/helpers/docs/amp_youtube.md +0 -0
  97. data/lib/amp_html/helpers/docs/audio_tag.md +0 -0
  98. data/lib/amp_html/helpers/docs/canonical_document_link.md +0 -0
  99. data/lib/amp_html/helpers/docs/form_tag.md +0 -0
  100. data/lib/amp_html/helpers/docs/image_tag.md +0 -0
  101. data/lib/amp_html/helpers/docs/input_tag.md +0 -0
  102. data/lib/amp_html/helpers/docs/javascript_include_tag.md +0 -0
  103. data/lib/amp_html/helpers/docs/noscript_tag.md +0 -0
  104. data/lib/amp_html/helpers/docs/schema_tag.md +0 -0
  105. data/lib/amp_html/helpers/docs/stylesheet_link_tag.md +0 -0
  106. data/lib/amp_html/helpers/docs/video_tag.md +0 -0
  107. data/lib/amp_html/helpers/help.rb +23 -0
  108. data/lib/amp_html/root.rb +7 -0
  109. data/lib/amp_html/test.rb +169 -0
  110. data/lib/amp_html/test/help.rb +11 -0
  111. data/lib/amp_html/test/templates/README.md +43 -0
  112. data/lib/amp_html/test/templates/css/!important.md +1 -0
  113. data/lib/amp_html/test/templates/css/-amp-.md +1 -0
  114. data/lib/amp_html/test/templates/css/-moz-binding.md +1 -0
  115. data/lib/amp_html/test/templates/css/@import.md +1 -0
  116. data/lib/amp_html/test/templates/css/behavior.md +1 -0
  117. data/lib/amp_html/test/templates/css/filter.md +1 -0
  118. data/lib/amp_html/test/templates/css/i-amp-.md +1 -0
  119. data/lib/amp_html/test/templates/css/overflow.md +1 -0
  120. data/lib/amp_html/test/templates/html/applet.md +1 -0
  121. data/lib/amp_html/test/templates/html/audio.md +1 -0
  122. data/lib/amp_html/test/templates/html/base.md +1 -0
  123. data/lib/amp_html/test/templates/html/embed.md +1 -0
  124. data/lib/amp_html/test/templates/html/frame.md +1 -0
  125. data/lib/amp_html/test/templates/html/frameset.md +1 -0
  126. data/lib/amp_html/test/templates/html/http-equiv.md +1 -0
  127. data/lib/amp_html/test/templates/html/iframe.md +1 -0
  128. data/lib/amp_html/test/templates/html/img.md +1 -0
  129. data/lib/amp_html/test/templates/html/javascript_include_tag.md +1 -0
  130. data/lib/amp_html/test/templates/html/object.md +1 -0
  131. data/lib/amp_html/test/templates/html/onclick.md +1 -0
  132. data/lib/amp_html/test/templates/html/onmousehover.md +1 -0
  133. data/lib/amp_html/test/templates/html/param.md +1 -0
  134. data/lib/amp_html/test/templates/html/stylesheet_link_tag.md +1 -0
  135. data/lib/amp_html/test/templates/html/video.md +1 -0
  136. data/lib/amp_html/test/templates/markup/!doctype.md +1 -0
  137. data/lib/amp_html/test/templates/markup/amp_document_link.md +1 -0
  138. data/lib/amp_html/test/templates/markup/amp_head.md +1 -0
  139. data/lib/amp_html/test/templates/markup/amp_html_doctype.md +1 -0
  140. data/lib/amp_html/test/templates/markup/canonical_document_link.md +1 -0
  141. data/lib/amp_html/test/templates/markup/head_body.md +1 -0
  142. data/lib/amp_html/test/templates/markup/html.md +1 -0
  143. data/lib/amp_html/test/templates/markup/meta_viewport.md +1 -0
  144. data/lib/amp_html/validate.rb +46 -0
  145. data/lib/amp_html/validate/help.rb +11 -0
  146. data/lib/amp_html/validate/templates/README.md +32 -0
  147. data/lib/amp_html/version.rb +13 -0
  148. data/lib/generators/amphtml/assets_generator.rb +31 -0
  149. data/lib/generators/amphtml/bundle_generator.rb +50 -0
  150. data/lib/generators/amphtml/components_generator.rb +84 -0
  151. data/lib/generators/amphtml/helpers_generator.rb +32 -0
  152. data/lib/generators/amphtml/install_generator.rb +53 -0
  153. data/lib/generators/amphtml/views_generator.rb +62 -0
  154. data/lib/generators/templates/assets/README.md +0 -0
  155. data/lib/generators/templates/assets/stylesheets/application.scss +15 -0
  156. data/lib/generators/templates/components/README.md +0 -0
  157. data/lib/generators/templates/components/assets/javascripts/application.js +15 -0
  158. data/lib/generators/templates/components/helpers/ad_tag_helper.rb +83 -0
  159. data/lib/generators/templates/components/helpers/analytics_tag_helper.rb +30 -0
  160. data/lib/generators/templates/components/helpers/anim_tag_helper.rb +42 -0
  161. data/lib/generators/templates/components/helpers/iframe_tag_helper.rb +27 -0
  162. data/lib/generators/templates/components/helpers/javascript_tag_helper.rb +12 -0
  163. data/lib/generators/templates/components/helpers/lists_tag_helper.rb +82 -0
  164. data/lib/generators/templates/components/helpers/notification_tag_helper.rb +16 -0
  165. data/lib/generators/templates/components/helpers/serviceworker_tag_helper.rb +15 -0
  166. data/lib/generators/templates/components/helpers/social_tag_helper.rb +228 -0
  167. data/lib/generators/templates/components/public/remote.html +28 -0
  168. data/lib/generators/templates/components/views/_components.html.erb +141 -0
  169. data/lib/generators/templates/components/views/_google_analytics.html.erb +23 -0
  170. data/lib/generators/templates/helpers/README.md +1 -0
  171. data/lib/generators/templates/helpers/amp/fallback_tag_helper.rb +16 -0
  172. data/lib/generators/templates/helpers/amp/font_tag_helper.rb +37 -0
  173. data/lib/generators/templates/helpers/amp/link_tag_helper.rb +11 -0
  174. data/lib/generators/templates/helpers/amp/mustache_tag_helper.rb +13 -0
  175. data/lib/generators/templates/helpers/amp/noscript_tag_helper.rb +13 -0
  176. data/lib/generators/templates/helpers/amp/placeholder_tag_helper.rb +16 -0
  177. data/lib/generators/templates/helpers/amp/schema_tag_helper.rb +16 -0
  178. data/lib/generators/templates/helpers/amp/stylesheets_tag_helper.rb +21 -0
  179. data/lib/generators/templates/helpers/amp_tag_helper.rb.erb +65 -0
  180. data/lib/generators/templates/helpers/asset_tag_helper.rb.erb +119 -0
  181. data/lib/generators/templates/helpers/form_tag_helper.rb.erb +79 -0
  182. data/lib/generators/templates/install/README.md +1 -0
  183. data/lib/generators/templates/install/amphtml.rb.erb +19 -0
  184. data/lib/generators/templates/install/amphtml.yml.erb +189 -0
  185. data/lib/generators/templates/views/README.md +1 -0
  186. data/lib/generators/templates/views/application.html.erb +71 -0
  187. data/lib/generators/templates/views/application/_head.html.erb +47 -0
  188. data/lib/generators/templates/views/application/_resources.html.erb +16 -0
  189. data/lib/generators/templates/views/application/_schema.html.erb +6 -0
  190. data/lib/generators/templates/views/config/mime_types.rb +8 -0
  191. metadata +294 -0
@@ -0,0 +1,130 @@
1
+
2
+ # [Components](https://github.com/slooob/amp-html/tree/master/lib/amp-html/components/docs) / Social BETA
3
+
4
+
5
+ ## Information
6
+
7
+ The AMP-HTML Social Component allows to embed content of various social-platforms and more in an AMP document.
8
+
9
+ ---
10
+
11
+ ### Quick info
12
+
13
+ #### Latest component release: 0.7.0 (Pre-release) - 2017-03-21
14
+
15
+ [**Changelog for version 0.7.0**](https://github.com/slooob/amp-html/blob/master/CHANGELOG.md#070-pre-release---2017-03-21)
16
+
17
+ #### Requirements
18
+
19
+ The Social Component does not depend on any other components.
20
+
21
+ #### Dependents
22
+
23
+ No other components depend on the Social Component.
24
+
25
+ #### [DeepIntegration](https://github.com/slooob/amp-html/tree/master/lib/amp-html/components/docs#deepintegration-components): Enabled
26
+
27
+ #### [Availability](https://github.com/slooob/amp-html/tree/master/lib/amp-html/components/docs#availability-of-components): Installable
28
+
29
+ ---
30
+
31
+ ## Installation
32
+
33
+ Run in the command line:
34
+
35
+ amp-html install social
36
+
37
+ Now you are ready to use the Social Component.
38
+
39
+ To learn more about this component, without opening the documentation, run:
40
+
41
+ amp-html component social
42
+
43
+
44
+ ## Configuration
45
+
46
+ The Social Component allows you to specify a default provider for your app.
47
+
48
+ In your AMP-HTML configuration (`config/amp-html.yml`) search for the section of the Social Component.
49
+
50
+ There you can set your default network like so:
51
+
52
+ default_provider: twitter
53
+
54
+ You can always override this provider default by passing a different provider to your social integration in your view.
55
+
56
+ A list of all by AMP preconfigured providers: https://github.com/ampproject/amp-html/blob/master/extensions/amp-social-share/0.1/amp-social-share-config.js
57
+
58
+ To use a provider that is not preconfigured by AMP, specify the default_data_share_endpoint:
59
+
60
+ default_provider: whatsapp
61
+ default_data_share_endpoint: whatsapp://send
62
+
63
+
64
+ ## Usage
65
+
66
+ **The AMP-HTML Social Component introduces a lot of seperate helpers. To take a look at the functionality of each of them, take a look at their references, lnked below.**
67
+
68
+ ### Examples: Embed a Tweet
69
+
70
+ You can embed a tweet like so:
71
+
72
+ <%= amp_twitter(tweet_id) %>
73
+ <%= amp_twitter("585110598171631616", width: 486, height: 657, data: { cards: "hidden" }) %>
74
+
75
+ It also takes a block:
76
+
77
+ <%= amp_twitter("585110598171631616", width: 486, height: 657, data: { cards: "hidden" }) do %>
78
+ <%= amp_placeholder("blockquote", class: "twitter-tweet" data: { lang: "en" }) do %>
79
+ <p lang="en" dir="ltr">The story how I became what some people would call a frontend engineer and an exploration into what that even means<a href="https://t.co/HrVz4cGMWG">https://t.co/HrVz4cGMWG</a></p>&mdash; Malte Ubl (@cramforce) <a href="https://twitter.com/cramforce/status/585110598171631616">April 6, 2015</a>
80
+ <% end %>
81
+ <% end %>
82
+
83
+ Learn more about the `amp_twitter` helper in the dedicated reference linked below.
84
+
85
+ **References:** [`amp_placeholder`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_placeholder.md)
86
+
87
+ ### Examples: Social Share
88
+
89
+ It is that easy to create a social share button:
90
+
91
+ <%= amp_social_share(type) %>
92
+ <%= amp_social_share("twitter") %>
93
+
94
+ It assumes that the current document canonical url is the URL you want to share and the page title is the text you want to share.
95
+
96
+ When you want to pass parameters to the share endpoint, you can specify `data-param-<attribute>` that will be appended to the share endpoint.
97
+
98
+ <%= amp_social_share("linkedin", width: "60", height: "44", data: { param: { text: "Hello world", url: "https://railsamp.com/" } }) %>
99
+
100
+ If the provider is not preconfigured ([preconfigured providers](https://github.com/ampproject/amp-html/blob/master/extensions/amp-social-share/0.1/amp-social-share-config.js)):
101
+
102
+ <%= amp_social_share("whatsapp", width: "60", height: "44", data: { share: { endpoint: "whatsapp://send" } param: { text: "Check out this article: TITLE - CANONICAL_URL" } }) %>
103
+
104
+ It also takes a block:
105
+
106
+ <%= amp_social_share("whatsapp", width: "60", height: "44", data: { share: { endpoint: "whatsapp://send" } param: { text: "Check out this article: TITLE - CANONICAL_URL" } }) do %>
107
+ Share on Whatsapp
108
+ <% end %>
109
+
110
+ Learn more about the `amp_social_share` helper in the dedicated reference linked below.
111
+
112
+ **References:** [AMP HTML URL Variable Substitutions](https://github.com/ampproject/amp-html/blob/master/spec/amp-var-substitutions.md)
113
+
114
+
115
+ ### Helpers
116
+
117
+ The following helpers are usable with the Social Component of AMP-HTML
118
+
119
+ * [`amp_twitter`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_twitter.md)
120
+ * [`amp_instagram`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_instagram.md)
121
+ * [`amp_facebook`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_facebook.md)
122
+ * [`amp_youtube`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_youtube.md)
123
+ * [`amp_reddit`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_reddit.md)
124
+ * [`amp_social_share`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_social_share.md)
125
+ * [`amp_soundcloud`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_soundcloud.md)
126
+ * [`amp_vine`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_vine.md)
127
+ * [`amp_gfycat`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_gfycat.md)
128
+ * [`amp_pin_it`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_pin_it.md)
129
+ * [`amp_pin_widget`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_pin_widget.md)
130
+ * [`amp_pinterest_follow`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_pinterest_follow.md)
@@ -0,0 +1,50 @@
1
+
2
+ # [Components](https://github.com/slooob/amp-html/tree/master/lib/amp-html/components/docs) / Stylesheets
3
+
4
+
5
+ ## Information
6
+
7
+ The AMP-HTML Stylesheets Component allows the use of stylesheets in AMP documents.
8
+
9
+ ---
10
+
11
+ ### Quick info
12
+
13
+ #### Latest component release: 0.6.1 (Pre-release) - 2017-03-19
14
+
15
+ [**Changelog for version 0.6.1**](https://github.com/slooob/amp-html/blob/master/CHANGELOG.md#061-pre-release---2017-03-19)
16
+
17
+ #### Requirements
18
+
19
+ The Stylesheets Component does not depend on any other components.
20
+
21
+ #### Dependents
22
+
23
+ No other components depend on the Stylesheets Component.
24
+
25
+ #### [DeepIntegration](https://github.com/slooob/amp-html/tree/master/lib/amp-html/components/docs#deepintegration-components): Disabled
26
+
27
+ #### [Availability](https://github.com/slooob/amp-html/tree/master/lib/amp-html/components/docs#availability-of-components): Build-in
28
+
29
+ ---
30
+
31
+ ## Usage
32
+
33
+ By default every stylesheet (`.scss`) file inside of your `app/assets/stylesheets/amp` (depending on your AMP-HTML configuration) directory is included in your application layout.
34
+
35
+ You can include some view specific styles utilizing the `amp_css` helper in your `<head>` tag:
36
+
37
+ <%= amp_css do %>
38
+ /* Your CSS here */
39
+ <% end %>
40
+
41
+ For a detailed reference on the `amp_css` helper, follow the link below.
42
+
43
+
44
+ ### Helpers
45
+
46
+ The following helpers are usable with the Stylesheets Component of AMP-HTML
47
+
48
+ * [`amp_css`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_css.md)
49
+ * [`amp_css_link` (in development)](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_css_link.md)
50
+ * [`amp_global_css` (deprecated)](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_global_css.md)
@@ -0,0 +1,19 @@
1
+ module AmpHtml
2
+ module Components
3
+ class Help
4
+
5
+ def self.all
6
+ puts IO.read File.join AmpHtml.root, 'amp_html', 'components', 'docs', 'README.md'
7
+ end
8
+
9
+ def self.component name
10
+ begin
11
+ puts IO.read File.join AmpHtml.root, 'amp_html', 'components', 'docs', "#{name}.md"
12
+ rescue Exception
13
+ warn 'Component is not available'
14
+ end
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,34 @@
1
+ module AmpHtml
2
+ module Components
3
+
4
+ COMPONENTS = ['analytics', 'iframe', 'notifications', 'anim', 'ad', 'social', 'javascript', 'service_worker', 'lists']
5
+
6
+ class Install
7
+
8
+ def self.bundle
9
+ success1 = system "rails g amp-html:components#{ ' -s' if AmpHtml.split_view }#{ ' -f ' + AmpHtml.raw_format if AmpHtml.raw_format }#{ ' --analytics' if AmpHtml.components && AmpHtml.components.include?('analytics') || AmpHtml.components && AmpHtml.components.include?('notifications') }#{ ' --iframe' if AmpHtml.components && AmpHtml.components.include?('iframe') || AmpHtml.components && AmpHtml.components.include?('javascript') || AmpHtml.components && AmpHtml.components.include?('service_worker') }#{' --notifications' if AmpHtml.components && AmpHtml.components.include?('notifications') }#{ ' --anim' if AmpHtml.components && AmpHtml.components.include?('anim') }#{ ' --ad' if AmpHtml.components && AmpHtml.components.include?('ad') }#{ ' --social' if AmpHtml.components && AmpHtml.components.include?('social') }#{ ' --javascript' if (AmpHtml.components && AmpHtml.components.include?('javascript')) }#{ ' --service_worker' if (AmpHtml.components && AmpHtml.components.include?('service_worker')) }#{ ' --lists' if (AmpHtml.components && AmpHtml.components.include?('lists')) }"
10
+ success2 = system "rails g amp-html:install --only_initializer#{ ' --javascript' if (AmpHtml.components && AmpHtml.components.include?('javascript')) }"
11
+ if success1 && success2
12
+ puts IO.read File.join AmpHtml.root, 'amp_html', 'components', 'templates', 'README.md'
13
+ else
14
+ puts IO.read File.join AmpHtml.root, 'amp_html', 'components', 'templates', 'ERROR.md'
15
+ end
16
+ end
17
+
18
+ def self.install component
19
+ if COMPONENTS.include? component
20
+ success1 = system "rails g amp-html:install#{ ' -s' if AmpHtml.split_view }#{ ' -f ' + AmpHtml.raw_format if AmpHtml.raw_format }#{ ' --analytics' if (AmpHtml.components && AmpHtml.components.include?('analytics')) || AmpHtml.components && AmpHtml.components.include?('notifications') || component == 'analytics' || component == 'notifications' }#{ ' --iframe' if (AmpHtml.components && AmpHtml.components.include?('iframe')) || AmpHtml.components && AmpHtml.components.include?('javascript') || AmpHtml.components && AmpHtml.components.include?('service_worker') || component == 'iframe' || component == 'javascript' || component == 'service_worker' }#{' --notifications' if (AmpHtml.components && AmpHtml.components.include?('notifications')) || component == 'notifications' }#{ ' --anim' if (AmpHtml.components && AmpHtml.components.include?('anim')) || component == 'anim' }#{ ' --ad' if (AmpHtml.components && AmpHtml.components.include?('ad')) || component == 'ad' }#{ ' --social' if (AmpHtml.components && AmpHtml.components.include?('social')) || component == 'social' }#{ ' --javascript' if (AmpHtml.components && AmpHtml.components.include?('javascript')) || component == 'javascript' }#{ ' --service_worker' if (AmpHtml.components && AmpHtml.components.include?('service_worker')) || component == 'service_worker' }#{ ' --lists' if (AmpHtml.components && AmpHtml.components.include?('lists')) || component == 'lists' }"
21
+ success2 = system "rails g amp-html:components#{ ' -s' if AmpHtml.split_view }#{ ' -f ' + AmpHtml.raw_format if AmpHtml.raw_format }#{ ' --analytics' if (AmpHtml.components && AmpHtml.components.include?('analytics')) || AmpHtml.components && AmpHtml.components.include?('notifications') || component == 'analytics' || component == 'notifications' }#{ ' --iframe' if (AmpHtml.components && AmpHtml.components.include?('iframe')) || AmpHtml.components && AmpHtml.components.include?('javascript') || AmpHtml.components && AmpHtml.components.include?('service_worker') || component == 'iframe' || component == 'javascript' || component == 'service_worker' }#{' --notifications' if (AmpHtml.components && AmpHtml.components.include?('notifications')) || component == 'notifications' }#{ ' --anim' if (AmpHtml.components && AmpHtml.components.include?('anim')) || component == 'anim' }#{ ' --ad' if (AmpHtml.components && AmpHtml.components.include?('ad')) || component == 'ad' }#{ ' --social' if (AmpHtml.components && AmpHtml.components.include?('social')) || component == 'social' }#{ ' --javascript' if (AmpHtml.components && AmpHtml.components.include?('javascript')) || component == 'javascript' }#{ ' --service_worker' if (AmpHtml.components && AmpHtml.components.include?('service_worker')) || component == 'service_worker' }#{ ' --lists' if (AmpHtml.components && AmpHtml.components.include?('lists')) || component == 'lists' }"
22
+ success3 = system "rails g amp-html:views --only_resources#{ ' --javascript' if (AmpHtml.components && AmpHtml.components.include?('javascript')) || component == 'javascript' }"
23
+ if success1 && success2 && success3
24
+ puts "Successfully installed '#{component}' component!"
25
+ puts IO.read File.join AmpHtml.root, 'amp_html', 'components', 'templates', 'README.md'
26
+ else
27
+ puts IO.read File.join AmpHtml.root, 'amp_html', 'components', 'templates', 'ERROR.md'
28
+ end
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ **An error occurred while installing AMP-HTML components**
2
+
3
+ ---
4
+
5
+ Please visit "https://github.com/slooob/amp-html/issues" to report a bug.
@@ -0,0 +1,12 @@
1
+
2
+ **Your installation of AMP-HTML components completed successfully!**
3
+
4
+ You can now use the components specified in `config/amp-html.yml`.
5
+
6
+ ---
7
+
8
+ Learn more about AMP-HTML components: https://github.com/slooob/amp-html/tree/master/lib/amp-html/components/docs
9
+
10
+ Get help: https://github.com/slooob/amp-html/issues
11
+
12
+ View guides: https://github.com/slooob/amp-html/wiki/Guides
@@ -0,0 +1,170 @@
1
+ module AmpHtml
2
+
3
+ def self.default_format
4
+ config = get_config
5
+ if config.key :default_format
6
+ config[:default_format]
7
+ else
8
+ 'amp'
9
+ end
10
+ end
11
+ def self.raw_format
12
+ config = get_config
13
+ config[:default_format]
14
+ end
15
+
16
+ def self.fallback_format
17
+ config = get_config
18
+ config[:fallback_format]
19
+ end
20
+
21
+
22
+ def self.components
23
+ config = get_config
24
+ if config.key :components
25
+ config[:components]
26
+ else
27
+ nil
28
+ end
29
+ end
30
+
31
+
32
+ def self.split_view
33
+ config = get_config
34
+ if config.key :split_view
35
+ config[:split_view]
36
+ else
37
+ false
38
+ end
39
+ end
40
+
41
+
42
+ def self.assets_only_amp
43
+ config = get_config
44
+ if config.key(:assets) && config[:assets].key :only_amp
45
+ config[:assets][:only_amp]
46
+ else
47
+ if AmpHtml.split_view
48
+ false
49
+ else
50
+ true
51
+ end
52
+ end
53
+ end
54
+
55
+
56
+ def self.application_name
57
+ config = get_config
58
+ if config.key(:application) && config[:application].key :name
59
+ config[:application][:name]
60
+ else
61
+ Rails.application.class.parent
62
+ end
63
+ end
64
+ def self.application_type
65
+ config = get_config
66
+ if config.key(:application) && config[:application].key :type
67
+ config[:application][:type]
68
+ else
69
+ nil
70
+ end
71
+ end
72
+ def self.application_date_published
73
+ config = get_config
74
+ if config.key(:application) && config[:application].key :date_published
75
+ config[:application][:date_published]
76
+ else
77
+ DateTime.now
78
+ end
79
+ end
80
+ def self.application_image
81
+ config = get_config
82
+ if config.key(:application) && config[:application].key :image
83
+ config[:application][:image]
84
+ else
85
+ nil
86
+ end
87
+ end
88
+
89
+
90
+ def self.forms_selector
91
+ config = get_config
92
+ if config.key(:forms) && config[:forms].key :amp_selector
93
+ config[:forms][:amp_selector]
94
+ else
95
+ false
96
+ end
97
+ end
98
+
99
+
100
+ def self.analytics_default_vendor
101
+ config = get_config
102
+ if config.key(:analytics) && config[:analytics].key :default_vendor
103
+ config[:analytics][:default_vendor]
104
+ else
105
+ nil
106
+ end
107
+ end
108
+
109
+ def self.google_analytics_account
110
+ config = get_config
111
+ if config.key(:analytics) && config[:analytics].key(:google_analytics) && config[:analytics][:google_analytics].key :account
112
+ config[:analytics][:google_analytics][:account]
113
+ else
114
+ nil
115
+ end
116
+ end
117
+
118
+
119
+ def self.ad_default_network
120
+ config = get_config
121
+ if config.key(:ad) && config[:ad].key :default_network
122
+ config[:ad][:default_network]
123
+ else
124
+ nil
125
+ end
126
+ end
127
+
128
+ def self.auto_ads_default_network
129
+ config = get_config
130
+ if config.key(:ad) && config[:ad].key(:auto_ads) && config[:ad][:auto_ads].key :default_network
131
+ config[:ad][:auto_ads][:default_network]
132
+ else
133
+ nil
134
+ end
135
+ end
136
+
137
+
138
+ def self.social_share_default_provider
139
+ config = get_config
140
+ if config.key(:social) && config[:social].key(:share) && config[:social][:share].key :default_provider
141
+ config[:social][:share][:default_provider]
142
+ else
143
+ nil
144
+ end
145
+ end
146
+ def self.social_share_default_data_share_endpoint
147
+ config = get_config
148
+ if config.key(:social) && config[:social].key(:share) && config[:social][:share].key :default_data_share_endpoint
149
+ config[:social][:share][:default_data_share_endpoint]
150
+ else
151
+ nil
152
+ end
153
+ end
154
+
155
+
156
+ private
157
+
158
+
159
+ def self.get_config
160
+ require 'yaml'
161
+
162
+ begin
163
+ YAML.load_file('config/amp-html.yml')
164
+ rescue Exception
165
+ warn 'WARNING (AMP): You need to run `rails g amp-html:bundle` first.'
166
+ exit
167
+ end
168
+ end
169
+
170
+ end
@@ -0,0 +1,11 @@
1
+ module AmpHtml
2
+ module Configuration
3
+ class Help
4
+
5
+ def self.all
6
+ puts IO.read File.join AmpHtml.root, 'amp_html', 'configuration', 'docs', 'README.md'
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,98 @@
1
+
2
+ # AMP-HTML Helpers
3
+
4
+
5
+ ## About Helpers
6
+
7
+ AMP-HTML helpers are an easy way to use AMP specific tags and features in your Ruby on Rails views.
8
+
9
+ ### Takes a block?
10
+
11
+ Some helpers can "take a block", others cannot. If a helper can take a block, you can wrap it around of some other code-snippet:
12
+
13
+ <%= i_am_a_wrapper do %>
14
+ <%= i_am_inside_of_a_block %>
15
+ <% end %>
16
+
17
+ ### DeepIntegration Helpers
18
+
19
+ DeepIntegration helpers are parts of a [DeepIntegration component](https://github.com/slooob/amp-html/tree/master/lib/amp-html/components/docs#deepintegration-components).
20
+
21
+ ### Availability of Helpers
22
+
23
+ The availability of helpers summarizes whether a helper is included in the vanilla version of AMP-HTML or if it needs to be installed as a part of a [component](https://github.com/slooob/amp-html/tree/master/lib/amp-html/components/docs) in order to get used.
24
+
25
+ ---
26
+
27
+ ## Helpers Reference
28
+
29
+ Take a look at the references of the helpers of AMP-HTML.
30
+
31
+ ### Built-in
32
+
33
+ * [`amp_audio` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_audio.md)
34
+ * [`amp_css`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_css.md)
35
+ * [`amp_css_link` (in development)](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_css_link.md)
36
+ * [`amp_document_link` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_document_link.md)
37
+ * [`amp_fallback` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_fallback.md)
38
+ * [`amp_font_link` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_font_link.md)
39
+ * [`amp_form_response` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_form_response.md)
40
+ * [`amp_form` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_form.md)
41
+ * [`amp_global_css` (deprecated)](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_global_css.md)
42
+ * [`amp_google_font` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_google_font.md)
43
+ * [`amp_head`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_head.md)
44
+ * [`amp_html_doctype`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_html_doctype.md)
45
+ * [`amp_image` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_image.md)
46
+ * [`amp_input` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_input.md)
47
+ * [`amp_link` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_link.md)
48
+ * [`amp_placeholder` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_placeholder.md)
49
+ * [`amp_resources` (deprecated)](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_resources.md)
50
+ * [`amp_selector` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_selector.md)
51
+ * [`amp_serviceworker` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_serviceworker.md)
52
+ * [`amp_video` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_video.md)
53
+ * [`amp?` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp.md)
54
+ * [`audio_tag`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/audio_tag.md)
55
+ * [`canonical_document_link` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/canonical_document_link.md)
56
+ * [`form_tag`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/form_tag.md)
57
+ * [`image_tag`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/image_tag.md)
58
+ * [`input_tag`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/input_tag.md)
59
+ * [`javascript_include_tag`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/javascript_include_tag.md)
60
+ * [`noscript_tag`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/noscript_tag.md)
61
+ * [`schema_tag`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/schema_tag.md)
62
+ * [`stylesheet_link_tag`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/stylesheet_link_tag.md)
63
+ * [`video_tag`](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/video_tag.md)
64
+
65
+ ### Installable
66
+
67
+ * [`amp_ad` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_ad.md)
68
+ * [`amp_analytics` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_analytics.md)
69
+ * [`amp_anim` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_anim.md)
70
+ * [`amp_auto_ads` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_auto_ads.md)
71
+ * [`amp_close_user_notification_button` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_close_user_notification_button.md)
72
+ * [`amp_custom_ad` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_custom_ad.md)
73
+ * [`amp_embed` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_embed.md)
74
+ * [`amp_facebook` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_facebook.md)
75
+ * [`amp_font` (in development)](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_font.md)
76
+ * [`amp_gfycat` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_gfycat.md)
77
+ * [`amp_google_analytics` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_google_analytics.md)
78
+ * [`amp_iframe` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_iframe.md)
79
+ * [`amp_instagram` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_instagram.md)
80
+ * [`amp_js` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_js.md)
81
+ * [`amp_list` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_list.md)
82
+ * [`amp_live_list_items` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_live_list_items.md)
83
+ * [`amp_live_list_pagination` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_live_list_pagination.md)
84
+ * [`amp_live_list_update` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_live_list_update.md)
85
+ * [`amp_live_list` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_live_list.md)
86
+ * [`amp_mustache` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_mustache.md)
87
+ * [`amp_pin_it` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_pin_it.md)
88
+ * [`amp_pin_widget` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_pin_widget.md)
89
+ * [`amp_pinterest_follow` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_pinterest_follow.md)
90
+ * [`amp_pixel` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_pixel.md)
91
+ * [`amp_reddit` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_reddit.md)
92
+ * [`amp_social_share` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_social_share.md)
93
+ * [`amp_soundcloud` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_soundcloud.md)
94
+ * [`amp_twitter` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_twitter.md)
95
+ * [`amp_user_notification` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_user_notification.md)
96
+ * [`amp_video_ad` (in development)](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_video_ad.md)
97
+ * [`amp_vine` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_vine.md)
98
+ * [`amp_youtube` BETA](https://github.com/slooob/amp-html/blob/master/lib/amp-html/helpers/docs/amp_youtube.md)