This is a simple module that adds a css reset at a module level. One benefit of this appoach is that the 'reset' can be loaded before other modules that include some css etc. This means that the 'reset' should only normalise the user agent's styles and not styles that have been defined in other core and contributed modules that may be loaded by Drupal before the theme layer.

Project Page

https://www.drupal.org/sandbox/2dareis2do/2275019

Git Clone

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/2dareis2do/2275019.git css_reset

CommentFileSizeAuthor
#4 codeformats_2508285.patch1.98 KBkrknth

Comments

PA robot’s picture

Status: Active » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandbox2dareis2do2275019git

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

ayesh’s picture

Title: Css Reset » [D7] Css Reset

Hi Daniel,
Thanks for submitting this application. I'm not aware of such CSS resets modules either, and the aim of this module is clear and unique!

I have found a few points, but none of them are blocking issues. However, it's always good to clean them up to prevent buggy behavior and for best practices.

- Instead of using hook_init(), use hook_page_build() to add the CSS reset file. hook_init is removed in D8, and in D7, hook_init is invoked on Ajax pages as well, but not cached. hook_page_build is perfect to add CSS files because the output can be cached, and Drupal does not invoke it unless the page is serving full HTML.

- This modules does not define any PHP classes. It's not necessary to use the files[] in the module .info file to explicitly define them. It only adds some overhead to the code registry scanner.

kamescg’s picture

It's not necessary, but it can improve readability (IMHO) - store the "drupal_add_css" options in a $options variable.

$options = array(
'group' => CSS_SYSTEM,
'every_page' => TRUE,
'media' => 'all',
'preprocess' => TRUE,
'weight' => '-1001'
)
drupal_add_css($path . '/' . 'meyer.min.css', $options);

krknth’s picture

StatusFileSize
new1.98 KB

Attached patch for code formats & a tag issue

File : css_reset.module

Function : clear_cache_action
Please add comments incase you are using any drupal core functions.

Please fix code format issues

Line 48: String concatenation should be formatted with a space separating the operators (dot .) and the surrounding terms drupal_add_css($path . '/' . 'meyer.min.css',

File : css_reset.admin.inc

Please do not use a tags, use l() function to generate links.

Please fix code format issues

Line 24: Use an indent of 2 spaces, with no tabs
'#type' => 'checkbox',
Line 25: Use an indent of 2 spaces, with no tabs
'#title' => t('Enable Reset library site wide'),
Line 26: Use an indent of 2 spaces, with no tabs
'#default_value' => variable_get('css_reset_sitewide', FALSE),

Please add git clone link :)

2dareis2do’s picture

Issue summary: View changes
2dareis2do’s picture

Many thanks for all your comments which I have to say have been very helpful.

Ayesh

As suggested I have replaced the use of hook_init(), with hook_page_build(). As you explained it makes much more sense from a caching/performance perspective. I have removed instances where I make use of files[] in the .info file.

kamescg

Your suggestion of replacing drupal_add_css" options with an $options variable to make the code more readable is a good one.

krknth

many thanks for your patch which I have applied. I have also addressed one of the code formatting options that you mention. Not sure what you mean by clear cache action?

PA Robot
I have re-packaged as a 7.x-1.x branch and addressed some of the issues identified by your scraper.

Hopefully you should also have git access? If not I have uploaded with the changes as a gunzip on the drupal project home page.

krknth’s picture

@2dareis2do I mean add comment for function clear_cache_action ( if u agree :) )

2dareis2do’s picture

Status: Needs work » Needs review
2dareis2do’s picture

Issue summary: View changes
gaja_daran’s picture

Hi,
Fix all pareview issues.

2dareis2do’s picture

Hi gaja,

Thanks for the tip,

I have addressed all the pareview (not preview, god I hate autocomplete) issues, (of which there were many) apart from:

FILE: /var/www/drupal-7-pareview/pareview_temp/css_reset.module
---------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------
55 | WARNING | Do not use drupal_add_css() in hook_page_build(), use
| | #attached on the $page render array instead
---------------------------------------------------------------------------

