2015-02-07 11:54:23 +01:00
|
|
|
|
# Momo
|
2015-02-07 00:30:30 +01:00
|
|
|
|
|
2015-02-07 11:50:54 +01:00
|
|
|
|
Momo is a template based on Cordova/Phonegap that aims to easily design some
|
|
|
|
|
cross-platform applications. The whole application content is described in a
|
|
|
|
|
JSON manifest and It implements its own self-update mecanisms.
|
|
|
|
|
|
2015-03-19 11:02:33 +01:00
|
|
|
|
## Debug Package
|
2015-03-19 11:01:49 +01:00
|
|
|
|
|
|
|
|
|
Scan the following QRCode to install the debug version of the package :
|
|
|
|
|
|
|
|
|
|
![qr_code_image](https://chart.googleapis.com/chart?chs=116x116&cht=qr&chl=https://build.phonegap.com/apps/1327372/install/VR56zMQ89Zu_NZyDNq_s&chld=L|1&choe=UTF-8 "Momo Debug Application")
|
|
|
|
|
|
2015-02-07 11:54:23 +01:00
|
|
|
|
## Installation
|
2015-02-07 00:30:30 +01:00
|
|
|
|
|
|
|
|
|
Clone the repo:
|
|
|
|
|
|
|
|
|
|
git clone ssh://git@repos.entrouvert.org/momo && cd momo/
|
|
|
|
|
|
|
|
|
|
With [node](http://nodejs.org/) installed (avoid outdated *apt-get* package):
|
|
|
|
|
|
|
|
|
|
sudo npm install phonegap -g
|
|
|
|
|
|
2015-02-07 14:57:55 +01:00
|
|
|
|
Install cordovas plugins:
|
|
|
|
|
|
2015-08-13 23:49:36 +02:00
|
|
|
|
phonegap plugin add cordova-plugin-file
|
|
|
|
|
phonegap plugin add cordova-plugin-file-transfer
|
|
|
|
|
phonegap plugin add cordova-plugin-zip
|
|
|
|
|
phonegap plugin add cordova-plugin-whitelist
|
|
|
|
|
phonegap plugin add cordova-plugin-inappbrowser # optional
|
2015-02-07 14:57:55 +01:00
|
|
|
|
|
|
|
|
|
If plugin registry server seems to be down :'( use git instead ;)
|
|
|
|
|
|
2015-02-08 10:41:26 +01:00
|
|
|
|
phonegap plugin add https://github.com/apache/cordova-plugin-file.git
|
2015-02-07 14:57:55 +01:00
|
|
|
|
phonegap plugin add https://github.com/apache/cordova-plugin-file-transfer.git
|
2015-08-14 00:15:14 +02:00
|
|
|
|
phonegap plugin add https://github.com/MobileChromeApps/cordova-plugin-zip.git
|
2015-08-13 23:49:36 +02:00
|
|
|
|
phonegap plugin add https://github.com/apache/cordova-plugin-whitelist.git
|
|
|
|
|
phonegap plugin add https://github.com/apache/cordova-plugin-inappbrowser.git # optional
|
2015-02-07 14:57:55 +01:00
|
|
|
|
|
2015-02-07 00:30:30 +01:00
|
|
|
|
## Assets Management
|
|
|
|
|
|
|
|
|
|
Momo implements a self-update mecanism based on AJAX, localStorage, cordova
|
|
|
|
|
file transfer and chromium zip. The *meta* section in the manifest
|
|
|
|
|
`www/index.json` allows to give some parameters to the update :
|
|
|
|
|
|
|
|
|
|
{"meta": {
|
|
|
|
|
|
|
|
|
|
// Application Title
|
|
|
|
|
"title": "Ma ville au quotidien",
|
|
|
|
|
|
|
|
|
|
// Icon (a new build is required in oder to change the application launcher icon)
|
|
|
|
|
"icon": "icon.png",
|
|
|
|
|
|
|
|
|
|
// Footer contact
|
|
|
|
|
"contact": "info@example.net",
|
|
|
|
|
|
|
|
|
|
// Update Frequency (in seconds)
|
|
|
|
|
"updateFreq": 100,
|
|
|
|
|
|
|
|
|
|
// Distant manifest url
|
|
|
|
|
"updateUrl": "http://localhost/momo/index.json?0.0.1",
|
|
|
|
|
|
|
|
|
|
// Distant assets archive
|
|
|
|
|
"assetsUrl": "http://localhost/momo/assets.zip?0.0.1"
|
|
|
|
|
|
|
|
|
|
}, ...}
|
|
|
|
|
|
2015-08-22 10:47:56 +02:00
|
|
|
|
The assets.zip file will be downloaded and uncompressed right into the
|
|
|
|
|
application root folder; beware this could overwrite files, it is advised
|
|
|
|
|
to use subdirectories (typically the zip file should contain its files in
|
|
|
|
|
a assets/ directory).
|
2015-02-07 00:30:30 +01:00
|
|
|
|
|
2015-08-22 10:47:56 +02:00
|
|
|
|
The zip file structure could look like this:
|
2015-02-07 00:30:30 +01:00
|
|
|
|
|
2015-08-22 10:47:56 +02:00
|
|
|
|
- `assets/index.js`: Some extra script to be loaded dynamically in the application
|
|
|
|
|
- `assets/index.css`: A css stylesheet that will be injected as well
|
|
|
|
|
- `assets/*.[png,woff,...]`: images, fonts & other static files
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In the manifest pages content, you must specify URLs to you assets using paths
|
|
|
|
|
relative to the root of the assets.zip. If it contains an image in
|
|
|
|
|
assets/dijon.jpg, it should be referenced like this:
|
2015-02-07 00:30:30 +01:00
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
"title": "Ma ville",
|
|
|
|
|
"content": "<p>Bienvenue !</p><img src='assets/dijon.jpg' class='momo-image' />"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Don't forget to enable CORS on the server that will distribute the assets.
|
|
|
|
|
|
|
|
|
|
- Nginx: `add_header Access-Control-Allow-Origin *;`
|
|
|
|
|
- Apache: `Header set Access-Control-Allow-Origin "*"` (.htaccess will do)
|
|
|
|
|
|
|
|
|
|
You want to make sure the server keeps a cache version of the asset according to
|
|
|
|
|
the `updateFreq` value in the JSON manifest.
|
|
|
|
|
|
|
|
|
|
## Work in development
|
|
|
|
|
|
|
|
|
|
The cordovas libraries wont work in development environment, so you may want to
|
|
|
|
|
set a local path where to get the already unzipped assets. In `www/js/index.js`:
|
|
|
|
|
|
|
|
|
|
var DEBUG_WWW_URL = 'http://localhost/momo/www/';
|
|
|
|
|
|
|
|
|
|
In order to start a dev server, use command:
|
|
|
|
|
|
|
|
|
|
phonegap serve
|
|
|
|
|
|
|
|
|
|
Then point your browser to [http://localhost:3000/](http://localhost:3000/). You
|
|
|
|
|
may get a *HTTP Error 500* for cordova.js and *TypeError: Arguments to path.join
|
|
|
|
|
must be strings* in your console. This is due to your localmachine that doesn't
|
|
|
|
|
expose the sensors and the software components supported by cordova. But those
|
|
|
|
|
errors aren't blocking, you can keep doing stuff.
|
|
|
|
|
|
2015-02-07 11:57:44 +01:00
|
|
|
|
There is a much more convenient way to test you app which is to use the
|
|
|
|
|
[PhoneGap Developper App](http://app.phonegap.com/). With this, you'll be able
|
|
|
|
|
to test your app directly into you device. Note that cordova's plugins and
|
|
|
|
|
librairies are not usable using `phonegap serve`, so you must provide some
|
|
|
|
|
environement hooks in your code.
|
2015-02-07 00:30:30 +01:00
|
|
|
|
|
|
|
|
|
Make sure you don't browse the app twice at the same time, the phonegap's
|
|
|
|
|
autoreload mechanism uses socket.io that gets confused and keeps reloading the
|
2015-02-07 12:31:37 +01:00
|
|
|
|
app. If anyhow you wish to use many browsers in parallel, you may want to
|
2015-02-07 00:30:30 +01:00
|
|
|
|
launch the server with the option :
|
|
|
|
|
|
|
|
|
|
phonegap serve --no-autoreload
|
|
|
|
|
|
2015-02-07 14:57:55 +01:00
|
|
|
|
## Define target platforms
|
|
|
|
|
|
|
|
|
|
First, add the plateforms you wish to build a new release on:
|
|
|
|
|
|
|
|
|
|
Before you can build the project, you need to specify a set of target platforms.
|
|
|
|
|
Your ability to run these commands depends on whether your machine supports each
|
|
|
|
|
SDK, and whether you have already installed each SDK.
|
|
|
|
|
|
|
|
|
|
Run any of these from a Mac:
|
|
|
|
|
|
|
|
|
|
phonegap platform add ios
|
|
|
|
|
phonegap platform add amazon-fireos
|
|
|
|
|
phonegap platform add android
|
|
|
|
|
phonegap platform add blackberry10
|
|
|
|
|
phonegap platform add firefoxos
|
|
|
|
|
|
|
|
|
|
Run any of these from a Windows machine, where wp refers to different versions
|
|
|
|
|
of the Windows Phone operating system:
|
|
|
|
|
|
|
|
|
|
phonegap platform add wp8
|
|
|
|
|
phonegap platform add windows
|
|
|
|
|
phonegap platform add amazon-fireos
|
|
|
|
|
phonegap platform add android
|
|
|
|
|
phonegap platform add blackberry10
|
|
|
|
|
phonegap platform add firefoxos
|
|
|
|
|
|
|
|
|
|
Run this to check your current set of platforms:
|
|
|
|
|
|
|
|
|
|
phonegap platforms ls
|
|
|
|
|
|
|
|
|
|
See more on [Cordova CLI
|
|
|
|
|
Interface](http://cordova.apache.org/docs/en/4.0.0/guide_cli_index.md.html)
|
|
|
|
|
|
2015-02-07 11:57:44 +01:00
|
|
|
|
## Build Application
|
2015-02-07 00:30:30 +01:00
|
|
|
|
|
2015-02-07 14:57:55 +01:00
|
|
|
|
Then in order to build application for all configured platform, use:
|
2015-02-07 00:30:30 +01:00
|
|
|
|
|
|
|
|
|
phonegap build
|
|
|
|
|
|
|
|
|
|
You can also build for a specific platform [`ios`, `android`, etc.]:
|
|
|
|
|
|
|
|
|
|
phongap build <platform>
|
|
|
|
|
|
|
|
|
|
To build a new "ready-to-publish" release, use the flag:
|
|
|
|
|
|
|
|
|
|
phongap build --release
|
2015-02-07 11:57:44 +01:00
|
|
|
|
|
|
|
|
|
Find the built releases in the `platforms/` folder.
|
2015-02-07 00:30:30 +01:00
|
|
|
|
|
2015-02-07 12:31:37 +01:00
|
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
Momo is licensed under the [GNU General Public License v3.0](http://www.gnu.org/)
|