GithubHelp home page GithubHelp logo

samples's Introduction

AMP Samples

This is a collection of functional standalone samples demonstrating different features of Accelerated Mobile Pages.

  • amp-camp: Demo showing how to create an e-commerce site with AMP
  • amp-paywall-demo: Demo app containing sample usages of amp-access, amp-analytics and amp-user-notification
  • amp-pwa: React-based, single-page progressive web app that displays AMP documents via Shadow DOM
  • amp-update-cache: Demo app for update-cache requests
  • amp-pwa-reader: Vanilla JS, detailed and SEO-friendly single-page progressive web app that displays AMP documents via Shadow DOM
  • amp-tube: A simple YouTube search engine and viewer app, implemented in AMP

samples's People

Contributors

amedina avatar andreban avatar antoinebisch avatar appsforartists avatar cramforce avatar davidscales avatar demianrenzulli avatar dependabot[bot] avatar dknecht avatar drewroberts avatar dvoytenko avatar eduardogoncalves avatar hugronaphor avatar jeffjose avatar jimmynguyc avatar kristoferbaxter avatar maguayo avatar morsssss avatar nainar avatar newmuis avatar pbakaus avatar remino avatar renovate-bot avatar samouri avatar sebastianbenz avatar tomayac avatar volkanunsal avatar wesleycyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

samples's Issues

PWA issues

  • Install SW from leaf pages.
  • Fix Ads
  • Click on "The Scenic" should not do a full page nav
  • Show a content link to a different article that does a client side nav

Migrate to SSL by default

The shadow reader works on HTTPS, but not by default.

Users that type "amp.cards" on the browser will land into a non-secure site, which won't register the SW (which is one of the main features of this demo).

Current live sample site gives error

On the sample site after first click I get the error below on chrome Version 58.0.3029.96 (64-bit):

