SparkEdUAB / SparkEd_V2_API

MIT License
0 stars 0 forks source link

Gitpod Ready-to-Code

SparkEd

Build Status JavaScript Style Guide

Software for organizing and presenting educational and training content for delivery on most platforms.

SparkEd was deployed on a server and it loaded more than 1,500 resources. It worked very well in an office setting and was tested with 20 hosts. We plan to deploy the system in a school with more than 600 students.

To get started check out our wiki

Check here for the online documentation how to use this project.

For Contributors

Read the Code of Conduct here

The project uses the following stack

Development

if you don't have meteor run the script below

curl https://install.meteor.com/ | sh

For Windows Users

Download and install git

Use PowerSell in administrator mode

Go through the requirements found here before installing meteorjs

After doing the above now you can install meteor

choco install meteor

After installing meteor use git to clone the repo WINDOWS USERS

Clone the repo

git clone https://github.com/SparkEdUAB/SparkEd.git
cd SparkEd

Install dependencies

meteor npm install or meteor yarn

Run the application

meteor

If you have challenges with language translations, you need to set the environment variables

export UNIVERSE_I18N_LOCALES = all

Contribution

Fork this repo

Clone your forked repo

git clone https://github.com/your-github-username/SparkEd.git

Add this repo to your remotes as upstream.

git remote add upstream https://github.com/SparkEdUAB/SparkEd

Before pushing anything to your fork, always

git pull upstream master

Make sure your commit messages should be clear not vague e.g "Changes and Updates made"
Work from a branch other than master whenever possible and branch name should be clear
Write clean and transparent code which is easy to maintain
When making PRs, give clear descriptions of the changes you made.

Testing

npm run test or yarn run test

linting

npm run lint or yarn run lint

Before you make commit, make sure that the linting are passing, check with the eslintrc.yml to check the rules.

Sync

We have 2 scripts,

one exports the specified database collection from the main server, it will be checking every 24 hours. The other scripts downloads the exported database collection from the main server, and merges the local server with new data.

Example of the script (exports chunks)

colls=( fs.chunks fs.files Resources References)
if [ -d  "dump" ] ;  then
    echo "Directory exist and will be removed"
    sleep 1
    echo "Removing the directory"
    sleep 2
    rm -rf dump dump.tar.gz
fi
for  coll  in  ${colls[@]}
    do
    echo  $coll
    # for the remote main server
    mongodump -h localhost:27017 -d sparked -c $coll
done

echo "compressing the dumped directory "

tar cvzf /var/www/sparked/bundle/public/dump.tar.gz dump/
# bundle and send to the public to be downloadable (main server)

Deployment

SparkEd was meant to run in an offline environment but you are initially required to have internet to have it deployed, you can check our wiki for more info on setting up a proper server.

The wiki mentioned above includes deployment as well, the guide I am going to show is to allow you to simply put up a stable server that in a shorter time.
Just like in Development mentioned here I will assume that you have a working version of SparkEd on your local machine, you can follow the instructions mentioned above in the development to get it running.

Requirements

To get started, install mup (meteor-up)
mup allows you to deploy your meteor apps to any server and anywhere, it runs on a docker container

npm install --global mup or yarn add global mup

The above command will install mup globally, and it will allow you to access it anywhere in your terminal.
next run the following command

mup init

The above will initialize the meteor up for your project, make sure you are inside SparkEd
it creates a directory called .deploy which contains 2 files mup.js and settings.json

├── .deploy
│   └── mup.js
    └── settings.json

The mup.js file is the one you will want to pay attention to, it contains the server information you will need to update as required


  servers: {
    one: {
      host: '', // change this to the server address
      username: '', // username of the server
      password: '', // password for the username above
      // pem: './path/to/pem', // in case you are using an ssh key
    },
  },

   app: {
   name: 'SparkEd',  // name of the app is SparkEd
   path: '../', // Specify the location of the app, used ../ because we are in .deploy directory
   env: {
    ROOT_URL: '', // this is server address of where you are deploying to, it can be a local IP of the server you are deploying to
    MONGO_URL: 'mongodb://mongodb/meteor',
    MONGO_OPLOG_URL: 'mongodb://mongodb/local',
   },

Double check to make sure that your details are correct, if something doesn't work, kindly create an issue to let us know
run the following command to get the setup meteor up

mup setup

The above command might take a while, make sure you have a good internet and just wait for it, when it is done run the following command

mup deploy

The above command will deploy SparkEd on the specified server address

Make sure you read more info here on meteor-up

Docker

To run the current image built

docker pull olivierjm/spark

and run it as specified here

Build an image

You can build a docker image in 2 ways

Running the image

In the normal way you would run the image as follows

docker run imagename:tag

but we need to provide environment vairables that meteor can pick up and use like _ROOTURL, PORT, _MONGOURL and any other envs that you might want to pass along.

If you are using an external mongodb then you can provide the link to connect to when running the image.

  docker run -d \
  -e ROOT_URL=http://your_url \
  -e MONGO_URL=mongodb://url:dbname \
  -e MONGO_OPLOG_URL=mongodb://oplog_url \
  -p 80:3000 \
  yourname/sparked:tag

If you set INSTALL_MONGO to true when building the image or in the launchpad.conf then you don't need to set the _MONGOURL

  docker run -d \
  -e ROOT_URL=http://your_url \
  -p 80:3000 \
  yourname/sparked:tag

check http://your_url in your browser if the image run successfully then you should be able to have everything workin.

Issues

Check here for issues, urgent issues that need attention are pinned on top of other issues. feel free to file an issue if you are experiencing a problem or dive in the existing ones to contribute.

Contributors

We acknowledge contributors who added value to this project in any way.