/part-up

Single page meteor app available at https://part-up.com

Primary LanguageJavaScriptGNU Affero General Public License v3.0AGPL-3.0

Part-up

Join the conversation of the Platform Development tribe on Part-up

Installation

  • Clone this repository
  • Ensure meteor & node are installed
  • Copy the file config/development/env.sh.dist to config/development/env.sh
  • Run npm start (in the root folder of the app)
  • App running at: http://localhost:3000/
  • If you want to contribute to Part-up please read CONTRIBUTING.md

Optional installation steps

  • If you want to do something with an icon, be sure that imagemagick is installed (OS X: brew install imagemagick).
  • If you want developer credentials (for an AWS bucket / Social login etc..) install ansible: brew install ansible and decrypt config/development/env.sh-encrypted to config/development/env.sh.

Code formatting

We use ESLint and Prettier for code formatting to maintain the same code style across the app. Here's a vscode Settings.json example to make them work well together and will format the code on save:

{
  "editor.detectIndentation": false,
  "editor.formatOnSave": true,
  "editor.insertSpaces": true,
  "editor.tabSize": 2,
  "eslint.autoFixOnSave": true,
  "files.eol": "\n",
  "files.trimTrailingWhitespace": true,
}

Working with Meteor

All of our meteor code can be found in the app directory. In here we are working with local meteor packages inside the packages directory.

There are three main packages,

  • partup-client-base client helpers;
  • partup-lib shared between client and server;
  • partup-server server code.

if you need to create a new package please check this guide

Frontend

The front-end consists of blaze templates of which many are a package itself, these start with partup-client-. Any functionality that is not directly tied to a template and can be seen as helper functionality lives in the partup-client-base package which is only exposed to the client.

Pages

We export all pages as a single package partup-client-pages. A page can contain components with page-specific functionality and make use of multiple widgets. A page, in fact, only represents a composition. Therefore, the scss file should only contain position defenitions of the inside components. Pages are directly bound to routes and should handle any navigation functionality. Pages are also responsible for handling state (e.g. subscriptions) and pass handlers to components that live outside the page package.

Widgets

A widget only provides functionality to fulfill a single responsibility. They contain all the functionality required and don't depend on logic of on any other part of the application. Widgets may manage their own state in a limited way, where they should recieve as much data as possible from the page they live in. Widgets are stand-alone packages. The scss file should only contain component composition rules.

Small components

The whole app is made up of small styled components. These components are not functional by themselves and only provide styling like buttons, inputs, titles, paragraphs and menus. Each component should be defined as a scss class prefixed with “pu-”, for example “pu-button”. Be aware not to define any styling dealing with the position of the component inside its parent or relative to its siblings.

Backend

Schema

We use SimpleSchema to define our data structure. The schema can be found in the partup-lib package, this is because the client also uses it for validation. Any rules about the model is defined here.

Collections

Collections in meteor are used both server and client side. However, the client should only read from these whilst the server uses these to query mongo. For this, we have created helper methods to be used by the server. Data returned from mongo will be transformed into a model, this model may also have extra functionality. When you need to access a collection from the client you first need to subscribe to it. We do this via publications, these can be found in partup-server.

Mutations

When a mutation of data needs to be stored on the server you can call a meteor method. In this we define every mutation allowed for a collection.

Routes

We have page routes for navigation in partup-lib and routes to send data via POST requests in partup-server.

Application testing

Please take a look as this epic: https://github.com/part-up/part-up/issues/528 There is a specific chapter written about how to test a meteor application like part-up.com.

Refer to CONTRIBUTING.md for more information about the tests we write.

Fixtures

We have fixture data to test part-up locally in partup-server.

Unit and integration testing

npm run test:watch

End to end test

npm run test:e2e

Unit testing

meteor run --test

DevOps

Quick deployment

  • cd devops
  • ./devops provision <environment> all --tags=app (provide the SHA hash of the commit to be deployed, make sure it is build by Jenkins upfront)

MongoDB

  • Connecting: mongo "<host>/<database>" -u "<user>" -p "<password>"
  • Dumping: mongodump "<host>" --db "<database>" -u "<user>" -p "<password>" -o \date +%s``
  • Restoring: mongorestore "<host>" --db "<database>" -u "<user>" -p "<password>"
  • Restoring Meteor LoginServiceConfiguration: mongorestore "<host>" --db "<database>" -u "<user>" -p "<password>" -c "meteor_accounts_loginServiceConfiguration" <bson file from dump>
  • Emptying all Collections (run in mongo shell): db.getCollectionNames().forEach(function(collectionName) { db[collectionName].remove({}); });
  • Make user (super)admin: db.users.update({ '_id': '<insertuseridhere>' }, { $set: { 'roles': ['admin'] } })
  • Find faulty / wrongly uploaded pictures: db.getCollection('cfs.images.filerecord').find({'copies':{$exists:false}})
  • Overwrite the language of a specific part-up: db.getCollection('partups').find({'_id':'<<partupid>>'},{$set: {'language':'nl'}});

Data dumps

Clean userdump

  • regular mongo dump command
  • unpack bson for f in *.bson; do bsondump "$f" > "$f.json"; done
  • cat users.bson.json | sed 's/accessToken" : "[^"]*"/accessToken" : ""/g' > users.bson-clean.json
  • cat users.bson-clean.json | sed 's/hashedToken" : "[^"]*"/hashedToken" : ""/g' > users.bson-clean-2.json
  • cat users.bson-clean-2.json | sed 's/bcrypt" : "[^"]*"/bcrypt" : ""/g' > users.bson-clean-3.json
  • cat users.bson-clean-3.json | sed 's/token" : "[^"]*"/token" : ""/g' > users.bson-clean-4.json

Phraseapp translation

Add new keys using the i18n convention to the main locale /part-up/app/i18n/phraseapp.en.i18n.json and commit them to your branch.

After merging the PR for your branch, Ralph Boeije will import the new keys to Phraseapp and add the translations to the other locales.

License

Copyright (C) 2017 Part-up

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. You can find it at /part-up/LICENSE and the supplement at /part-up/License supplement