Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enketo-transformer

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enketo-transformer - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

CHANGELOG.md

7

package.json
{
"name": "enketo-transformer",
"version": "1.1.1",
"version": "1.2.0",
"description": "Library that transforms ODK-compliant XForms in a format that enketo-core consumes",

@@ -32,3 +32,3 @@ "main": "src/transformer.js",

"express": "4.12.x",
"libxslt": "0.4.x",
"libxslt": "0.4.1",
"q": "2.0.x",

@@ -39,4 +39,5 @@ "request": "2.58.x"

"chai": "3.0.x",
"chai-as-promised": "5.1.x"
"chai-as-promised": "5.1.x",
"language-tags": "1.0.x"
}
}

@@ -55,1 +55,6 @@ Enketo Transformer [![Build Status](https://travis-ci.org/enketo/enketo-transformer.svg?branch=master)](https://travis-ci.org/enketo/enketo-transformer) [![Dependency Status](https://david-dm.org/enketo/enketo-transformer.svg)](https://david-dm.org/enketo/enketo-transformer)

A vagrant configuration file and provisioning script is included.
## Change Log
See [change log](./CHANGELOG.md)

@@ -5,5 +5,7 @@ "use strict";

var fs = require( 'fs' );
var pkg = require( '../package' );
var crypto = require( 'crypto' );
var libxslt = require( 'libxslt' );
var libxmljs = libxslt.libxmljs;
var language = require( './language' );
var sheets = require( 'enketo-xslt' );

@@ -38,2 +40,3 @@ var debug = require( 'debug' )( 'transformer' );

htmlDoc = _replaceMediaSources( htmlDoc, survey.manifest );
htmlDoc = _replaceLanguageTags( htmlDoc );
// TODO: does this result in self-closing tags?

@@ -165,2 +168,45 @@ survey.form = htmlDoc.root().get( '*' ).toString( false );

/**
* Replaces all lang attributes to the valid IANA tag if found.
* Also add the dir attribute to the languages in the language selector.
*
* @see http://www.w3.org/International/questions/qa-choosing-language-tags
*
* @param {[type]} doc libxmljs object
* @return {[type]} libxmljs object
*/
function _replaceLanguageTags( doc ) {
var languageElements;
var languages;
languageElements = doc.find( '/root/form/select[@id="form-languages"]/option' );
// list of parsed language objects
languages = languageElements.map( function( el ) {
return language.parse( el.text() );
} );
// add or correct dir and value attributes, and amend textcontent of options in language selector
languageElements.forEach( function( el, index ) {
el.attr( {
dir: languages[ index ].dir,
value: languages[ index ].tag
} ).text( languages[ index ].desc );
} );
// correct lang attributes
languages.forEach( function( lang ) {
if ( lang.src === lang.tag ) {
return;
}
doc.find( '/root/form//*[@lang="' + lang.src + '"]' ).forEach( function( el ) {
el.attr( {
lang: lang.tag
} );
} );
} );
return doc;
}
/**
* Converts a url to a local (Enketo Express) url.

@@ -180,6 +226,6 @@ * If required we could make the url prefix dynamic by exporting a function that takes a prefix parameter.

* gets a hash of the 2 XSL stylesheets
* @return {string} hash representing version of XSL stylesheets - NOT A PROMISE
* @return {string} hash representing version of XSL stylesheets
*/
function _getVersion() {
return _md5( sheets.xslForm + sheets.xslModel );
return _md5( sheets.xslForm + sheets.xslModel + pkg.version );
}

@@ -186,0 +232,0 @@

/* global describe, require, it*/
"use strict";
var Q = require( 'q' ),
chai = require( "chai" ),
chaiAsPromised = require( "chai-as-promised" ),
expect = chai.expect,
fs = require( "fs" ),
transformer = require( "../src/transformer" );
var Promise = require( 'q' ).Promise;
var chai = require( "chai" );
var chaiAsPromised = require( "chai-as-promised" );
var expect = chai.expect;
var fs = require( "fs" );
var transformer = require( "../src/transformer" );

@@ -22,3 +22,3 @@ chai.use( chaiAsPromised );

it( 'without an error', function() {
return Q.all( [
return Promise.all( [
expect( result ).to.eventually.to.be.an( 'object' ),

@@ -78,3 +78,3 @@ expect( result ).to.eventually.have.property( 'form' ).and.to.not.be.empty,

return Q.all( [
return Promise.all( [
expect( result1 ).to.eventually.have.property( 'form' ).and.to.contain( 'theme-one' ),

@@ -94,3 +94,3 @@ expect( result2 ).to.eventually.have.property( 'form' ).and.to.contain( 'theme-one' ),

return Q.all( [
return Promise.all( [
expect( result ).to.eventually.have.property( 'form' ).and.to.not.contain( 'theme-one' ),

@@ -103,3 +103,2 @@ expect( result ).to.eventually.have.property( 'form' ).and.to.contain( 'theme-mytheme' )

} );
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