Description
PropBox handles the various nuances of viewing AND editing different types of properties
(depending on their expected types: CVTs, images, unique properties, addresses, datetime, numbers, etc.)
along with proper formatting (for viewing) and validation (when editing).
PropBox is not only a client-side library, it hosts a variety of services for reading and writing property values.
These JSON(P) services are available to all acre apps through a special entry point/alias the acreteam has setup under /acre/form/propbox.
For example, /acre/form/propbox/propbox can be invoked within any acre app.
Usage:
In you acre template:
<html>
<acre:script>
var c = acre.require("/user/daepark/propbox/components", "release"); // required
var id = "/en/blade_runner"; // topic id
var pid = "/film/film/starring"; // property id
</acre:script>
<head>
<!-- some default styles (optional) -->
<link rel="stylesheet" type="text/css" href="http://default.freebaseapps.com/default_style"/>
<!-- required -->
<link rel="stylesheet" type="text/css" href="http://propbox.freebaseapps.com/propbox.css"/>
<!-- required -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<!-- required -->
<script type="text/javascript" src="http://propbox.freebaseapps.com/propbox.js"></script>
</head>
<body style="margin:2em;">
${c.propbox(id, pid)}
</body>
</html>
Examples:
Document
-
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.,,
Recipes:
By default, topics link to http://www.freebase.com/view/topic_id.
To override, create a server-side script called "helpers" with a function called "url_for".
function url_for(id, ect_id) {
return "/myview?id=" + id;
};
Here is an alternative topic view:
view the source
PropBox services:
All services return JSON results in the form
{
"status" : "200 OK",
"code" : "/api/status/ok",
"result" : {
"data" : ...
"html" : ...
},
"transaction_id" : "cache;cache03.p01.sjc1:8101;2009-12-04T22:17:05Z;0012",
"timestamp" : "2009-12-04T22:17:05Z"
}
Or if authentication is required, an http status code of 401 is returned:
{
"status" : "401 User Authorization Required",
"code" : "/api/status/error/auth",
"messages" : [
{
"message" : "User must be logged in to use this service.",
"code" : "/api/status/error/auth/required",
"info" : null
}
],
"transaction_id" : "cache;cache02.p01.sjc1:8101;2009-12-04T22:19:54Z;0007",
"timestamp" : "2009-12-04T22:19:54Z"
}
/acre/form/propbox/all
| Accessible via: |
/acre/form/propbox/all |
| Permits HTTP GET: |
Yes |
| Permits HTTP POST: |
No |
| Login required: |
No |
| Arguments: |
| name |
required |
| id |
Yes |
| pid |
Yes |
|
By default PropBox returns the first 10 topic property values. This returns all values.
/acre/form/propbox/add_begin
| Accessible via: |
/acre/form/propbox/add_begin |
| Permits HTTP GET: |
Yes |
| Permits HTTP POST: |
No |
| Login required: |
Yes |
| Arguments: |
| name |
required |
| id |
Yes |
| pid |
Yes |
|
Returns the add form for the specified topic property.
/acre/form/propbox/edit_begin
| Accessible via: |
/acre/form/propbox/edit_begin |
| Permits HTTP GET: |
Yes |
| Permits HTTP POST: |
No |
| Login required: |
Yes |
| Arguments: |
| name |
required |
| id |
Yes |
| pid |
Yes |
|
Simple authentication check before enabling editing (sort/remove) for the specified topic property.
/acre/form/propbox/propbox
| Accessible via: |
/acre/form/propbox/propbox |
| Permits HTTP GET: |
Yes |
| Permits HTTP POST: |
No |
| Login required: |
No |
| Arguments: |
| name |
required |
| id |
Yes |
| pid |
Yes |
|
Return the PropBox content for the specified topic property.
/acre/form/propbox/rm
| Accessible via: |
/acre/form/propbox/rm |
| Permits HTTP GET: |
No |
| Permits HTTP POST: |
Yes |
| Login required: |
Yes |
| Arguments: |
| name |
required |
| id |
Yes |
| pid |
Yes |
| value |
Yes |
|
Remove a topic property value. Depending on the nature of the property, value can be a literal value or a topic id.
Example: Remove triple </en/test_insance> </user/daepark/default_domain/test_type/topic> </en/blade_runner>
id=/en/test_instance
pid=/user/daepark/default_domain/test_type/topic
value=/en/blade_runner
Example: Remove triple </en/test_insance> </user/daepark/default_domain/test_type/date> <2009-12-02>
id=/en/test_instance
pid=/user/daepark/default_domain/test_type/date
value=2009-12-02
/acre/form/propbox/sort
| Accessible via: |
/acre/form/propbox/sort |
| Permits HTTP GET: |
No |
| Permits HTTP POST: |
Yes |
| Login required: |
Yes |
| Arguments: |
| name |
required |
| id |
Yes |
| pid |
Yes |
| value |
Yes |
|
Sort topic property values.
To sort, MQL requires all the preceding values to be specified up to the item being sorted.
The value param should be an array of these topic property values to be sorted.
Example: Sort [/en/blade_runner, /en/bob_dylan]
id=/en/test_instance
pid=/user/daepark/default_domain/test_type/topic
value=/en/blade_runner
value=/en/bob_dylan
/acre/form/propbox/add_submit
| Accessible via: |
/acre/form/propbox/add_submit |
| Permits HTTP GET: |
No |
| Permits HTTP POST: |
Yes |
| Login required: |
Yes |
| Arguments: |
| name |
required |
| id |
Yes |
| pid |
Yes |
| old |
No |
| delete |
No |
|
/acre/form/propbox/address_submit
| Accessible via: |
/acre/form/propbox/address_submit |
| Permits HTTP GET: |
No |
| Permits HTTP POST: |
Yes |
| Login required: |
Yes |
| Arguments: |
| name |
required |
| id |
Yes |
| pid |
Yes |
| country |
Yes |
| street |
No |
| street2 |
No |
| city |
No |
| state |
No |
| zipcode |
No |
| old |
No |
| delete |
No |
|
/acre/form/propbox/image_upload_submit
| Accessible via: |
/acre/form/propbox/image_upload_submit |
| Permits HTTP GET: |
No |
| Permits HTTP POST: |
Yes |
| Login required: |
Yes |
| Arguments: |
|
/acre/form/propbox/image_submit
| Accessible via: |
/acre/form/propbox/image_submit |
| Permits HTTP GET: |
No |
| Permits HTTP POST: |
Yes |
| Login required: |
Yes |
| Arguments: |
| name |
required |
| id |
Yes |
| pid |
Yes |
| value |
No |
| url |
No |
| name |
No |
| license |
No |
| fair_use_license_holder |
No |
| public_domain_license_holder |
No |
| cc_by_license_holder |
No |
| cc_by_sa_license_holder |
No |
| gnu_license_holder |
No |
|
/acre/form/propbox/document_submit
| Accessible via: |
/acre/form/propbox/document_submit |
| Permits HTTP GET: |
No |
| Permits HTTP POST: |
Yes |
| Login required: |
Yes |
| Arguments: |
| name |
required |
| id |
Yes |
| pid |
Yes |
| value |
Yes |
| old |
No |
| delete |
No |
|