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

EZP-29301: Added support for custom attributes on elements #35

Merged
merged 11 commits into from
Apr 19, 2019

Conversation

SerheyDolgushev
Copy link
Contributor

@SerheyDolgushev SerheyDolgushev commented Apr 9, 2019

Question Answer
JIRA issue EZP-29301
Bug/Improvement no
New feature yes
Target version master
BC breaks no
Tests pass yes
Doc needed no

Allows storing custom attributes. This PR does not provide any UI to modify/edit them in Online Editor. But it lets you migrate content from eZ Legacy to eZ Platform.

We used the following example content for tests:

<?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>

Generated content in Online Editor:

<div class="ez-data-source__richtext">
    <h2 class="header_class_1" data-ez-custom-attirbute-ezca_header_1="header">Header</h2>
    <table class="table_class_1" title="summary" style="width:100%;" data-ez-custom-attirbute-summary="summary"
           data-ez-custom-attirbute-caption="" data-ez-custom-attirbute-ezca_table_1="table">
        <tbody>
            <tr class="tr_class_1" data-ez-custom-attirbute-ezca_tr_1="tr1">
                <td class="td_class_1" style="width:0px;vertical-align:top;" data-ez-custom-attirbute-valign="top"
                    data-ez-custom-attirbute-ezca_td_1="td11">
                    <p>c11</p>
                </td>
                <td>
                    <p>c12</p>
                </td>
            </tr>
            <tr data-ez-custom-attirbute-ezca_tr_1="tr2">
                <td>
                    <p>c21</p>
                </td>
                <td>
                    <p>c22</p>
                </td>
            </tr>
        </tbody>
    </table>
    <p>
        <strong class="strong_class_1" data-ez-custom-attirbute-ezca_strong_1="strong">Strong text</strong>
    </p>
    <p>
        <em class="em_class_1" data-ez-custom-attirbute-ezca_em_1="em">Italic text</em>
    </p>
    <p class="para_class_1" data-ez-custom-attirbute-ezca_para_1="para_1" data-ez-custom-attirbute-ezca_para_2="para_2">
        Paragraph
    </p>
    <ol class="ol_class_1" data-ez-custom-attirbute-ezca_ol_1="ol">
        <li class="li_class_1">Ordered item 1</li>
        <li>Ordered item 2</li>
    </ol>
    <ul class="ul_class_1" data-ez-custom-attirbute-ezca_ul_1="ul">
        <li>Unordered item 1</li>
        <li>Unordered item 2</li>
    </ul>
    <p>
        <a data-cke-saved-href="#" href="#" class="link_class_1" data-ez-custom-attirbute-ezca_link_1="link">Link</a>
    </p>
</div>

Output:

<div class="ezrichtext-field">
    <h2 class="header_class_1" data-ez-custom-attirbute-ezca_header_1="header">Header</h2>
    <table class="table_class_1" title="summary" style="width:100%;" data-ez-custom-attirbute-summary="summary"
           data-ez-custom-attirbute-caption="" data-ez-custom-attirbute-ezca_table_1="table">
        <tbody>
            <tr class="tr_class_1" data-ez-custom-attirbute-ezca_tr_1="tr1">
                <td class="td_class_1" style="width:0px;vertical-align:top;" data-ez-custom-attirbute-valign="top"
                    data-ez-custom-attirbute-ezca_td_1="td11">
                    <p>c11</p>
                </td>
                <td>
                    <p>c12</p>
                </td>
            </tr>
            <tr data-ez-custom-attirbute-ezca_tr_1="tr2">
                <td>
                    <p>c21</p>
                </td>
                <td>
                    <p>c22</p>
                </td>
            </tr>
        </tbody>
    </table>
    <p>
        <strong class="strong_class_1" data-ez-custom-attirbute-ezca_strong_1="strong">Strong text</strong>
    </p>
    <p>
        <em class="em_class_1" data-ez-custom-attirbute-ezca_em_1="em">Italic text</em>
    </p>
    <p class="para_class_1" data-ez-custom-attirbute-ezca_para_1="para_1" data-ez-custom-attirbute-ezca_para_2="para_2">
        Paragraph
    </p>
    <ol class="ol_class_1" data-ez-custom-attirbute-ezca_ol_1="ol">
        <li class="li_class_1">Ordered item 1</li>
        <li>Ordered item 2</li>
    </ol>
    <ul class="ul_class_1" data-ez-custom-attirbute-ezca_ul_1="ul">
        <li>Unordered item 1</li>
        <li>Unordered item 2</li>
    </ul>
    <p data-ez-custom-attirbute-ezca_link_1="link">Link</p>
</div>

TODO:

  • Implement feature / fix a bug.
  • Implement tests.
  • Fix new code according to Coding Standards ($ composer fix-cs).
  • Ask for Code Review.

// Maintainer edit: updated PR title and issue type - this is not a bug, it just was not supported yet in the new stack

Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

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

Please add some test fixtures for this feature to https://github.com/ezsystems/ezplatform-richtext/tree/master/tests/lib/eZ/RichText/Converter/Xslt/_fixtures

Otherwise we have no way of tracing regressions when doing changes. It also gives better overview of what the feature provides.

@alongosz alongosz changed the title EZP-30421: Custom attributes EZP-30421: Added support for custom attributes on elements Apr 12, 2019
@alongosz alongosz changed the title EZP-30421: Added support for custom attributes on elements EZP-29301: Added support for custom attributes on elements Apr 12, 2019
@SerheyDolgushev
Copy link
Contributor Author

@alongosz will do it a bit later today

@SerheyDolgushev
Copy link
Contributor Author

@alongosz please have a look at 10c38f5

@SylvainGuittard
Copy link

ping @alongosz for another review :)

Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

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

The only concern I have here is naming which is not consistent with other existing names.

We've decided with @dew326 that we want:

  • for DocBook: ezattribute
  • for OE XHTML5 format: data-ezattribute-....

Additionally I'd change Relax NG definition name to ez.xhtml.data.attribute looking over existing naming convention. This one has no impact on processed DocBook or output for OE.

Below there are some examples of needed changes, but it needs to be fixed in more places:

@SerheyDolgushev
Copy link
Contributor Author

@alongosz done. Please review.

@katarzynazawada katarzynazawada self-assigned this Apr 18, 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