CVS edit link for bunoti

The current workflow of setting up the WYSIWYG API module and configuring Input Filters is inefficient and can be automated.

I've developed a module for in-house use to remove my need to think about manual configuration (and re-configuration) of input filters to match WYSIWYG editor settings. It's a neat module that's worth sharing and should shave off the time needed to manually set up input filters, learning time to know how to set them up, and the frustration of not knowing about them in the first place.

CommentFileSizeAuthor
#1 wysiwyg_autosetter.zip11.5 KBbunoti

Comments

bunoti’s picture

StatusFileSize
new11.5 KB

Module zip attached and contains documentation in README.txt

By the way, when I watched Lullabot's DVD "Site Building with Drupal 2", the wysiwyg configuration chapter took about 35 minutes. It should run to about 15 minutes with this module. I think this module should have been made part of WYSIWYG API from the start to make it more intelligent.

The module currently supports CKEditor and the default Filtered HTML filter, which should serve the majority of use-cases.

If I find some time later, I may add support for other editors and custom filters in the future.

I also have a need to auto detect modules that interact with WYSIWYG (for example the Insert module) and auto-set the tags needed by them, so I may add support for that as well when I get around to it.

P.S. I just thought of an improvement and will add a .install to register the initial variables automatically at install time without needing to visit the module's form and clicking save. For the time being, install the module and visit its form at site/admin/settings/wysiwyg/autosetter and click save just to get the initial variables set. You don't need to use the advanced settings area there unless they're needed.
P.P.S. Will show to Addison Berry from Lullabot to review since she presents on this topic often.

avpaderno’s picture

Status: Postponed (maintainer needs more info) » Needs work
Issue tags: +Module review

Hello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review the code, pointing out what it needs to be changed.

As per requirements, the motivation message should be expanded to contain more features of the proposed project. For themes, it should include also a screenshot of the theme, and (when possible) a link to a working demo site using the proposed theme; for modules, it should include also a comparison with the existing solutions.

sun’s picture

Thanks for your application.

Looking at the code, this module contains some serious issues:

  1. You are changing the Filtered HTML text format (hard-coded), but that format should not allow extended HTML markup in almost all cases.
  2. The module does not seem to take other potentially enabled filters into account (such as line break filter).
  3. The module only works for CKEditor.
  4. System variables should be in the namespace of this module (i.e., use the module name as prefix).
  5. system_settings_form() should only be invoked once.

Overall, I think this module tries to do what is still being discussed in #242096: Expose filter configurations for editors and related issues.

It's also similar to the obsolete http://drupal.org/project/tinymce_autoconf module, although that module really "installed" a default configuration only, i.e., a one-time operation, instead of a permanent synchronization attempt.

My personal opinion (which has no effect on this application) is that we should work on #242096 and related issues instead, since the desired functionality is pretty complex and there is really a lot that can go wrong (including security concerns).

bunoti’s picture

The issue you refer to dates way back to 2008 so I'm less than enthusiastic fiddling around with their module and submitting a patch to its maintainers. Why do I have to worry about an issue sitting in their issue queue from 2008? If they haven't solved this problem by now, they may not be interested. Looks like a solution left for contrib.

Regarding the break filter and support only for CKEditor, as I said in documentation, CKEditor is the most covered editor, and editors are independent units anyway and modules start with fewer features than the complete set. Adding a break filter is probably a matter of 1 line and adding support for additional editors is a matter of getting oriented with them. As can be seen from documentation, the module is already structured with the intention of additional editor support in the future if there's demand for them, but for the time being, the module covers my use-case perfectly, and honestly, given how tight my time is, I have no plans to add more features to a module that hasn't been committed yet. If people need them, they'll ask for them in the issue queue and I'll build on the module and fit them in my free time.

I have no doubt the module is very helpful as is and should be helpful to others in the publishing industry who need this automation.

Regarding 1, I have no idea what you're referring to. Please elaborate.

Regarding the namespace, do you mean that instead of calling the variable filter_html_1_add, I should call it wysiwyg_autosetter_filter_html_1_add? As explained in the documentation, this naming was chosen to remain consistent with wysiwyg. wysiwyg calls its variables filter_html_1 and mine are called filter_html_1_add and filter_html_1_remove. Please provide more detail.

Regarding 5, as covered in documentation, this adds flexibility to the module while taking advantage of built-in Form API functions for the save UI and the actual saving. It keeps my code DRY and minimal and makes sure any changes made to the module settings page still take effect regardless of the order the user follows when setting up things (extra flexibility for user convenience). So it saves the user an extra manual step - they don't have to visit the editor settings page just to click save.

Also, as I said in documentation, this module "fixes" security concerns, not adds to them. It automates the process of matching the tags to the editor buttons the user selects so that frustrated users don't have to switch to the risky Full HTML filter. The only tags the module adds on its own are the ones already added by Drupal itself (can't be a risk) and the br and p tags (which also can't be a risk). It allows admin to add/remove tags as desired, but how is that a security concern? They can do that through the regular filter configuration interface anyway, and it doesn't make sense to take away that ability from them. The module retains this flexibility while adding the automation for each button the user chooses on the editor. The module simply maps tags to user selections. This is admin input after all and the module only responds to user actions. Can you elaborate specifically what security concerns you have in mind?

Andrew

avpaderno’s picture

Status: Needs work » Needs review

The respect of namespace is quite important and it is a requirement, not something that is optional.

bunoti’s picture

Sure, but what changes are you saying need to be made? I'm mapping the names to the names by wysiwyg, so are they doing it wrong and what changes do you recommend?

avpaderno’s picture

Status: Needs review » Needs work
  • The points reported in this review are not in order or importance / relevance.
  • Most of the times I report the code that present an issue. In such cases, the same error can be present in other parts of the code; the fact I don't report the same issue more than once doesn't mean the same issue is not present in different places.
  • Not all the reported points are application blockers; some of the points I report are simple suggestions to who applies for a CVS account. For a list of what is considered a blocker for the application approval, see CVS applications review, what to expect. Keep in mind the list is still under construction, and can be changed to adapt it to what has been found out during code review, or to make the list clearer to who applies for a CVS account.
  1. See http://drupal.org/coding-standards to understand how a module should be written. In particular, see how the code should be formatted; how the functions, Drupal variables, global variables, and constants defined from the module should be named.
  2.   system_settings_form($form);
      autoset_allowed_html();
      return system_settings_form($form);
    
    

    The function system_settings_form() is called twice.

  3. The module, which is not an input filter, doesn't implement hook_uninstall().
  4. Hook implementation comments should be like the following one:
    /**
     * Implements hook_menu().
     */
    

I agree with sun that it's should be better to submit a patch for the existing project, rather than creating a new module. We prefer cooperation.
Issues are not magically resolved; without somebody who wrote the code to fix a bug, Drupal 7 would not exist.

bunoti’s picture

Though I'd love to patch their work, I really don't see my free time allowing me to read through their entire module code to figure out a way to patch it. The link by sun shows they seem to have received patches in the past that they didn't roll in anyway and the need for this feature continues to exist for 2 years. Something about it tells me it's by design.

The submitted module is an independent implementation that works as designed for those who need it. It works perfect for us, so if others who use CKEditor want it, just grab it and test it for yourself. It's well documented, open source, so anything you don't like about it, feel free to just change it to suit your needs.

Happy automation.

avpaderno’s picture

so anything you don't like about it, feel free to just change it to suit your needs

The points I reported in my previous comment needs to be changed, in order for the CVS application to be approved. As I already reported, the respect of the namespace (and other points reported in Drupal coding standards) is not something optional.

It is not the task of who approves CVS applications to change the code for who applies.

sun’s picture

Thanks for your reply.

It seems there is some major confusion:

  • re 1) This module alters filter 1, which is "Filtered HTML", as you also documented in code. Filtered HTML, however, is normally exposed to anonymous users for writing posts and comments. Therefore, it is unsuitable as default (and with this module the only automatically setup) text format having a client-side editor attached.

    This module semi-automates the HTML filter configuration for Filtered HTML. Thus, users who are not familiar with all details may change their editor button configuration only without ever looking at the Filtered HTML configuration again. Effectively making their sites vulnerable and open to attacks, which are the security concerns here.

    Instead of the Filtered HTML format, this module should configure the Full HTML format. Ideally, of course, you'll likely want to support any text format and add a warning or help text to remind administrators that altering the editor configuration may make text format less secure. But until that is the case, you should only work with the Full HTML text format in this module.

  • re 4) The "filter_html_*" variable(s) belong to the HTML filter ("Allowed HTML tags") of Filter module in Drupal core, not Wysiwyg module. Thus, the variables are within the namespace of Filter module.
  • re #4: No one happened to work on #242096: Expose filter configurations for editors yet, so it's only natural that nothing happened.
  • re 5) It is good that you use Drupal's API correctly. However, system_settings_form() should not be invoked twice. I wonder where this is not documented correctly. Do you have a link to a site or page, which says it should be invoked more than once?
avpaderno’s picture

Status: Needs work » Closed (won't fix)

I am closing this application due to lack of replies.

avpaderno’s picture

Component: Miscellaneous » new project application
Issue summary: View changes

Please read the following links as this is very important information about CVS applications.