Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#6970 closed change (rejected)

Add commands section to manifest template and packagerChrome.py

Reported by: weissmar Assignee:
Priority: Unknown Milestone:
Module: Unknown Keywords:
Cc: BrentM, sebastian Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: no Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

Description (last modified by weissmar)

Background

We want to add the ability to add keyboard shortcuts to AdBlock for Chrome using the commands API (https://developer.chrome.com/apps/commands). In order to do this, a couple of changes need to be made to the build process, so that we can add something like the following to our metadata.adblock file:

[commands]
toggle_pause = 
  Ctrl+Shift+P
  Ctrl+Shift+P
  Command+Shift+P
  Ctrl+Shift+P
  Ctrl+Shift+P
  Toggle_Pause/Resume_on_all_sites

and then run the build.py script and end up with the following in our manifest.json file:

  "commands": {
    "toggle_pause": {
      "description": "Toggle Pause/Resume on all sites", 
      "suggested_key": {
        "chromeos": "Ctrl+Shift+P", 
        "default": "Ctrl+Shift+P", 
        "linux": "Ctrl+Shift+P", 
        "mac": "Command+Shift+P", 
        "windows": "Ctrl+Shift+P"
      }
    }
  },

What to change

We'd like to add the following to packagerChrome.py (in the buildtools repo) in the createManifest function:

    if metadata.has_section('commands'):
        commands = {}
        for key, values in metadata.items('commands'):
            if key == '':
                continue
            default, windows, mac, chromeos, linux, description = values.split()
            commands[key] = {
                'suggested_key': {
                    'default': default,
                    'windows': windows,
                    'mac': mac,
                    'chromeos': chromeos,
                    'linux': linux
                },
                'description': description.replace('_', ' ')
            }
        templateData['commands'] = commands

That code should go before the line that renders the template (manifest = template.render(templateData))

We'd also like to add the following to manifest.json.tmpl (in the templates folder of the buildtools repo):

  {%- if commands %}
  "commands": {{commands|json}},
  {%- endif %}

Change History (3)

comment:1 Changed 12 months ago by weissmar

  • Description modified (diff)

comment:2 Changed 12 months ago by sebastian

  • Cc sebastian added
  • Resolution set to rejected
  • Status changed from new to closed

You can already configure arbitrary manifest keys (see #6552). In the case here you would add folowing to the mainfest section in metadata.adblock:

commands.toggle_pause.description = Toggle Pause/Resume on all sites
commands.toggle_pause.suggested_key.chromeos = Ctrl+Shift+P
commands.toggle_pause.suggested_key.default = Ctrl+Shift+P
commands.toggle_pause.suggested_key.linux = Command+Shift+P
commands.toggle_pause.suggested_key.mac = Ctrl+Shift+P

comment:3 Changed 12 months ago by weissmar

So you can -- thanks!

Note: See TracTickets for help on using tickets.