initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

9
node_modules/xmldoc/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,9 @@
# Ignore dependencies
node_modules
# IntelliJ
.idea
*.iml
# NPM Cruft
npm-debug.log

23
node_modules/xmldoc/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,23 @@
Copyright 2012 Nick Farina.
All rights reserved.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

138
node_modules/xmldoc/README.md generated vendored Normal file
View File

@@ -0,0 +1,138 @@
## Introduction
`xmldoc` lets you parse XML documents with ease. It's a pure-JavaScript, one-file XML document class with a single dependency on the excellent [`sax`][sax] parser.
For more on why I wrote this class, see the [blog post][blog].
[blog]: http://nfarina.com/post/34302964969/a-lightweight-xml-document-class-for-nodejs-javascript
## Installation
npm install xmldoc
Or just download the repository and include it in your `node_modules` directly. Or just download the [single JS file][blob]!
[blob]: https://github.com/nfarina/xmldoc/blob/master/lib/xmldoc.js
## Usage
```js
var xmldoc = require('../lib/xmldoc');
var document = new xmldoc.XmlDocument("<some>xml</some>");
// do things
```
## Classes
The primary exported class is `XmlDocument`, which you'll use to consume your XML text. `XmlDocument` contains a hierarchy of `XmlElement` instances representing the XML structure.
Both `XmlElement` and `XmlDocument` contain the same members and methods you can call to traverse the document or a subtree.
## Members
* `name` - the node name, like "tat" for `<tat>`. XML "namespaces" are ignored by the underlying [sax-js](https://github.com/isaacs/sax-js) parser, so you'll simply get "office:body" for `<office:body>`.
* `attr` - an object dict containing attribute properties, like `bookNode.attr.title` for `<book title="...">`.
* `val` - the string "value" of the node, if any, like "world" for `<hello>world</hello>`.
* `children` - an array of `XmlElement` children of the node.
* `firstChild`, `lastChild` - pretty much what it sounds like; null if no children
* `line`, `column`, `position`, `startTagPosition` - information about the element's original position in the XML string.
Each member defaults to a sensible "empty" value like `{}` for `attr`, `[]` for `children`, and `""` for `val`.
## Methods
All methods with `child` in the name operate only on direct children; they do not do a deep/recursive search.
It's important to note that `xmldoc` is designed for when you know exactly what you want from your XML file. For instance, it's great for parsing API responses with known structures, but it's not great at teasing things out of HTML documents from the web.
If you need to do lots of searching through your XML document, I highly recommend trying a different library like [node-elementtree](https://github.com/racker/node-elementtree).
### eachChild(func)
Similar to [underscore's][underscore] `each` method, it will call `func(child, index, array)` for each child of the given node.
### childNamed(name)
Pass it the name of a child node and it will search for and return the first one found, or `undefined`.
### childrenNamed(name)
Like `childNamed` but returns all matching children in an array, or `[]`.
### childWithAttribute(name,value)
Searches for the first child with the given attribute value. You can omit `value` to just find the first node with the given attribute defined at all.
### descendantWithPath(path)
Searches for a specific "path" using dot notation. Example:
```xml
<book>
<author>
<name isProper="true">George R. R. Martin</name>
...
</author>
...
</book>
```
If you just want the `<name>` node and you have the `XmlElement` for the `<book>` node, you can say:
```js
var nameNode = bookNode.descendantWithPath("author.name"); // return <name> node
```
### valueWithPath(path)
Just like `descendantWithPath`, but goes deeper and extracts the `val` of the node. Example:
```js
var authorName = bookNode.valueWithPath("author.name"); // return "George R. R. Martin"
```
You can also use the `@` character to request the value of a particular _attribute_ instead:
```js
var authorIsProper = bookNode.valueWithPath("author.name@isProper"); // return "true"
```
This is not [XPath][]! It's just a thing I made up, OK?
### toString([options])
This is just an override of the standard JavaScript method, it will give you a string representation of your XML document or element. Note that this is for debugging only! It is not guaranteed to always output valid XML.
The default implementation of `toString()`, that is, the one you get when you just `console.log("Doc: " + myDoc)` will pretty-print the XML with linebreaks and indents. You can pass a couple options to control the output:
```js
xml.toString({compressed:true}) // strips indents and linebreaks
xml.toString({trimmed:true}) // trims long strings for easier debugging
xml.toString({preserveWhitespace:true}) // prevents whitespace being removed from around element values
```
Putting it all together:
```js
var xml = "<author><name>looooooong value</name></author>";
console.log("My document: \n" + new XmlDocument(xml).toString({trimmed:true}))
```
Prints:
My Document:
<hello>
loooooooo…
</hello>
## Feedback
Feel free to file issues or hit me up on [Twitter][twitter].
[underscore]: http://underscorejs.org
[XPath]: http://en.wikipedia.org/wiki/XPath
[twitter]: http://twitter.com/nfarina
[sax]: https://github.com/isaacs/sax-js

60
node_modules/xmldoc/examples/example.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
// Designed to be run from Node.js - i.e. "node example.js"
var XmlDocument = require('../lib/xmldoc').XmlDocument;
// Demonstrate parsing an in-memory XML string
var xmlString = '<suggestions><book title="Twilight"/><book title="Twister"/></suggestions>';
var suggestions = new XmlDocument(xmlString);
// Demonstrate how toString() will pretty-print the XML for debugging
console.log("Parsed: \n%s", suggestions);
// Demonstrate a simple eachChild() loop, printing our book titles
suggestions.eachChild(function(book) {
console.log("Found book with title: '%s'", book.attr.title);
console.log("==> The <book> tag started at position %s and the complete element ended at line %s, column %s, position %s.", book.startTagPosition, book.line, book.column, book.position);
});
// Now load an XML file from disk and parse it
var fs = require('fs'),
path = require('path');
fs.readFile(path.join(__dirname, "test.xml"), 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
// Parse the XML
var results = new XmlDocument(data);
// Demonstrate toString() with an option to abbreviate long strings and compress the output
console.log("Parsed: \n%s", results.toString({trimmed:true, compressed:true}));
// Pull out the <books> node
var books = results.childNamed("books");
// Demonstrate firstChild/lastChild
console.log("First book has ISBN '%s', last book has ISBN '%s'", books.firstChild.attr.isbn, books.lastChild.attr.isbn);
// Print out the ISBNs
books.eachChild(function (book) {
console.log("Found book with ISBN '%s'", book.attr.isbn);
});
// Look for all children with a certain node name
var allBooks = books.childrenNamed("book");
// The result is an array of <book> XmlElement instances
console.log("Found %s books.", allBooks.length);
// Search for a particular book
var twilight = books.childWithAttribute("isbn","478-2-23-765712-2");
// Result is a single XmlElement instance for <book>
console.log("Title of book with given ISBN: '%s'", twilight.valueWithPath("title"));
return null;
});

25
node_modules/xmldoc/examples/test.html generated vendored Normal file
View File

@@ -0,0 +1,25 @@
<!doctype html>
<html lang="en">
<head>
<title>xmldoc browser test</title>
<script type="text/javascript" src="../node_modules/sax/lib/sax.js"></script>
<script type="text/javascript" src="../lib/xmldoc.js"></script>
<script type="text/javascript">
// Demonstrate parsing an in-memory XML string
var xmlString = '<suggestions><book title="Twilight"/><book title="Twister"/></suggestions>'
var suggestions = new XmlDocument(xmlString);
// Demonstrate how toString() will pretty-print an abbreviated version of the XML for debugging
console.log("Parsed: \n" + suggestions);
// Demonstrate a simple eachChild() loop, printing our book titles
suggestions.eachChild(function(book) {
document.write("<p>Found book with title: '" + book.attr.title + "'</p>");
});
</script>
</head>
<body>
</body>
</html>

20
node_modules/xmldoc/examples/test.xml generated vendored Normal file
View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<results totalResults="74">
<books>
<book isbn="978-3-16-148410-0">
<title>Harry Potter and the Half-Blood Prince</title>
<price>29.95</price>
<authors>
<author>J.K. Rowling</author>
</authors>
</book>
<book isbn="478-2-23-765712-2">
<title>Twilight</title>
<price>19.95</price>
<authors>
<author>Stephenie Meyer</author>
<author>The Hand of God</author>
</authors>
</book>
</books>
</results>

3
node_modules/xmldoc/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
// This file is just added for convenience so this repository can be
// directly checked out into a project's deps folder
module.exports = require('./lib/xmldoc');

257
node_modules/xmldoc/lib/xmldoc.js generated vendored Normal file
View File

@@ -0,0 +1,257 @@
(function () {
var sax;
if (typeof module !== 'undefined' && module.exports) {
// We're being used in a Node-like environment
sax = require('sax');
}
else {
// assume it's attached to the Window object in a browser
sax = this.sax;
if (!sax) // no sax for you!
throw new Error("Expected sax to be defined. Make sure you're including sax.js before this file.");
}
/*
XmlElement is our basic building block. Everything is an XmlElement; even XmlDocument
behaves like an XmlElement by inheriting its attributes and functions.
*/
function XmlElement(tag) {
// Capture the parser object off of the XmlDocument delegate
var parser = delegates[delegates.length - 1].parser;
this.name = tag.name;
this.attr = tag.attributes || {};
this.val = "";
this.isValCdata = false;
this.children = [];
this.firstChild = null;
this.lastChild = null;
// Assign parse information
this.line = parser.line;
this.column = parser.column;
this.position = parser.position;
this.startTagPosition = parser.startTagPosition;
}
// SaxParser handlers
XmlElement.prototype._opentag = function(tag) {
var child = new XmlElement(tag);
// add to our children array
this.children.push(child);
// update first/last pointers
if (!this.firstChild) this.firstChild = child;
this.lastChild = child;
delegates.unshift(child);
};
XmlElement.prototype._closetag = function() {
delegates.shift();
};
XmlElement.prototype._text = function(text) {
if (text) this.val += text;
};
XmlElement.prototype._cdata = function(cdata) {
if (cdata) {
this.val += cdata;
this.isValCdata=true;
}
};
XmlElement.prototype._error = function(err) {
throw err;
};
// Useful functions
XmlElement.prototype.eachChild = function(iterator, context) {
for (var i=0, l=this.children.length; i<l; i++)
if (iterator.call(context, this.children[i], i, this.children) === false) return;
};
XmlElement.prototype.childNamed = function(name) {
for (var i=0, l=this.children.length; i<l; i++) {
var child = this.children[i];
if (child.name === name) return child;
}
return undefined;
};
XmlElement.prototype.childrenNamed = function(name) {
var matches = [];
for (var i=0, l=this.children.length; i<l; i++)
if (this.children[i].name === name)
matches.push(this.children[i]);
return matches;
};
XmlElement.prototype.childWithAttribute = function(name,value) {
for (var i=0, l=this.children.length; i<l; i++) {
var child = this.children[i];
if ( (value && child.attr[name] === value) || (!value && child.attr[name]) )
return child;
}
return undefined;
};
XmlElement.prototype.descendantWithPath = function(path) {
var descendant = this;
var components = path.split('.');
for (var i=0, l=components.length; i<l; i++)
if (descendant)
descendant = descendant.childNamed(components[i]);
else
return undefined;
return descendant;
};
XmlElement.prototype.valueWithPath = function(path) {
var components = path.split('@');
var descendant = this.descendantWithPath(components[0]);
if (descendant)
return components.length > 1 ? descendant.attr[components[1]] : descendant.val;
else
return undefined;
};
// String formatting (for debugging)
XmlElement.prototype.toString = function(options) {
return this.toStringWithIndent("", options);
};
XmlElement.prototype.toStringWithIndent = function(indent, options) {
var s = indent + "<" + this.name;
var linebreak = options && options.compressed ? "" : "\n";
var preserveWhitespace = options && options.preserveWhitespace;
for (var name in this.attr)
if (Object.prototype.hasOwnProperty.call(this.attr, name))
s += " " + name + '="' + escapeXML(this.attr[name]) + '"';
var finalVal = '';
if (this.isValCdata){
finalVal = '<![CDATA['+this.val+']]>';
} else if (preserveWhitespace) {
finalVal = escapeXML(this.val);
} else{
finalVal = escapeXML(this.val.trim());
}
if (options && options.trimmed && finalVal.length > 25)
finalVal = finalVal.substring(0,25).trim() + "…";
if (this.children.length) {
s += ">" + linebreak;
var childIndent = indent + (options && options.compressed ? "" : " ");
if (finalVal.length)
s += childIndent + finalVal + linebreak;
for (var i=0, l=this.children.length; i<l; i++)
s += this.children[i].toStringWithIndent(childIndent, options) + linebreak;
s += indent + "</" + this.name + ">";
}
else if (finalVal.length) {
s += ">" + finalVal + "</" + this.name +">";
}
else s += "/>";
return s;
};
/*
XmlDocument is the class we expose to the user; it uses the sax parser to create a hierarchy
of XmlElements.
*/
function XmlDocument(xml) {
xml && (xml = xml.toString().trim());
if (!xml)
throw new Error("No XML to parse!");
// Expose the parser to the other delegates while the parser is running
this.parser = sax.parser(true); // strict
addParserEvents(this.parser);
// We'll use the file-scoped "delegates" var to remember what elements we're currently
// parsing; they will push and pop off the stack as we get deeper into the XML hierarchy.
// It's safe to use a global because JS is single-threaded.
delegates = [this];
this.parser.write(xml);
// Remove the parser as it is no longer needed and should not be exposed to clients
delete this.parser;
}
// make XmlDocument inherit XmlElement's methods
extend(XmlDocument.prototype, XmlElement.prototype);
XmlDocument.prototype._opentag = function(tag) {
if (typeof this.children === 'undefined')
// the first tag we encounter should be the root - we'll "become" the root XmlElement
XmlElement.call(this,tag);
else
// all other tags will be the root element's children
XmlElement.prototype._opentag.apply(this,arguments);
};
// file-scoped global stack of delegates
var delegates = null;
/*
Helper functions
*/
function addParserEvents(parser) {
parser.onopentag = parser_opentag;
parser.onclosetag = parser_closetag;
parser.ontext = parser_text;
parser.oncdata = parser_cdata;
parser.onerror = parser_error;
}
// create these closures and cache them by keeping them file-scoped
function parser_opentag() { delegates[0]._opentag.apply(delegates[0],arguments) }
function parser_closetag() { delegates[0]._closetag.apply(delegates[0],arguments) }
function parser_text() { delegates[0]._text.apply(delegates[0],arguments) }
function parser_cdata() { delegates[0]._cdata.apply(delegates[0],arguments) }
function parser_error() { delegates[0]._error.apply(delegates[0],arguments) }
// a relatively standard extend method
function extend(destination, source) {
for (var prop in source)
if (source.hasOwnProperty(prop))
destination[prop] = source[prop];
}
// escapes XML entities like "<", "&", etc.
function escapeXML(value){
return value.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/&/g, '&amp;').replace(/'/g, '&apos;').replace(/"/g, '&quot;');
}
// Are we being used in a Node-like environment?
if (typeof module !== 'undefined' && module.exports)
module.exports.XmlDocument = XmlDocument;
else
this.XmlDocument = XmlDocument;
})();

82
node_modules/xmldoc/package.json generated vendored Normal file
View File

@@ -0,0 +1,82 @@
{
"_args": [
[
"xmldoc@^0.4.0",
"/home/bernhard/freifunk-app/node_modules/react-native"
]
],
"_from": "xmldoc@>=0.4.0 <0.5.0",
"_id": "xmldoc@0.4.0",
"_inCache": true,
"_installable": true,
"_location": "/xmldoc",
"_nodeVersion": "4.1.1",
"_npmUser": {
"email": "nfarina@gmail.com",
"name": "nfarina"
},
"_npmVersion": "2.14.4",
"_phantomChildren": {},
"_requested": {
"name": "xmldoc",
"raw": "xmldoc@^0.4.0",
"rawSpec": "^0.4.0",
"scope": null,
"spec": ">=0.4.0 <0.5.0",
"type": "range"
},
"_requiredBy": [
"/react-native"
],
"_resolved": "https://registry.npmjs.org/xmldoc/-/xmldoc-0.4.0.tgz",
"_shasum": "d257224be8393eaacbf837ef227fd8ec25b36888",
"_shrinkwrap": null,
"_spec": "xmldoc@^0.4.0",
"_where": "/home/bernhard/freifunk-app/node_modules/react-native",
"author": {
"email": "nfarina@gmail.com",
"name": "Nick Farina",
"url": "http://nfarina.com"
},
"bugs": {
"url": "https://github.com/nfarina/xmldoc/issues"
},
"contributors": [
{
"name": "Nick Farina",
"email": "nfarina@gmail.com"
}
],
"dependencies": {
"sax": "~1.1.1"
},
"description": "A lightweight XML Document class for JavaScript.",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "d257224be8393eaacbf837ef227fd8ec25b36888",
"tarball": "https://registry.npmjs.org/xmldoc/-/xmldoc-0.4.0.tgz"
},
"gitHead": "48c1b3b4414fa612e5eff005346d6787ab441b98",
"homepage": "https://github.com/nfarina/xmldoc#readme",
"license": {
"type": "MIT",
"url": "https://raw.github.com/nfarina/xmldoc-js/master/LICENSE"
},
"main": "./index",
"maintainers": [
{
"name": "nfarina",
"email": "nfarina@gmail.com"
}
],
"name": "xmldoc",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/nfarina/xmldoc.git"
},
"scripts": {},
"version": "0.4.0"
}