summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2015-02-06 16:55:04 (GMT)
committerwebchick2015-02-06 16:55:04 (GMT)
commit1b9e6bdbab3c9c4ea3f7d31b8e1113252e9d658e (patch)
tree6bfd553f6645e223da45094be04af7eaf7640bdf
parent98d23400a4c25b652d3e76d1d06fd118f2b8462e (diff)
Issue #2349677 by davidhernandez, Xen, emma.maria, runand, mortendk: Copy filter templates to Classy
-rw-r--r--core/modules/filter/src/Tests/FilterUnitTest.php24
-rw-r--r--core/modules/filter/src/Tests/TextFormatElementFormTest.php6
-rw-r--r--core/modules/filter/templates/filter-caption.html.twig2
-rw-r--r--core/modules/filter/templates/filter-guidelines.html.twig10
-rw-r--r--core/modules/filter/templates/filter-tips.html.twig19
-rw-r--r--core/modules/filter/templates/text-format-wrapper.html.twig9
-rw-r--r--core/themes/classy/templates/filter-caption.html.twig18
-rw-r--r--core/themes/classy/templates/filter-guidelines.html.twig31
-rw-r--r--core/themes/classy/templates/filter-tips.html.twig63
-rw-r--r--core/themes/classy/templates/text-format-wrapper.html.twig28
10 files changed, 164 insertions, 46 deletions
diff --git a/core/modules/filter/src/Tests/FilterUnitTest.php b/core/modules/filter/src/Tests/FilterUnitTest.php
index 3e87393..2c2a5c9 100644
--- a/core/modules/filter/src/Tests/FilterUnitTest.php
+++ b/core/modules/filter/src/Tests/FilterUnitTest.php
@@ -118,7 +118,7 @@ class FilterUnitTest extends KernelTestBase {
// Data-caption attribute.
$input = '<img src="llama.jpg" data-caption="Loquacious llama!" />';
- $expected = '<figure class="caption caption-img"><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>';
+ $expected = '<figure><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>';
$output = $test($input);
$this->assertIdentical($expected, $output->getProcessedText());
$this->assertIdentical($attached_library, $output->getAssets());
@@ -130,14 +130,14 @@ class FilterUnitTest extends KernelTestBase {
// HTML entities in the caption.
$input = '<img src="llama.jpg" data-caption="&ldquo;Loquacious llama!&rdquo;" />';
- $expected = '<figure class="caption caption-img"><img src="llama.jpg" /><figcaption>“Loquacious llama!”</figcaption></figure>';
+ $expected = '<figure><img src="llama.jpg" /><figcaption>“Loquacious llama!”</figcaption></figure>';
$output = $test($input);
$this->assertIdentical($expected, $output->getProcessedText());
$this->assertIdentical($attached_library, $output->getAssets());
// HTML encoded as HTML entities in data-caption attribute.
$input = '<img src="llama.jpg" data-caption="&lt;em&gt;Loquacious llama!&lt;/em&gt;" />';
- $expected = '<figure class="caption caption-img"><img src="llama.jpg" /><figcaption><em>Loquacious llama!</em></figcaption></figure>';
+ $expected = '<figure><img src="llama.jpg" /><figcaption><em>Loquacious llama!</em></figcaption></figure>';
$output = $test($input);
$this->assertIdentical($expected, $output->getProcessedText());
$this->assertIdentical($attached_library, $output->getAssets());
@@ -146,33 +146,33 @@ class FilterUnitTest extends KernelTestBase {
// not allowed by the HTML spec, but may happen when people manually write
// HTML, so we explicitly support it.
$input = '<img src="llama.jpg" data-caption="<em>Loquacious llama!</em>" />';
- $expected = '<figure class="caption caption-img"><img src="llama.jpg" /><figcaption><em>Loquacious llama!</em></figcaption></figure>';
+ $expected = '<figure><img src="llama.jpg" /><figcaption><em>Loquacious llama!</em></figcaption></figure>';
$output = $test($input);
$this->assertIdentical($expected, $output->getProcessedText());
$this->assertIdentical($attached_library, $output->getAssets());
// Security test: attempt an XSS.
$input = '<img src="llama.jpg" data-caption="<script>alert(\'Loquacious llama!\')</script>" />';
- $expected = '<figure class="caption caption-img"><img src="llama.jpg" /><figcaption>alert(\'Loquacious llama!\')</figcaption></figure>';
+ $expected = '<figure><img src="llama.jpg" /><figcaption>alert(\'Loquacious llama!\')</figcaption></figure>';
$output = $test($input);
$this->assertIdentical($expected, $output->getProcessedText());
$this->assertIdentical($attached_library, $output->getAssets());
// Ensure the filter also works with uncommon yet valid attribute quoting.
$input = '<img src=llama.jpg data-caption=\'Loquacious llama!\' />';
- $expected = '<figure class="caption caption-img"><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>';
+ $expected = '<figure><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>';
$output = $test($input);
$this->assertIdentical($expected, $output->getProcessedText());
$this->assertIdentical($attached_library, $output->getAssets());
// Finally, ensure that this also works on any other tag.
$input = '<video src="llama.jpg" data-caption="Loquacious llama!" />';
- $expected = '<figure class="caption caption-video"><video src="llama.jpg"></video><figcaption>Loquacious llama!</figcaption></figure>';
+ $expected = '<figure><video src="llama.jpg"></video><figcaption>Loquacious llama!</figcaption></figure>';
$output = $test($input);
$this->assertIdentical($expected, $output->getProcessedText());
$this->assertIdentical($attached_library, $output->getAssets());
$input = '<foobar data-caption="Loquacious llama!">baz</foobar>';
- $expected = '<figure class="caption caption-foobar"><foobar>baz</foobar><figcaption>Loquacious llama!</figcaption></figure>';
+ $expected = '<figure><foobar>baz</foobar><figcaption>Loquacious llama!</figcaption></figure>';
$output = $test($input);
$this->assertIdentical($expected, $output->getProcessedText());
$this->assertIdentical($attached_library, $output->getAssets());
@@ -198,17 +198,17 @@ class FilterUnitTest extends KernelTestBase {
// Both data-caption and data-align attributes: all 3 allowed values for the
// data-align attribute.
$input = '<img src="llama.jpg" data-caption="Loquacious llama!" data-align="left" />';
- $expected = '<figure class="caption caption-img align-left"><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>';
+ $expected = '<figure class="align-left"><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>';
$output = $test($input);
$this->assertIdentical($expected, $output->getProcessedText());
$this->assertIdentical($attached_library, $output->getAssets());
$input = '<img src="llama.jpg" data-caption="Loquacious llama!" data-align="center" />';
- $expected = '<figure class="caption caption-img align-center"><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>';
+ $expected = '<figure class="align-center"><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>';
$output = $test($input);
$this->assertIdentical($expected, $output->getProcessedText());
$this->assertIdentical($attached_library, $output->getAssets());
$input = '<img src="llama.jpg" data-caption="Loquacious llama!" data-align="right" />';
- $expected = '<figure class="caption caption-img align-right"><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>';
+ $expected = '<figure class="align-right"><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>';
$output = $test($input);
$this->assertIdentical($expected, $output->getProcessedText());
$this->assertIdentical($attached_library, $output->getAssets());
@@ -216,7 +216,7 @@ class FilterUnitTest extends KernelTestBase {
// Both data-caption and data-align attributes, but a disallowed data-align
// attribute value.
$input = '<img src="llama.jpg" data-caption="Loquacious llama!" data-align="left foobar" />';
- $expected = '<figure class="caption caption-img"><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>';
+ $expected = '<figure><img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption></figure>';
$output = $test($input);
$this->assertIdentical($expected, $output->getProcessedText());
$this->assertIdentical($attached_library, $output->getAssets());
diff --git a/core/modules/filter/src/Tests/TextFormatElementFormTest.php b/core/modules/filter/src/Tests/TextFormatElementFormTest.php
index f2d682b..b889c4a 100644
--- a/core/modules/filter/src/Tests/TextFormatElementFormTest.php
+++ b/core/modules/filter/src/Tests/TextFormatElementFormTest.php
@@ -117,9 +117,9 @@ class TextFormatElementFormTest extends KernelTestBase implements FormInterface
$output = $this->render($form);
$this->setRawContent($output);
$this->assertFieldByName('textformat[value]');
- $this->assertRaw('<h4 class="label">Full HTML</h4>');
- $this->assertRaw('<h4 class="label">Filtered HTML</h4>');
- $this->assertRaw('<h4 class="label">Test format</h4>');
+ $this->assertRaw('<h4>Full HTML</h4>');
+ $this->assertRaw('<h4>Filtered HTML</h4>');
+ $this->assertRaw('<h4>Test format</h4>');
$this->assertNoPattern('|<h4[^>]*></h4>|', 'No empty H4 element found.');
}
diff --git a/core/modules/filter/templates/filter-caption.html.twig b/core/modules/filter/templates/filter-caption.html.twig
index eb9d248..f015ac0 100644
--- a/core/modules/filter/templates/filter-caption.html.twig
+++ b/core/modules/filter/templates/filter-caption.html.twig
@@ -12,7 +12,7 @@
* - string classes: The classes of the captioned HTML tag.
*/
#}
-<figure class="caption caption-{{ tag }}{%- if classes %} {{ classes }}{%- endif %}">
+<figure{%- if classes %} class="{{ classes }}"{%- endif %}>
{{ node }}
<figcaption>{{ caption }}</figcaption>
</figure>
diff --git a/core/modules/filter/templates/filter-guidelines.html.twig b/core/modules/filter/templates/filter-guidelines.html.twig
index 783992b..317cfa6 100644
--- a/core/modules/filter/templates/filter-guidelines.html.twig
+++ b/core/modules/filter/templates/filter-guidelines.html.twig
@@ -19,13 +19,7 @@
* @ingroup themeable
*/
#}
-{%
- set classes = [
- 'filter-guidelines-item',
- 'filter-guidelines-' ~ format.format,
- ]
-%}
-<div{{ attributes.addClass(classes) }}>
- <h4 class="label">{{ format.label }}</h4>
+<div{{ attributes }}>
+ <h4>{{ format.label }}</h4>
{{ tips }}
</div>
diff --git a/core/modules/filter/templates/filter-tips.html.twig b/core/modules/filter/templates/filter-tips.html.twig
index b17de01..b020c23 100644
--- a/core/modules/filter/templates/filter-tips.html.twig
+++ b/core/modules/filter/templates/filter-tips.html.twig
@@ -24,30 +24,19 @@
{% if tips|length %}
{% if multiple %}
- <div class="compose-tips">
+ <div>
{% endif %}
{% for name, tip in tips %}
{% if multiple %}
- {%
- set tip_classes = [
- 'filter-type',
- 'filter-' ~ name|clean_class,
- ]
- %}
- <div{{ tip.attributes.addClass(tip_classes) }}>
+ <div{{ attributes }}>
<h3>{{ tip.name }}</h3>
{% endif %}
{% if tip.list|length %}
- <ul class="tips">
+ <ul>
{% for item in tip.list %}
- {%
- set item_classes = [
- long ? 'filter-' ~ item.id|replace({'/': '-'}),
- ]
- %}
- <li{{ item.attributes.addClass(item_classes) }}>{{ item.tip }}</li>
+ <li{{ tip.attributes }}>{{ item.tip }}</li>
{% endfor %}
</ul>
{% endif %}
diff --git a/core/modules/filter/templates/text-format-wrapper.html.twig b/core/modules/filter/templates/text-format-wrapper.html.twig
index 4e5ff6d..ce3ba55 100644
--- a/core/modules/filter/templates/text-format-wrapper.html.twig
+++ b/core/modules/filter/templates/text-format-wrapper.html.twig
@@ -15,14 +15,9 @@
* @ingroup themeable
*/
#}
-<div class="text-format-wrapper form-item">
+<div>
{{ children }}
{% if description %}
- {%
- set classes = [
- aria_description ? 'description',
- ]
- %}
- <div{{ attributes.addClass(classes) }}>{{ description }}</div>
+ <div{{ attributes }}>{{ description }}</div>
{% endif %}
</div>
diff --git a/core/themes/classy/templates/filter-caption.html.twig b/core/themes/classy/templates/filter-caption.html.twig
new file mode 100644
index 0000000..eb9d248
--- /dev/null
+++ b/core/themes/classy/templates/filter-caption.html.twig
@@ -0,0 +1,18 @@
+{#
+/**
+ * @file
+ * Default theme implementation for a filter caption.
+ *
+ * Returns HTML for a captioned image, audio, video or other tag.
+ *
+ * Available variables
+ * - string node: The complete HTML tag whose contents are being captioned.
+ * - string tag: The name of the HTML tag whose contents are being captioned.
+ * - string caption: The caption text.
+ * - string classes: The classes of the captioned HTML tag.
+ */
+#}
+<figure class="caption caption-{{ tag }}{%- if classes %} {{ classes }}{%- endif %}">
+{{ node }}
+<figcaption>{{ caption }}</figcaption>
+</figure>
diff --git a/core/themes/classy/templates/filter-guidelines.html.twig b/core/themes/classy/templates/filter-guidelines.html.twig
new file mode 100644
index 0000000..783992b
--- /dev/null
+++ b/core/themes/classy/templates/filter-guidelines.html.twig
@@ -0,0 +1,31 @@
+{#
+/**
+ * @file
+ * Default theme implementation for guidelines for a text format.
+ *
+ * Available variables:
+ * - format: Contains information about the current text format, including the
+ * following:
+ * - name: The name of the text format, potentially unsafe and needs to be
+ * escaped.
+ * - format: The machine name of the text format, e.g. 'basic_html'.
+ * - attributes: HTML attributes for the containing element.
+ * - tips: Descriptions and a CSS ID in the form of 'module-name/filter-id'
+ * (only used when 'long' is TRUE) for each filter in one or more text
+ * formats.
+ *
+ * @see template_preprocess_filter_tips()
+ *
+ * @ingroup themeable
+ */
+#}
+{%
+ set classes = [
+ 'filter-guidelines-item',
+ 'filter-guidelines-' ~ format.format,
+ ]
+%}
+<div{{ attributes.addClass(classes) }}>
+ <h4 class="label">{{ format.label }}</h4>
+ {{ tips }}
+</div>
diff --git a/core/themes/classy/templates/filter-tips.html.twig b/core/themes/classy/templates/filter-tips.html.twig
new file mode 100644
index 0000000..b17de01
--- /dev/null
+++ b/core/themes/classy/templates/filter-tips.html.twig
@@ -0,0 +1,63 @@
+{#
+/**
+ * @file
+ * Default theme implementation for a set of filter tips.
+ *
+ * Available variables:
+ * - tips: Descriptions and a CSS ID in the form of 'module-name/filter-id'
+ * (only used when 'long' is TRUE) for each filter in one or more text
+ * formats.
+ * - long: A flag indicating whether the passed-in filter tips contain extended
+ * explanations, i.e. intended to be output on the path 'filter/tips'
+ * (TRUE), or are in a short format, i.e. suitable to be displayed below a
+ * form element. Defaults to FALSE.
+ * - multiple: A flag indicating there is more than one filter tip.
+ *
+ * @see template_preprocess_filter_tips()
+ *
+ * @ingroup themeable
+ */
+#}
+{% if multiple %}
+ <h2>{{ 'Text Formats'|t }}</h2>
+{% endif %}
+
+{% if tips|length %}
+ {% if multiple %}
+ <div class="compose-tips">
+ {% endif %}
+
+ {% for name, tip in tips %}
+ {% if multiple %}
+ {%
+ set tip_classes = [
+ 'filter-type',
+ 'filter-' ~ name|clean_class,
+ ]
+ %}
+ <div{{ tip.attributes.addClass(tip_classes) }}>
+ <h3>{{ tip.name }}</h3>
+ {% endif %}
+
+ {% if tip.list|length %}
+ <ul class="tips">
+ {% for item in tip.list %}
+ {%
+ set item_classes = [
+ long ? 'filter-' ~ item.id|replace({'/': '-'}),
+ ]
+ %}
+ <li{{ item.attributes.addClass(item_classes) }}>{{ item.tip }}</li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+
+ {% if multiple %}
+ </div>
+ {% endif %}
+ {% endfor %}
+
+ {% if multiple %}
+ </div>
+ {% endif %}
+{% endif %}
diff --git a/core/themes/classy/templates/text-format-wrapper.html.twig b/core/themes/classy/templates/text-format-wrapper.html.twig
new file mode 100644
index 0000000..4e5ff6d
--- /dev/null
+++ b/core/themes/classy/templates/text-format-wrapper.html.twig
@@ -0,0 +1,28 @@
+{#
+/**
+ * @file
+ * Default theme implementation for a text format-enabled form element.
+ *
+ * Available variables:
+ * - children: Text format element children.
+ * - description: Text format element description.
+ * - attributes: HTML attributes for the containing element.
+ * - aria_description: Flag for whether or not an ARIA description has been
+ * added to the description container.
+ *
+ * @see template_preprocess_text_format_wrapper()
+ *
+ * @ingroup themeable
+ */
+#}
+<div class="text-format-wrapper form-item">
+ {{ children }}
+ {% if description %}
+ {%
+ set classes = [
+ aria_description ? 'description',
+ ]
+ %}
+ <div{{ attributes.addClass(classes) }}>{{ description }}</div>
+ {% endif %}
+</div>