Login
Quick Search
Feed Contents
QuickHelp by wolf27-12-2008 20:58
Scripting by wolf23-4-2009 0:16

QuickHelp

by wolf at 3-3-2008 10:48; Wiki ID: QuickHelp

Addressing

The hierarchical structure of feeds and entries is directly reflected in the URLs you use to access an entry or feed. In general, URLs that end with a slash point to a feed, while URLs not ending with a slash reference an entry within a feed. For example:

/myfeed/points to a feed
/myfeed/Entrypoints to an entry in the feed with the ID "Entry".

To access the raw Atom feeds, the URLs should begin with /atom/content/ or /atom/feeds/:

/atom/content/myfeed/returns the raw Atom feed as stored in the db. Entry contents are not processed for display.
/atom/feeds/myfeed/returns an Atom feed suitable for viewing with an Atom-enabled news reader. Entry contents are post-processed for display, e.g. wiki markup is transformed into HTML.

Navigating

The navigation bar on the top right of the page displays the position of the current feed or entry in the feed hierarchy. To navigate back to an ancestor feed, click on one of the links.

Creating a new feed/page

To create a new feed, just change the URL in the location bar of the browser and have it point to a non-existing feed. A "page not found" form will be displayed. To create the feed, enter a title and submit the form.

You can also use the navigation bar. Enter the name of the feed into the input box and click on the New Page button. The feed will be created relative to the current feed.

Editing

The editor provides shortcuts to some formatting actions in the toolbar. However, you can also enter Common Wiki markup directly in the text. The Wiki Markup Help box in the sidebar lists some wiki markup syntax examples.

Every entry should have a title and an ID. The ID is used to identify the entry in an URL or link to it. It should be a simple string, only characters, no whitespace. If no ID is specified, the editor will create one from the first 3 words of the title when saving the entry.

Note: Every entry does also have an internal Atom ID, but this one is rather complex and too long to type.

Images and Attachments

Before an image can be embedded into an entry, it has to be uploaded to the feed. This is done through the upload dialog, which opens if you click on the Upload Images link in the Edit menu.

Once an image has been uploaded, you can insert a link to it through the image icon in the editor's toolbar.

Other attachments than images can be uploaded in the same way. After uploading an attachment (e.g. a PDF document), you can link to it from within the entry using a relative URL.

Scripting

by wolf at 10-11-2007 16:29; Wiki ID: Scripting

Using the Script Macro

You can directly embed XQuery code into a wiki entry using the script macro. For example:

5 + 4  = {script}5 + 4{/script}

renders into:

5 + 4 = 9

A script can access the current HTTP request, response or session and thus evaluate parameters passed in by the user:

{html}
<form method="POST">
  <input type="text" name="name" /><input type="submit" value="Send"/>
</form>
{/html}
{script}
let $name := request:get-parameter("name", ())
return
<p>
{
  if ($name) then concat("Hello ", $name, "!")
  else "Please enter your name!"
}
</p>
{/script}

Here's a working example using the code above:

Please enter your name!

The XQuery script can also be executed on a database instance running outside the current web application. The XQuery will be posted to the URI specified in the parameter, which should point to eXist's REST interface (usually /rest or /servlet). The trailing part of the URL defines the collection on which the query is executed. For the example above, we simply add an uri attribute, pointing to the local REST interface:

{script uri="http://localhost:8000/rest/db" forward="yes"}
let $name := request:get-parameter("name", ())
return
<p>
{
  if ($name) then concat("Hello ", $name, "!")
  else "Please enter your name!"
}
</p>
{/script}

If parameter forward is set to "yes" (the default), the current request parameters will be appened to the server URI and are thus available to the target XQuery. However, the HTTP session or other request properties are not forwarded.

Including External Contents

External contents can be included into an entry by using the include macro:

$include(uri="http://localhost:8000/rest/db/wiki/util/test.xml")

Loading Entry Contents from an URL

The content of an entry in a feed can also be loaded from an external URL. This is currently not possible through the web interface, though editing an entry manually is easy and can be done with any WebDAV-enabled editor (the WebDAV URL is http://localhost:8000/webdav/db/).

If the content element in the entry has a src attribute, the contents of the entry will be loaded from the URL specified in the attribute. For example:

<feed xmlns="http://www.w3.org/2005/Atom">
    <id>urn:uuid:de020fd6-412e-48eb-8fb9-618d8b007724</id>
    <updated>2008-03-10T15:22:51+01:00</updated>
    <title>Test Page</title>
    <entry>
        <id>urn:uuid:3c4bd8eb-5d64-4ab5-9cd8-3501e47c5b2d</id>
        <content type="text/xml" src="http://localhost:8000/rest/db/wiki/util/test.xql"/>
    </entry>
</feed>

To generate this, create a dummy entry through the web interface, then open the feed via WebDAV, delete the dummy content and add the src attribute.

Getting Entry Contents from an XQuery Script

If the type attribute of the content element is "application/xquery", the content will be loaded from the URL given in the src attribute and executed as an XQuery script. For example, the twitter feed is included as follows:

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:wiki="http://exist-db.org/xquery/wiki">
    <id>urn:TwitterFeed</id>
    <updated>2007-11-05T20:17:19+01:00</updated>
    <published>2007-10-20T23:50:56+02:00</published>
    <link href="?id=urn:TwitterFeed" rel="edit" type="application/atom+xml"/>
    <title type="text">Twitter Feed</title>
    <category scheme="http://atomic.exist-db.org/config/twitter" term="user">existdb</category>
    <category scheme="http://atomic.exist-db.org/config/twitter" term="max-entries">6</category>
    <category scheme="http://atomic.exist-db.org/config/twitter" term="view">user</category>
    <wiki:id>TwitterFeed</wiki:id>
    <content type="application/xquery" src="twitter.xql"/>
</entry>

This will call the XQuery twitter.xql stored in the same collection as the feed (because it is a relative link).

The query has access to the entry element from which it was called through the external variable entry. In the twitter example above, Atom category elements are used to pass configuration data to the query.

Links
Latest Posts
AtomicWiki 0.4