Documention for: lds-local.r
Created by: sunanda
on: 20-Jan-2004
Last updated by: sunanda on: 2-Mar-2006
Format: html
Downloaded on: 30-Apr-2025

1. History
1.1. 2-Mar-2006 -- 0.0.8
1.2. 28-Jan-2006 -- 0.0.7
1.3. 9-Feb-2005 -- 0.0.6
1.4. 8-Sep-2004 -- 0.0.5
1.5. 9-Jul-2004 -- 0.0.4
1.6. 28-Apr-2004 -- 0.0.3
1.7. 19-Jan-2004 -- 0.0.1
1.8. 20-Feb-2004 -- 0.0.2
2. Overview
3. Uses
4. Levels of access
4.1. Public
4.2. Member
4.3. Owner
5. Installing Library Data Services
6. Using Library Data Services
6.1. Initialising the interface
6.2. Calling the interface
6.3. Calling the interface with a token
7. Status reply
7.1. Status/1
7.2. Status/2
7.3. Status/3
7.4. Examples
8. Library tokens
8.1. Getting a token
8.2. Install the token
8.3. Using the token
8.4. Multiple tokens
9. General Library requests
9.1. help
9.1.1. Example
9.2. list-users
9.2.1. Example
10. Mailing List requests
10.1. get-rml-message
10.1.1. Example 1 -- get a single message
10.1.2. Example 2 -- get all messages for a given thread
10.1.3. Example 3 -- get the latest message
10.2. get-rml-status
10.2.1. Example
10.3. search-rml
10.3.1. Parameter
10.3.2. Examples of the search parameter:
10.3.3. Response object
10.3.4. Searchable years
10.4. Examples
11. Script requests
11.1. get-script
11.1.1. Example:
11.1.2. Note to script owners
11.2. list-scripts-by-filter
11.2.1. Example
11.3. list-search-filters
11.4. search-scripts
11.4.1. Example
11.5. list-scripts-owned-by
11.5.1. Example -- get list of scripts owned by Sunanda
11.6. list-updated-scripts
11.6.1. Example 1: what's new in the last 15 days?
11.6.2. Example 2: Download new versions of scripts changed in the last 31 days
12. Script Archive requests
12.1. list-archive-versions
12.1.1. Example:
12.2. get-archive-version
12.2.1. Examples:
13. Update scripts requests
13.1. contribute-script
13.1.1. Parameters
13.1.2. Example of the dialect:
13.1.3. Examples of use
13.2. get-script-documentation
13.2.1. Examples:
13.2.2. Note to script owners
14. Script owner requests
14.1. List-my-scripts
14.1.1. Example
14.2. get-script-stats
14.2.1. Example
15. Package read requests
15.1. get-package-header
15.1.1. data/package-file-list fields
15.1.2. Possible errors.
15.1.3. Example -- header for package lds-demo1-package.r
15.1.4. file-type:package
15.2. get-package-file
15.2.1. Example -- file notes.txt package lds-demo1-package.r
15.2.2. Notes
16. Package update requests
16.1. Overview before we start
16.2. Transaction level support
16.2.1. Step 1: contribute-script
16.2.2. Step 2: update-package-header
16.2.3. Step 3: upload-package-file
16.2.4. Step 4: include-script-in-package
16.2.5. Step 5: update-package-header again
16.3. Steps involved in updating a package
16.3.1. Step 1: update-package-header
16.3.2. Step 2: upload-package-file
16.3.3. Step 3: remove-file-from-package
16.3.4. Step 4 include-script-in-package
16.3.5. Step 5 remove-script-from-package
16.3.6. Step 6: update-package-header
16.4. update-package-header
16.4.1. Parameters
16.4.2. Response
16.4.3. Examples
16.5. upload-package-file
16.5.1. Parameters
16.5.2. Examples
16.5.3. What you get back
16.6. include-script-in-package
16.6.1. Parameters
16.6.2. Example
16.7. Remove-file-from-package
16.7.1. Parameters
16.7.2. Example
16.8. Remove-script-from-package
16.8.1. Parameters
16.8.2. Example
17. Other requests
17.1. rss-get-feed-data
17.1.1. response object
17.1.2. response object/generation-info
17.1.3. response object/script-library
17.1.4. response object/mailing-list-archive
17.1.5. response object/news
17.1.6. Example
18. Token requests
18.1. token-test
18.1.1. Example:
18.2. token-cancel
18.2.1. Example:
19. Random points and answers to NAQs (never-asked questions)
19.1. Why not use LNS (Lightweight Network Services)?
19.2. Validation and verification
19.3. Sorting
19.4. Caching
19.5. XML
  Version: 0.0.8
  31-Jan-2006
  Sunanda
 

1. History

1.1. 2-Mar-2006 -- 0.0.8

1.2. 28-Jan-2006 -- 0.0.7

1.3. 9-Feb-2005 -- 0.0.6

1.4. 8-Sep-2004 -- 0.0.5

1.5. 9-Jul-2004 -- 0.0.4

1.6. 28-Apr-2004 -- 0.0.3

Archive version requests added: Extra fields added to list-package-header to support installation folders and better download information

1.7. 19-Jan-2004 -- 0.0.1

Initial version

1.8. 20-Feb-2004 -- 0.0.2

Package handling requests added:

2. Overview

Library Data Services (LDS) is an interface to the REBOL.org website that lets any REBOL program retrieve data from the Library in a REBOL format. Example: get the list of Library members
   probe lds/send-server 'get-user-list []

     make object! [
     status: [0 0 "]
     data:
     make object! [
         user-list: ["gregg" "volker" "sunanda"]
     ]
   ]
 
What comes back is a REBOL object with just two fields:

3. Uses

You could use this interface to:

4. Levels of access

LDS defines three levels of access:

4.1. Public

Broadly, any data you can retrieve via a web browser while not logged on:

4.2. Member

Things you can do as a member of the Library:

4.3. Owner

Things you can do as the owner of a script:

5. Installing Library Data Services

Run it directly from the REBOL.org server:

do http://www.rebol.org/library/public/lds-local.r

That's all it takes.


6. Using Library Data Services

6.1. Initialising the interface

Issue this call once before you call the service:

do http://www.rebol.org/library/public/lds-local.r

6.2. Calling the interface

All calls have the same format:

response-data: lds/send-server 'request [parameters]

6.3. Calling the interface with a token

A Library token is needed if you are doing something at the Member or Owner level.

Getting a token is explained later (see Library Tokens).

A call using a token looks like this:

response-data: lds/send-server/use-token 'request [parameters]


7. Status reply

LDS always replies with values in the Status field. It is a block with three parts:

7.1. Status/1

An integer! between 000 - 999. The values are divided into specific ranges:

7.2. Status/2

May contain context-sensitive information. For example, if the status/3 text is "script not found" , status/2 may contain the script name we were looking for. Not all requests support this.

7.3. Status/3

A short text, in english, describing the problem.

7.4. Examples

   probe lds/send-server 'list-updated-scripts ["zzzzz"]

   make object! [
       status: [200 0 "non-integer days"]
       data: none
   ]
  
(zzzzz should be an integer)
  probe lds/send-server 'get-script ["xxxx.r"]

  make object! [
       status: [300 0 "unknown script"]
       data: none
   ]
  
(xxxx.r is not a script in the Library)
  probe lds/send-server 'get-script ["sssss.r"]

  make object! [
       status: [400 0 "can't connect"]
       data: none
  ]
  
(You may be offline)

8. Library tokens

To use some LDS requests, you must be a member of the Library.

If you are not a member of the Library, you can join by going here:

http://www.rebol.org/cgi-bin/cgiwrap/rebol/signup.r

LDS needs you to supply a Library token on each call. This identifies who you are in much the same way that a cookie does when you visit the Library using the web interface.

8.1. Getting a token

Log on, and visit this page:

http://www.rebol.org/cgi-bin/cgiwrap/rebol/lds-library-tokens.r

Tell it how many tokens you want (one is normally enough -- see multiple tokens below for why you may want more than one) and click "send me tokens" .

The tokens will be emailed to your registered address.

8.2. Install the token

A token looks something like this:

    #{00C04C0913E76ECFF780DD73}
  

Save it as a text file called lds-library-token.txt in the folder from which you execute Library Data services, eg:

   write %lds-library-token.txt  mold  #{00C04C0913E76ECFF780DD73}
  

The token is now ready for use.

8.3. Using the token

Add the /use-token refinement to each lds/send-server request, eg:

Response-object: lds/send-server/user-token 'token-test ["test my token"]

8.4. Multiple tokens

If you use LDS from more than one location (perhaps on different machines) you need a different token for each location. You can have as many tokens as you want.


9. General Library requests

9.1. help

Returns a list of all LDS requests and some help on each of them -- a good way to see if you have an out-of-date copy of these notes.

9.1.1. Example

 probe lds/send-server 'help none

  make object! [
   status: [0 0 "]
   data:
   make object! [
     request-list: [
       "get-rml-message"
       make object! [
           authorisation?: false
           purpose: {Retrieve a message from the REBOL Mailing list archive}
           parameters: "Msgid [integer!]"
           response: "Object containing message and control headers"
             ]
    "get-script"
    make object! [
  [snip]
  

9.2. list-users

Retrieve list of activated Library members

("activated" means they have logged on at least once)

9.2.1. Example

  probe lds/send-server 'list-users []

  make object! [
      status: [0 0 "]
      data:
      make object! [
          user-list: ["volker" "gregg" "sunanda"]
      ]
  ]

  

10. Mailing List requests

Use these requests to read messages from the Mailing list archive

10.1. get-rml-message

Retrieve a message from the REBOL Mailing list archive

10.1.1. Example 1 -- get a single message

  probe res: lds/send-server 'get-rml-message [237859]
 
The fields in the data object for this request are:

10.1.2. Example 2 -- get all messages for a given thread

  msgs: copy []
  res: lds/send-server 'get-rml-message [213498]
  forever  [
           append msgs res/data
           if res/data/links/3 = 0 [break] ;; no next-in-thread link
           res: lds/send-server 'get-rml-message reduce [res/data/links/3]
        ]
  print ["There were" length? msgs "message(s) in the thread"]

 

10.1.3. Example 3 -- get the latest message

  msgs: copy []
  res: lds/send-server 'get-rml-message ["latest"]

 

10.2. get-rml-status

Sends you back some status information about the Mailing list archive.

10.2.1. Example

  probe res: lds/send-server 'get-rml-status []

  make object! [
     status: [0 0 "]
     data:
     make object! [
         counts: [241337 241337]
         threads: [8706]
         years: [1980 2000 2001 2002 2003 2004 2005 2024]
     ]
 
The fields in the data object for this request are:

get-rml-status is most useful for getting the full span of years for a search-rml request....See immediately below.

10.3. search-rml

Sends you back the message ids for all threads that meet your search criteria

10.3.1. Parameter

The parameter is a single quoted string. It should contain at least one word on which you want to search. It may also contain one or more years.

10.3.2. Examples of the search parameter:

10.3.3. Response object

Contains both the message ids of the messages that matched your search, and some reflected back fields to confirm what has been searched.

An example is

  make object! [
     status: [0 0 "]
     data:
     make object! [
         target-words: ["apple" "pink" "white"]
         search-type: "posts"
         span: [2003 2002 2001 2000]
         msgids: [207276]
     ]
 ]
 

10.3.4. Searchable years

Using the search-rml request, you can search on all years for which threads exist. This includes some strange ones, such as 1980 and 2024. They exist because we take the date field in the original email's header as correct. and, obviously, in some cases they were not: the sender's ISP or server was badly set up.

We don't have much choice about that. The Mailing list archive started some years after the Mailing list, so we don't have accurate context information to correct the problem.

10.4. Examples

  probe lds/send-server 'search-rml ["async version"]
  make object! [
     status: [0 0 "]
     data:
     make object! [
         target-words: ["async" "version"]
         search-type: "subjects"
         msgids: [234122]
     ]
 ]
 

  probe  lds/send-server 'search-rml ["1960 1961 help me to get a good job 2004 2003"]

 make object! [
     status: [0 0 "]
     data:
     make object! [
         target-words: ["get" "good" "help" "job" "me"]
         search-type: "posts"
         span: [2004 2003]
         msgids: [230329 230451 ....snipped .....]
     ]
  ]
 

Note that the span contains only the years we could search (we don't have messages from the 1960s), and the target-words does not include the stop words "to" and "a".


11. Script requests

Use these requests to search the Script Library, and to download scripts.

11.1. get-script

Retrieve latest version of a script

Returns the source of the named script

11.1.1. Example:

  probe lds/send-server 'get-script ["wumpus.r"]

  make object! [
     status: [0 0 "]
     data:
     make object! [
         script: {REBOL[
     Title:   "Hunt the Wumpus"
     Date:    20-Jul-2003
     File:^- %wumpus.r
     Purpose: "A REBOL version of a retro text game. Just for fun."
     Author:  "Gregg Irwin"
     EMail:   greggirwin@acm.org
     Version: 1.0.1
      Library: [
         level: 'intermediate
         platform: 'all
  [snip]

 

11.1.2. Note to script owners

If you own a script, and check its download count on the statistics page of REBOL.org: LDS get-script downloads are counted as "Total LDS downloads" .

11.2. list-scripts-by-filter

Returns a list of script names that match the search filter.

11.2.1. Example

   probe lds/send-server 'list-scripts-by-filter [domain-xml]

  make object! [
      status: [0 0 "]
      data:
      make object! [
          script-list: ["json.r" "xmlgen.r" "rblxelparser.r"]
      ]
  ]
  

11.3. list-search-filters

Returns an object with all the possible filters that can be used with list-scripts-by-filter

The response object has a series of blocks, each represents a possible set of filters, for example

type: [article demo dialect faq function ... ]

means you can filter on type-article type-demo etc

11.4. search-scripts

Returns a list of script names that contain the words you asked for

11.4.1. Example

    probe lds/send-server 'search-scripts ["decompress"]

  make object! [
      status: [0 0 "]
      data:
      make object! [
          script-list: ["compress.r" "autoextract.r"]
      ]
  ]
  

The script-list returned is in script relevance order: best matches first.

11.5. list-scripts-owned-by

Returns a list of scripts owned by a given Library member

If the owner name is not recognised, the script-list is returned as an empty block.

11.5.1. Example -- get list of scripts owned by Sunanda

   probe lds/send-server 'list-scripts-owned-by ["sunanda"]

  make object! [
      status: [0 0 "]
      data:
      make object! [
         script-list: ["cookie-example.r" "oneliner-chess-board.r"
 "oneliner-monty-hall.r"]

 

11.6. list-updated-scripts

Get a list of new or updated scripts in the last [n] days

Lets you find which scripts have been added or updated in the last n days. n is an integer: 1 or more

11.6.1. Example 1: what's new in the last 15 days?

  probe lds/send-server 'list-updated-scripts [15]

  make object! [
      status: [0 0 "]
      data:
      make object! [
          script-list: ["mtv.r" "mvt.r" "mvs.r"]
      ]
  ]
  

11.6.2. Example 2: Download new versions of scripts changed in the last 31 days

  res1: lds/send-server 'list-updated-scripts [31]
  foreach scr res1/data/script-list
  [
   res2: lds/send-server 'get-script reduce [scr]
   write to-file scr res2/data/script
  ]

 

12. Script Archive requests

Use these requests to get archived versions of scripts (each time a script owner updates a script, we put the previous version in the archive. In some cases, the previous versions remain available for download).

12.1. list-archive-versions

REBOL.org usually only shows the latest version of each script. Previous versions may still be available. This request returns a list of all publicly available versions of a script.

12.1.1. Example:

  probe lds/send-server 'list-archive-versions [demo1.r]

  make object! [
     status: [0 0 "]
     data:
     make object! [
         archive-versions: [
             [7 15-Mar-2004 "Fixed bug in header"]
             [12 28-Apr-2004 "Version 2.0 -- supports IOS"]
             ]
     ]
    ]
 

In the above example, there are two publicly-available versions of the script: 7 and 12. The version number is an internal number to the Library. It will usually be different to the owners' version number in the script itself.

The highest version number show will always be the current live version of the script. Lower numbered entries are back-versions of the script that the owner has left publicly available.

To retrieve an archive version of a script use the request get-archive-version.

12.2. get-archive-version

Retrieve an archived version of a script (see list-archive-versions for more details)

12.2.1. Examples:

Get archive version 17 for script demo1.r:

  probe res: lds/send-server 'get-archive-version ["demo1.r/17"]

  make object! [
     status: [0 0 "]
     data:
     make object! [
         script: #{
   789CC551C14AC34010BDEF574C03524592565191F46015EB410445C54BE86193
   snip
   ED800F8DA6768B8BCD39E0D9FE255DA877CE25EAB52D030000
   }
     ]
    ]

 

demo1.r has a publicly available version 17, so it has been returned:

Get archive version 14 for script demo1.r:

   probe res: lds/send-server 'get-archive-version ["demo1.r/14"]

   make object! [
     status: [301 "demo1.r" "not available"]
     data: none
     diagnostics: [41641 33710 0.11]
  ]

 

Version 14 of demo1.r is nor publicly available. If you need that exact version, contact the owner and ask them to make it available.


13. Update scripts requests

13.1. contribute-script

Use this request to either add a new script to the Library; or update an existing script that you own.

13.1.1. Parameters

Are a dialect with these words: mode, note, and script. Mode and script must always be present. Note is optional.

13.1.2. Example of the dialect:

note "changed error handling" mode check script {rebol [file: %zzz.r .....}

13.1.3. Examples of use

     scr: {rebol [] quit}
     response-object: lds/send-server/use-token 'contribute-script
     compose [mode "check" note "fix error handling" script (scr)]
  

This example does not send an acceptable script! This is what you'd get back:

   Probe response-object

   make object! [
   status: [210 30 "problems with script"]
    data:
     make object! [
     validation: ["file" "We need a File: field in the REBOL header."
     "title" "We need a Title: field in the REBOL header."
     "date" {The Date: field in the REBOL header needs to be a valid REBOL
 date. (Not none)}
     "purpose" "We need a Purpose: string in the REBOL header."]
      ]
      ]
  

13.2. get-script-documentation

Retrieve the documentation for a script, either as HTML or in its editable format

13.2.1. Examples:

  probe res: lds/send-server 'get-script-documentation ["lds-
 local.r/editable"]

 make object! [
     status: [0 0 "]
     data:
     make object! [
         documentation: #{
 789CED7D6977DBD6D9E077FF8A1BF6742C69448AE04E2675476BDF74ECC68D9D
 E4EDE8B8E7402428210601160045AB99FCF77996BB622129937E9BCE8CCE492C
 91C05D9EFBECDBFDC617B1BF08FED0C89369D36BBCFAE6CC7FF5CD43E7D5EBF0
 2EF5D32771E5E7BE7817A48FE134C8BE39836F04FD7C330B1FC534F2B38C5E85
 [snip]

  print decompress res/data/documentation

   [h2 Library Data Services
   [contents

   [asis
    Version: 0.0.5
    12-Sep-2004
    Sunanda
 [snip]

 

13.2.2. Note to script owners

If you own a script, and check its download count on the statistics page of REBOL.org: LDS get-script downloads are counted as "Total LDS downloads" .


14. Script owner requests

Use these requests to get information about a script that is only available to the script owner.

14.1. List-my-scripts

Returns the list of scripts that you own. Similar to list-scripts-owned-by, but you identify yourself by using a Library token.

14.1.1. Example

response-object: lds/send-server/use-token 'list-my-scripts []

14.2. get-script-stats

Returns owner statistics for the script -- only available if you own the script.

14.2.1. Example

response-object: lds/send-server/use-token 'get-script-stats [lds-local.r]


15. Package read requests

Use these requests to query or retrieve files from packages.

There is a also special LDS utility that makes working with packages easy:

do http://www.rebol.org/library/public/repack.r

15.1. get-package-header

Retrieve the header for a package -- i.e. the index to that package.

15.1.1. data/package-file-list fields

15.1.2. Possible errors.

The package may not exist, or may not be available. See http://www.rebol.org/cgi-bin/cgiwrap/rebol/boiler.r?display=lds-package-dow nloader-help.html for a list of the package error messages

15.1.3. Example -- header for package lds-demo1-package.r

  probe res: lds/send-server 'get-package-header ["lds-demo1-package.r"]

  make object! [
     status: [0 0 "]
     data:
     make object! [
         user-notes: {Run lds-demo1.r under REBOL/View and see if you can
 Spot The Developer!}
         package-file-list: [
             make object! [
                 file-name: "image1.jpg"
                 cgi-type: "image/pjpeg"
                 install-folder: "images/"
                 file-type: "file"
                 version: 0.0.4
                 last-updated: 17-Apr-2004/16:17:19.39+1:00
                 notes: "
                 checksum: #{4001620992AE7B6974F159A6D957571CD1558E36}
                 file-size: 17165
                 compressed-size: 12573
             ]
             make object! [
                 file-name: "image2.jpg"
                 cgi-type: "image/pjpeg"
                 install-folder: "images/"
                 file-type: "file"
                 version: 0.1.0
                 notes: "
                 checksum: #{B76028C7C1D1DFFF2584788BEC82B8F7A8B55C07}
                 file-size: 75276
                 compressed-size: 39052
             ]
 etc -- one entry per file

 

15.1.4. file-type:package

This means that the file is itself another package. That probably means that his package requires all the files from that package to be downloaded for a complete installation.

The package header for the current package does not include all the files for the included package. If you are writing a package installer or downloader you may need to take into account file-type:package. If you do, issues include:

15.2. get-package-file

Retrieve one file from a package

15.2.1. Example -- file notes.txt package lds-demo1-package.r

  probe res probe res: lds/send-server 'get-package-file
 ["lds-demo1-package.r/notes.txt"]

  make object! [
     status: [0 0 "]
     data:
     make object! [
         file: #{
  789C7552D16ED3500C7D8F947F70DF3AD4A06D8C017B63A39B040C101DF0EC24
  6E7AD5C48E1CA7617F8FEF6DD6371429B24F7C8E8FEDE4599EDDB5A1DA83096C
  0CD5F26C89AD15D50B3898F46779F6BF67D38B81ED087EAE6FBF7F859A0ED44A
  snip
  074DF93BCF8F8B9881F70EA41B9DFEB6237F9567171F8A7B2A8BCBF3F3AB3CFB
  07C289D8E6C6020000
  }
     ]
  ]

 

15.2.2. Notes

The file as returned is compressed:

  decompress res/data/file
  {^M
  ^M
  Click to Start^M
  (alt-click to stop)^M
  ^M
  ^M
  ^M
  ^M
  Spot the REBOL developer!^M
 

To save it, and lose all those ^M thingies in a text file, always save the file as binary:

  write/binary %notes.txt decompress res/data/file
  print read %notes.txt

  Click to Start
  (alt-click to stop)

  

Saving the file as binary is always the correct thing to do: the file may be a JPG or executable, or some other non-text format.


16. Package update requests

16.1. Overview before we start

A package is a multi-file unit that makes up one contribution to the Library.

From a user's perspective, it is three things:

All the LDS requests for uploading or updating packages will need a Library token.

Again, as with the contribute-script request, there is a mode parameter on every request.

16.2. Transaction level support

To create a full and usable package, several requests (perhaps many) have to be issued and succeed. If the server or the client fail part-way through, there will be an incomplete or unusable package left on public view.

This is not so different from when a user is uploading files by hand to create a package -- their connection could fail at any point. I just mention in it case LDS clients want to get clever with some restart code.

LDS itself will not be offering any sort of journaling or rollback. It sees and actions individual requests.

16.2.1. Step 1: contribute-script

Use contribute-script request to upload a new script. Include 'package in the Library header 'type field.

After successfully contributing a new script, various automated mechanisms start telling the world the good news (email notices, RSS feed, "what's new" pages, etc)

So some quick off-the-mark people may be looking at the new package before we've uploaded all the files. Nothing much we can do about that. It's part of the way packages were implemented as a bolt-on.

16.2.2. Step 2: update-package-header

Use this request to:

16.2.3. Step 3: upload-package-file

Use this request for each of your files that are part of the package.

16.2.4. Step 4: include-script-in-package

Use this request for any existing Library scripts that are part of the package.

16.2.5. Step 5: update-package-header again

Use this again to set the package as available . People can now download your new package.

16.3. Steps involved in updating a package

If you later need to change the package, use these steps:

16.3.1. Step 1: update-package-header

Set the package as unavailable to prevent people accidentally downloading an incomplete or inconsistent package

16.3.2. Step 2: upload-package-file

To add new files or update existing ones

16.3.3. Step 3: remove-file-from-package

To remove a file from the package

16.3.4. Step 4 include-script-in-package

To include additional Library scripts in the package

16.3.5. Step 5 remove-script-from-package

To remove a Library script from the package.

16.3.6. Step 6: update-package-header

Use this again to set the package as available . People can now download your updated package.

16.4. update-package-header

Use this request to add or update the header details of a package

16.4.1. Parameters

Are a dialect with four words : mode, script-name and status and user-notes

16.4.2. Response

A data object that normalises the dialect -- if you had any fields missing or with unacceptable values, you can see from the response what we assumed.

16.4.3. Examples

A full request looks something like:

    lds/send-server/use-token 'update-package-header
      [script-name "example-package.r"
       mode "update"
       status "private"
       user-notes  "Only works on MACs"
     ]
  

(As with all these requests, the order of the keywords in the dialect does not matter)

These following examples stand in for a lot of detailed exposition about error checking and what we do with bad requests.

The data section of the response is the internal, normalised dialect words -- so you can see how LDS-server has interpreted missing or bad data:

   probe lds/send-server/use-token 'update-package-header [
         script-name "example-package.r"
         mode "update"
        ]

  make object! [
     status: [300 0 "unknown script"]
     data:
     make object! [
         script-name: "example-package.r"
         mode: "update"
         status: none
         user-notes: none
     ]
    ]
 

Problem: no such script. Expect similar errors for:

   probe lds/send-server/use-token 'update-package-header [
         script-name "example-package.r"
         user-notes "zzz"
       ]

  make object! [
     status: [0 0 "]
     data:
     make object! [
         script-name: "example-package.r"
         mode: "check"
         status: none
         user-notes: "zzz"
     ]
   ]
 

Appears to have worked (got a 0 response), but the missing mode was taken as check -- so no changes made.

   lds/send-server/use-token 'update-package-header [
         script-name "example-package.r"
         mode "do it"
         user-notes "zzz"
        ]

  make object! [
     status: [0 0 "]
     data:
     make object! [
         script-name: "example-package.r"
         mode: "check"
         status: none
         user-notes: "zzz"
     ]
    ]

 

Mode is bad (not check or update ) -- treated as its safest value, check . Again, no update.

  probe lds/send-server/use-token 'update-package-header [
         script-name "example-package.r"
         mode "update"
         user-notes "zzz"
        ]

  make object! [
     status: [0 0 "]
     data:
     make object! [
         script-name: "example-package.r"
         mode: "update"
         status: none
         user-notes: "zzz"
     ]
  ]
 

This one worked. It updated the user notes, but did not change the status (because none was specified).

  lds/send-server/use-token 'update-package-header [
       script-name "example-package.r"
       mode "update"
       status "confused"
       ]

  make object! [
     status: [0 0 "]
     data:
     make object! [
         script-name: "example-package.r"
         mode: "update"
         status: "private"
         user-notes: none
     ]
   ]
  

This one worked, but may not have done what you expected. There was a status, but it was a bad value (neither private or public ) we normalised it to private that being the safest value. The user notes remain unchanged.

  probe lds/send-server/use-token 'update-package-header [
         script-name "example-package.r"
         mode "update"
         status "public"
         user-notes "
        ]

  make object! [
     status: [0 0 "]
     data:
     make object! [
         script-name: "example-package.r"
         mode: "update"
         status: "public"
         user-notes: "linux only"
     ]
  ]
 

Changes the status to public and sets the user notes to "

16.5. upload-package-file

Use this to add or update details of a file in the package

16.5.1. Parameters

Are a dialect with these words: mode, script-name, file-name, install-folder, user-notes, version, contents, and checksum. Mode, script-name and file-name must always be present

16.5.2. Examples

  probe lds/send-server/use-token 'upload-package-file
      [script-name "example-package.r"
       mode "update"
        file-name "image-1.jpg"
        install-folder "images/"
        user-notes "Photo of Fluffy Bunny"
        version "0.0.5"
        contents  #{...binary field...}
        checksum #checksum/secure of contents (to detect in-flight damage)
    ]
  

Uploads a new file (or completely replaces the details of an existing one)

   lds/send-server/use-token 'upload-package-file
      [script-name "example-package.r"
       mode "update"
        file-name "image-1.jpg"
        install-folder "my/images/"
        user-notes "Better Photo of Fluffy Bunny"
        version "1.0.5"
        ]
  

Will change the install-folder, user-notes and version

   lds/send-server/use-token 'upload-package-file
      [script-name "example-package.r"
       file-name "image-1.jpg"
       mode "update"
       user-notes "Even better Photo of Fluffy Bunny"
      ]
 

Will change just the user notes.

16.5.3. What you get back

Upload-package-file returns the normalised dialect, but the contents field is set to [omitted] -- no point sending back a 5meg file, or however large the file is.

16.6. include-script-in-package

Use this to include an existing Library script in the package. Note that you don't upload the script (after all, we already have it). You just tell us to make it part of the package.

16.6.1. Parameters

Are a dialect with these words: mode, script-name, file-name, install-folder, library-script-name.

16.6.2. Example

 lds/send-server/use-token 'include-script-in-package
      [script-name "example-package.r"
       mode "update"
       library-script-name: "convert-base.r"
       install-folder "lib-scripts/"
      ]

  

16.7. Remove-file-from-package

Use this to remove a file you have uploaded to a package.

16.7.1. Parameters

Are a dialect with these words: mode, script-name, file-name, and install-folder.

16.7.2. Example

 lds/send-server/use-token 'remove-file-from-package
      [script-name "example-package.r"
       mode "update"
      install-folder: "
      file-name "image-1.jpg"
    ]

 

image-1.jpg will not be a part of the package after this request is run. (Note: this does not mean it was a part of the package before; but, if it was, it isn't now)

16.8. Remove-script-from-package

Use this to remove a Library script from the package.

16.8.1. Parameters

Are a dialect with these words: mode, script-name, file-name, install-folder, library-script-name.

16.8.2. Example

 lds/send-server/use-token 'remove-script-from-package
      [script-name "example-package.r"
       mode "update"
      install-folder: "
      Library-script-name "convert-base.r"
    ]
 

/convert-base.r will not be a part of the package after this request is run. (Note: this does not mean it was a part of the package before; but, if it was, it isn't now)


17. Other requests

17.1. rss-get-feed-data

Retrieves the raw data used to generate the Library's RSS feed.

You can subscribe to the Library's RSS feed by visiting get RSS feed. 

Alternatively, you can used this LDS request to retrieve the same data as a REBOL object. In addition, there are some extra fields not supplied to the RSS readers.

17.1.1. response object

has these fields:

17.1.2. response object/generation-info

Has these useful fields

17.1.3. response object/script-library

Is a block of objects, one per script included in the RSS feed data.

17.1.4. response object/mailing-list-archive

Is a block of objects, one per included in the RSS feed data.

17.1.5. response object/news

Is a block of objects, one per news item included in the RSS feed data. News is the little snippets you can find on the top right of the REBOL.org home page.

17.1.6. Example

  probe lds/send-server 'rss-get-feed-data []
   


18. Token requests

Use these requests to work with your Library tokens.

18.1. token-test

Test if your Library token works:

If the token is valid, you get your text back. If not, you get an error message about the token

18.1.1. Example:

response-object: lds/send-server/use-token 'token-test ["any text"]

18.2. token-cancel

Cancels your current token. It will never work again.

18.2.1. Example:

response-object: lds/send-server/use-token 'token-cancel []


19. Random points and answers to NAQs (never-asked questions)

19.1. Why not use LNS (Lightweight Network Services)?

LDS predates LNS by a year, so LNS simply wasn't a possibility.

It would be good to add an LNS interface to the Library. If any one wants to volunteer to help with that, please drop us a feedback message

19.2. Validation and verification

All validation and verification of requests is done on REBOL.org. Lds-local does no parameter checking -- it simply passes the parameters you supply to REBOL.org.

19.3. Sorting

The lists you get back from LDS are not usually not sorted. Any sequencing is purely accidental, and should not be relied on. LDS provides the data, it is your choice what order to handle or present it.

One exception is the ''search-scripts request. The scripts-list it returns is sorted according to the relevance of the results: best fit first.

19.4. Caching

Each time you call lds/send-server, it talks to the REBOL.org server. There is a case for caching results as many things do not change that often. It's on the upgrade list.

19.5. XML

I've been thinking of adding an XML refinement:

lds/send-server/xml 'help none

So what you get back is an XML page, not a REBOL object. Easy to do, but no point, unless anyone needs it.

end