|
|
(14 intermediate revisions by 4 users not shown) |
Line 1: |
Line 1: |
| <div class="title">Getting Started</div>
| | The content on this page has moved to https://documentation.open-xchange.com/latest/ui/customize/app/first-app.html |
|
| |
|
| <div style="float:right; padding: 10px;">[[File:OX_AppSuite_UI_Development_Workflow.png]]</div>
| | Note: Open-Xchange is in the process of migrating all its technical documentation to a new and improved documentation system (documentation.open-xchange.com). Please note as the migration takes place more information will be available on the new system and less on this system. Thank you for your understanding during this period of transition. |
| | |
| __TOC__
| |
| | |
| Hello and welcome to the world of OX App Suite development. This document is designed to get you started with developing your first app for OX App Suite as quickly and simply as possible. However, along the way we will also tempt you to learn more by linking to some more in-depth documentation about the various topics we cover.
| |
| | |
| <div style="clear: both"></div>
| |
| | |
| == Installing the Development Tools ==
| |
| | |
| First, you need to install some tools which are necessary for UI development.
| |
| | |
| $ npm install -g grunt-cli bower yo generator-ox-ui-module
| |
| | |
| == Create a Workspace ==
| |
| | |
| All your app development can take place inside one working directory. The examples will assume you have created a directory named <tt>myapp</tt> inside your home directory:
| |
| | |
| $ mkdir ~/myapp
| |
| $ cd ~/myapp
| |
| | |
| It doesn't need to be in your home directory, and the actual name should reflect the name of your app. The main point is that all commands will be executed in this directory and all paths will be relative to this directory from now on.
| |
| | |
| Now, you can generate a grunt configuration using:
| |
| | |
| $ yo ox-ui-module
| |
| | |
| The source code of your app will reside in the subfolder named <tt>apps</tt>. To avoid name collisions please pick a unique subfolder inside that. The easiest and recommended way is to use a domain name that you own. Typically, the domain elements are reversed, like in Java. <tt>example.com</tt> becomes <tt>com.example</tt>:
| |
| | |
| $ mkdir -p apps/com.example
| |
| | |
| == Writing an App ==
| |
| | |
| As an example, let's create the smallest possible app and test it. It requires only two files: <tt>apps/com.example/register.js</tt> for the source code of the app:
| |
| | |
| <pre class="language-javascript">
| |
| define('com.example/register', function () {
| |
| 'use strict';
| |
| alert('Hello, World!');
| |
| });
| |
| </pre>
| |
| | |
| and <tt>apps/com.example/manifest.json</tt> for the [[AppSuite:UI_manifests_explained | manifest]] which tells the UI that your app exists and what to do with it:
| |
| | |
| <pre class="language-javascript">{ "namespace": "core" }</pre>
| |
| | |
| == Building an App ==
| |
| | |
| The source code of your app can't be used by OX App Suite as it. It first has to be processed by the [[AppSuite:UI_build_system | build system]]. This step will check the source code for syntax errors, compress it, and depending on the structure of your code, many other things. The processed code is then written to a directory named <tt>build</tt> by default. Start the build with this command:
| |
| | |
| $ grunt
| |
| | |
| If your editor supports it, you can configure it to call the build system after every file save. Take care to call it from the top directory of your app's workspace, not from the directory of the saved file.
| |
| | |
| == Testing an App ==
| |
| | |
| The freshly built code can now be tested. Instead of uploading your code to an OX App Suite server, you can use the [[AppSuite:Appserver|appserver]] proxy to inject your code into the UI code of any existing OX App Suite installation. For example, to start <tt>appserver</tt> using [http://ox.io/ ox.io] as the server, you will need a local configuration pointing to that server. You can generate it with this command:
| |
| | |
| $ grunt show-config:local --output grunt/local.conf.json
| |
| | |
| Open up the file <tt>grunt/local.conf.json</tt> in your editor and add <tt><nowiki>"https://ox.io/appsuite/"</nowiki></tt> to the <tt>server</tt> setting of the appserver section. Then start the development server:
| |
| | |
| $ grunt dev
| |
| | |
| This command will serve your app from the local directory <tt>build</tt>, and get everything else from the URL specified in the <tt>server</tt> setting.
| |
| | |
| Once appserver is running, you can access OX App Suite by opening your browser using this address:
| |
| | |
| http://localhost:8337/appsuite
| |
| | |
| After logging in, the app should be loaded and display the <tt>alert</tt> message.
| |
| | |
| === Development cycle ===
| |
| | |
| Once you are sure that your setup works, you can extend the example and write the actual code for your app. The <tt>dev</tt> task will detect any changes and rebuild your app and even reload all browsers connected to
| |
| <tt>http://localhost:8337/appsuite</tt>.
| |
| | |
| While developing always keep in mind, that there is an [[AppSuite:Debugging_the_UI | article about debugging the user interface]] which helps you avoid and fix typical errors.
| |
| | |
| == Packaging ==
| |
| | |
| Together with our ox-ui-module generator (from version 0.8.0), we provide you with generators for packaging information.
| |
| | |
| === Generating a source tarball ===
| |
| | |
| There is a grunt tasks to create source packages. You can use it to create a tar.gz file containing all sources needed to build the project. This source package should contain all dependencies that are installed during <tt>bower install</tt> and <tt>npm install</tt> (basically containing your <tt>bower_components</tt> and <tt>node_modules</tt> directories). To generate this file, run:
| |
| | |
| $ grunt dist:source --include-dependencies
| |
| | |
| This file (can be found in the <tt>dist/</tt> directory) together with the distribution specific packaging information will be needed to build the package.
| |
| | |
| === RPM packages ===
| |
| | |
| In order to generate a spec file for your project, run:
| |
| | |
| $ yo ox-ui-module:rpm-pkg
| |
| | |
| Will generate a spec file, with some default values read from your <tt>package.json</tt> file. So you might want to make this file as complete as possible. However, yeoman will ask you about the information missing.
| |
| | |
| ''Please remember, that the generated spec file is only a scaffold for a real one. It will work for very simple cases, but as soon as your package gets more complicated, you will have to adjust it to your needs.''
| |
| | |
| Once you have the spec file in your project, you can use
| |
| | |
| $ grunt rpm-buildpackage # or rpm-build if you are on shared-grunt-config-7.6.0
| |
| | |
| === DEB packages ===
| |
| | |
| Creating packages for the Debian distribution works similar to rpm packages. Just run:
| |
| | |
| $ yo ox-ui-module:deb-pkg
| |
| | |
| This will generate a debian directory containing all needed files. Some default values will be read from your <tt>package.json</tt> file. So you might want to make this file as complete as possible. However, yeoman will ask you about the information missing.
| |
| | |
| ''Please remember, that the generated spec file is only a scaffold for a real one. It will work for very simple cases, but as soon as your package gets more complicated, you will have to adjust it to your needs.''
| |
| | |
| Once you have a debian/ directory for your project, you can go on.
| |
| To enable some grunt tasks to help you, you need to install (with npm install) <tt>grunt-contrib-compress</tt> and <tt>grunt-exec</tt>. Now you can run:
| |
| | |
| $ grunt dist:dpkg-source
| |
| | |
| You can now use the files in the dist/ directory to build your packages. A simple example would look like:
| |
| | |
| $ cd dist/unicorn-0.0.1/
| |
| dpkg-buildpackage -b
| |
| | |
| == i18n ==
| |
| | |
| To use the proven way to translate your AppSuite application, you should now check out the [[AppSuite:I18n | documentation]] about all [[AppSuite:I18n | i18n]] tasks. Please browse to the [[AppSuite:I18n | i18n]] page.
| |
| | |
| == Further Reading ==
| |
| * Congratulations you have just built your first app for OX App Suite, but please keep in mind that there are [[AppSuite:Developing for the UI#What_can_i_build.3F | quite a few options]] for developing for OX App Suite.
| |
| * In case you want to upgrade your existing app for OX App Suite, read [[Appsuite:Upgrade_app_using_yo | the upgrade guide]].
| |
| * More information on the build system can be found on github:
| |
| ** [https://github.com/Open-Xchange-Frontend/shared-grunt-config See all available grunt tasks]
| |
| ** [https://github.com/Open-Xchange-Frontend/generator-ox-ui-module Documentation of all generator tasks]
| |
| * If you're stuck somewhere, the article about [[AppSuite:Debugging_the_UI | debugging the UI]] might help you.
| |
| * You can read this to get a better overview of [[AppSuite:Developing for the UI | developing the user inferface]].
| |