Skip to content

Instantly share code, notes, and snippets.

@brito
Last active July 16, 2016 00:10
Show Gist options
  • Select an option

  • Save brito/c98e769f48295970692b4ee603cc2c72 to your computer and use it in GitHub Desktop.

Select an option

Save brito/c98e769f48295970692b4ee603cc2c72 to your computer and use it in GitHub Desktop.
WebCenter Portal REST (RIDC)

Back in 2013 I wrote some HTML/JS/CSS to create a client-side carousel for WebCenter Portal 11g.

This won't work out of the box on 12c, because of the migration from folders_g to Framework Folders.

The content comes from a WebCenter Content backend in the same domain.

The content is put into an auto-advancing carousel.

The carousel has an index that on hover changes the feature, and a parallax hover-scroller, which is awesome but probably not tablet-friendly.

component.html

is the value of an HTML component on the target page. Uses the collection id to pull the items and use metadata to generate a carousel.

carousel.js

pulls data using cs.js and generates HTML (that matches carousel.css) for a dynamic carousel.

carousel.css

uses media query for responsive and styles the following structure:

.carousel
  a

.carousel-feature
  figure
    :before
    img
    figcaption
  figure.feature

cs.js

is the interface for the RIDC (idcplg) server for WebCenter Content. It works roughly with this syntax:

// function call for service and parameter
cs(type, id)
// returns something that could be confused for a Promise/A but instead a ‘wish’
.then(function(response){
  // result is very SOAPy, so there is an onion to peel
  var items = 
    // Designed to handle the returns from many services, but only one implemented here
    cs[type](response)
    // convert to HTML
      .map(function(item){
      // etc. (see file)

Your content metadata will need the following:

  • dID
  • dDocTitle
  • xSupplementalMarkings
  • xComments
  • dWebURL
<script data="COLLECTION_DISPLAY/999999999999024157"></script>
/**
* /cs Query Content Server
* @return wish (skeletal Promise.then)
* circa 2013
*/
function cs(type, id){
var params = { IdcService: type, IsJson: true };
switch(type){
// file: cs/COLLECTION_DISPLAY
case 'COLLECTION_DISPLAY':
params.hasCollectionID = true;
params.dCollectionID = id;
cs['COLLECTION_DISPLAY'] = function(response){
var contents = response.ResultSets.CONTENTS
|| console.warn(response.LocalData.StatusMessage),
fields = contents.fields,
rows = contents.rows.map(function(row){
var item = {};
row.forEach(function(value, i){ item[fields[i].name] = value });
return item;
});
return rows;
};
break;
}
// params to url
var p = [];
for (var name in params) p.push(name+'='+params[name]);
var url = '/cs/idcplg?' + p.join('&');
// make request
var xhr = new XMLHttpRequest;
xhr.onload =
xhr.onerror = function(){
fulfill(JSON.parse(xhr.response)); };
xhr.open('GET', url);
xhr.setRequestHeader('Accept', 'application/json');
xhr.send();
// fulfill wish
var fairy;
function fulfill(response){ return fairy(response) }
var wish = { then: function(fn){ fairy = fn }};
return wish;
}
@jasonmoo
Copy link
Copy Markdown

Woot! Good to see your code again sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment