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

Handled custom attributes when converting XmlText to RichText #92

Merged
merged 9 commits into from
Apr 30, 2019

Conversation

SerheyDolgushev
Copy link
Contributor

Related to ezsystems/ezplatform-richtext#35

Following eZ XML:

<?xml version="1.0" encoding="utf-8"?>
<section xmlns:image="http://ez.no/namespaces/ezpublish3/image/" xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"
         xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">
    <section>
        <header class="header_class_1" custom:ezca_header_1="header">Header</header>
        <paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">
            <table class="table_class_1" border="0" width="100%" custom:summary="summary" custom:caption=""
                   custom:ezca_table_1="table">
                <tr class="tr_class_1" custom:ezca_tr_1="tr1">
                    <td class="td_class_1" xhtml:width="0" custom:valign="top" custom:ezca_td_1="td11">
                        <paragraph>c11</paragraph>
                    </td>
                    <td>
                        <paragraph>c12</paragraph>
                    </td>
                </tr>
                <tr custom:ezca_tr_1="tr2">
                    <td>
                        <paragraph>c21</paragraph>
                    </td>
                    <td>
                        <paragraph>c22</paragraph>
                    </td>
                </tr>
            </table>
        </paragraph>
        <paragraph>
            <strong class="strong_class_1" custom:ezca_strong_1="strong">Strong text</strong>
        </paragraph>
        <paragraph>
            <emphasize class="em_class_1" custom:ezca_em_1="em">Italic text</emphasize>
        </paragraph>
        <paragraph class="para_class_1" custom:ezca_para_1="para_1" custom:ezca_para_2="para_2">Paragraph</paragraph>
        <paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">
            <ol class="ol_class_1" custom:ezca_ol_1="ol">
                <li class="li_class_1" custom:ezca_li_1="li">
                    <paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">Ordered item 1</paragraph>
                </li>
                <li>
                    <paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">Ordered item 2</paragraph>
                </li>
            </ol>
            <ul class="ul_class_1" custom:ezca_ul_1="ul">
                <li>
                    <paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">Unordered item 1</paragraph>
                </li>
                <li>
                    <paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">Unordered item 2</paragraph>
                </li>
            </ul>
        </paragraph>
        <paragraph>
            <link class="link_class_1" url_id="67" custom:ezca_link_1="link">Link</link>
        </paragraph>
    </section>
</section>

Is converted to:

<?xml version="1.0" encoding="UTF-8"?>\n
<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
         xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml"
         xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom" version="5.0-variant ezpublish-1.0">
    <title ezxhtml:level="2" ezxhtml:class="header_class_1">
        <ez-custom-attributes>
            <ezvalue key="ezca_header_1">header</ezvalue>
        </ez-custom-attributes>
        Header
    </title>
    <informaltable class="table_class_1" width="100%" title="summary">
        <ez-custom-attributes>
            <ezvalue key="summary">summary</ezvalue>
            <ezvalue key="caption"/>
            <ezvalue key="ezca_table_1">table</ezvalue>
        </ez-custom-attributes>
        <tbody>
            <tr class="tr_class_1">
                <ez-custom-attributes>
                    <ezvalue key="ezca_tr_1">tr1</ezvalue>
                </ez-custom-attributes>
                <td class="td_class_1" ezxhtml:width="0" valign="top">
                    <ez-custom-attributes>
                        <ezvalue key="valign">top</ezvalue>
                        <ezvalue key="ezca_td_1">td11</ezvalue>
                    </ez-custom-attributes>
                    <para>c11</para>
                </td>
                <td>
                    <para>c12</para>
                </td>
            </tr>
            <tr>
                <ez-custom-attributes>
                    <ezvalue key="ezca_tr_1">tr2</ezvalue>
                </ez-custom-attributes>
                <td>
                    <para>c21</para>
                </td>
                <td>
                    <para>c22</para>
                </td>
            </tr>
        </tbody>
    </informaltable>
    <para>
        <emphasis role="strong" ezxhtml:class="strong_class_1">
            <ez-custom-attributes>
                <ezvalue key="ezca_strong_1">strong</ezvalue>
            </ez-custom-attributes>
            Strong text
        </emphasis>
    </para>
    <para>
        <emphasis ezxhtml:class="em_class_1">
            <ez-custom-attributes>
                <ezvalue key="ezca_em_1">em</ezvalue>
            </ez-custom-attributes>
            Italic text
        </emphasis>
    </para>
    <para ezxhtml:class="para_class_1">
        <ez-custom-attributes>
            <ezvalue key="ezca_para_1">para_1</ezvalue>
            <ezvalue key="ezca_para_2">para_2</ezvalue>
        </ez-custom-attributes>
        Paragraph
    </para>
    <orderedlist ezxhtml:class="ol_class_1">
        <ez-custom-attributes>
            <ezvalue key="ezca_ol_1">ol</ezvalue>
        </ez-custom-attributes>
        <listitem ezxhtml:class="li_class_1">
            <ez-custom-attributes>
                <ezvalue key="ezca_li_1">li</ezvalue>
            </ez-custom-attributes>
            <para>Ordered item 1</para>
        </listitem>
        <listitem>
            <para>Ordered item 2</para>
        </listitem>
    </orderedlist>
    <itemizedlist ezxhtml:class="ul_class_1">
        <ez-custom-attributes>
            <ezvalue key="ezca_ul_1">ul</ezvalue>
        </ez-custom-attributes>
        <listitem>
            <para>Unordered item 1</para>
        </listitem>
        <listitem>
            <para>Unordered item 2</para>
        </listitem>
    </itemizedlist>
    <para>
        <link xlink:href="ezurl://67" xlink:show="none" ezxhtml:class="link_class_1">
            <ez-custom-attributes>
                <ezvalue key="ezca_link_1">link</ezvalue>
            </ez-custom-attributes>
            Link
        </link>
    </para>
