Gaia/Hacking: Difference between revisions

no edit summary
(Adding back the Apache configuration guide as the wiki doesn't currently document any way of running a server, is there a different preferred way of doing this?)
No edit summary
Line 109: Line 109:
New browser-chrome tests should be put directly in the $GAIA/tests/ directory.
New browser-chrome tests should be put directly in the $GAIA/tests/ directory.
There is already a few of them there that you can look at to have a better idea about how to write yours!
There is already a few of them there that you can look at to have a better idea about how to write yours!
== Hosting Gaia using Apache ==
For development you might find it helpful to host Gaia apps using your own Apache web server. Below is a quick guide on how to set that up, this is based on Ubuntu but should work on other platforms with a few modifications.
If you haven't already installed Apache, you should install it
$ sudo apt-get install apache2
Enable virtual hosts by changing the first two lines of /etc/apache2/sites-available/default to:
NameVirtualHost *
<VirtualHost *>
(Note that the first line is new, the second line should replace the first line in the default version of that file)
Create a virtual host config at /etc/apache2/sites-available/gaiamobile.org
# Redirect [browser|sms|...].gaiamobile.org to ${GAIA}/apps/[browser|sms|...]/.
<VirtualHost *>
  ServerName  homescreen.gaiamobile.org
  ServerAlias *.gaiamobile.org
  VirtualDocumentRoot /path/to/gaia/apps/%1/
</VirtualHost>
<VirtualHost *>
  ServerName gaiamobile.org
  ServerAlias gaiamobile.org
  DocumentRoot /path/to/gaia
</VirtualHost>
# Add the correct mimetypes for offline cache manifest
AddType text/cache-manifest .appcache
# Prevent Apache from caching apps files
<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresDefault "access plus 0 hours"
  ExpiresByType text/html "access plus 0 hours"
  ExpiresByType text/xml "access plus 0 hours"
  ExpiresByType text/css "access plus 0 hours"
  ExpiresByType text/plain "access plus 0 hours"
  ExpiresByType application/x-javascript "access plus 0 hours"
  ExpiresByType application/javascript "access plus 0 hours"
  ExpiresByType text/javascript "access plus 0 hours"
  ExpiresByType text/cache-manifest "access plus 0 hours"
  ExpiresByType image/gif "access plus 0 hours"
  ExpiresByType image/png "access plus 0 hours"
  ExpiresByType image/jpeg "access plus 0 hours"
  ExpiresByType image/x-icon "access plus 0 hours"
</IfModule>
Enable the Apache modules
$ sudo a2enmod expires
$ sudo a2enmod vhost_alias
Enable the gaiamobile.org virtual host
$ sudo a2ensite gaiamobile.org
Restart Apache
$ sudo apache2ctl graceful


== Loading Gaia from a server ==
== Loading Gaia from a server ==
Line 175: Line 115:
For development you might find it helpful to load Gaia from a web server instead of relying on the application cache.
For development you might find it helpful to load Gaia from a web server instead of relying on the application cache.


This require 2 steps. The first one is to generate a profile that does not relies on the Application Cache:
First you need to generate a profile that does not rely on the Application Cache. From your Gaia directory run:


  DEBUG=1 make
  DEBUG=1 make


The second will map all the sudomains to your localhost.
The generated profile directory also contains a web server. When you run B2G desktop using this profile the web server will run on port 8080...
Note: it will not be needed anymore once https://bugzilla.mozilla.org/show_bug.cgi?id=722197 will be fixed.
 
b2g -p /path/to/gaia/profile/directory
 
Currently you also need to map all the subdomains to localhost to get B2G to load gaiamobile.org from your own machine.
 
Note: This will not be needed any more once https://bugzilla.mozilla.org/show_bug.cgi?id=722197 is fixed.


Edit '''/etc/hosts''' (or [http://en.wikipedia.org/wiki/Hosts_%28file%29#Location_in_the_file_system somewhere else] on other systems) and add the following line  
Edit '''/etc/hosts''' (or [http://en.wikipedia.org/wiki/Hosts_%28file%29#Location_in_the_file_system somewhere else] on other systems) and add the following line  
Line 237: Line 182:
=== Touch events ===
=== Touch events ===
To enable the necessary interfaces in the Firefox web browser you need to go to about:config and add the boolean preference '''dom.w3c_touch_events.enabled''' and set it to '''true'''.
To enable the necessary interfaces in the Firefox web browser you need to go to about:config and add the boolean preference '''dom.w3c_touch_events.enabled''' and set it to '''true'''.
=== Hosting Gaia using Apache ===
As an alternative to B2G's own web server, you may find it helpful to host Gaia apps using your own Apache web server. Below is a quick guide on how to set that up, this is based on Ubuntu but should work on other platforms with a few modifications.
If you haven't already installed Apache, you should install it
$ sudo apt-get install apache2
Enable virtual hosts by changing the first two lines of /etc/apache2/sites-available/default to:
NameVirtualHost *
<VirtualHost *>
(Note that the first line is new, the second line should replace the first line in the default version of that file)
Create a virtual host config at /etc/apache2/sites-available/gaiamobile.org
# Redirect [browser|sms|...].gaiamobile.org to ${GAIA}/apps/[browser|sms|...]/.
<VirtualHost *>
  ServerName  homescreen.gaiamobile.org
  ServerAlias *.gaiamobile.org
  VirtualDocumentRoot /path/to/gaia/apps/%1/
</VirtualHost>
<VirtualHost *>
  ServerName gaiamobile.org
  ServerAlias gaiamobile.org
  DocumentRoot /path/to/gaia
</VirtualHost>
# Add the correct mimetypes for offline cache manifest
AddType text/cache-manifest .appcache
# Prevent Apache from caching apps files
<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresDefault "access plus 0 hours"
  ExpiresByType text/html "access plus 0 hours"
  ExpiresByType text/xml "access plus 0 hours"
  ExpiresByType text/css "access plus 0 hours"
  ExpiresByType text/plain "access plus 0 hours"
  ExpiresByType application/x-javascript "access plus 0 hours"
  ExpiresByType application/javascript "access plus 0 hours"
  ExpiresByType text/javascript "access plus 0 hours"
  ExpiresByType text/cache-manifest "access plus 0 hours"
  ExpiresByType image/gif "access plus 0 hours"
  ExpiresByType image/png "access plus 0 hours"
  ExpiresByType image/jpeg "access plus 0 hours"
  ExpiresByType image/x-icon "access plus 0 hours"
</IfModule>
Enable the Apache modules
$ sudo a2enmod expires
$ sudo a2enmod vhost_alias
Enable the gaiamobile.org virtual host
$ sudo a2ensite gaiamobile.org
Restart Apache
$ sudo apache2ctl graceful
Confirmed users
394

edits