Uncaught Error: No ampdoc found for [object HTMLElement]
at va (https://cdn.ampproject.org/shadow-v0.js:7:358)
at ta.f.createError (https://cdn.ampproject.org/shadow-v0.js:4:36)
at xf.getAmpDoc (https://cdn.ampproject.org/shadow-v0.js:129:512)
at HTMLElement.b.connectedCallback (https://cdn.ampproject.org/shadow-v0.js:161:11)
at https://cdn.ampproject.org/rtv/001493770802531/v0/amp-carousel-0.1.js:21:318
at Array.forEach (native)
at S.push.f.f.buildSlides (https://cdn.ampproject.org/rtv/001493770802531/v0/amp-carousel-0.1.js:21:142)
at S.push.f.f.buildCarousel (https://cdn.ampproject.org/rtv/001493770802531/v0/amp-carousel-0.1.js:16:326)
at S.push.f.f.buildCallback (https://cdn.ampproject.org/rtv/001493770802531/v0/amp-carousel-0.1.js:11:465)
at HTMLElement.b.build (https://cdn.ampproject.org/shadow-v0.js:155:514)

Dependency deprecation warning: babel-preset-es2015 (npm)

On registry https://registry.npmjs.org/, the "latest" version (v6.24.1) of dependency babel-preset-es2015 has the following deprecation notice:

🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!

Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.

Affected package file(s): amp-pwa/src/components/amp-document/package.json

If you don't care about this, you can close this issue and not be warned about babel-preset-es2015's deprecation again. If you would like to completely disable all future deprecation warnings then add the following to your config:

"suppressNotifications": ["deprecationWarningIssues"]

Click handler doesn't work properly in Safari

Hi, I'm developer working for NetMoms.de and we create new PWA app using AMP for WordPress contents (AMP in PWA pattern). Since we're SPA (build in ReactJS) we depend on amp-document.

We use amp-document's click listener to load other AMP pages without escaping from PWA (basically we check clicked link's URL and take WP post slug from it and push it to React Router's history - so PWA URL changes, new AMP document is being requested but we're still inside SPA/PWA).

However we've noticed some issues with Safari (iOS as well on macOS).

It looks like click listener doesn't see a anything from ShadowDOM.
It receives event which target is shadow root and not exactly clicked element. Since Safari doesn't support event.path you use pollyfill https://github.com/ampproject/amp-publisher-sample/blob/master/amp-pwa/src/components/amp-document/amp-document.js#L208 while debugging inside while-statement it confirmed that event.target is shadow root element (I clicked img element inside figure, article, a (and other parents) but in Safari I only see nodes from shadowRoot up to html root (in fact 6x div, body and html).

amp-document-1

ShadowDOM in our case is open as I've commented out closing it in https://github.com/ampproject/amp-publisher-sample/blob/master/amp-pwa/src/components/amp-document/amp-document.js#L222 due to some other requirements.

Tested on: Safari v11.0.2 & macOS High Sierra 10.13.2 but it also happens in iOS devices.

ask for reactjs sample

Hi currently, I am working on project that using ReactJS and I also need to use AMP. In the future, I wonder you guys have any plan to implement the sample for ReactJS version?

Creating a PWAMP application using wordpress as CMS

Our team is trying to build a lite app using PWA + AMP (PWAMP as you call it ). We were actually very convinced with the approach that was implemented in https://amp.cards. However, we want to do the same using the WordPress CMS. I have been Scratching my head for days and come with the following approach that is actually what PWAMP is band rather using WordPress as CMS
image
Now the first part is relatively easy using amp plugin provided by amp contributors. And even using PWA plugin that creates the app. Now we are facing the following dilemma -

  1. Styling that the CMS was using before was using ELEMENTOR which we think doesn't support AMP for now and shows a lot of validation errors
  2. Theme Supported by amp currently, we couldn't find one that can have news card like structure like the one you had an amp.cards project
  3. We still don't understand how to implement a shadow reader for PWA in WordPress even with the only plugin that exists in the store https://wordpress.org/plugins/pwamp/

I have done a lot of research and still, am confused with what to do.

Could please refer any sample project like this that exist or from where to learn from. And also another relevant git repo's related to this issue.

Optmize images

Optimize the following images to reduce their size by 20MiB (79% reduction).

Compressing content/hero/6.jpeg could save 1.3MiB (83% reduction).
Compressing content/hero/5.jpeg could save 1.1MiB (82% reduction).
Compressing content/hero/20.jpeg could save 1MiB (78% reduction).
Compressing content/hero/15.jpeg could save 984.3KiB (77% reduction).
Compressing content/hero/22.jpeg could save 982.7KiB (86% reduction).
Compressing content/hero/7.jpeg could save 912.9KiB (77% reduction).
Compressing content/hero/27.jpeg could save 875.1KiB (77% reduction).
Compressing content/hero/19.jpeg could save 861.2KiB (86% reduction).
Compressing content/hero/21.jpeg could save 852.9KiB (91% reduction).
Compressing content/hero/1.jpeg could save 796.4KiB (80% reduction).
Compressing content/hero/17.jpeg could save 773.7KiB (89% reduction).
Compressing content/hero/12.jpeg could save 744.9KiB (74% reduction).
Compressing content/hero/16.jpeg could save 744.2KiB (74% reduction).
Compressing content/hero/28.jpeg could save 740.4KiB (90% reduction).
Compressing content/hero/29.jpeg could save 686KiB (73% reduction).
Compressing content/hero/2.jpeg could save 655.8KiB (75% reduction).
Compressing content/hero/9.jpeg could save 644.2KiB (80% reduction).
Compressing content/hero/24.jpeg could save 621.4KiB (79% reduction).
Compressing content/hero/18.jpeg could save 582.1KiB (77% reduction).
Compressing content/hero/3.jpeg could save 543.2KiB (73% reduction).
Compressing content/hero/23.jpeg could save 530.1KiB (75% reduction).
Compressing content/hero/13.jpeg could save 523.5KiB (77% reduction).
Compressing content/hero/14.jpeg could save 461.1KiB (71% reduction).
Compressing content/hero/11.jpeg could save 422.3KiB (65% reduction).
Compressing content/hero/25.jpeg could save 406.4KiB (75% reduction).
Compressing content/hero/26.jpeg could save 398.2KiB (81% reduction).
Compressing content/hero/8.jpeg could save 392.7KiB (69% reduction).
Compressing content/hero/10.jpeg could save 359.5KiB (81% reduction).
Compressing content/hero/4.jpeg could save 301.8KiB (72% reduction).
Compressing content/hero/30.jpeg could save 232.5KiB (67% reduction).

Issue with AMP Access server examples

I'm seeing the following error when trying to view the AMP Access server examples.

log.js:162 Authorization failed:  SyntaxError: Unexpected token e in JSON at position 0
    at amp-access-client.js:128
    at <anonymous>

Steps to reproduce:

  1. Enable 'amp-access-jwt' and 'amp-access-server' at https://cdn.ampproject.org/experiments.html
  2. git clone [email protected]:ampproject/amp-publisher-sample.git
  3. cd amp-paywall-demo
  4. npm install
  5. npm start
  6. Visit http://localhost:8002/amp-access/sample/server/0
  7. Observe error in console.

Any help with how to resolve this issue would be appreciated.

amp-access: Perform logout via "login" config

Configure logout link via login config:

      "login": {
        "login": "<% host %>/amp-access/login/?rid=READER_ID&url=CANONICAL_URL",
        "logout": "<% host %>/amp-access/logout/?returnUrl=AMPDOC_URL"
      },

Then use for logout button

          <a on="tap:amp-access.logout" class="logout">Logout</a>

Explain advantage of having access to AMP runtime variables.

//cc @dvoytenko @andreban

Consider some accessibility for the top of the page at https://amp-article.herokuapp.com/

Following some discussion in the wg-outrach channel on Slack with Jay Gray and Matthias Rohmer we are providing some feedback for the following page: https://amp-article.herokuapp.com/

I love 😍😍😍 all the great illustrations and animation work being demonstrated here
[https://amp-article.herokuapp.com/]
however, the top of the page (opening scene visual effects) is a serious blocker for progressing further.

Consider moving that effect further down the page or removing it for accessibly ...
I’m not referring to screen readers but other issues including:

  • Anxiety
  • Autism
  • Dyslexia
  • Low vision

Jay Gray thought he had a monitor issue and we felt is was a User Experience blocker for immersion on this site/page.

[amp-pwa-reader]: articles not loading offline

In Chrome 65, the images & runtime cache assets aren't being cached, apparently due to a quota exceeded error:

screen shot 2018-04-13 at 1 13 05 pm

As a result, only the pre-cached files are loading offline, so the user gets basically en empty app shell.

In Firefox, images & runtime caches are populating. The home page appears to load offline, but previously visited articles don't (assuming thats intended functionality). There are no errors logged, just a stalled loading icon.

Unable to install amp-paywall-demo

Hello,

I am trying to install and run your amp-paywall-demo: https://github.com/ampproject/samples/tree/master/amp-paywall-demo

I tried to follow the installation guide, and thus, I clones the repository (which worked fine), followed by npm install which unfortunately failed.

I tried to debug the error myself but was unable to do so.
I also googled the error, and searched for similar problems among the Issues in this repo, but that did not help either.

I created public gists with the output of the error, as well as the debug.log file
error: https://gist.github.com/rafaelmarques7/0b8c0da099fb53f00252b2d428f0ffd2
debug: https://gist.github.com/rafaelmarques7/707f1932f63cd042cdf1e6952c1093ab

I was hoping you can assists me with this soon, as my team is eager to use this service.

Much appreciated,
Rafael

[amp-pwa-reader] Facebook doesn't show preview pages

When posting a link from the reader on Facebook, it is unable go gather data to build a preview of the post. This is usually a big deal for publishers and it would be great if the demo could cover this use case.

Here's a screenshot on what is currently shown:
screen shot 2017-07-24 at 9 54 15 am

Error in running Amp-pwa sample

Could not find a required file.
Name: index.html
Searched in: /home/user_name/Desktop/web/samples/amp-pwa/public

npm ERR! Linux 4.15.0-43-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'react-scripts start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the amp-pwa package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! react-scripts start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs amp-pwa
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls amp-pwa
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/user_name/Desktop/web/samples/amp-pwa/npm-debug.log

Login Flow: redirect back to article if user is already logged in

Given the user is logged in via the publisher domain. On mobile safari third-party cookies are disabled by default. No access to cookies mean that when the user views an article via the CDN, the publisher backend is not able to determine whether the user is logged in.

When the user clicks the login button, the login flow opens on the publisher domain. There the login flow is able to determine a logged in user and should redirect the user back to the article (after saving the readerid user mapping).

Our sample doesn't support this use case yet and shows the login dialog.

//cc @dvoytenko @ashwinlimaye @andreban

Replace nav links in AMP article

My code cleverly replaces the menu on the Guardian's AMP pages with a menu where everything links to the Shadow Reader. Hooray! Unfortunately it does no such thing for the top nav links.

Do it!

screen shot 2018-05-01 at 3 53 20 pm

Install instructions error

I followed the instructions, installed NPM and NODEJS, on Ubuntu 16.04 using Nginx. Can't even being to explain, but just nothing works. That's it! Just like you say posted on in the reaadme. But that's not it. Very frustrating trying to keep us with the AMP project. It's just getting really sloppy. Nothing works.

Clear cookies?

If remove cookies, how to ensure continuity pages? I tried it, when clear the cookies, the page can access free and need't login in. But when this page needs to pay to watch, how to ensure safety and continuous?

Serve cards with initial HTML

Now that we have a server, we could serve cards with the initial HTML bundle instead of requesting them from the browser.

Use RSS instead of YQL

Now that we have a server, instead of using YQL, we can fetch RSS directly from the Guardian. Then we can trim and use only the info we need, outputting JSON to the client.

Dependency deprecation warning: babel-preset-es2015 (npm)

On registry https://registry.npmjs.org, the "latest" version (v6.24.1) of dependency babel-preset-es2015 has the following deprecation notice:

🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!

Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.

Affected package file(s): amp-pwa/src/components/amp-document/package.json

If you don't care about this, you can close this issue and not be warned about babel-preset-es2015's deprecation again. If you would like to completely disable all future deprecation warnings then add the following to your config:

"suppressNotifications": ["deprecationWarningIssues"]

amp-camp fails to start

Hi, thanks for sharing these samples - very cool!

My problem: I've followed the readme to start amp-camp, but the app fails to boot up.

Steps to reproduce

  1. run npm install
  2. run gulp

Expected results
I expect the server to boot up.

Actual Results
It crashes with this stack trace:

Mikes-MBP:amp-camp mike$ gulp
[14:51:51] Using gulpfile ~/workspace/ecom/amp-camp/gulpfile.js
[14:51:51] Starting 'default'...
[14:51:51] Starting 'build'...
[14:51:51] Starting 'images'...
[14:51:52] Finished 'images' after 30 ms
[14:51:52] Starting 'favicon'...
[14:51:52] Finished 'favicon' after 28 ms
[14:51:52] Starting 'rootConfig'...
[14:51:52] Finished 'rootConfig' after 7.25 ms
[14:51:52] Starting 'html'...
[14:51:52] Starting 'styles'...
[14:51:52] File src/sass/blog.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52] File src/sass/blog.css created.
[14:51:52] File src/sass/cart-popup.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52]   @media (max-width: 40rem)
[14:51:52] File src/sass/cart-popup.css created.
[14:51:52] File src/sass/cart.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 40.06rem)
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52] File src/sass/cart.css created.
[14:51:52] File src/sass/checkout.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52] File src/sass/checkout.css created.
[14:51:52] File src/sass/contact.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52] File src/sass/contact.css created.
[14:51:52] File src/sass/footer.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52] File src/sass/footer.css created.
[14:51:52] File src/sass/global.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 40.06rem) and (max-width: 52rem)
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52]   @media (min-width: 52.06rem) and (max-width: 64rem)
[14:51:52]   @media (min-width: 64.06rem)
[14:51:52]   @media (max-width: 40rem)
[14:51:52] File src/sass/global.css created.
[14:51:52] File src/sass/header.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52] File src/sass/header.css created.
[14:51:52] File src/sass/index.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 40.06rem)
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52]   @media (max-width: 52rem)
[14:51:52] File src/sass/index.css created.
[14:51:52] File src/sass/menu.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52] File src/sass/menu.css created.
[14:51:52] File src/sass/product-details.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52] File src/sass/product-details.css created.
[14:51:52] File src/sass/product-listing.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52] File src/sass/product-listing.css created.
[14:51:52] File src/sass/related-products.css found.
[14:51:52] Processed media queries:
[14:51:52]   @media (min-width: 40.06rem) and (max-width: 52rem)
[14:51:52]   @media (min-width: 52.06rem)
[14:51:52]   @media (max-width: 40rem)
[14:51:52] File src/sass/related-products.css created.
[14:51:52] File src/sass/social.css found.
[14:51:52] File src/sass/social.css created.
[14:51:52] Finished 'styles' after 141 ms
[14:51:52] Starting 'buildHtml'...
[14:51:52] Finished 'buildHtml' after 423 ms
[14:51:52] Finished 'html' after 565 ms
[14:51:52] Starting 'server'...
[14:51:52] Finished 'server' after 4.66 ms
[14:51:52] Starting 'validate'...
[14:51:53] AMP Validation results:

