Favicon creator using Real Favicon Generator API.

Features:
Created icons for:

  • iOS
  • Windows 8
  • Firefox
  • Android
  • OpenGraph
  • Coast
  • Yandex

Requirements:
Drupal 7.x
Utilizes the farbtastic library which is included in core.

Installation:
Download and enable the module and any/all sub-modules.
Go to /admin/config/user-interface/favicon_generator configure and save the settings.
Go to Appearance settings (either general and/or theme specific).
Un-check 'Use the default shortcut icon.' if enabled.
Set a path to the icon file or upload a new image.
Save configuration.
It may take a few seconds to fetch and save the files.

Notes:
The icon file should be square and be at least 70x70 px, preferably 300x300 px or larger, for best quality - although the module will do it's best to resize small files.

Module Link:
https://www.drupal.org/sandbox/johncook/2378569

Link to git Repository:

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/johncook/2378569.git favicon_generator
cd favicon_generator

Comments

ijortengab’s picture

Hai,
- please add prefix in your title of Issue Post with [D7]
- change git clone with:
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/johncook/2378569.git favicon_generator
your current code for cloning git is only for you as maintener, not for public.

ijortengab’s picture

My review use bartik theme.

1. In file favicon_generator.info
- Add this line:
configure = admin/config/user-interface/favicon_generator
- You don't need define package if you set "package = Other". You should remove it.
2. in file favicon_generator.module inside function favicon_generator_theme_form_submit()
- Your code don't anticipate if $settings['favicon_path'] is empty string. It makes
image_get_info() return FALSE. Not all themes provide input for favicon_path.
3. Founds to many issue of coding standard in
http://pareview.sh/pareview/httpgitdrupalorgsandboxjohncook2378569git

john cook’s picture

Title: Favicon Generator » [D7] Favicon Generator
Issue summary: View changes

#1 Done

john cook’s picture

#2 Done

john cook’s picture

Status: Needs work » Needs review
PA robot’s picture

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.

sahil chadha’s picture

Done

john cook’s picture

Issue summary: View changes
gaurav.pahuja’s picture

Status: Needs review » Needs work

There are multiple TODOs in this module that you mentioned.
One of most important one is related to access.

Please work on these issues and then submit for review.

john cook’s picture

Status: Needs work » Needs review

Added permissions for admin UI and some other fixes re: #9

sendinblue’s picture

Assigned: Unassigned » sendinblue

for review by me

sendinblue’s picture

Manual Reviews

- Secure code
(*) Your admin functions are accessible by anon users because the hook_menu() has 'access callback' set to TRUE. Don't use this entry unless you provide your own access callback function.

$items['api/favicon'] = array(
    'title' => 'favicon_generator',
    'page callback' => 'favicon_generator_json_return',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );

- Coding style & Drupal API usage
(+) All of your variables should be removed by variable_del() function once uninstall

sendinblue’s picture

Assigned: sendinblue » Unassigned
Status: Needs review » Needs work
john cook’s picture

Status: Needs work » Needs review

Removed debugging functions into a new file so not accessible on live sites and added install file to remove variables on uninstall. Re: #12

john cook’s picture

Issue summary: View changes
john cook’s picture

Added image resizing to remove sizing requirements.

john cook’s picture

Issue summary: View changes

Modularized function to enable/disable the types of icons.

sagar ramgade’s picture

Automated Review

Review of the 7.x-1.x branch (commit 7b12e08):

./favicon_generator.api.inc: all functions should be prefixed with your module/theme name to avoid name clashes. See https://www.drupal.org/node/318#naming

