Giter Site home page Giter Site logo

ampproject / amp.dev Goto Github PK

View Code? Open in Web Editor NEW
578.0 69.0 693.0 1.15 GB

The AMP Project Website.

Home Page: https://amp.dev

License: Other

CSS 8.82% JavaScript 16.53% Python 2.27% HTML 56.74% Dockerfile 0.05% Tcl 0.02% SCSS 9.87% Handlebars 0.31% Shell 0.01% EJS 0.12% Jinja 5.25%

amp.dev's Introduction

amp.dev

Staging Production

The official homepage of the AMP Project.

Contributing

We welcome contributions to amp.dev.

  • Bug reports and feature requests: something missing or not working on amp.dev? Please file an issue here.
  • Documentation & Guides: see this guide for more information on how to contribute documentation to amp.dev.
  • Code samples & demos: see this guide for more information on how to contribute sample code to amp.dev.

Note: fixing spelling mistakes and other small changes are often easiest by directly editing the file on Github.

Inline editing on Github

Setup

Note: Setting up amp.dev requires a working Python 3 environment on your machine which might not be easy to get going. You can skip this by using the Docker-based setup.

Requirements

Note: For those intending to conduct development on this repository beyond fixing typos, Linux and macOS are the only currently supported operating systems. Windows is not supported at this time.

  1. Install the LTS version of Node.js. An easy way to do so is by using nvm.

    $ nvm install --lts
  2. If it has not already been done, install Python 3 and ensure pip is properly set up by adding the pip user base binary directory to $PATH.

    macOS

    1. Install Homebrew.
    2. Run the following command to ensure everything is up to date. Xcode version 10.3 or the most recent stable version is required.
      $ brew doctor
    3. Run the following command to install Python. Version 3.7 is required at latest.
      $ brew install python libyaml
    4. Run the following command to add the pip user base binary directory to $PATH.
      $ echo "export PATH=\"$(python -m site --user-base)/bin\":\$PATH" >> ~/.bash_profile
    5. Run the following command for the changes to take effect.
      $ source ~/.bash_profile

    Linux (Debian-based)

    Note: If using Linux, refer to the section of pip's official documentation titled Ensure you can run pip from the command line for pip installation troubleshooting.

    1. Run the following command to add the pip user base binary directory to $PATH.
      $ echo "export PATH=\"$(python -m site --user-base)/bin\":\$PATH" >> ~/.bashrc
    2. Run the following command for the changes to take effect.
      $ source ~/.bashrc
    3. Run the following command to use a faster YAML parser.
      $ sudo apt install -y python-yaml libyaml-dev
  3. Install Grow, the static site generator used to build amp.dev. Do so by using pip instead of its installer. Using pip will enable importing from the grow package in Python later on.

Note: Be sure to use the pip command associated with Python 3 as Grow 1 depends on Python 3.

Mac

  LDFLAGS="-L$(brew --prefix)/lib" CFLAGS="-I$(brew --prefix)/include" pip3 install --global-option="--with-libyaml" --force pyyaml
  pip3 install --user grow

Linux

 $ pip3 install --global-option="--with-libyaml" --force pyyaml
 $ pip3 install --user grow

Fork & clone the repository

To get started with contributing to amp.dev, you first need to fork the repository. Once you've done that you can clone the repository:

$ git clone https://github.com/YOUR-USERNAME/amp.dev

... and then install the dependencies via NPM:

$ cd amp.dev
$ npm install

Develop

If it's your first time working on amp.dev, it is recommended to bootstrap your local environment. To do so, make sure you have set up a valid GitHub access token in an environment variable named AMP_DOC_TOKEN like so:

$ export AMP_DOC_TOKEN="c59f6..."

This command enables the import from GitHub to run flawlessly. The actual import occurs by running the following command, which will also build the Playground and Boilerplate Generator once.

$ npm run bootstrap

Tip: Due to bad network conditions or GitHub's API rate-limiting there might be errors during import. Try running the above command with the -- --queue-imports flag to prevent them.

You can then start developing in your local environment with the command below. The task will take care of building and copying all files, watching them for changes, and rebuilding them when needed. Beware that changes to the Express backend require the Gulp task to be restarted.

$ npm run develop

This command prints a lot to the shell and will most likely end on Server ready. Press ctrl-c to quit.. Seeing this line means everything went fine so far unless otherwise stated in the logs; the site should be available at http://localhost:8080/. The service running on port 8081 is only Grow rendering the pages.

You can contribute your changes back to the main repository by creating a pull request.

Setup with Docker