blog-article.html: PASS
blog-listing.html: PASS
cart-details.html: PASS
checkout-success.html: PASS
checkout.html: PASS
contact.html: PASS
index.html: PASS
product-details.html: PASS
product-listing.html: PASS
product-not-found.html: PASS
[14:51:53] Finished 'validate' after 461 ms
[14:51:53] Finished 'build' after 1.1 s
[14:51:53] Starting 'nodemon'...
[14:51:53] Finished 'nodemon' after 28 ms
[14:51:53] Starting 'browser-sync'...
[14:51:53] [nodemon] 1.19.0
[14:51:53] [nodemon] to restart at any time, enter `rs`
[14:51:53] [nodemon] watching: *.*
[14:51:53] [nodemon] starting `node ./dist/server/server.js`
[14:51:53] Finished 'browser-sync' after 11 ms
[14:51:53] Starting 'watch'...
[14:51:53] Finished 'watch' after 19 ms
[14:51:53] Finished 'default' after 1.16 s
[Browsersync] Proxying: http://localhost:8080
[Browsersync] Access URLs:
 -------------------------------------
       Local: http://localhost:3000
    External: http://192.168.1.95:3000
 -------------------------------------
          UI: http://localhost:3001
 UI External: http://localhost:3001
 -------------------------------------
/Users/mike/workspace/ecom/amp-camp/dist/server/server.js:20
ampOptimizer.setConfig({
             ^

TypeError: ampOptimizer.setConfig is not a function
    at Object.<anonymous> (/Users/mike/workspace/ecom/amp-camp/dist/server/server.js:20:14)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
    at internal/main/run_main_module.js:21:11
[14:51:53] [nodemon] app crashed - waiting for file changes before starting...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.