Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/multisite-…
Browse files Browse the repository at this point in the history
…job-queues
  • Loading branch information
rjmackay committed Nov 14, 2018
2 parents f1c3aaf + ea6fe38 commit 16fba85
Show file tree
Hide file tree
Showing 42 changed files with 1,127 additions and 328 deletions.
17 changes: 11 additions & 6 deletions app/Http/Middleware/CheckDemoExpiration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ public function handle($request, Closure $next, $guard = null)
$isNotGet = !$request->isMethod('get');

if ($multisite && $isNotGet && $isDemoTier) {
$now = new DateTime();
$expiration_date = strtotime(service('site.config')['expiration_date']);
$extension_date = strtotime(service('site.config')['extension_date']);

if ($expiration_date < $now && (!$extension_date || $extension_date < $now)) {
abort(503, 'The demo period for this deployment has expired.');
$now = strtotime('now');
$config = service('site.config');
if ($config) {
$expiration_date = array_key_exists('expiration_date', $config) ?
strtotime($config['expiration_date']) : null;
$extension_date = array_key_exists('extension_date', $config) ?
strtotime($config['extension_date']) : null;

if ($expiration_date < $now && (!$extension_date || $extension_date < $now)) {
abort(503, 'The demo period for this deployment has expired.');
}
}
}
return $next($request);
Expand Down
Binary file added docs/.gitbook/assets/api-request-flow (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/api-request-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/app-tiers (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/app-tiers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/arch-layers (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/arch-layers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/create-usecase (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/create-usecase-collab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/create-usecase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/data-flow (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/data-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/delete-usecase (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/delete-usecase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/read-usecase (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/read-usecase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/search-usecase (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/search-usecase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/update-usecase (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/update-usecase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 50 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,51 @@
# Documentation
# README

[![Build Status](https://travis-ci.org/ushahidi/platform.png)](https://travis-ci.org/ushahidi/platform) [![Coverage Status](https://coveralls.io/repos/github/ushahidi/platform/badge.svg)](https://coveralls.io/github/ushahidi/platform) [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)

## What is Ushahidi?

Ushahidi is an open source web application for information collection, visualization and interactive mapping. It helps you to collect info from: SMS, Twitter, RSS feeds, Email. It helps you to process that information, categorize it, geo-locate it and publish it on a map.

## A note for grassroots organizations

If you are starting a deployment for a grassroots organization, you can apply for a free social-impact responder account [here](https://www.ushahidi.com/plans/apply-for-free) after verifying that you meet the criteria.

## Required reading: Code of Conduct.

We love having you here. To ensure everyone has a good experience, we ask **everyone** that interacts with our community and staff to read our code of conduct.

{% page-ref page="code-of-conduct.md" %}

## Getting Involved

{% page-ref page="contributing-or-getting-involved.md" %}

## Using the Platform

If you are not a developer, or just don't want to set it up yourself, you can start a hosted deployment [here](https://www.ushahidi.com/).

All the documentation on using the platform is here

{% page-ref page="using-the-ushahidi-platform-v3-v4/untitled.md" %}

## Technical documentation

### How to install and run the Ushahidi Platform

{% page-ref page="setup\_alternatives/" %}

### Changing the UI styles for the platform. An introduction to our Pattern Library.

{% page-ref page="changing-ui-styles-introduction-to-the-pattern-library.md" %}

## Useful Links

* [Download](https://github.com/ushahidi/platform-release/releases)
* [Other Installation Guides](https://github.com/ushahidi/platform/tree/adff3c2af479788bfdea05fa4a198e08080a98f0/docs/docs/setup_alternatives/README.md)
* [User Documentation](https://www.ushahidi.com/support)
* [Technical Documentation](https://github.com/ushahidi/platform/tree/adff3c2af479788bfdea05fa4a198e08080a98f0/docs/docs/README.md)
* [Get Involved](https://www.ushahidi.com/support/get-involved)
* [Bug tracker](https://github.com/ushahidi/platform/issues)
* [Ushahidi](http://ushahidi.com)
* [Ushahidi Platform v2](https://github.com/ushahidi/Ushahidi_Web)

- [Getting Started](./getting_started.md)
- [Architecture](./architecture.md)
- DB Schema [svg](schema.svg) [png](schema.svg)
21 changes: 21 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Table of contents

* [README](README.md)
* [Code of Conduct](code-of-conduct.md)
* [Contributing \| Getting Involved](contributing-or-getting-involved.md)
* [Setup Guides](setup_alternatives/README.md)
* [Installing for production environments](setup_alternatives/installing-for-production-environments.md)
* [Platform Client installation](setup_alternatives/setting-up-the-platform-client.md)
* [\[API\] Vagrant setup](setup_alternatives/vagrant-setup.md)
* [\[API\] XAMPP](setup_alternatives/xampp.md)
* [PLATFORM\_RELEASE\_INSTALL](setup_alternatives/platform_release_install.md)
* [Changing UI styles: introduction to the pattern library](changing-ui-styles-introduction-to-the-pattern-library.md)
* [Architecture](architecture/README.md)
* [Use case internals](architecture/use-case-internals.md)
* [Untitled](untitled.md)
* [Untitled](untitled-1.md)

## Using the Ushahidi Platform \(V3 - V4\)

* [Using the Ushahidi Platform](using-the-ushahidi-platform-v3-v4/untitled.md)

52 changes: 0 additions & 52 deletions docs/architecture.md

This file was deleted.

94 changes: 94 additions & 0 deletions docs/architecture/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Architecture

## High Level Data Flows

At a high level Ushahidi consumes messages from various channels \(SMS, Email, Twitter, our own web interface\), transforms these into posts. Ushahidi core stores and exposes this data in a REST API. The primary consumers of the REST API are our web client and mobile app.

![Data Flow](../.gitbook/assets/data-flow%20%281%29.png) [source](https://www.planttext.com/?text=RP71Ri8m38RlVWehf-sGDq0LQ6CI1n2YJ3jKFGIQKaiXGOsd7YRU7RTgkmKj1ylvVyVvd2mZcvQ_hmw0YPt5pzYOXYh2TyC6Frpe08fZHyosBQ78jxd4zTMGAm5yg2ogwOZ27q1PBw-u3v6dN1tM-H5N-ur24x7VI3wRky1Kqzam1H_L80-Xc47UGcjBk0l6Dfn845Utcp1ysHDkl53LvYp-BwHkwTAmpWQ64JNL-Y4I1VeuASytmuYyqCxM__d5M50kvXPFS7ygidIAj9UkGkTrbhm9mDBwIdxe0G00)

## Application tiers

The Platform is split into 3 layers: Presentation \(Client / Web interface\), Services \(API\), and Data.

![Application tiers](../.gitbook/assets/app-tiers%20%281%29.png) [source](http://www.nomnoml.com/#view/%23title%3A%20Application%20Tiers

[Presentation|
%20%20%20%20[AngularJS]
%20%20%20%20[Endpoints]
]

[Services|
%20%20%20%20[API]o->[Kohana]%20
%20%20%20%20[API]o->[Ushahidi%20Core]
%20%20%20%20[Kohana]-->[PHP]
%20%20%20%20[Ushahidi%20Core]-->[PHP]%20%20%20
]

[Data|
%20%20%20%20[MySQL]
]

[Presentation]<->[Services]
[Services]<->[Data]


%23direction%3A%20right)

### API

The REST API provides all data access. This provides for the main Ushahidi user interface, but also any external services and partners that need to access data.

The API layer consists of a core application \(models, usecases, etc\) and a delivery layer \(routing and controllers\). The core application is pure object-oriented PHP and the delivery mechanism is a PHP application built using the Kohana Framework.

In theory the Kohana application could handle frontend views and interactions too, but splitting the API out allows us far greater flexibility in the variety of applications that we can build. Mobile apps, 3rd party integrations, etc are not 2nd class citizens: they can consume the same API as our primary frontend. The API has to be able to do everything to our data.

Containing the core business logic within a core application that is separate from the Kohana delivery layer allows us to test the core application, independent of the database \(or any other implementation details\) while also enforcing the internal API by which the rest of the system operates. This allows us to modify internal details, such as the database structure, without breaking the external API, as well as ensuring that the entire system remains in a stable, tested state.

### Web Client

The Frontend is a javascript application, built on AngularJS. It loads all data from the Platform API. The JS app is entirely static so can be hosted on any simple webserver.

### Data Layer \(Mysql\)

The database layer is a standard MySQL server. You can see a schema here [svg](https://github.com/tuxpiper/platform/tree/fcc78a1dd925ff383509ac9e862ad295850d187f/docs/schema.svg) [png](https://github.com/tuxpiper/platform/tree/fcc78a1dd925ff383509ac9e862ad295850d187f/docs/schema.png)

## Internal API Architecture

### API Delivery

Within the API there are two layers: the delivery and the business logic \(core application\). The delivery layer follows a Model View Controller \(MVC\) pattern, with the View consisting of JSON output. The Controllers use a [Service Locator](https://en.wikipedia.org/wiki/Service_locator_pattern) to load and execute various tools, taking the API request inputs and returning the requested resources.

#### Core Application

Within the core application, we use generally follow the [Clean Architecture](http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html). The central part of the business logic is defined as use cases and entities. All dependencies flow inwards towards the entities, which have no dependencies.

![Software architecture layers](../.gitbook/assets/arch-layers%20%281%29.png)

In order to bring user input to the use cases, we pass simple data structures from the delivery layer into the use case. The request structure is a simple array and contains all of the inputs for that specific use case. Once the usecase is complete it returns another simple data structure \(response\) back to the delivery layer for conversion via a Formatter. Data flow within the platform can be visualized as:

![API Request Flow](../.gitbook/assets/api-request-flow.png) [source](http://www.nomnoml.com/#view/%23title%3A%20General%20API%20request%20flow

[<start>app]->[Kohana]
[Kohana]->[Controller]
[Controller]->[<state>request]
[<state>request]->[Usecase]
[Usecase]->[<state>response]
[<state>response]->[OutputFormatter]
[OutputFormatter]->[<end>json]

[<state>request|
payload%3B
identifier%3B
filters]

[Dependencies|
%20Repository%3B
%20Validator%3B
%20Authorizer%3B
%20etc...
]o->[Usecase]

%23direction%3A%20right)

See [Use Case Internals](use-case-internals.md) for more detail

2 changes: 2 additions & 0 deletions docs/architecture/use-case-internals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Use case internals

56 changes: 56 additions & 0 deletions docs/changing-ui-styles-introduction-to-the-pattern-library.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Changing UI styles: introduction to the pattern library

The Platform Client uses the Pattern Library to standardize the styles and have them available in a single place that can be edited by frontend developers without advanced knowledge of AngularJS.

The Pattern Library runs as a dependency of the web client, it's included in the package.json file and is just a [regular npm library](https://www.npmjs.com/package/ushahidi-platform-pattern-library). Please note that unless you specifically need to change the layout beyond what's possible in the client's codebase, or want to change styles \(such as colors, fonts, etc\) the pattern library will **not** need to be setup as a stand alone project.

## Use cases for editing \(or not\) the pattern library

### Use case: adding a new view to the client

To add new views in the Platform Client, we recommend you first check if you can compose those views with pre-existing patterns from our pattern library.

You can see the available patterns and more documentation specific to the pattern library here.

{% embed url="http://preview.ushahidi.com/platform-pattern-library/master/" %}

### Use case: changing the color palette

To change the color palette, you will need to modify the pattern library's color variables. The good thing is that all colors are defined here, and you can easily change them and see the results in the patterns before moving forward with applying the changes to the client.

{% embed url="http://preview.ushahidi.com/platform-pattern-library/master/assets/html/1\_basics/" %}

### Changing other styles like icons, fonts, or adding layouts

When you need completely new layouts with new styles, you will need to add or modify the pattern library.

We recommend you review the different structures in the pattern library, and follow the instructions and documentation to use it here

{% embed url="http://preview.ushahidi.com/platform-pattern-library/master/index.html" %}

## Setting up the pattern library for development

The pattern library holds all styles for the platform-client and its here changes to the css is made.

Clone the pattern library

```text
git clone https://github.com/ushahidi/platform-pattern-library.git;
```

Install the dependencies.

```text
cd platform-pattern-library;
npm install;
```

Start the pattern library in http://localhost:8000 by running:

```text
gulp
```

Once the pattern-library is running, the front-end guidelines and a guide on how to work with the pattern-library and its structure can be found on http://localhost:8000/assets/html/front-end-guidelines/introduction.html


2 changes: 2 additions & 0 deletions docs/code-of-conduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Code of Conduct

Loading

0 comments on commit 16fba85

Please sign in to comment.