</section>

@@ -149,6 +149,18 @@
<xsl:template match="line">
</xsl:template>

<xsl:template name="custom-attributes">
<xsl:if test="@*[namespace-uri() = 'http://ez.no/namespaces/ezpublish3/custom/' and not( local-name() = 'class' ) and not( local-name() = 'align' )]">
<xsl:element name="ez-custom-attributes" namespace="http://docbook.org/ns/docbook">
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be aligned with requested naming changes in ezsystems/ezplatform-richtext#35 (review)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@SerheyDolgushev
Copy link
Contributor Author

@alongosz it is done. Some of the tests are failing because old ezpublish.rng schema is used, which does not allow to have ezattribute element. So it is related to #91.

Thinking about merging #91 into this PR.

@SerheyDolgushev
Copy link
Contributor Author

I think the next logical steps here would be:

  1. Wait until EZP-29301: Added support for custom attributes on elements ezplatform-richtext#35 will be merged.
  2. Merge here Injected RichText Validator from DIC into RichText Converter #91.
  3. Add richtext dependency in this PR.
  4. In this PR switch tests to use EzSystems\EzPlatformRichText\eZ\RichText\Validator\Validator.
  5. Release it as a new major version.

@andrerom @vidarl @alongosz what do you think about it?

@alongosz
Copy link
Member

I think the next logical steps here would be:

  1. Wait until ezsystems/ezplatform-richtext#35 will be merged.
  2. Merge here Injected RichText Validator from DIC into RichText Converter #91.
  3. Add richtext dependency in this PR.
  4. In this PR switch tests to use EzSystems\EzPlatformRichText\eZ\RichText\Validator\Validator.
  5. Release it as a new major version.

From my side this is good plan, but points 3-5 indeed need to be validated by @andrerom and/or @vidarl :)

@alongosz alongosz changed the title Handle custom attributes Handled custom attributes when converting XmlText to RichText Apr 18, 2019
@vidarl
Copy link
Member

vidarl commented Apr 24, 2019

#91 is fine and should be merged to master and then this one can be rebased I think..

It would be nice have all travis stuff working again before merging this one. @alongosz : Any luck with #94 ?

@vidarl vidarl changed the title Handled custom attributes when converting XmlText to RichText [WIP]Handled custom attributes when converting XmlText to RichText Apr 24, 2019
@SerheyDolgushev
Copy link
Contributor Author

Waiting for merge #91 to continue the work here.

@lserwatka
Copy link
Member

#91 was merged

@SerheyDolgushev
Copy link
Contributor Author

@vidarl Please check the latest changes.

Copy link
Member

@vidarl vidarl left a comment

Choose a reason for hiding this comment

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

I find the PR fine, but would like to have all green on travis before we merge this, ref. #94

@SerheyDolgushev
Copy link
Contributor Author

Sorry, but all failed tests does not depend on #94 I believe. They are failing because of ezsystems/ezplatform-richtext v1.1.1 requires php ^7.1 .
So I don't think #94 will have any impact on this PR.
@vidarl

@vidarl
Copy link
Member

vidarl commented Apr 30, 2019

Right, so since this PR introduces dependency to ezsystems/ezplatform-richtext v1.1.1, the travis config should be changed accordingly

@SerheyDolgushev
Copy link
Contributor Author

@vidarl thanks for explanations. Don't have a lot of experience in travis, but b04817a seems pretty straightforward.

@andrerom andrerom changed the title [WIP]Handled custom attributes when converting XmlText to RichText Handled custom attributes when converting XmlText to RichText Apr 30, 2019
@andrerom
Copy link
Contributor

andrerom commented Apr 30, 2019

Failure is due to CS checker and PHP 7.3, I'll update that in master 👍

@andrerom andrerom merged commit 8d2f1d8 into ezsystems:master Apr 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants