-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/Automattic/amp-wp into a…
…dd/864-native-widget-support
- Loading branch information
Showing
50 changed files
with
887 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
Follow the steps below to generate a new version of the allowed tags class: | ||
- Download a copy of the latet AMPHTML repository from github: | ||
git clone [email protected]:ampproject/amphtml.git | ||
- Copy this file into the repo's validator subdirectory: | ||
|
@@ -149,6 +149,8 @@ def GenerateHeaderPHP(out): | |
out.append(' * Note: This file only contains tags that are relevant to the `body` of') | ||
out.append(' * an AMP page. To include additional elements modify the variable') | ||
out.append(' * `mandatory_parent_blacklist` in the amp_wp_build.py script.') | ||
out.append(' *') | ||
out.append(' * phpcs:ignoreFile') | ||
out.append(' */') | ||
out.append('class AMP_Allowed_Tags_Generated {') | ||
out.append('') | ||
|
@@ -223,15 +225,15 @@ def GenerateAttributesPHP(out, attributes, indent_level = 4): | |
indent = '' | ||
for i in range(0,indent_level): | ||
indent += '\t' | ||
|
||
sorted_attributes = sorted(attributes.items()) | ||
for (attribute, values) in collections.OrderedDict(sorted_attributes).iteritems(): | ||
logging.info('generating php for attribute: %s...' % attribute.lower()) | ||
out.append('%s\'%s\' => array(' % (indent, attribute.lower())) | ||
GeneratePropertiesPHP(out, values) | ||
out.append('%s),' % indent) | ||
logging.info('...done with: %s' % attribute.lower()) | ||
|
||
out.append('') | ||
logging.info('... done') | ||
|
||
|
@@ -305,26 +307,42 @@ def GenerateFooterPHP(out): | |
logging.info('entering ...') | ||
|
||
# Output the footer. | ||
out.append('\tpublic static function get_allowed_tags() {') | ||
out.append('\t\treturn self::$allowed_tags;') | ||
out.append('\t}') | ||
out.append('') | ||
out.append(''' | ||
/** | ||
* Get allowed tags. | ||
* | ||
* @since 0.5 | ||
* @return array Allowed tags. | ||
*/ | ||
public static function get_allowed_tags() { | ||
return self::$allowed_tags; | ||
} | ||
/** | ||
* Get list of globally-allowed attributes. | ||
* | ||
* @since 0.5 | ||
* @return array Allowed tag. | ||
*/ | ||
public static function get_allowed_attributes() { | ||
return self::$globally_allowed_attrs; | ||
} | ||
/** | ||
* Get layout attributes. | ||
* | ||
* @since 0.5 | ||
* @return array Allowed tag. | ||
*/ | ||
public static function get_layout_attributes() { | ||
return self::$layout_allowed_attrs; | ||
}''') | ||
|
||
out.append('\tpublic static function get_allowed_attributes() {') | ||
out.append('\t\treturn self::$globally_allowed_attrs;') | ||
out.append('\t}') | ||
out.append('') | ||
|
||
out.append('\tpublic static function get_layout_attributes() {') | ||
out.append('\t\treturn self::$layout_allowed_attrs;') | ||
out.append('\t}') | ||
out.append('') | ||
|
||
out.append('}') | ||
out.append('') | ||
|
||
out.append('?>') | ||
out.append('') | ||
logging.info('... done') | ||
|
||
|
||
|
@@ -434,6 +452,18 @@ def GetTagRules(tag_spec): | |
also_requires_tag_list.append(UnicodeEscape(also_requires_tag)) | ||
tag_rules['also_requires_tag'] = {'also_requires_tag': also_requires_tag_list} | ||
|
||
if hasattr(tag_spec, 'requires_extension') and len( tag_spec.requires_extension ) != 0: | ||
requires_extension_list = [] | ||
for requires_extension in tag_spec.requires_extension: | ||
requires_extension_list.append(requires_extension) | ||
tag_rules['requires_extension'] = {'requires_extension': requires_extension_list} | ||
|
||
if hasattr(tag_spec, 'also_requires_tag_warning') and len( tag_spec.also_requires_tag_warning ) != 0: | ||
also_requires_tag_warning_list = [] | ||
for also_requires_tag_warning in tag_spec.also_requires_tag_warning: | ||
also_requires_tag_warning_list.append(also_requires_tag_warning) | ||
tag_rules['also_requires_tag_warning'] = {'also_requires_tag_warning': also_requires_tag_warning_list} | ||
|
||
if tag_spec.disallowed_ancestor: | ||
disallowed_ancestor_list = [] | ||
for disallowed_ancestor in tag_spec.disallowed_ancestor: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.