function hook_favicon_generator_admin() {
function hook_favicon_generator_spec(array $settings) {
No automated test cases were found, did you consider writing Simpletests or PHPUnit tests? This is not a requirement but encouraged for professional software development.

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: 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
[No: Does not follow] 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
[ No: List of security issues identified.]
line no 146 , $r = json_decode($response->data); since it is coming from the 3rd party, it needs to sanitized accordingly. For more info Check Santization functions
Coding style & Drupal API usage
  1. (*) favicon_generator_theme_form_submit in favicon_generator. module is doing validation for favicon image size, This should be in the validation function and form_set_error() can be used
  2. (*) Form #title for every form (.module, aa) should be enclosed by t() so that it can be translated
  3. (*) Rename file favicon_generator.api.inc to favicon_generator.api.php

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.

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.

sagar ramgade’s picture

Status: Needs review » Needs work
klausi’s picture

@Sagar: "$r = json_decode($response->data);": is not a XSS security issue by itself, since no data is printed to HTML in this line. You only need to sanitize user provided data when actually printing something.

sagar ramgade’s picture

Thanks, Now i read it carefully. It is not being used anywhere for printing.

john cook’s picture

Status: Needs work » Needs review

Did adjustments suggested in #18 except Coding style part 1.

This is due to system_theme_settings_submit() needing to execute before the validation can take place. The validation attempts to fix the errors and, if it fails, can continue with the standard favicon implementation.

john cook’s picture

Issue summary: View changes
wiifm’s picture

Hey John,

Nice work on the module, I actually have been doing all of this manually in Drupal, and wrote about this on my blog post, when someone mentioned you are creating this module.

My cursarely look over the module:

  • Why are you using the default favicon path in the appearance admin screen, rather than a dedicated form upload in your admin settings screen? To me this seems like a more natural place for it to be. I mean the configure link does point to it from the modules page, yet you cannot upload the favicon? You can maybe do a form alter on the appearance admin screen to mention the favicon is now being controlled by favicon_generator (and link to it).
  • Why introduce 4 sub modules into the equation? Having to install 5 modules is too much for what should be a lightweight API that for the most part does nothing, here there are a lot of files and a lot of code included on every page request. My thoughts - have a single module, with includes for the 1 time use code (e.g. the favicon fetching and downloading code). The alter hooks are fine if you want to support further contrib modules down the path (ideally they would be merged in).

I am also keen to help with the development of the module, if you need the help.

Sean

john cook’s picture

Hi Sean

I used the default favicon upload screen for three reasons.

  1. It allows a site designer to do the basic set up and allow site administrators to change the icon if needed.
  2. It allows a different favicon for each theme easily.
  3. It's where people go to set the favicon.

I may duplicate this on the favicon generator admin screen so it can all be set up in one go, but it'll only change the default favicon.

I split it into sub modules so the site designer can request different platforms easily. I admit that the ones there at the moment might be better included but I am shortly going to add functionality for the Yandex browser (popular in Russia but unheard of anywhere else).
And since you mentioned it, I'm starting to think about having different favicon sources. So you could get favicon.ico from one place and the open graph image from another.

I hop this answers your question. Any thing please ask.

John

joachim’s picture

> * Implements hook_settings().

Hasn't been a hook since something like Drupal 4.7.

> * @author JohnCook

Our coding guidelines recommend not putting author names in code -- this can deter future contributors. Credit will be in the git history.

> * Implements hook_form_submit().

That's not a hook either. Check the documentation at api.drupal.org ;) That should say something like 'Additional submit handler for the yada yada form'. ('Additional' since you're adding it in with form alteration).

        $path = dirname(__FILE__) . '/README.txt';
        if (file_exists($path)) {
          $readme = file_get_contents($path);
        }

Your code should probably know the contents of its own module folder... ;)

john cook’s picture

Completed suggestions from #26

