2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# Contributing to Pinafore
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-29 22:13:27 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Internationalization
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								To contribute or change translations for Pinafore, look in the [src/intl ](https://github.com/nolanlawson/pinafore/tree/master/src/intl ) directory. Create a new file or edit an existing file based on its [two-letter language code ](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes ) and optionally, a region. For instance, `en-US.js`  is American English, and `fr.js`  is French.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The default is `en-US.js` , and any strings not defined in a language file will fall back to the strings from that file.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-02 22:44:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Installing
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								To install with dev dependencies, run:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    yarn
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Dev server
  
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								To run a dev server with hot reloading:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 01:44:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    yarn run dev
							 
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Now it's running at `localhost:4002` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-26 02:03:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								**Linux users:** for file changes to work,
							 
						 
					
						
							
								
									
										
										
										
											2018-12-18 01:21:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								you'll probably want to run `export CHOKIDAR_USEPOLLING=1` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								because of [this issue ](https://github.com/paulmillr/chokidar/issues/237 ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								## Linting
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Pinafore uses [JavaScript Standard Style ](https://standardjs.com/ ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Lint:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 01:44:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    yarn run lint
							 
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Automatically fix most linting issues:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 01:44:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    yarn run lint-fix
							 
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Integration tests
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Integration tests use [TestCafé ](https://devexpress.github.io/testcafe/ ) and a live local Mastodon instance
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								running on `localhost:3000` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Running integration tests
  
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The integration tests require running Mastodon itself,
							 
						 
					
						
							
								
									
										
										
										
											2019-03-18 16:09:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								meaning the [Mastodon development guide ](https://docs.joinmastodon.org/development/overview/ )
							 
						 
					
						
							
								
									
										
										
										
											2020-04-26 02:03:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								is relevant here. In particular, you'll need a recent
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								version of Ruby, Redis, and Postgres running. For a full list of deps, see `bin/setup-mastodon-in-travis.sh` .
							 
						 
					
						
							
								
									
										
										
										
											2018-04-12 16:44:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								Run integration tests, using headless Chrome by default:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    npm test
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Run tests for a particular browser:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 01:44:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    BROWSER=chrome yarn run test-browser
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    BROWSER=chrome:headless yarn run test-browser
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    BROWSER=firefox yarn run test-browser
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    BROWSER=firefox:headless yarn run test-browser
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    BROWSER=safari yarn run test-browser
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    BROWSER=edge yarn run test-browser
							 
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-30 22:50:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								If the script isn't able to set up the Postgres database, try running:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    sudo su - postgres
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Then:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    psql -d template1 -c "CREATE USER pinafore WITH PASSWORD 'pinafore' CREATEDB;"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Testing in development mode
  
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								In separate terminals:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1\. Run a Mastodon dev server:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 01:44:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    yarn run run-mastodon
							 
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								2\. Run a Pinafore dev server:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 01:44:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    yarn run dev
							 
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								3\. Run a debuggable TestCafé instance:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-09 22:25:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    npx testcafe --debug-mode chrome tests/spec
							 
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Test conventions
  
						 
					
						
							
								
									
										
										
										
											2018-03-31 00:55:55 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The tests have a naming convention:
							 
						 
					
						
							
								
									
										
										
										
											2018-04-12 03:33:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  `0xx-test-name.js` : tests that don't modify the Mastodon database (read-only) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  `1xx-test-name.js` : tests that do modify the Mastodon database (read-write) 
						 
					
						
							
								
									
										
										
										
											2018-04-12 03:33:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								In principle the `0-`  tests don't have to worry about
							 
						 
					
						
							
								
									
										
										
										
											2018-04-12 16:44:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								clobbering each other, whereas the `1-`  ones do.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-02 00:00:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Mastodon used for testing
  
						 
					
						
							
								
									
										
										
										
											2018-05-02 00:00:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								There are two parts to the Mastodon data used for testing:
							 
						 
					
						
							
								
									
										
										
										
											2018-05-02 00:00:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								1.  A Postgres dump and a tgz containing the media files, located in `fixtures`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								2.  A script that populates the Mastodon backend with test data (`restore-mastodon-data.js`). 
						 
					
						
							
								
									
										
										
										
											2018-05-02 00:00:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-26 02:03:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The reason we don't use a Postgres dump for everything
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								is that Mastodon will ignore changes made after a certain period of time, and we
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								don't want our tests to randomly start breaking one day. Running the script ensures that statuses,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								favorites, boosts, etc. are all "fresh".
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Updating the test data
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								You probably don't want to do this, as the `0xx`  tests are pretty rigidly defined against the test data.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Write a `1xx`  test instead and insert what you need on-the-fly.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If you really need to, though, you can either:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1.  Add new test data to `mastodon-data.js`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								or
							 
						 
					
						
							
								
									
										
										
										
											2018-06-07 22:26:47 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								1.  Comment out `await restoreMastodonData()`  in `run-mastodon.js`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								2.  Make your changes manually to the live Mastodon 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								3.  Run the steps in the next section to back it up to `fixtures/`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Updating the Mastodon version
  
						 
					
						
							
								
									
										
										
										
											2018-06-07 22:26:47 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1.  Run `rm -fr mastodon`  to clear out all Mastodon data 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1.  Comment out `await restoreMastodonData()`  in `run-mastodon.js`  to avoid actually populating the database with statuses/favorites/etc. 
						 
					
						
							
								
									
										
										
										
											2019-07-08 05:54:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								2.  Update the `GIT_TAG_OR_BRANCH`  in `run-mastodon.js`  to whatever you want 
						 
					
						
							
								
									
										
										
										
											2020-05-03 01:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								3.  If the Ruby version changed, install it and update `setup-mastodon-in.travis.sh`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								4.  Run `yarn run-mastodon`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								5.  Run `yarn backup-mastodon-data`  to overwrite the data in `fixtures/`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								6.  Uncomment `await restoreMastodonData()`  in `run-mastodon.js`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								7.  Commit all changed files 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								8.  Run `rm -fr mastodon/`  and `yarn run run-mastodon`  to confirm everything's working 
						 
					
						
							
								
									
										
										
										
											2018-06-07 22:26:47 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-11-20 08:01:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Check `mastodon.log`  if you have any issues.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-05-05 22:02:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that we also run `db:migrate`  just to play it safe, but
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								updating the `fixtures/`  should make that a no-op.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-11-20 08:01:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Unit tests
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								There are also some unit tests that run in Node using Mocha. You can find them in `tests/unit`  and
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 01:44:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								run them using `yarn run test-unit` .
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-21 20:44:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Debug build
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								To disable minification in a production build (for debugging purposes), you can run:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    DEBUG=1 yarn build
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Debugging Webpack
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The Webpack Bundle Analyzer `report.html`  and `stats.json`  are available publicly via e.g.:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  [dev.pinafore.social/report.html ](https://dev.pinafore.social/report.html ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  [dev.pinafore.social/stats.json ](https://dev.pinafore.social/stats.json ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-28 01:44:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is also available locally after `yarn run build`  at `.sapper/client/report.html` .
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Codebase overview
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Pinafore uses [SvelteJS ](https://svelte.technology ) and [SapperJS ](https://sapper.svelte.technology ). Most of it is a fairly typical Svelte/Sapper project, but there
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								are some quirks, which are described below. This list of quirks is non-exhaustive.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Prebuild process
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The `template.html`  is itself templated. The "template template" has some inline scripts, CSS, and SVGs
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								injected into it during the build process. SCSS is used for global CSS and themed CSS, but inside of the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								components themselves, it's just vanilla CSS because I couldn't figure out how to get Svelte to run a SCSS
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								preprocessor.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Lots of small files
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Highly modular, highly functional, lots of single-function files. Tends to help with tree-shaking and
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								code-splitting, as well as avoiding circular dependencies.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-29 06:12:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### emoji-picker-element is loaded as a third-party bundle
  
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-29 06:12:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								`emoji-picker-element`  uses Svelte 3, whereas we use Svelte 2. So it's just imported 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								as a bundled custom element, not as a Svelte component.
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Some third-party code is bundled
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								For various reasons, `a11y-dialog` , `autosize` , and `timeago`  are forked and bundled into the source code.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This was either because something needed to be tweaked or fixed, or I was trimming unused code and didn't
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								see much value in contributing it back, because it was too Pinafore-specific.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Every Sapper page is "duplicated"
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								To get a nice animation on the nav bar when you switch columns, every page is lazy-loaded as `LazyPage.html` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This "lazy page" is merely delayed a few frames to let the animation run. Therefore there is a duplication
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 09:08:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								between `src/routes`  and `src/routes/_pages` . The "lazy page" is in the former, and the actual page is in the
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:57:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								latter. One imports the other.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### There are multiple stores
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Originally I conceived of separating out the virtual list into a separate npm package, so I gave it its
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								own Svelte store (`virtualListStore.js`). This never happened, but it still has its own store. This is useful
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								anyway, because each store has its state maintained in an LRU cache that allows us to keep the scroll position
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								in the virtual list e.g. when the user hits the back button.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Also, the main `store.js`  store is explicitly
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								loaded by every component that uses it. So there's no `store`  inheritance; every component just declares
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								whatever store it uses. The main `store.js`  is the primary one.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### There is a global event bus
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								It's in `eventBus.js` . This is useful for some stuff that is hard to do with standard Svelte or DOM events.