Thanks to visit codestin.com
Credit goes to github.com

Skip to content

wleona3/dotcom

 
 

Repository files navigation

Dotcom

The new face of https://www.mbta.com/.

Supported browsers

We strive to support all users – but the variety of browsers, operating systems and devices available necessitates a more intentioned approach. Generally speaking, Dotcom supports the stable latest releases of all major web browsers (Chrome, Safari, Firefox, Microsoft Edge, and Internet Explorer 11) and platforms (Windows, MacOS, iOS, Android). Other interfaces using the underlying engines of the aforementioned browsers – that's WebKit, Blink, Gecko – are not explicitly supported but are expected to function correctly.

From a development standpoint, polyfills and code transforms are implemented via Babel with the target browsers noted in the site .browserslistrc.

Getting Started

Welcome to Dotcom. There are more details and background information in this Notion document, but read on to get started on your setup!

  1. Request a V3 API key at https://api-dev.mbtace.com/. After getting an API key, it's customary to click "request increase" for your key's 'Per-Minute Limit'.

  2. Install Homebrew:

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  3. Install asdf package version manager

    • Follow the instructions on https://github.com/asdf-vm/asdf

      brew install asdf
    • Install the necessary tools to set up asdf plugins:

      brew install gpg gawk # for nodejs plugin
      brew install autoconf [email protected] # for erlang plugin
      brew install wxwidgets # optional for erlang for building with wxWidgets (start observer or debugger!)
      brew install libxslt fop # optional for erlang for building documentation and elixir reference builds
    • Add asdf plugins

      asdf plugin add erlang
      asdf plugin add elixir
      asdf plugin add nodejs
      

      You can verify the plugins were installed with asdf plugin list.

      While Erlang, Elixir, and NodeJS are essential for any development on Dotcom.

      You're welcome to add more plugins for personal use! But these are the ones set up in .tool-versions and invoked in the next step:

    • Now run the install:

      asdf install
      
    • Verify that all the languages for our setup were installed:

      asdf current
      

      You should see the following output with versions specified from .tool-versions:

       elixir         <version> (set by ~/dotcom/.tool-versions)
       erlang         <version> (set by ~/dotcom/.tool-versions)
       nodejs         <version> (set by ~/dotcom/.tool-versions)
       ...
      

      If you are missing any versions, you should re-run asdf install.

      You may have to individually install each version

      asdf install plugin_name <version> (set by ~/dotcom/.tool-versions)
      
  4. Install our Elixir dependencies. From the root of this repo:

    mix deps.get
    
  5. Install our Node dependencies. From the root of this repo:

    npm run install
    

    You won't see a node_modules folder at the root of this project -- this installs packages into apps/site/assets.

    Minor note - you may see a prompt to upgrade npm. This isn't needed, and "lockfileVersion": 1 in our apps/site/assets/package-lock.json file means it was generated with an npm version prior to 7.

  6. Build the project:

    npm run build
    
    • If this fails try adding the following line to defp deps section in mix.exs:
    {:fs, git: "https://github.com/synrc/fs.git", override: true}
    

npm run build does several things: builds the Phoenix application assets, builds all the front-end assets, and then compiles the entire Elixir application.

  1. Set up required environment variables:
    cp .envrc.template .envrc
    
    Then uncomment the V3_API_KEY line and fill it in with the key you obtained in the first step. If you have direnv installed (recommended), it will automatically load and unload the environment using this file. If not, source .envrc will load or update the variables in your shell session manually.

For details on environment configuration, including optional variables, see ENVIRONMENT.md.

Running the Server

Start the server with mix phx.server

Then, visit the site at http://localhost:4001/

Algolia

Algolia powers our search features. Sometimes after content updates or GTFS releases we will find that the search results do not contain up-to-date results. When this happens you can re-index the Algolia data by running: mix algolia.update.

Commiting Code

When commiting code a bunch of checks are run using git pre-commit hook

This is configured using the tool husky and should install as part of the regular npm run install process

This allows all code changed during a commit to be linted and formatted before being commited.

If you wish to modify the checks ran during the pre-commit process the pre-commit file can be modified with any command line commands/scripts

These checks can be skipped by using the --no-verify flag when runnint the commit git command

Additional Resources

New to the team, or looking for further developer resources?

Nested Applications

About

mbta.com

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 57.7%
  • TypeScript 21.3%
  • JavaScript 8.9%
  • SCSS 6.5%
  • HTML 5.2%
  • Python 0.2%
  • Other 0.2%