Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 Update grow to v1.0.0 #5292

Merged
merged 32 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
98b7489
:construction: Update imports
lluerich Feb 2, 2021
9b80e67
:construction: Python3 specific changes
lluerich Feb 2, 2021
15d2e27
:package: Update extension due to grow update
lluerich Feb 2, 2021
277c77a
Merge branch 'future' into grow-1-update
lluerich Feb 2, 2021
40cf73d
:mute: Remove additional logs
lluerich Feb 2, 2021
12e3caa
:recycle: Join conditions
lluerich Feb 2, 2021
a163240
:recycle: Remove unneeded import
lluerich Feb 2, 2021
5131d0b
🚧 Tentatively enable CI build
matthiasrohmer Feb 2, 2021
c2c2d03
🔧 Enable build stage on Travis CI
matthiasrohmer Feb 2, 2021
fd4f1a0
Merge branch 'grow-1-update' of github.com:ampproject/amp.dev into gr…
lluerich Feb 2, 2021
e7b2f63
📦 Add python3 to apt packages for Travis
matthiasrohmer Feb 2, 2021
7523632
Merge branch 'grow-1-update' of github.com:ampproject/amp.dev into gr…
lluerich Feb 3, 2021
769c242
🐛 Also install python3-pip as apt package
matthiasrohmer Feb 3, 2021
ac3842b
Merge branch 'grow-1-update' of github.com:ampproject/amp.dev into gr…
matthiasrohmer Feb 3, 2021
9ca94a2
🚧 Install python3.5-complete instead of just python3
matthiasrohmer Feb 3, 2021
5615d25
🚧 Try utilizing pyenv to update Python version
matthiasrohmer Feb 3, 2021
b28a169
🚧 Try to set CLOUDSDK_PYTHON for gsutil
matthiasrohmer Feb 3, 2021
4470618
🎉 Use Grow 1 and Python 3 to build pages
matthiasrohmer Feb 3, 2021
de4d047
:construction: Adapt to python3 open()
lluerich Feb 4, 2021
0e70139
Merge branch 'future' into grow-1-update
lluerich Feb 4, 2021
bf65697
:wrench: Enable full build on Travis CI
lluerich Feb 4, 2021
31f2f05
Merge branch 'grow-1-update' of github.com:ampproject/amp.dev into gr…
lluerich Feb 4, 2021
86ef68b
:wrench: Fix indentation
lluerich Feb 4, 2021
4c70db1
🐛 Unquote $order key in document frontmatter
matthiasrohmer Feb 8, 2021
935bc9e
🐛 Correct path for amp-animation reference documentation
matthiasrohmer Feb 8, 2021
4439d58
🐛 Unquote remaining $order keys in documents
matthiasrohmer Feb 8, 2021
de085ad
👽 Gracefully handle encoding when rewriting TOC
matthiasrohmer Feb 8, 2021
5a420a6
📝 Update instructions to use Grow 1 and Python 3
matthiasrohmer Feb 8, 2021
0915e53
🔧 Update minimum required Grow version to 1
matthiasrohmer Feb 8, 2021
c03bce3
:alien: Fix style of code snippets
lluerich Feb 8, 2021
3c896e4
Merge branch 'future' into grow-1-update
lluerich Feb 8, 2021
d0c78ff
⏪ Disable full builds for PRs again
matthiasrohmer Feb 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pages/extensions/amp_dependencies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from grow import extensions
from grow.documents import document, static_document
from grow.extensions import hooks
from amp_dependencies import AmpDependencies
from auto_dependency_injector import AutoDependencyInjector
from .amp_dependencies import AmpDependencies
from .auto_dependency_injector import AutoDependencyInjector

# Used to determine where to print the script tags
PLACEHOLDER = '__AMP__DEPENDENCIES__'
Expand Down
2 changes: 1 addition & 1 deletion pages/extensions/amp_dependencies/amp_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def inject(self, content):
self.injected = True

dependencies = ''
for name, details in self._dependencies.iteritems():
for name, details in self._dependencies.items():
version = details[0]