which I think may be a false positive?

I have also addressed a few other issues including:

  1. removing the minified css version - my feeling is that this will be concatenated and aggregated, along with the rest of the css so minification really serves minimal benefit. The flip side is it should making installing and using this module more straightforward and if the user really wants there is nothing to stop them from minifying this file should they choose. Infact, we could easily add the option to use a minified version of the file as opposed to the unminified version if required.
  2. I have removed the references to meyer as the default css reset and simply called this reset. This new name is neutral and leaves the door open for a developer/site builder/themer to use and choose any reset they want there. This could be meyer, normalise or something else. That said, the default reset is actually meyer, there is a copy of this (unminified) and a variation that I have come up with that developers etc can use if required.

I need to investigate a bit more but I am also looking into setting up a simple test. This is new ground for me here so I need to research a bit further. Regardless, I hope that this module is moving closer to a full release?

Thanks for your support.

azeiteiro’s picture

Manual Review

-> Fix git url in your git clone command;
-> * Implements hook_help()
It is recommended to get the basic understanding of the module to new users.
2dareis2do’s picture

Hi Azeiteiro

Thanks for your manual review. I have implemented hook_help as suggested. Certainly this makes sense.

I am not sure what you mean when you say "> Fix git url in your git clone command;" I have updated the link to be the same as the link provided. I am not sure how this works because I presume no one else has my password which is required to checkout/clone the files?

2dareis2do’s picture

Issue summary: View changes
PA robot’s picture

Issue summary: View changes

Fixed the git clone URL in the issue summary for non-maintainer users.

I'm a robot and this is an automated message from Project Applications Scraper.

2dareis2do’s picture

Ok great. Clever things these robots.

Also addressed a few formatting issues with the enclosed resets and spelling issues as shown on recent pareview report. Removed minified css file as this could not be processed.

thatpatguy’s picture

This module appears to work as intended. As you stated above, there is a warning being thrown by pareview. Whether it's a false positive or not, I think you might need to check with the developers on IRC as to what they think. From what I understand, you are better off doing it the way you're doing it. Also, it's a warning and not an error. I don't know how strict those with approval permission are, however. You should check on IRC or something.

Also, I think included the Meyer reset.css might also violate the 3rd party assets/code requirements. Again you might want to check on IRC.

Lastly, I think this module would be even nicer if it just supported any custom css file created and uploaded into the css_reset directory in the library. Meyer's reset CSS is great, but I could see other applications where you'd want to use something else/something custom.

Automated Review

There is one warning in the code:
http://pareview.sh/pareview/httpgitdrupalorgsandboxhenryw2496335git

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.

No duplication
Yes: Does not cause module duplication and/or fragmentation.

Master Branch
Yes: Does follow the guidelines for master branch.

Licensing
Yes: Follows the licensing requirements.

3rd party assets/code
No: I could be wrong here, but I think by adding the meyer reset to your module goes against this requirement, where you should just point people to where to get it in your documentation (which you have also done). I appreciate that you added the file into your module to make it easier for the suer, but I believe this puts it in violation.

README.txt/README.md
Yes: Follows the guidelines for in-project documentation and/or the README Template.

Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.

Secure code
Yes: Meets the security requirements.

2dareis2do’s picture

Many thanks thatopatguy

I think the link you reference should be

http://pareview.sh/pareview/httpgitdrupalorgsandbox2dareis2do2275019git

Certainly the idea is you can use any reset of your choice including your own. I have renamed the file to reset.css and by default I have referenced meyer which I have also included as the default as well as my own variation by way of example.

Just checking on MeyerWeb and it says the following:

"If you want to use my reset styles, then feel free! It's all explicitly in the public domain (I have to formally say that or else people ask me about licensing). You can grab a copy of the file to use and tweak as fits you best. If you're more of the copy-and-paste type, or just want an in-page preview of what you'll be getting, here it is."

http://meyerweb.com/eric/tools/css/reset/

I will check on IRC as suggested if this is acceptable with regards the use of 3rd Party assets / and code. I will also check with regards the use of drupal_add_css() in hook_page_build(), (use | | #attached on the $page render array instead)

2dareis2do’s picture

As suggested by paraview, I am trying to to replace drupal_add_css(), which works well, within hook_page_build() with #attached but seem to be having issues getting the form working. So I currently have:

/**
 * Implements hook_page_build().
 */
function css_reset_page_build() {
  $path = libraries_get_path('css_reset');
  // Needs to be in the CSS_SYSTEM group rather than the CSS_DEFAULT group.
  $options = array(
    'group' => CSS_SYSTEM,
    'every_page' => TRUE,
    'media' => 'all',
    'preprocess' => TRUE,
    'weight' => '-1001',
  );
// trying to replace
 // drupal_add_css($path . '/reset.css', $options);


  /* use attached instead */
  $page['#attached']['css'][$path . '/reset.css'] = $options;
}

However the attached stylesheet is not rendering. What am I doing wrong?

2dareis2do’s picture

Ok I think I figured it out. I need to add:

  return drupal_render($page);

so

/**
 * Implements hook_page_build().
 */
function css_reset_page_build() {
  $path = libraries_get_path('css_reset');
  // Needs to be in the CSS_SYSTEM group rather than the CSS_DEFAULT group.
  $options = array(
    'group' => CSS_SYSTEM,
    'every_page' => TRUE,
    'media' => 'all',
    'preprocess' => TRUE,
    'weight' => '-1001',
  );
// trying to replace
 // drupal_add_css($path . '/reset.css', $options);
  /* use attached instead */
  $page['#attached']['css'][$path . '/reset.css'] = $options;
  return drupal_render($page);
}
2dareis2do’s picture

Title: [D7] Css Reset » [D7] CSS Reset
nbouhid’s picture

Status: Needs review » Needs work

Automated Review

No issues identified http://pareview.sh/pareview/httpgitdrupalorgsandbox2dareis2do2275019git

Manual Review

Individual user account
Yes: Follows.
No duplication
Yes.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Follows the guidelines for 3rd party assets/code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes: Meets the security requirements
Coding style & Drupal API usage

css_reset.test

  1. Update the documentation for the testCssResetMenus() test. Seems it was copied from the js_example module.
      /**
       * Tests the menu paths defined in js_example module.
       */
      public function testCssResetMenus() {
        $paths = array(
          'admin/config/media/css-reset',
        );
        foreach ($paths as $path) {
          $this->drupalGet($path);
          $this->assertResponse(403, '403 response for path: ' . $path);
        }
      }
  2. (*) Do you really this that test is needed? I'd say it's not since it isn't testing any module functionality. It could at least check if the CSS file is being added. Consider removing it or updating it.

css_reset.module

  1. (*) You don't need to return anything on this hook. Remove the last lines
    /**
     * Implements hook_page_build().
     */
    function css_reset_page_build() {
      $path = libraries_get_path('css_reset');
      // Needs to be in the CSS_SYSTEM group rather than the CSS_DEFAULT group.
      $options = array(
        'group' => CSS_SYSTEM,
        'every_page' => TRUE,
        'media' => 'all',
        'preprocess' => TRUE,
        'weight' => '-1001',
      );
      // drupal_add_css($path . '/reset.css', $options);
      /*Do not use drupal_add_css() in hook_page_build(), use
      | | #attached on the $page render array instead */
      $page['#attached']['css'][$path . '/reset.css'] = $options;
      // dprint_r($page);
      return drupal_render($page);
    }
    

css_reset.install

  1. (*) Based on how you're including your css file. This should not be necessary any more.
    /**
     * Implements hook_install().
     */
    function css_reset_install() {
      db_update('system')
        ->fields(array('weight' => -1001))
        ->condition('name', 'css_reset', '=')
        ->execute();
    }
    

CSS files included

  1. (*) Although it follows the licensing standard, it's also using the library api. So there is no need to have these on the module.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

Seems that is almost ready for being published. Only one major issue found.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

PA robot’s picture

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

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.

avpaderno’s picture

Category: Support request » Task
Issue tags: -Module review