Contextual links is not a module

sun - November 7, 2009 - 16:30
Project:Drupal
Version:7.x-dev
Component:system.module
Category:bug report
Priority:normal
Assigned:sun
Status:reviewed & tested by the community
Issue tags:Contextual links, D7 API clean-up
Description

Before proceeding with any other architectural and UX improvements for contextual links, we want to move them into an own module, because they have nothing to do with System module and only add cruft to sites that don't want them.

#607244: Decrease performance impact of contextual links made this possible.

#622766: Contextual links UI elements are not a library is required to start work here.

http://drupal.org/project/contextual_links throws a 404, so no problem here.

I kindly request to

mkdir modules/contextual_links
touch modules/contextual_links/contextual_links.info
cvs add modules/contextual_links/contextual_links.info
cvs commit

because adding directories is a mess with CVS.

#1

Rob Loach - November 7, 2009 - 18:18

Subscribinationed.

#2

David_Rothstein - November 7, 2009 - 23:11

What are the reasons for a module? Contextual links are a standard UI element, and we don't normally make modules for each of these (for example, Vertical Tabs are not a module...)

I think they might actually make more sense as a theme setting. This allows a theme to decide it doesn't want to support displaying them at all, and also allows the site administrator to toggle them on or off for themes that do support them.

#3

sun - November 7, 2009 - 23:21

1) Who said it's a standard UI element? No one.

2) Contextual links are an optional feature. Features need to be able to be completely disabled. In fact, there may well be a better_contextual_links contrib module. Take away the presumptions, please.

3) As mentioned in the OP, further changes to contextual links should happen in follow-ups. A per-theme setting may be worth to explore. But not in here.

#4

moshe weitzman - November 8, 2009 - 12:47

@sun - please settle down. your reply has the effect of chilling conversation. David's question is completely on topic.

it is extremely unusual to create a shell module dir in CVS before that module arises. I don't even see a draft of such a module. Perhaps use git/bzr or upload individual files.

#5

sun - November 8, 2009 - 21:14
Status:active» needs review
AttachmentSizeStatusTest resultOperations
cl.patch13.03 KBIdleFailed: Failed to apply patch.View details | Re-test

#6

System Message - November 8, 2009 - 21:30
Status:needs review» needs work

The last submitted patch failed testing.

#7

sun - November 8, 2009 - 23:29
Status:needs work» needs review

Is there are (simple) reason for why my git checkout of HEAD has differrent $Id$ tags than my CVS checkout of HEAD?

The date format is different. And due to that, this patch, which moves an entire file, doesn't apply. Fixed manually for now.

AttachmentSizeStatusTest resultOperations
cl.patch13.03 KBIdleFailed: 14571 passes, 262 fails, 7018 exceptionsView details | Re-test

#8

System Message - November 8, 2009 - 23:45
Status:needs review» needs work

The last submitted patch failed testing.

#9

David_Rothstein - November 9, 2009 - 03:20

We don't need to make contextual links a module in order to enable a 'better_contextual_links' contrib module - we just need to make them alterable. This should be simple if we make them a standard element with a pre-render function, because then hook_element_info_alter() can be used to change any aspect of how they are built. This seems like a good idea to me either way, so I posted a patch for it in a separate issue at #627288: Contextual links are not alterable.

I know a theme setting is a separate issue, but the reason I mentioned it here is that it would also fulfill the goal of allowing them to be disabled. We could have both that and a module, but at some point there are too many different ways to disable the same thing...... Also (unfortunately), looking at http://api.drupal.org/api/function/system_theme_settings/7 and http://api.drupal.org/api/function/_system_rebuild_theme_data/7 it seems like the process for adding a theme setting/feature for an optional module is a bit dicey?

One advantage of making it a separate module is the permission - that does seem to make more sense on the permission screen when it's in its own area, as opposed to stuffed in with everything else in system.module.

#10

catch - November 9, 2009 - 03:31

system.module really ought to be split up anyway in D8, it's just a big dump of random stuff at the moment, so making this into a module seems like a decent step along the way. It makes as much sense as user, node and field modules being separate modules from system (i.e. a lot, despite those ones being required).

#11

Rob Loach - November 9, 2009 - 15:52
Status:needs work» needs review

Fixed a couple things.

AttachmentSizeStatusTest resultOperations
contextuallinksmodule.patch15.09 KBIdleFailed: 14577 passes, 229 fails, 5117 exceptionsView details | Re-test

#12

