Tutorial 2 > Next tutorial
NRS Tutorial: Building an NRS application
1. Create an application
Go to the administration interface of NRS and select
the 'Templates' tab. Create a new application
called 'myapp' by creating a new template of type
'application' and with a name 'myapp/app'. After
creating it, select 'myapp'. You are now in the
application template for the new 'myapp' application.
From here you can add new templates to your 'myapp'
application.
2. Add a news template
Create a news template by selecting type 'news' and name
'news'. Notice the tab navigation appears, now
that there are 2 groups in the application.
3. Configure news template
Select the 'edit' link for the 'news' template, and under
snippets, add a url to a news source: http://www.news.com.
Click the 'save button' to add it. Now click the
'edit' link next to your new news source, and
specify a parse rule to extract the news off the
page: <title link><desc><date label="PST">
Click 'save' and then 'back to template'. You
can now click 'back to template list' and select
your news template by clicking on the 'news' link.
You have just added a news source!
4. Add a search template
Now click on the 'app' tab to return to your application's
editor, and add a search page by creating a new
template of type 'search' and name 'search'. Click
the 'edit' link next to 'search' and add a search
url under searches: http://www.google.com . Click
'save' and then 'back to template list'. To test
your search page, select the 'search' link and
try a search. For searches, the system will try
to extract the search results automatically. If
this does not work well enough you can specify
a parse rules like you did for the news source
to improve the results returned. Specifying a
parse rule also lets you extract metadata such
as date and size along with the search results.
5. Add more templates
Now you get the idea, you can add directory pages
and other templates to your application. You can
also hide the 'app' template from users by specifying
in its properties the IP/Username of the application
administrator.
When adding new templates you specify a name or a path.
If you only specify a name, your template will
assume the 'group' property of the template to
be the same as the given name. The 'group' property
controls which tab the template falls under. When
multiple templates fall under the same tab, a
drop-down list appears with all templates of the
same tab. Using the 'app', 'group', and 'name'
properties of a template you can control building
applications with a tab bar interface. In the
URL namespace, a template with app=A, group=B,
and name=C would result in a URL path of /A/B/C.
6. Change HTML
Templates are rendered into HTML using XSL files. You can
replace the logo on all pages in your application
by using the 'group set' function. Specify a filename
of a text file containing new XSL for either the
whole file, or just the section you wish to override.
In this case put in the file a new logo section:
<xsl:template
name="drawlogo">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#7C8C93"><img alt="" src="/dot.gif" width="1" height="116"/></td>
<td><img alt="logo" src="http://www.mysite.com/mylogo.gif"/></td>
</tr>
</table>
</xsl:template>
The url to your new image would be placed in the
anchor's href. If you want the system to serve
the image, you can place it in the application
directory or create a directory under the application
directory called images for example.
Back to support
|