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

Allow <body> attributes #6281

Merged
merged 4 commits into from Jan 2, 2014
Merged

Allow <body> attributes #6281

merged 4 commits into from Jan 2, 2014

Conversation

hellekin
Copy link

This allows plugin authors to add attributes to the body tag.

This patch comes after a request by @melvincarvalho to implement <body about="this"> as a feature to bootstrap Semantic Web and Linked Data support in Elgg.

Usage:

elgg_register_plugin_hook_handler('output:before', 'page', 'my_body_attrs');

Then:

function my_body_attrs($hook, $type, $value, $params) {
    $value['body_attrs'] = array('about' => 'this');
    return $value;
}

* @return string
* @since 1.9.0
*/
function elgg_set_body_attrs($body_attrs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just use elgg_format_attributes with some additional params filtering?

Copy link
Author

Choose a reason for hiding this comment

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

My bad, I overlooked elgg_format_attributes. As @mrclay prefers no filtering, then using it directly would work, which makes that function useless.

@Srokap
Copy link
Contributor

Srokap commented Dec 18, 2013

Tests are failing on coding standards violations, see: https://travis-ci.org/Elgg/Elgg/jobs/15621582

@Srokap
Copy link
Contributor

Srokap commented Dec 18, 2013

In general we have slightly different plan for this feature. See: #4830

@mrclay What's your opinion about this PR?

It's never nice to implement sth in one version just to replace it in the next version.

@mrclay
Copy link
Member

mrclay commented Dec 18, 2013

Not crazy about this implementation. Why don't we call the trigger in the view and use elgg_format_attributes. There's no need for a new function, nor to limit the attributes. data-* could be useful, e.g.

$body_attrs = array(
'unauthorized' => 'attribute',
'class' => 'may be multiple',
'id' => 'i#s^-&&%\\/fr@ien!dl(y',
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we want to support cleaning such mess. See what HTML 4.01 standard says about ID values

Only thing I've found in HTML 5.1 working draft is much more permissive. If that would be it, we actually shouldn't do such filtering, might think about escaping though.

So I would just say that developer CAN hurt himself and I'm not convinced we should prevent it in this case (BTW, it seems that you filter out : which is actually valid one).

/cc @mrclay @ewinslow

@hellekin
Copy link
Author

Here, simplicity rules.

@Srokap
Copy link
Contributor

Srokap commented Jan 2, 2014

I'm leaning towards merging it in current shape if @mrclay won't object

mrclay added a commit that referenced this pull request Jan 2, 2014
Allow setting BODY attributes in page/default view
@mrclay mrclay merged commit 5cfefc0 into Elgg:master Jan 2, 2014
@hellekin hellekin deleted the body_vars branch February 1, 2014 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants