New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pressgang-rest

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pressgang-rest

A high level library for REST communication with a PressGang Component Content Management System (CCMS) Server

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

#node-pressgang-rest

A node module that provides a REST client library for the PressGang CCMS. It provides a more semantic interface for application development than the raw PressGang REST interface. Uses restler for the REST interface.

##Installation

npm install pressgang-rest

Basic Usage v.0.1.0 and up

var pressgang = require('pressgang-rest);

Get a topic:

pressgang.getTopic('http://127.0.0.1:8080', 4324, {revision: 2343, expand: tags}, 
    function (err, topic) {
        if (err) return console.log(err);
        console.log('Got Topic %s at revision %s', topic.id, topic.revision);
        console.log('XML is %s', topic.xml);
    });

revision and expand are optional. expand can take any of the root expandable entities, which include:

tags
incomingRelationships
outgoingRelationships
sourceUrls_OTM
bugzillaBugs_OTM
properties
logDetails
revisions

Get a Content Spec:

pressgang.getSpec('http://127.0.0.1:8080', 7069, function (err, spec) {
    if (err) return console.log(err);
    console.log('Got Spec ID %s at revision %s', spec.id, spec.revision);
    console.log('The spec contents: %s', spec.content);
    console.log('The spec metadata: %s', JSON.stringify(spec.metadata));
});

Basic Usage v.0.0.13 and below

First, require pressgang-rest:

var PressGangCCMS = require('pressgang-rest').PressGangCCMS;

Next, create a new PressGangCCMS object:

var pressgang = new PressGangCCMS('http://127.0.0.1:8080/TopicIndex');

Now, you can get the XML of a topic:

pressgang.getTopicData('xml', 8445, 
	function(err, result){
		console.log('The topic xml content is:' + result);
	});

To get the JSON representation of a topic:

pressgang.getTopicData('json', 8445, 
	function(err, result){
		console.log('The JSON representation of the topic is:' 
		+ JSON.stringify(result);
	});

To get a specific revision of a topic:

pressgang.getTopicData('json', 8445, 10405, 
    function(err, result){
		console.log('The XML of revision 10405 is:' 
		+ result.xml;
	});

isContentSpec will return true if an ID is a Content Specification:

pressgang.isContentSpec(456, 
	function(err, is){
		if (is) console.log('Topic 456 is a Content Specification')
	});    

getContentSpec returns a Content Spec object, which has the plain text content of the Content Spec, and a metadata record.

pressgang.getContentSpec(456, 
    function(err, result){
		console.log(result.spec); // Plain-text of the spec
        console.log(result.metadata); // All the spec metadata in an object
	});    

You can change the logging level of the PressGangCCMS Object to get details for debugging. The loglevel defaults to 0. Higher levels produce more trace output on the console:

pressgang.loglevel = 2;

You can also do quick and dirty topic operations, like this:

getTopic returns a JSON representation of a topic.

PressGangCCMS.getTopic('http://localhost:8080', 3445, function(topic) { console.log(topic); });

getTopic takes an optional revision parameter between the topic ID and the callback. Here 3445 is the topic id, and 23433 is the revision:

PressGangCCMS.getTopic('http://localhost:8080', 3445, 23433, function(topic) { console.log(topic); });

##Source Code The source is hosted on github at https://github.com/jwulf/node-pressgang-rest.

Up to 0.0.13 it was written using Microsoft TypeScript, and compiled to JavaScript using the node typescript module. There is a TypeScript declaration file in the module.

From 0.1.0 I made it straight-forward JavaScript. Tests have not been updated yet.

Keywords

FAQs

Package last updated on 16 Sep 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc