telligent-parser

2.2.0 • Public • Published

Telligent Converter JS (telligent-converter-js)

Build Status Codacy Badge Codacy Badge

Description

Telligent Community has an in-browser editor for it's widgets and themes but this editor is slow and lacks powerful features that your favorite IDE offers. You can export/import these widgets and themes, but everything is exported combined into a single XML file. With all widget/theme files encoded in base64. This requires a lot of manual labour to make widgets/themes editable. It is also a pain for version control.

This JavaScript project will let you decode and encode* these widget/theme files so you wind up with an easily managable and editable project structure.

* encoding has not yet been implemented

Usage

Decoding Theme(s)

To decode widgets, place the the XML file containing the theme(s) in the root folder and name it themes.xml. Then use the following code for your app.js.

import { readdir } from 'fs';
import config from '../config.json';
import { widgetDecoder, themeDecoder, helpers } from './decoder/index';

// Decode Themes XML file
const themesFile = '../themes.xml';
const themesXml = helpers.openXmlFile(themesFile, config);
const themesJson = helpers.convertXmlToJson(themesXml);
themeDecoder(themesJson, config);

Run with npm start.

Decoding Widgets

To decode widgets, place the widgets in the input folder and use the following code for your app.js.

import { readdir } from 'fs';
import config from '../config.json';
import { widgetDecoder, themeDecoder, helpers } from './decoder/index';

// Decode each widget
const { inputFolder } = config;
readdir(inputFolder, (err, files) => {
  if (err) throw err;
  files.forEach((file) => {
    const widgetXml = helpers.openXmlFile(file, config);
    const widgetJson = helpers.convertXmlToJson(widgetXml);
    widgetDecoder(widgetJson.scriptedContentFragments.scriptedContentFragment, config);
  });
});

Encoding

Not yet supported.

TODO

  • Remove DRY code
  • Add Encoding
  • Turn into package

Readme

Keywords

none

Package Sidebar

Install

npm i telligent-parser

Weekly Downloads

0

Version

2.2.0

License

ISC

Unpacked Size

284 kB

Total Files

47

Last publish

Collaborators

  • jasperrr91