rikki_iki’s picture

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: 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 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.
Coding style & Drupal API usage
[List of identified issues in no particular order. Use (*) and (+) to indicate an issue importance.
  1. If I change the module settings page (ie change background colour) after uploading my favicon file to the theme settings page, the favicons aren't regenerated. I need to go back to the theme settings page and re-save. Perhaps just adding a message to this affect when saving the module settings page will save some people a bit of confusion.

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.

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.

john cook’s picture

Added message to re-save theme settings as suggested in #28.

polaki_viswanath’s picture

Hi

These are some suggessions which must be fixed,

Readme file
1. Spell check, change "moule" to "module".

Module file
1. Remove blank lines.
3. It would be better if you would add a configuration form for getting the api key and its settings values from site admin.
4. Remove unused variables from the code.
5. In the sub modules please remove unwanted blank lines from code.

favicon_generator.css file
1. Line length must not exceed 80 characters.

Please use http://pareview.sh for reviewing.

Thanks

john cook’s picture

Re: #30

Spell error fixed.
Lines wrapped in css file.

Module file
3. The API key is for the module not the site, therefor extra configuration is not necessary. It would also increase the difficulty is setting up the module - the site admin would need to go to a 3rd party to get the key.

1 & 5. Blank lines are there to aid readability.

4. I've looked through the code and could not find any unused variables.

Also, I've checked with http://pareview.sh and it shows no errors.

cfischer83’s picture

Great module! I can see using this a lot.

Here are some recommendations and observations:

  1. Your documentation says the files should be 260px or bigger, but when I saved the file it says "Your icon should be at least 300x300 for optimal results." and yet in the code there's another message that says "270x270".
  2. I get ambiguous messaging when there's an error. In Watchdog it showed that the file I referenced didn't exist, but the error message displayed to me seemed generic and did not tell me the file could not be found.
john cook’s picture

Issue summary: View changes
john cook’s picture

Re: #32

1. There was a change in the API to allow for Open Graph images (coming soon) where the icon needs to be 300x300. For the other icons 260x260 px is recommended. I have changed both documentation and code to reflect 300x300 recommended size.

2. I am part way through re-doing the errors. Most of the watchdog errors refer to errors communicating with realfavicongenerator.net. I will redo the error messages to be more helpful next.

john cook’s picture

Re: #32 part 2.

The module now provides more specific error messages when the site admin might be able to fix the problem. Although if the problem is with favicongenerator.net then the general 'try again later' message will still appear with more specific details in watchdog.

john cook’s picture

Issue summary: View changes
john cook’s picture

Issue summary: View changes
john cook’s picture

Issue summary: View changes
polaki_viswanath’s picture

Hi John

I have a suggession that when we uninstall the module the icon generated must be deleted along with the changed settings of default icon, since the generated icon is used for all the devices. I think it would be better to use the default icon if the module is not used in the site.

Thanks

john cook’s picture

Hi polaki,

I'll have to have a think about your suggestion.

My plan is to allow the site admin to insert the required html into the template manually and disable / uninstall the module so that the site can be sped-up for uncached sites. Of course, automatically deleting the icons would break this functionality.

At the moment, when the module is disabled / uninstalled the site returns to the standard Drupal behavior.

natts’s picture

Status: Needs review » Needs work

Hi John, how is progress on this? I could review it for you when ready.

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.

john cook’s picture

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

@natts, sorry for the delay in replying.

I feel it's in a functional / usable state at the moment. Please feel free to review it at any time.

ajay_reddy’s picture

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: 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
[No: Does not follow] 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]
Coding style & Drupal API usage
(*) Line 106: Potential problem: drupal_set_message() only accepts filtered text, be sure to use check_plain(), filter_xss() or similar to ensure your $variable is fully sanitized. (Drupal Docs) [security_dsm]
drupal_set_message($result, 'error');

This review uses the Project Application Review Template.

Found issues on Click here

prashant.c’s picture

Hi John,

Coding style & Drupal API usage

(*)Line 106: Potential problem: drupal_set_message() only accepts filtered text, be sure to use check_plain(), filter_xss() or similar to ensure your $variable is fully sanitized. (Drupal Docs) [security_dsm]
drupal_set_message($result, 'error');

cherebedov.s’s picture

Status: Needs review » Needs work

Hi, please check your code in here.
http://pareview.sh/pareview/httpgitdrupalorgsandboxjohncook2378569git
You have a some issues. Thank's.

klausi’s picture

Status: Needs work » Needs review

That minor coding standard errors are surely not application blockers, anything else that you found or should this be RTBC instead? Please do a real manual review.

cherebedov.s’s picture

@klausi, ok, sorry.

harings_rob’s picture

Hi,

I evaluated the module, and I have a few remarks.

These remarks a purely informational, and they should not block the application from passing.

1. In the _favicon_generator_download_and_save_icons function, you decode the response before you check if the response has errors, I would swap this, as it now is pretty confusing.

2. Avoid using variables named $r, they hold no information.

3. Improve inline documentation.

4. Non hook functions should be prefixed with an underscore.

function favicon_generator_theme_form_submit($form, &$form_state) {

5. There are a lot of coding standard issues. They are easy to resolve, so I suggest you do so.

I have no further comments. I think this module is ready for release.

harings_rob’s picture

Status: Needs review » Reviewed & tested by the community
mlncn’s picture

Status: Reviewed & tested by the community » Fixed

Apologies for the months-long delays in this, when it had clearly passed relevant reviews long ago. Thanks for your contribution! Congratulations, you are now a vetted Git user. You can promote this to a full project.

When you create new projects (typically as a sandbox to start) you can then promote them to a full project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.