We provide a Dockerfile for development based on one of the official Python-images. When using this you can skip setting up Python and a local installation of Grow on your machine. Though make sure you completed all other installation steps, like cloning the repository, installing all Node.js dependencies and exporting a valid GitHub token as outlined in Fork & clone the repository and Develop. When those steps are completed instead of running the project with npm run develop you can build a development Docker image with the followiung command, run from the project root directory:

$ npx gulp developImageBuild

After the image has been successfully built start a container with the following command:

$ npx gulp developContainer

This command also mounts the pages directory, meaning all changes you are doing to any of the markdown files in pages/content are reflected to the container and can be reviewed without rebuilding the image.

Maintenance

Documents

Made changes to a lot of Grow documents at once and not quite sure if all references are still valid? You can run npm run lint:grow to pick up broken ones.

Run a test build

To run a local test build that does all the minifying and vends the static pages instead of proxying them through to Grow you can run:

$ npm run build:local
$ npm run start:local

Tip: For more rapid local testing, it may be preferable to only build a subset of specified locales. Run the following command with --locales being a comma seperated list of locale abbreviations you want to build, e.g. en,fr or even just en.

npm run build:local -- --locales <list of locales>

Build

Caution: starting a build will automatically clean all locations of possible remainings from previous builds. Make sure you don't have anything there that you want to keep - additionally check your working copy for eventual unintended local changes.

npm run build:local -- --locales <list of locales>

To perform a build run the following command with --env being one of the following valid environments: development, local, staging or production:

$ npx gulp build --env <environment>

This command builds all parts of the project and might take a while. Usually, all builds on amp-dev-staging.appspot.com and amp.dev are built using Travis CI. In case you want to reproduce one of those remote builds in your local environment, you can fetch the build artifacts by running:

$ npx gulp fetchArtifacts --travis-build <build_number>

Copyright 2019 The AMP HTML Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

amp.dev's People

Contributors

alabiaga avatar captainlee2009 avatar caroqliu avatar coryphwang avatar crystalonscript avatar dandzdandz avatar fstanis avatar gitlocalize-app[bot] avatar keevcodes avatar leeee avatar lilies avatar lluerich avatar matthiasrohmer avatar mattludwig avatar meggin avatar morsssss avatar mshetty2 avatar patrickkettner avatar pbakaus avatar rachnakumar avatar renovate-bot avatar renovate[bot] avatar robinvanopstal avatar sebastianbenz avatar sebil avatar sidval avatar siregar avatar techhtml avatar tharders avatar wuzhi1023 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amp.dev's Issues

Reorganize extensions

The list of extensions is growing and it probably makes sense to start to group them in some way (e.g. social plugins, video players, …)

I think right now all of them are kind of hidden away (but that might be just me).

amp-analytics implementation issues on amproject.org

The hits being sent to google-analytics.com are missing the &cid parameter. This hits are being dropped and not tracked.

example page:
https://www.ampproject.org/docs/reference/extended/amp-analytics.html
using the debug server for https://www.google-analytics.com/debug/collect?v=1&_v=a0&aip=true&_s=&dl=https%3A%2F%2Fwww.ampproject.org%2Fdocs%2Freference%2Fextended%2Famp-analytics.html&dt=amp-analytics&sr=2560x1440&_utmht=14540832363216&jid=&cid=&tid=UA-67833617-1&t=pageview&_r=1&z=0.0456467

{
  "hitParsingResult": [ {
    "valid": false,
    "parserMessage": [ {
      "messageType": "INFO",
      "description": "IP Address from this hit was anonymized to 72.241.118.0.",
      "messageCode": "VALUE_MODIFIED"
    }, {
      "messageType": "INFO",
      "description": "A default value was used for the parameter 'cid'. Please see http://goo.gl/a8d4RP#cid for details.",
      "messageCode": "DEFAULT_VALUE_USED",
      "parameter": "cid"
    }, {
      "messageType": "ERROR",
      "description": "A value is required for parameter 'cid'. Please see http://goo.gl/a8d4RP#cid for details.",
      "messageCode": "VALUE_REQUIRED",
      "parameter": "cid"
    } ],
    "hit": "/debug/collect?v=1\u0026_v=a0\u0026aip=true\u0026_s=\u0026dl=https%3A%2F%2Fwww.ampproject.org%2Fdocs%2Freference%2Fextended%2Famp-analytics.html\u0026dt=amp-analytics\u0026sr=2560x1440\u0026_utmht=1454083780209\u0026jid=\u0026cid=\u0026tid=UA-67833617-1\u0026t=pageview\u0026_r=1\u0026z=0.07820693154899105"
  } ],
  "parserMessage": [ {
    "messageType": "INFO",
    "description": "Found 1 hit in the request."
  } ]
}

Clarification on <amp-video> tag