System Message - November 9, 2009 - 16:10
Status:needs review» needs work

The last submitted patch failed testing.

#13

Rob Loach - November 9, 2009 - 16:18

menu_contextual_links would need documentation updates.

#14

sun - November 9, 2009 - 16:32

+++ modules/block/block.tpl.php 9 Nov 2009 15:50:34 -0000
@@ -11,7 +11,6 @@
- * - $contextual_links (array): An array of contextual links for the block.
@@ -37,11 +36,7 @@
-<?php if ($contextual_links): ?>
<?php print render($contextual_links); ?>
-<?php endif; ?>

huh? Why are you removing the template variable rendering?

I'm on crack. Are you, too?

#15

Rob Loach - November 9, 2009 - 17:45

I was surprised by that too, but it seemed that render was still smart enough to still display the contextual links even after their removal from the block.tpl.php template file. Not sure why, I just assumed it was some render magic as it was working, and working quite nicely.

.... I think it's because drupal_render goes through every child element, and only prints it if the #printed variable isn't hit. Since it's not #printed in block.tpl.php, it prints it through drupal_render().

#16

sun - November 9, 2009 - 17:53

Because you did not remove it from the overridden template in the theme?

#17

David_Rothstein - November 9, 2009 - 17:56

They still display in Garland because Garland's block.tpl.php prints them explicitly. Seven's doesn't, though, which means they won't display at all in Seven with the latest patch.

There's also a problem here in that the $contextual_links variable is not defined when the module is disabled, leading to PHP notices in the template file. Presumably that's why the testbot is reporting 5117 exceptions :)

#18

David_Rothstein - November 10, 2009 - 22:51

By the way, I just created #629160: Add a theme setting for contextual links and posted a patch there. They are independent issues (and either can theoretically be done without the other), but it is worth crosslinking since they are related.

#19

sun - November 11, 2009 - 20:44
Status:needs work» needs review

Re-rolled more easily thanks to http://mikkel.hoegh.org/blog/2009/nov/9/attention-all-drupal-git-mirror-...

This is a straight move of functions and files. Can we go ahead?

AttachmentSizeStatusTest resultOperations
contextual_links.18.patch13.15 KBIdleFailed: 14667 passes, 180 fails, 7019 exceptionsView details | Re-test

#20

System Message - November 11, 2009 - 21:15
Status:needs review» needs work

The last submitted patch failed testing.

#21

sun - November 11, 2009 - 23:17
Status:needs work» needs review

- Fixed template variables.

- Added Contextual links module to default profile.

AttachmentSizeStatusTest resultOperations
contextual_links.20.patch15.24 KBIdlePassed: 14698 passes, 0 fails, 0 exceptionsView details | Re-test

#22

sun - November 12, 2009 - 00:04

Tests pass.

Incorporated #13.

AttachmentSizeStatusTest resultOperations
contextual_links.21.patch15.68 KBIdlePassed: 14702 passes, 0 fails, 0 exceptionsView details | Re-test

#23

sun - November 12, 2009 - 00:06

Fixed PHPDoc of hook implementations according to new standard.

AttachmentSizeStatusTest resultOperations
contextual_links.22.patch15.67 KBIdlePassed: 14689 passes, 0 fails, 0 exceptionsView details | Re-test

#24

catch - November 12, 2009 - 03:55
Status:needs review» reviewed & tested by the community

This is just moving code around, the important place where it's not just a simple move of code is the change from system_preprocess() to contextual_links_preprocess(). When system.module is implementing hooks on behalf of includes, that makes sense, when it's implementing hooks on behalf of itself, then that usually deserves to be its own module.

#25

David_Rothstein - November 12, 2009 - 04:46
Status:reviewed & tested by the community» needs review

I fixed a few small issues (which can be seen in the interdiff file), including one that prevented the contextual links from appearing correctly at all... since the library was not being registered for the correct module.

I think this one should probably be good to go.

This still feels to me like as a single UI element, it may be too small of a feature to really belong on the modules page, but it definitely improves the code organization and definitely improves the permission page, so it seems to makes sense. I also realized that the technical conflict between having theme settings for an optional module that I mentioned above is not as bad as I thought - or rather, it probably is as bad as I thought, but it is already affecting the comment module (see #629826: Theme setting toggles for comments appear when the comment module is disabled) so we wouldn't be making things any worse by doing that for this one too :)

AttachmentSizeStatusTest resultOperations
contextual_links.25.patch18.87 KBIdlePassed: 14715 passes, 0 fails, 0 exceptionsView details | Re-test
interdiff.22.25.txt2.21 KBIgnoredNoneNone

#26

David_Rothstein - November 12, 2009 - 04:53

Actually let's not delete that function reference from the PHP docs of hook_menu_contextual_links_alter(), but rather replace it with the new function name.

AttachmentSizeStatusTest resultOperations
contextual_links.26.patch18.91 KBIdlePassed: 14727 passes, 0 fails, 0 exceptionsView details | Re-test
interdiff.22.26.txt2.25 KBIgnoredNoneNone

#27

sun - November 12, 2009 - 05:07

+++ modules/contextual_links/contextual_links.module 12 Nov 2009 04:50:47 -0000
@@ -0,0 +1,141 @@
+/**
+ * Implement hook_permission().
+ */
...
+/**
+ * Implement hook_library().
+ */

Implements is the current and ONLY valid coding standard. Please revert.

I'm on crack. Are you, too?

#28

David_Rothstein - November 14, 2009 - 21:33

Hm, you are right - it does appear to be the official coding standard now, even though 95% of core is currently violating it :)

AttachmentSizeStatusTest resultOperations
contextual_links.28.patch18.91 KBIdlePassed on all environments.View details | Re-test

#29

David_Rothstein - November 19, 2009 - 06:00
Status:needs review» reviewed & tested by the community

I only contributed about 3 lines of code to this patch, and reviewed it while doing so, so I think I can safely mark this RTBC :)

We have a few other issues that have been marked postponed on this one, so I think we want to either get this committed soon (or otherwise un-postpone those...)

#30

sun - November 21, 2009 - 14:17

yes, please.

Any patches for #601150: Improved UI for contextual links (none exists yet) will break after this one lands.

#31

Dries - November 21, 2009 - 14:25

Mmm, I want to give this some more thought because I'm not 100% convinced this should live in a stand-alone module. It makes sense from a code perspective, but less so from a feature perspective -- although it is not unreasonable. I'll thinker about this a bit.

#32

sun - November 28, 2009 - 14:56

Did we think about it?

#33

webchick - November 28, 2009 - 16:47

I'm also not sure about this. Vertical tabs, collapsible fieldsets, local tasks, autocomplete fields, and other such common UI patterns elements are not disableable. In contrast to things like Dashboard, Toolbar, Shortcuts, etc. which are clearly features, contextual links feels like another such pattern. If contributed modules can't count on them being there, I fear we get back into Views, Zen, etc. all implementing their own different and often incompatible versions of the same thing, which is what that patch was intended to address.

I understand they look ugly as all hell now, but that's what #601150: Improved UI for contextual links is for.

If the desire is to retain the ability to "opt out" of contextual links, then a simple variable seems like it'd be sufficient, if it's not already present.

#34

sun - November 28, 2009 - 17:04

system.module really ought to be split up anyway in D8, it's just a big dump of random stuff at the moment, so making this into a module seems like a decent step along the way. It makes as much sense as user, node and field modules being separate modules from system (i.e. a lot, despite those ones being required).

When system.module is implementing hooks on behalf of includes, that makes sense, when it's implementing hooks on behalf of itself, then that usually deserves to be its own module.

This still feels to me like as a single UI element, it may be too small of a feature to really belong on the modules page, but it definitely improves the code organization and definitely improves the permission page, so it seems to makes sense.

And lastly:

For D7, we agreed that the entire concept of contextual links is too young to base any required functionality on it.

Not to mention that we reverted comment administration links from being contextual links due to performance reasons.

This is a "product feature" that may be suitable for 80% of Drupal sites, perhaps only 50%, perhaps only 20%. It would be wrong to do any assumptions for how Drupal is going to be used.

#35

Dries - November 28, 2009 - 21:34

Would be good to have some other people chime in. Any thoughts folks?

#36

Dave Reid - November 28, 2009 - 23:09

I'd prefer this is split properly in D8. Lots of things could be their own modules from system.module. I'd prefer we have this built-in currently so lots of other things can rely on it.

#37

sun - November 29, 2009 - 00:22

There is nothing to "rely on".

If your module's functionality absolutely needs them, then it ought to do what all modules do that want to rely on something:

dependencies[] = contextual_links

#38

catch - November 29, 2009 - 07:35

Yeah I don't see what's wrong with declaring dependencies either, it's not like you're requiring a separate download even.

 
 

Drupal is a registered trademark of Dries Buytaert.