cwrc / DEPRECATED--CWRC-Dialogs

0 stars 0 forks source link

!!! Deprecated repository (go to https://github.com/cwrc/CWRC-PublicEntityDialogs for the most recent code

CWRC Dialogs

This project aims to provide a set of dialogs to peform lookups, create and edit 4 types of entities for all CWRC applications.

These entities include:

Status

The current version has a working lookup dialog that queries the CWRC repository and the VIAF data source.

In order to use the CWRC Dialogs the file cD.js needs to be included like any other javascript framework.

Also, the dialogs depend on the following frameworks and APIs:

The following is an example of all the files that need to be included:

    <script src="https://github.com/cwrc/DEPRECATED--CWRC-Dialogs/raw/master/js/jquery-1.11.0.js"></script>
    <script src="https://github.com/cwrc/DEPRECATED--CWRC-Dialogs/raw/master/js/jquery-ui-1.10.4.custom.js"></script>       
    <script src="https://github.com/cwrc/DEPRECATED--CWRC-Dialogs/raw/master/js/knockout-2.3.0.js"></script>
    <script src="https://github.com/cwrc/DEPRECATED--CWRC-Dialogs/raw/master/js/bootstrap.js"></script>
    <script src="https://github.com/cwrc/DEPRECATED--CWRC-Dialogs/raw/master/js/bootstrap-datepicker.js"></script>
    <script src="https://github.com/cwrc/DEPRECATED--CWRC-Dialogs/raw/master/js/cwrc-api.js"></script>
    <script src="https://github.com/cwrc/DEPRECATED--CWRC-Dialogs/raw/master/js/cD.js"></script>
    <script src="https://github.com/cwrc/DEPRECATED--CWRC-Dialogs/raw/master/js/app.js"></script>

    <link rel="stylesheet" type="text/css" href="https://github.com/cwrc/DEPRECATED--CWRC-Dialogs/blob/master/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="https://github.com/cwrc/DEPRECATED--CWRC-Dialogs/blob/master/css/datepicker.css">
    <link rel="stylesheet" href="https://github.com/cwrc/DEPRECATED--CWRC-Dialogs/blob/master/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="https://github.com/cwrc/DEPRECATED--CWRC-Dialogs/blob/master/css/cD.css">

A test application is included with the code. This application can be reached by opening the index.html file. The test application queries the solr engine and adds entries to a list. The application logic is located on the app.js file.

From the app.js file you can see that the CWRC dialogs need to be initialized for the cwrc api to work. You can initialize it with the initializeWithLogin or initializeWithCookieData methods.

Service call urls can be customized by using the functions setCwrcApi, setGeonameUrl, and setViafUrl.

The location of entity schemas can be defined by using the functions setPersonSchema, setOrganizationSchema, or setPlaceSchema.

The interface as opened to the user includes:

The dialogs can be initialized using the function initializeWithCookieData by passing in the data string representing the cookies containing the session information. The passed in cookie string must be in the format "cookiename=cookiedata;". Each cookie can be separated by a semicolon. This cookie string usually can be obtained by using the javascript function document.cookie.

The objects popCreate, popSearch, and popEdit provide key base access to the create and search dialogs respectively using the entity names as keys (person, organization etc.)

Methods popCreatePerson, popCreateOrganization, popCreatePlace, popCreateTitle can take the following arguments as part of a hash:

When opening the search dialog on can pass different options to the call function that will modify the behaviour of the dialog.

An example follows

    var customAction = function(data) {

        var result = "";
        for (var i in data) {
            if (data.hasOwnProperty(i)) {
                result += i + " : " + data[i] + "   ";
            }
        }

        $("#resultHeader").text("Result");
        $("#entityXMLContainer").text(result);
    };

    var opts = {
        success: function(result) {
            $("#resultHeader").text("Added");
            $("#entityXMLContainer").text(JSON.stringify(result));
        },
        error : function(errorThrown) {
            $("#entityXMLContainer").text("");
            $("#resultHeader").text("Entity ");
        },
        buttons : [
            {
                label : "Show response",
                action : customAction
            }
        ],
        query : "Bruce Wayne"
    }

    cD.popSearchPerson(opts);

The data return has the following format:

The following is an example of a resulting object:

id : cwrc:640cbd44-fcfe-4d0a-b964-d10ae5bf68cb 
uri : http://commons.cwrc.ca/cwrc:640cbd44-fcfe-4d0a-b964-d10ae5bf68cb
name : Austin 
repository : cwrc 
data : <?xml version="1.0" encoding="UTF-8"?> <?xml-model href="http://cwrc.ca/schema/person.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?> <entity> <person> <recordInfo> <originInfo> <projectId>eccji</projectId> </originInfo> <accessCondition type="use and reproduction">Use of this public-domain resource is governed by the <a href="http://creativecommons.org/licenses/by-nc/3.0/" rel="license">Creative Commons Attribution-NonCommercial 3.0 Unported License</a>.</accessCondition> <personTypes> <personType>creator</personType> </personTypes> </recordInfo> <identity> <preferredForm> <namePart partType="surname">Austin</namePart> <namePart partType="forename">Prof.</namePart> </preferredForm> </identity> </person> </entity> 

Search

Search dialogs can use a endpoints the CWRC entities, VIAF, Geonames, or the Google GeoCode endpoints.

The CWRC entities endpoint assumes a Solr based JSON response. As of 2015-05-22, the Solr fields required:

object_label
object_url
PID
numFound