I have implemented the tag and it works fine. But I have some questions that I have not been able to find answers for and our Google advocate advised creating an issue .

  1. For a responsive page that has a video, the poster image does not adjust when the viewport size changes while other page components do. That is, when a page is rendered in a larger viewport, a larger image should be able to be specified for the video.
  2. Same comment for the controls. Also, can the controls be customized in any way?
  3. After a video starts to play, if a user starts to scroll through the article and the video is not in the viewport, should the video pause?

Thanks
Ian

Document CSS classes exposed to assist with desktop/mobile cases

AMP provides few CSS classes that we set on the document's body to assist with some typical desktop/mobile cases:

  • amp-mode-touch - this class is set when we detect touch input
  • amp-mode-mouse - this class is set when we detect mouse input
  • amp-mode-keyboard-active - this class is set when the keyboard is active

Mustache syntax gets partially eaten on amp-mustache reference page.

https://www.ampproject.org/docs/reference/extended/amp-mustache.html

Looks like something gets eaten there. E.g.:
"Notice also that because the body of the template has to be specified within the template element, it is impossible to specify expressions - they will always be escaped as. The triple-mustache } has to be used for these cases."

Original text from https://github.com/ampproject/amphtml/blob/master/extensions/amp-mustache/amp-mustache.md:
"Notice also that because the body of the template has to be specified within the template element, it is impossible to specify {{&var}} expressions - they will always be escaped as {{&var}}. The triple-mustache {{{var}}} has to be used for these cases."

This effect applies to this entire page - several of the curly braces get lost in translation.

Some documents on ampproject.org have validation errors

https://www.ampproject.org/docs/support/faqs.html#development=1
2 errors.

  1. Caused by this tag: <a class="tab hamburger" id="menu-button" href="">&#x2261;</a>. The empty href is considered invalid.
  2. Caused by this script tag:
    <script>
    document.getElementById('menu-button').onclick = function() {
      document.getElementsByTagName('header')[0].classList.toggle('menu-open');
      document.querySelector('div.content').classList.toggle('menu-open');
      document.querySelector('nav').classList.toggle('menu-open');
      return false;
    };
    </script>

Publish new AMP codelabs

We are planning on publishing a new set of AMP codelabs, and will make sure ampproject.org points to these codelabs throughout the docs.

Extension documentation should have reminder about include statement

General extension documentation has it here: https://github.com/ampproject/amphtml/blob/master/extensions/README.md#amp-html-extended-components

But I think it would improve usability of the extensions if there was a standard section that was something like:

# Include `amp-frame` on your page
Add `<script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>` in the head of your page.

Jekyll error occurs while generating amp-access-spec documentation

After importing reference docs with import_reference_docs.js, the following error occurs when running jekyll serve:

Configuration file: /<private>/docs/_config.yml
            Source: /<private>/docs
       Destination: /<private>/docs/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
  Liquid Exception: Syntax Error in tag 'highlight' while parsing the following markup: amp-mustache``` 
  Valid syntax: highlight <lang> [linenos] in /<private>/docs/_reference/extended/amp-access-spec.md

Create new URL checking section in validation errors doc

Group together URL checking errors into a new section, and elaborate in this section on the different checks for different tags.

Also, there's a small bug that I should fix in https://www.ampproject.org/docs/reference/validation_errors.html#mandatory-text-missing-or-incorrect.

Table formatting off-- so make that better too in this PR.

And finally, make sure validation docs in tutorial, etc., point to the new validation errors doc. Cross-referencing quite important for this stuff.

Content container falls below left navigation in Safari 8.x

The AMP docs have a layout issue in older versions of Safari that support Flexbox (Safari 8.x in particular) where the content div wraps below the left navigation. This happens because of a missing legacy display: -webkit-flex; style declaration in the .main rule in _sass/content.scss.

Steps to reproduce:

  1. Navigate to https://www.ampproject.org using Safari 8.x / OS X 10.10.x ("Yosemite")
  2. Click on Docs in the primary navigation menu
  3. Observe that the main content area wraps below the left side navigation menu

See attached screenshot for more detail:
safari8-amp-docs-layout

Unescaped HTML in docs

There seems to be some broken HTML (unescaped tags) in the AMP documentation main page. In particular, the page contains:

<p>AMP HTML documents MUST:</p>

<ul>
  <li>Start with the doctype &lt;!doctype html&gt;.</li>
  <li>Contain a top-level &lt;html ⚡&gt; tag (&lt;html amp&gt; is accepted as well).</li>
  <li>Contain &lt;head&gt; and &lt;body&gt; tags (They are optional in HTML).</li>
  <li>Contain a <link rel="canonical" href="$SOME_URL" /> tag inside their head that points to the regular HTML version of the AMP HTML document or to itself if no such HTML version exists.</li>
  <li>Contain a <meta charset="utf-8" /> tag as the first child of their head tag.</li>
  <li>Contain a <meta name="viewport" content="width=device-width,minimum-scale=1" /> tag inside their head tag. It’s also recommended to include initial-scale=1.</li>
  <li>Contain a <script async="" src="https://cdn.ampproject.org/v0.js"></script> tag as the last element in their head (this includes and loads the AMP JS library).</li>
  <li>Contain <style>body {opacity: 0}</style><noscript><style>body {opacity: 1}</style></noscript> in their head tag.</li>
</ul>

See e.g. <style>body {opacity: 0}</style><noscript>

CC @Meggin @pbakaus

Guide for AMP Analytics (incl. amp-analytics and amp-pixel)

Should touch on these points:

  • Capabilities of amp-pixel vs. amp-analytics. Why use one over the other?
  • Components are designed to work whether you're interested in collecting for yourself (owned ingestion endpoint) or want to transmit the data to a 3P (e.g. analytics provider for reporting, dashboards, etc.)
  • Basic overview of how amp-pixel works technically and how amp-analytics works technically (talk about how amp-analytics uses a "measure once, report to many" approach)
  • Guide to getting a basic amp-analytics request set up
  • How amp-analytics works if you want to send the data to a vendor; talk about vendor configuration
  • Link to a reference on what to do if you are a vendor and want to add a vendor config
  • Guides on how to use various attributes of amp-analytics and what use cases they address
  • Talk about client identifier

cc @Meggin

jekyll error in pages_toc.html

Running jekyll serve as per the README, I'm encountering:

Liquid Exception: undefined method `sort' for nil:NilClass in _includes/pages_toc.html, included in _get_started/create_page.md
jekyll 2.5.3 | Error:  undefined method `sort' for nil:NilClass

amp-img with layout responsive not visible

Using the Skeleton grid (http://getskeleton.com/) in my amp-html demo, I've set amp-img to layout=responsive because the images aspect ratio was being distorted on resize. With layout=responsive, this img width and height are changes to 0 and the image is not visible. Demo at pos.88k.com.tw (up temporarily)

cdn.ampproject.org/v0.js requirement?

According to https://www.ampproject.org/docs/get_started/create/basic_markup.html a requirement to being AMP compliant is to include <script async src="https://cdn.ampproject.org/v0.js"></script> right before the </head> tag. Could not the AMP JS code be served via a CDN like Akamai other than cdn.ampproject.org which might improve availability to clients? If a site could host the AMP JS with their other CDN content then CORS setup could would seem remain intact. If Google should rank pages based upon AMP compliance, this would seem to tie page ranking to another Google product, that being cdn.ampproject.org which, as I understand it, is served via Google's CDN.

Is this an ease of implementation detail? Saying the script tag right before </head> must be literally https://cdn.ampproject.org/v0.js? If so, then what about v1.js? Or is the test a regular expression? Could it not be that the script tag right before </head> somehow otherwise indicate that it is AMP JS by say the src attribute containing ampproject or there being an amp attribute included, ex <script async amp src="https://cdn.somedomain.com/v0.js"></script>

Requiring AMP JS code before </head> make sense and having it available via cdn.ampproject.org is great. However, forcing the use of a specific seems counter to an open web. Thoughts?

Launch Cache docs

We will deliver a complete set of Cache docs, and make sure ampproject.org refers to these docs.

import_reference_docs.js fails on empty extension component directory

The following ampproject/amphtml extension breaks at import_reference_docs.js#L167

To reproduce:

TypeError: Cannot read property 'path' of undefined
    at /Users/jellis/dev/projects/yieldbot/amphtml.docs/_scripts/import_reference_docs.js:167:29
    at /Users/jellis/dev/projects/yieldbot/amphtml.docs/node_modules/octonode/lib/octonode/repo.js:471:18
    at Client.errorHandle (/Users/jellis/dev/projects/yieldbot/amphtml.docs/node_modules/octonode/lib/octonode/client.js:196:14)
    at Request._callback (/Users/jellis/dev/projects/yieldbot/amphtml.docs/node_modules/octonode/lib/octonode/client.js:210:24)
    at Request.self.callback (/Users/jellis/dev/projects/yieldbot/amphtml.docs/node_modules/request/request.js:373:22)
    at emitTwo (events.js:100:13)
    at Request.emit (events.js:185:7)
    at Request.<anonymous> (/Users/jellis/dev/projects/yieldbot/amphtml.docs/node_modules/request/request.js:1318:14)
    at emitOne (events.js:95:20)
    at Request.emit (events.js:182:7)

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.