Skip to content

Commit

Permalink
Static production amp dev (#6533)
Browse files Browse the repository at this point in the history
* Static production amp dev updates (#6523)

* fix svg output of Cheerio

* another email example endpoint fix

* fixed paged-list example

* amp-form example fix

* fix about/websites rendering issue
  • Loading branch information
patrickkettner authored Nov 28, 2022
1 parent b4d6c54 commit df1c26b
Show file tree
Hide file tree
Showing 78 changed files with 960 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-grow-link-integrity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-yaml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: '**/node_modules'
key: node_modules-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: '**/node_modules'
key: node_modules-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -131,7 +131,7 @@ jobs:
with:
python-version: '3.9'

# - uses: actions/cache@v2
# - uses: actions/cache@v3
# with:
# path: ${{ env.pythonLocation }}
# key: ${{ env.pythonLocation }}
Expand Down Expand Up @@ -177,7 +177,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: '**/node_modules'
key: node_modules-${{ hashFiles('**/package-lock.json') }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand All @@ -147,7 +147,7 @@ jobs:
with:
python-version: '3.9'

# - uses: actions/cache@v2
# - uses: actions/cache@v3
# with:
# path: ${{ env.pythonLocation }}
# key: ${{ env.pythonLocation }}
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release-static-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand All @@ -130,7 +130,7 @@ jobs:
with:
python-version: '3.9'

# - uses: actions/cache@v2
# - uses: actions/cache@v3
# with:
# path: ${{ env.pythonLocation }}
# key: ${{ env.pythonLocation }}
Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-grow-extensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand All @@ -32,7 +32,7 @@ jobs:
with:
python-version: '3.x'

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-pixi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-playground.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
node-version: 14

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ !env.ACT }}
with:
path: '**/node_modules'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
display: inline-block;
width: var(--space-3);
height: var(--space-3);
background-position-x: -2px;
background-position: -2px, 0;
background-image: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjMDAwMDAwIiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxwYXRoIGQ9Ik03LjQxIDcuODRMMTIgMTIuNDJsNC41OS00LjU4TDE4IDkuMjVsLTYgNi02LTZ6Ii8+CiAgICA8cGF0aCBkPSJNMC0uNzVoMjR2MjRIMHoiIGZpbGw9Im5vbmUiLz4KPC9zdmc+");
transition: transform 0.25s ease-in-out;
transform: rotate(180deg);
Expand Down
2 changes: 0 additions & 2 deletions frontend/templates/layouts/default.j2
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@
{% include 'views/partials/burger-menu.j2' %}
{% endblock %}

{% include 'views/partials/search.j2' %}

{% block main %}
{# Only render the grid toggle during development #}
{% include 'views/partials/content.j2' %}
Expand Down
12 changes: 0 additions & 12 deletions frontend/templates/views/2021/partials/header.j2
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,6 @@ to provide its state to other components #}
{% include '/views/2021/partials/language-selector.j2' %}
{% endif %}

{% do doc.icons.useIcon('/icons/magnifier.svg') %}
<button id="searchTriggerOpen"
class="ap-search-trigger"
on="tap:searchLightbox"
role="button"
aria-label="{{ _('Search') }}"
tabindex="0">
<div class="ap-icon ap-search-trigger-icon">
<svg><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#magnifier"></use></svg>
</div>
</button>

<button class="ap-header-burger"
on="tap:AMP.setState({mainmenuopen: !mainmenuopen, noScrollState: !noScrollState})"
[class]="'ap-header-burger ' + (mainmenuopen ? '--mainmenuopen ' : '')"
Expand Down
8 changes: 0 additions & 8 deletions frontend/templates/views/partials/header.j2
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,6 @@
{{ doc.pod.amp_dev.template_cache.get(cache_key)|safe }}
{% endif %}

{% do doc.styles.addCssFile('/css/components/molecules/search-trigger.css') %}
{% do doc.icons.useIcon('/icons/magnifier.svg') %}
<div id="searchTriggerOpen" class="ap-m-search-trigger" on="tap:searchLightbox" role="button" aria-label="{{ _('Search') }}" tabindex="0">
<div class="ap-a-ico ap-m-search-trigger-icon">
<svg><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#magnifier"></use></svg>
</div>
</div>

{# blog.amp.dev shares the header with amp.dev but isn't localized.
Therefore it's nice to have a way to turn off the language selector #}
{% if language_selector != False %}
Expand Down
2 changes: 0 additions & 2 deletions frontend21/amp-dev.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@
{% include 'views/2021/partials/header.j2' %}
{% endblock %}

{% include 'views/partials/search.j2' %}

{% block main %}
{{ doc.html|render|safe }}
{% endblock %}
Expand Down
14 changes: 10 additions & 4 deletions gulpfile.js/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,12 @@ function optimizeFiles(cb) {
through.obj((file, encoding, callback) => {
const unoptimizedFile = file.contents.toString();

optimize({query: ''}, unoptimizedFile, {}).then((optimizedFile) => {
file.contents = Buffer.from(optimizedFile);
callback(null, file);
});
optimize({query: ''}, unoptimizedFile, {}, file.path).then(
(optimizedFile) => {
file.contents = Buffer.from(optimizedFile);
callback(null, file);
}
);
})
)
.pipe(gulp.dest((f) => f.base))
Expand Down Expand Up @@ -731,6 +733,10 @@ function collectStatics(done) {
);
}

await gulp
.src(`${project.paths.DIST}/inline-examples/documentation**/**/*`)
.pipe(gulp.dest(`${project.paths.DIST}/examples/sources/`));

await Promise.all(writes);
signale.await('Finished collecting static files!');
done();
Expand Down
8 changes: 5 additions & 3 deletions gulpfile.js/staticify.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const config = require('@lib/config');
const gulp = require('gulp');
const nunjucks = require('nunjucks');
const through = require('through2');
const {htmlContent} = require('@lib/utils/cheerioHelper');
const {project} = require('@lib/utils');
const {survey} = require('@lib/templates/SurveyFilter.js');
const {importBlog} = require('@lib/templates/ImportBlogFilter.js');
Expand Down Expand Up @@ -139,7 +140,7 @@ async function staticify(done) {
$this.attr('href', updatedURL);
});

const renderedPage = $.root().html();
const renderedPage = htmlContent($.root());

// we need to render a "default" version for the URLs, and treat the "website" version as such
if (format === FORMAT_WEBSITES) {
Expand All @@ -150,7 +151,8 @@ async function staticify(done) {
// In addition to the tools pages for each format, we need to render a seperate main version that
// shows all of them. Rather than render its twice, we can just toggle a classname.
$('.ap-a-pill').addClass('active');
contents = Buffer.from($.root().html());
contents = htmlContent($.root());
contents = Buffer.from(contents);
}

// eslint-disable-next-line no-invalid-this
Expand Down Expand Up @@ -232,7 +234,7 @@ async function staticify(done) {
);
$levelToggle.attr('on', updatedToggleLink);

renderedPage = $.root().html();
renderedPage = htmlContent($.root());
}

if (level === 'beginner') {
Expand Down
Loading

0 comments on commit df1c26b

Please sign in to comment.