Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suites Schema #6185

Open
ApCoder123 opened this issue Oct 10, 2021 · 1 comment
Open

Suites Schema #6185

ApCoder123 opened this issue Oct 10, 2021 · 1 comment
Labels
enhancement Issue/PR contains enhancements to the overall code of the site. feature Feature request

Comments

@ApCoder123
Copy link
Member

ApCoder123 commented Oct 10, 2021

Relates to #3708, #3707, #4510, #4034 (comment)

In the original discussions in the above issues about allowing entries in multiple categories, there was some mention of creating a single file for products that come under a central brand (e.g. Google). I've been playing around with this idea, and I think the schema could be modified to support this without many changes to the existing codebase.

Example JSON file for a suite entry:

{
  "Google": {
    "suite": true,
    "tfa": [
      "sms",
      "call",
      "totp",
      "custom-software",
      "u2f"
    ],
    "documentation": "https://www.google.com/intl/en-US/landing/2step/features.html",
    "sites": [
      {
        "Google Chat": {
          "domain": "chat.google.com",
          "keywords": [
            "communication"
          ]
        }
      },
      {
        "Google Drive": {
          "domain": "drive.google.com",
          "keywords": [
            "backup"
          ]
        }
      }
    ]
  }
}

The join-entries.rb script could then be modified to expand a suite entry's sites into individual entries in the entries array, meaning the current code for the site would receive the data in the same way as it does now.
Something like:

Dir.glob('entries/*/*.json') do |file|
  document = JSON.parse(File.read(file))
  suite = document.values[0]
  suite_name = document.keys[0]
  next unless suite.key? 'suite'

  suite['sites'].each do |site|

    suite.each do |k, v|
      next if k.eql?('sites') || k.eql?('suite')
      site.values[0][k] = v unless site.key? k
    end
    site['search'] = [suite_name]
    
    entries[site.keys[0]] = site.values[0]
  end
end

This would make brands with multiple sites much easier to edit, as only one entry needs to be changed, rather than multiple. Additionally, adding a search key will allow the main brand name (e.g. Google) to be added to the search words in the table (making the connection between products clearer, fixing #4510).

The only other change to the code would be to get the API scripts to use _data/all.json which has the expanded suite sites array instead of iterating the entries directory as they do currently.

Any thoughts?

@ApCoder123 ApCoder123 added enhancement Issue/PR contains enhancements to the overall code of the site. feature Feature request labels Oct 10, 2021
@phallobst
Copy link
Member

Sounds good and addresses quite a number of issues and shortcomings.

The "suite": true, is probably not necessary, since an existing "sites": will already indicate an entry of this kind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue/PR contains enhancements to the overall code of the site. feature Feature request
Projects
Status: Suggested
Development

No branches or pull requests

2 participants