if version is None:
Expand Down
8 changes: 4 additions & 4 deletions pages/extensions/amp_dependencies/auto_dependency_injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AutoDependencyInjector(object):
def add_auto_imports(doc, content, amp_dependencies):
"""
:type doc: document.Document
:type content: basestring
:type content: str
:type amp_dependencies: AmpDependencies
"""

Expand All @@ -34,7 +34,7 @@ def add_auto_imports(doc, content, amp_dependencies):
def should_do_auto_import(doc, content):
"""
:type doc: document.Document
:type content: basestring
:type content: str
:rtype: bool
"""
# Do not run for empty documents
Expand All @@ -52,11 +52,11 @@ def should_do_auto_import(doc, content):
return False

# Quick check if the page is really a AMP page
if not any(marker in content for marker in ['<html amp', '<html ⚡']):
if not any(marker in content for marker in ['<html amp'.encode('utf-8'), '<html ⚡'.encode('utf-8')]):
return False

# And has a head element
if '</head>' not in content:
if '</head>'.encode('utf-8') not in content:
return False

return True
Expand Down
2 changes: 1 addition & 1 deletion pages/extensions/amp_dev/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from extension import *
from .extension import *
4 changes: 2 additions & 2 deletions pages/extensions/amp_dev/markdown_extras/block_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def _transform(content):
r'v=(\w*)', attributes['src']).group(1) + '\' %}\n'

# Add in other variables
for name, value in attributes.iteritems():
if isinstance(value, basestring):
for name, value in attributes.items():
if isinstance(value, str):
replacement += '{% set ' + name + ' = \'' + value + '\' %}\n'
else:
value = str(value)
Expand Down
2 changes: 1 addition & 1 deletion pages/extensions/amp_example_preview/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from amp_example_preview import *
from .amp_example_preview import *
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def createTempDoc(self, formats):
def get_validation_errors(self, validator_output):
errors = []
validations = json.loads(validator_output)
for path, result in validations.iteritems():
for path, result in validations.items():
if result['status'] == 'FAIL':
error_message = self.get_error_text_pattern(path)
for error in result['errors']:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_components(identifiers):
result = []

if identifiers:
if isinstance(identifiers, basestring):
if isinstance(identifiers, str):
collection = identifiers.split(',')
else:
collection = identifiers
Expand Down
4 changes: 2 additions & 2 deletions pages/extensions/amp_example_preview/util/example_document.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re

from amp_component_versions import get_component, get_components
from constants import PREVIEW_MODES, PREVIEW_MODES_IN_IFRAME, PREVIEW_NONE, PREVIEW_INLINE
from .amp_component_versions import get_component, get_components
from .constants import PREVIEW_MODES, PREVIEW_MODES_IN_IFRAME, PREVIEW_NONE, PREVIEW_INLINE


class ExampleDocument(object):
Expand Down
12 changes: 6 additions & 6 deletions pages/extensions/amp_example_preview/util/example_exporter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import urlparse
import urllib.parse
import errno
from grow.documents import document
from constants import FORMAT_TYPE_IDS, DEFAULT_FORMAT
from example_document import ExampleDocument
from templates import load_template
from .constants import FORMAT_TYPE_IDS, DEFAULT_FORMAT
from .example_document import ExampleDocument
from .templates import load_template


TEMPLATE_PATH = 'layouts/example-pages/'
Expand Down Expand Up @@ -32,8 +32,8 @@ def __init__(self, doc, example_document, type_id):
self.base_url = doc.pod.get_podspec().yaml.get('base_urls').get('preview')

self.file_path = self.get_file_path(doc, example_document.index, type_id)
self.canonical = urlparse.urljoin(self.base_url, self.file_path)
self.url_without_format = urlparse.urljoin(self.base_url,
self.canonical = urllib.parse.urljoin(self.base_url, self.file_path)
self.url_without_format = urllib.parse.urljoin(self.base_url,
self.get_file_path(doc, example_document.index, DEFAULT_FORMAT))

self.language = doc.locale
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from example_document import ExampleDocument
from .example_document import ExampleDocument

EXAMPLE_PATTERN = re.compile(
r'\[\s*example(\s[^\]]*)?\](.*?(?:\n```html *\n(.*?)\n```' +
Expand Down
10 changes: 5 additions & 5 deletions pages/extensions/amp_example_preview/util/markdown_processor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from example_extractor import SourceCodeExtractor
from example_exporter import ExampleExporter
from preview import ExamplePreview
from amp_component_versions import get_component
from constants import ATTRIBUTE_EXAMPLE_TEMPLATES, ATTRIBUTE_EXAMPLE_IMPORTS, ATTRIBUTE_HAS_INLINE_PREVIEW
from .example_extractor import SourceCodeExtractor
from .example_exporter import ExampleExporter
from .preview import ExamplePreview
from .amp_component_versions import get_component
from .constants import ATTRIBUTE_EXAMPLE_TEMPLATES, ATTRIBUTE_EXAMPLE_IMPORTS, ATTRIBUTE_HAS_INLINE_PREVIEW

EXAMPLE_TRIGGER = '[example'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import re
from preview import ExamplePreviewMatch
from constants import ATTRIBUTE_EXAMPLE_TEMPLATES, ATTRIBUTE_EXAMPLE_IMPORTS
from templates import load_template
from amp_component_versions import remove_component_from_set
from .preview import ExamplePreviewMatch
from .constants import ATTRIBUTE_EXAMPLE_TEMPLATES, ATTRIBUTE_EXAMPLE_IMPORTS
from .templates import load_template
from .amp_component_versions import remove_component_from_set

# find existing imports
IMPORT_PATTERN = re.compile(r'<script(?:\s[^>]*)?\scustom-(element|template)\s*=\s*"?([^"\s>/]+)',
Expand Down
2 changes: 1 addition & 1 deletion pages/extensions/extract_highlights_info/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from grow import extensions
from page_info_collector import PageInfoCollector
from .page_info_collector import PageInfoCollector

CONFIG_INPUT_FILE = 'input_file'
CONFIG_OUTPUT_FOLDER = 'output_folder'
Expand Down
2 changes: 1 addition & 1 deletion pages/extensions/inline_text_assets/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from inline_text_assets import *
from .inline_text_assets import *
4 changes: 2 additions & 2 deletions pages/extensions/internal_links/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from grow import extensions
from grow.documents import static_document
from grow.extensions import hooks
from pod_internal_link_rewriter import PodInternalLinkRewriter
from component_version_resolver import ComponentVersionResolver
from .pod_internal_link_rewriter import PodInternalLinkRewriter
from .component_version_resolver import ComponentVersionResolver

class PodInternalLinkPostRenderHook(hooks.PostRenderHook):
"""Handle the post-render hook."""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import re
import traceback
from component_version_resolver import ComponentVersionResolver
from .component_version_resolver import ComponentVersionResolver
from grow.pods.pods import Pod
from grow.documents.document import Document
from grow.cache.object_cache import ObjectCache
Expand Down
2 changes: 1 addition & 1 deletion pages/extensions/jinja2_optimized_codehilite/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from jinja2_optimized_codehilite import *
from .jinja2_optimized_codehilite import *
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import StringIO
import io
from pygments.formatters import html
from jinja2_expression_unescape import unescape_in_expressions
from .jinja2_expression_unescape import unescape_in_expressions


class CustomHtmlFormatter(html.HtmlFormatter):

def format_unencoded(self, tokensource, outfile):
buffer = StringIO.StringIO()
buffer = io.StringIO()
super(CustomHtmlFormatter, self).format_unencoded(tokensource, buffer)
content = buffer.getvalue()
content = unescape_in_expressions(content)
Expand All @@ -15,4 +15,4 @@ def format_unencoded(self, tokensource, outfile):

@staticmethod
def connect_hook():
html.HtmlFormatter = CustomHtmlFormatter
html.HtmlFormatter = CustomHtmlFormatter
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Punctuation
from pygments.util import looks_like_xml, html_doctype_matches

from custom_js_lexer import CustomJavascriptLexer
from .custom_js_lexer import CustomJavascriptLexer
from pygments.lexers.css import CssLexer


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from grow import extensions
from custom_html_lexer import CustomHtmlLexer
from custom_js_lexer import CustomJavascriptLexer
from custom_html_formatter import CustomHtmlFormatter
from .custom_html_lexer import CustomHtmlLexer
from .custom_js_lexer import CustomJavascriptLexer
from .custom_html_formatter import CustomHtmlFormatter


class Jinja2OptimizedCodehiliteExtension(extensions.BaseExtension):
Expand Down
2 changes: 1 addition & 1 deletion pages/extensions/log_beautifier/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from log_beautifier import *
from .log_beautifier import *
19 changes: 16 additions & 3 deletions pages/extensions/log_beautifier/log_beautifier.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from grow import extensions
from grow.common import logger
from grow.common import logger, colors
from grow.server import manager

logger._get_logger = logger.get_logger
Expand Down Expand Up @@ -29,9 +29,22 @@ def get_logger(name='pod'):
def print_server_ready_message(pod, host, port):
home_doc = pod.get_home_doc()
root_path = home_doc.url.path if home_doc and home_doc.exists else '/'
url = 'http://{}:{}{}'.format(host, port, root_path)
url_base = 'http://{}:{}/'.format(host, port)
url_root = 'http://{}:{}{}'.format(host, port, root_path)
logger.LOGGER.info('Grow started successfully.')
return url

messages = manager.ServerMessages()
messages.add_message('Pod:', pod.root, colors.HIGHLIGHT)
messages.add_message('Server:', url_root, colors.HIGHLIGHT)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the idea of this extension is to silence the startup log and we are not printing them anyway, this can be removed.


# Trigger the dev manager message hook.
extra_urls = pod.extensions_controller.trigger(
'dev_manager_message', messages.add_message, url_base, url_root) or []

messages.add_message(
'Ready.', 'Press ctrl-c to quit.', colors.SUCCESS, colors.SUCCESS)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


return (url_root, extra_urls)

manager.print_server_ready_message = print_server_ready_message

Expand Down
4 changes: 2 additions & 2 deletions pages/extensions/markdown_in_html/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from grow.documents import document_format
from grow.extensions import hooks
from markdown.extensions import extra
from html_block_processor import HtmlBlockProcessor
from .html_block_processor import HtmlBlockProcessor

CLEAR_EXTRA_EXTENSIONS_FLAG = 'prevent_markdown_extra_auto_loading_other'

Expand Down Expand Up @@ -52,7 +52,7 @@ class MarkdownInHtmlExtension(extensions.BaseExtension):
def __init__(self, pod, config):
super(MarkdownInHtmlExtension, self).__init__(pod, config)

if config.has_key(CLEAR_EXTRA_EXTENSIONS_FLAG) and config.get(CLEAR_EXTRA_EXTENSIONS_FLAG):
if config.__contains__(CLEAR_EXTRA_EXTENSIONS_FLAG) and config.get(CLEAR_EXTRA_EXTENSIONS_FLAG):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... if config.get(CLEAR_EXTRA_EXTENSIONS_FLAG, None) should actually be enough. Methods pre- and postfixed with __ are not meant to be called directly.

# Clear the markdown extra extensions to prevent auto loading unwanted extensions
extra.extensions = []

Expand Down
2 changes: 1 addition & 1 deletion pages/extensions/markdown_toc_patch/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from markdown_toc_patch import *
from .markdown_toc_patch import *
2 changes: 1 addition & 1 deletion pages/extensions/markdown_toc_patch/markdown_toc_patch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from grow import extensions
from custom_toc_tree_processor import CustomTocTreeProcessor
from .custom_toc_tree_processor import CustomTocTreeProcessor


class MarkdownTocPatchExtension(extensions.BaseExtension):
Expand Down
2 changes: 1 addition & 1 deletion pages/extensions/url_beautifier/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from url_beautifier import *
from .url_beautifier import *