(→Debugging) |
(→Packaging) |
||
| Line 138: | Line 138: | ||
== Packaging == | == Packaging == | ||
| - | Web Runtime on MeeGo uses the <code>wgt</code> packaging format: it's a zip file with configuration metadata in a <code>config.xml</code> file. The configuration follows the [http://www.w3.org/TR/widgets/ W3C Widget Packaging and Configuration | + | Web Runtime on MeeGo uses the <code>wgt</code> packaging format: it's a zip file with configuration metadata in a <code>config.xml</code> file. The configuration follows the [http://www.w3.org/TR/widgets/ W3C Widget Packaging and Configuration] specification. |
Symbian uses <code>wgz</code> files, which are similar; however, <code>wgz</code> files contain a directory at the first level inside the archive, with the widget files inside; while <code>wgt</code> files don't have a top-level directory. The two formats also have different configuration files formats. | Symbian uses <code>wgz</code> files, which are similar; however, <code>wgz</code> files contain a directory at the first level inside the archive, with the widget files inside; while <code>wgt</code> files don't have a top-level directory. The two formats also have different configuration files formats. | ||
The MeeGo SDK enables Web Runtime (WRT) development for MeeGo. The following is a simple guide to get you going with this exciting, flexible, and highly portable development environment.
WebSDK is currently only supported on Windows, so these instructions are only applicable for that OS right now (2010-10-18).
Contents |
The MeeGo Web Runtime engine allows web "widgets" to run outside of the browser. A widget is a small application, or applet, that is built using web technologies such as Javascript, HTML, and CSS. These are often run inside a browser as add-ons. With MeeGo WRT these widgets can be installed and behave as stand-alone applications.
The best option for Web Runtime development at the moment is the WebSDK, maintained by Nokia. It is available from http://www.forum.nokia.com/Develop/Web/9hy25fa/ (you'll need to register for an account to get it). You need the Nokia Web SDK Technology Preview, which has support for MeeGo widgets.
The Nokia Forum website includes a good set of tutorials about developing widgets. However, the material on that site is focused on developing widgets for Symbian phones, rather than MeeGo. The reason for this page is to briefly highlight the differences when developing Web Runtime widgets for MeeGo.
Installing Web SDK is very straightforward: run the .exe file you downloaded and follow the prompts. You'll end up with two applications:
For the first project, we'll write a very simple "hello world" application which displays a form for a user to enter their name. JavaScript responds to the user's input and displays a personalised greeting, including the user's name.
http://developer.meego.com/elliot/helloworld.
Your project should now be visible in the File view, under Projects.
Expand the project and double-click on the index.html page. You should see the source of the HTML file in the main panel.
Add a paragraph inside the <body> tag, for example:
<p>Hello world</p>
Save it.
To preview the widget in the simulator:
Interactivity is added to widgets by writing JavaScript functions and hooking them to the interface. A JavaScript file is already included with your project, basic.js. You can add your own functions to this file.
Start by editing the index.html and adding a form with a text entry box and button:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Greet</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script language="javascript" type="text/javascript" src="basic.js"></script>
<link rel="stylesheet" href="basic.css" type="text/css"/>
</head>
<body onload="init();">
<!-- form to enter a name -->
<form method="post" action="index.html">
<p><label for="name">Name</label>: <input type="text" name="name" id="name"/></p>
<p><input type="button" value="Greet" onclick="greet();"/></p>
</form>
<!-- greeting will be displayed inside this paragraph -->
<p id="greetings"/>
</body>
</html>
The button's onclick attribute is set to the greet() callback, which we add to basic.js (note I've left the default init() function, which doesn't do anything at present):
function init() {
}
/* get the value from the name input element and display it in a greeting */
function greet() {
var name = document.getElementById('name').value;
if (name != '')
document.getElementById('greetings').innerHTML = "Hello " + name;
}
Open index.html in the simulator tab again. Enter something in the text box and click on the Greet button to call the JavaScript function and display a greeting.
You should see something like this:
Note: you may occasionally need to click on the Reload button in the simulator to load your changes, as it doesn't always pick up when you save a file.
Developing client-side JavaScript applications is beyond the scope of this tutorial, but good places to find out more are:
WebSDK provides debugging for widgets running inside the simulator.
basic.js file by double-clicking in the margin next to a line of code. Notice in the screenshot below how a small blue circle is displayed next to the line:Web Runtime on MeeGo uses the wgt packaging format: it's a zip file with configuration metadata in a config.xml file. The configuration follows the W3C Widget Packaging and Configuration specification.
Symbian uses wgz files, which are similar; however, wgz files contain a directory at the first level inside the archive, with the widget files inside; while wgt files don't have a top-level directory. The two formats also have different configuration files formats.
The WDE makes packaging very simple:
Once you have created a .wgt file, transfer it to your device and run it.
Example for QEMU:
scp -p 6666 <path to .wgt> meego@127.0.0.1:/<path on target image>
(See QEMU dev page for tips)
Install the qt-web-runtime components on the target
$ zypper install qt-web-runtime
Optional:
$ zypper install qt-web-runtime-devel $ zypper install qt-web-runtime-examples (installs 10 .wgt files in /usr/lib/wrt/examples/demowidgets/)
Once the Web Runtime components are installed, you are ready to install your new widget:
$ widgetinstaller <path to .wgt file>
This creates a new .desktop file in /usr/share/applications/ for your widget. Your widget will now appear with other applications. Run it by clicking on it in the Applications zone; or, run it from the command line with:
$ webwidgetrunner <path to .desktop file created in previous step>
???
caveats about the impossibility of debugging