Add gitattributes and run initial normalization

This commit is contained in:
0xboobface 2019-12-17 21:13:18 +01:00
parent 034fe81081
commit e734d46e9c
7 changed files with 224 additions and 216 deletions

10
.gitattributes vendored Normal file
View File

@ -0,0 +1,10 @@
# Auto detect text files and perform LF normalization
* text=auto
#
# The above will handle all files NOT found below
#
# These files are text and should be normalized (Convert crlf => lf)
*.bat text eol=crlf
*.java text diff=java
*.sh text eol=lf

View File

@ -1,2 +0,0 @@
# Auto detect text files and perform LF normalization
* text=auto

View File

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink">
<xs:attribute name="type" type="xs:token" fixed="simple"/>
<xs:attribute name="href" type="xlink:hrefType"/>
<xs:simpleType name="hrefType">
<xs:restriction base="xs:anyURI"/>
</xs:simpleType>
<xs:attribute name="show" type="xs:token" fixed="embed"/>
<xs:attribute name="actuate" type="xlink:actuateType" default="onRequest"/>
<xs:simpleType name="actuateType">
<xs:restriction base="xs:token">
<xs:enumeration value="onLoad"/>
<xs:enumeration value="onRequest"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink">
<xs:attribute name="type" type="xs:token" fixed="simple"/>
<xs:attribute name="href" type="xlink:hrefType"/>
<xs:simpleType name="hrefType">
<xs:restriction base="xs:anyURI"/>
</xs:simpleType>
<xs:attribute name="show" type="xs:token" fixed="embed"/>
<xs:attribute name="actuate" type="xlink:actuateType" default="onRequest"/>
<xs:simpleType name="actuateType">
<xs:restriction base="xs:token">
<xs:enumeration value="onLoad"/>
<xs:enumeration value="onRequest"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -1,33 +1,33 @@
FROM alpine/git as open-m3u8Git
WORKDIR /app
RUN git clone https://github.com/0xboobface/open-m3u8.git
FROM gradle:4.10-jdk10 as open-m3u8Build
WORKDIR /app/open-m3u8
COPY --from=open-m3u8Git --chown=gradle:gradle /app /app
RUN gradle install
FROM alpine/git as ctbrecGit
WORKDIR /app
RUN git clone https://github.com/0xboobface/ctbrec.git
FROM maven:3-jdk-11-slim as ctbrecBuild
ARG ctbrec
ARG versionM3u8
WORKDIR /app/master
COPY --from=ctbrecGit /app/ctbrec /app
COPY --from=open-m3u8Build /app/open-m3u8/build/libs/ /app/common/libs/
RUN mvn clean install:install-file -Dfile=/app/common/libs/open-m3u8-${versionM3u8}.jar -DgroupId=com.iheartradio.m3u8 -DartifactId=open-m3u8 -Dversion=${versionM3u8} -Dpackaging=jar -DgeneratePom=true
RUN mvn clean
RUN mvn install
FROM openjdk:12-alpine
WORKDIR /app
ARG memory
ARG version
ENV artifact ctbrec-server-${version}-final.jar
ENV path /app/server/target/${artifact}
COPY --from=ctbrecBuild ${path} ./${artifact}
EXPOSE 8080
CMD java ${memory} -cp ${artifact} -Dctbrec.config=/server.json ctbrec.recorder.server.HttpServer
FROM alpine/git as open-m3u8Git
WORKDIR /app
RUN git clone https://github.com/0xboobface/open-m3u8.git
FROM gradle:4.10-jdk10 as open-m3u8Build
WORKDIR /app/open-m3u8
COPY --from=open-m3u8Git --chown=gradle:gradle /app /app
RUN gradle install
FROM alpine/git as ctbrecGit
WORKDIR /app
RUN git clone https://github.com/0xboobface/ctbrec.git
FROM maven:3-jdk-11-slim as ctbrecBuild
ARG ctbrec
ARG versionM3u8
WORKDIR /app/master
COPY --from=ctbrecGit /app/ctbrec /app
COPY --from=open-m3u8Build /app/open-m3u8/build/libs/ /app/common/libs/
RUN mvn clean install:install-file -Dfile=/app/common/libs/open-m3u8-${versionM3u8}.jar -DgroupId=com.iheartradio.m3u8 -DartifactId=open-m3u8 -Dversion=${versionM3u8} -Dpackaging=jar -DgeneratePom=true
RUN mvn clean
RUN mvn install
FROM openjdk:12-alpine
WORKDIR /app
ARG memory
ARG version
ENV artifact ctbrec-server-${version}-final.jar
ENV path /app/server/target/${artifact}
COPY --from=ctbrecBuild ${path} ./${artifact}
EXPOSE 8080
CMD java ${memory} -cp ${artifact} -Dctbrec.config=/server.json ctbrec.recorder.server.HttpServer

View File

@ -1,9 +1,9 @@
version: 3
services:
ctbrec:
ports:
- '8080:8080'
volumes:
- 'ctbrec/config:/root/.config/ctbrec/'
- 'ctbrec/video:/root/ctbrec'
version: 3
services:
ctbrec:
ports:
- '8080:8080'
volumes:
- 'ctbrec/config:/root/.config/ctbrec/'
- 'ctbrec/video:/root/ctbrec'
image: bounty1342/ctbrec

View File

@ -1,45 +1,45 @@
Knockout orderable binding
==================
This knockout binding allows to create sortable tables. It works by sorting items in observableArray, so tables rendered by "foreach" binding are automatically refreshed by knockout.
##Design Goals
###Focused only on ordering
Some other plugins take control of entire table rendering, making it complicated to build arbitrary tables. This plugin is only focused on sorting of observableArrays, leaving rendering of HTML to knockout. It gives freedom of using custom item templates for tables or lists.
###Controllable from a view model
When binding applied for the first time it adds extra observables to a view model. So order can be changed programmatically like
viewModel.people.orderDirection("desc")
or
viewModel.people.orderDirection("lastName")
###Minimal view model setup
There is nothing to be configured on a view model manually to use the plugin. Only bindings have to be set on elements which will trigger observableArray to be reordered.
###Can be used with multiple observableArrays
Works well with multiple observableArray. oservableArrays can be ordered independently of each other.
##Usage
To make table header sortable set binding like this:
<th><a href="#" data-bind="orderable: {collection: 'people', field: 'firstName'}">First Name</a></th>
Default field to sort can also be provided:
<th><a href="#" data-bind="orderable: {collection: 'people', field: 'age', defaultField: true, defaultDirection: 'desc'}">Age</a></th>
It's also possible to sort by nested attibutes by separating the attribute names with a dot (should work with array indices too):
<th><a href="#" data-bind="orderable: {collection: 'people', field: 'pet.name'}">Pet name</a></th>
See full examples in examples folder.
##Dependencies
- [jQuery](http://jquery.com/)
- [Knockout](http://knockoutjs.com/)
##License
MIT license - [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)
Knockout orderable binding
==================
This knockout binding allows to create sortable tables. It works by sorting items in observableArray, so tables rendered by "foreach" binding are automatically refreshed by knockout.
##Design Goals
###Focused only on ordering
Some other plugins take control of entire table rendering, making it complicated to build arbitrary tables. This plugin is only focused on sorting of observableArrays, leaving rendering of HTML to knockout. It gives freedom of using custom item templates for tables or lists.
###Controllable from a view model
When binding applied for the first time it adds extra observables to a view model. So order can be changed programmatically like
viewModel.people.orderDirection("desc")
or
viewModel.people.orderDirection("lastName")
###Minimal view model setup
There is nothing to be configured on a view model manually to use the plugin. Only bindings have to be set on elements which will trigger observableArray to be reordered.
###Can be used with multiple observableArrays
Works well with multiple observableArray. oservableArrays can be ordered independently of each other.
##Usage
To make table header sortable set binding like this:
<th><a href="#" data-bind="orderable: {collection: 'people', field: 'firstName'}">First Name</a></th>
Default field to sort can also be provided:
<th><a href="#" data-bind="orderable: {collection: 'people', field: 'age', defaultField: true, defaultDirection: 'desc'}">Age</a></th>
It's also possible to sort by nested attibutes by separating the attribute names with a dot (should work with array indices too):
<th><a href="#" data-bind="orderable: {collection: 'people', field: 'pet.name'}">Pet name</a></th>
See full examples in examples folder.
##Dependencies
- [jQuery](http://jquery.com/)
- [Knockout](http://knockoutjs.com/)
##License
MIT license - [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)

View File

@ -1,112 +1,112 @@
ko.bindingHandlers.orderable = {
getProperty: function(o, s) {
// copied from http://stackoverflow.com/questions/6491463/accessing-nested-javascript-objects-with-string-key
s = s.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
s = s.replace(/^\./, ''); // strip a leading dot
var a = s.split('.');
while (a.length) {
var n = a.shift();
if (n in o) {
o = o[n];
} else {
return;
}
}
return o;
},
compare: function (left, right) {
if (typeof left === 'string' || typeof right === 'string') {
return left ? left.localeCompare(right) : 1;
}
if (left > right)
return 1;
return left < right ? -1 : 0;
},
sort: function (viewModel, collection, field) {
//make sure we sort only once and not for every binding set on table header
if (viewModel[collection].orderField() == field) {
viewModel[collection].sort(function (left, right) {
var left_field = ko.bindingHandlers.orderable.getProperty(left, field);
var right_field = ko.bindingHandlers.orderable.getProperty(right, field);
var left_val = (typeof left_field === 'function') ? left_field() : left_field;
right_val = (typeof right_field === 'function') ? right_field() : right_field;
if (viewModel[collection].orderDirection() == "desc") {
return ko.bindingHandlers.orderable.compare(right_val, left_val);
} else {
return ko.bindingHandlers.orderable.compare(left_val, right_val);
}
});
}
},
init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
//get provided options
var collection = valueAccessor().collection;
var field = valueAccessor().field;
//add a few observables to ViewModel to track order field and direction
if (viewModel[collection].orderField == undefined) {
viewModel[collection].orderField = ko.observable();
}
if (viewModel[collection].orderDirection == undefined) {
viewModel[collection].orderDirection = ko.observable("asc");
}
var defaultField = valueAccessor().defaultField;
var defaultDirection = valueAccessor().defaultDirection || "asc";
if (defaultField) {
viewModel[collection].orderField(field);
viewModel[collection].orderDirection(defaultDirection);
ko.bindingHandlers.orderable.sort(viewModel, collection, field);
}
//set order observables on table header click
$(element).click(function (e) {
e.preventDefault();
//flip sort direction if current sort field is clicked again
if (viewModel[collection].orderField() == field) {
if (viewModel[collection].orderDirection() == "asc") {
viewModel[collection].orderDirection("desc");
} else {
viewModel[collection].orderDirection("asc");
}
}
viewModel[collection].orderField(field);
});
//order records when observables changes, so ordering can be changed programmatically
viewModel[collection].orderField.subscribe(function () {
ko.bindingHandlers.orderable.sort(viewModel, collection, field);
});
viewModel[collection].orderDirection.subscribe(function () {
ko.bindingHandlers.orderable.sort(viewModel, collection, field);
});
},
update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
//get provided options
var collection = valueAccessor().collection;
var field = valueAccessor().field;
var isOrderedByThisField = viewModel[collection].orderField() == field;
//apply css binding programmatically
ko.bindingHandlers.css.update(
element,
function () {
return {
sorted: isOrderedByThisField,
asc: isOrderedByThisField && viewModel[collection].orderDirection() == "asc",
desc: isOrderedByThisField && viewModel[collection].orderDirection() == "desc"
};
},
allBindingsAccessor,
viewModel,
bindingContext
);
}
};
ko.bindingHandlers.orderable = {
getProperty: function(o, s) {
// copied from http://stackoverflow.com/questions/6491463/accessing-nested-javascript-objects-with-string-key
s = s.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
s = s.replace(/^\./, ''); // strip a leading dot
var a = s.split('.');
while (a.length) {
var n = a.shift();
if (n in o) {
o = o[n];
} else {
return;
}
}
return o;
},
compare: function (left, right) {
if (typeof left === 'string' || typeof right === 'string') {
return left ? left.localeCompare(right) : 1;
}
if (left > right)
return 1;
return left < right ? -1 : 0;
},
sort: function (viewModel, collection, field) {
//make sure we sort only once and not for every binding set on table header
if (viewModel[collection].orderField() == field) {
viewModel[collection].sort(function (left, right) {
var left_field = ko.bindingHandlers.orderable.getProperty(left, field);
var right_field = ko.bindingHandlers.orderable.getProperty(right, field);
var left_val = (typeof left_field === 'function') ? left_field() : left_field;
right_val = (typeof right_field === 'function') ? right_field() : right_field;
if (viewModel[collection].orderDirection() == "desc") {
return ko.bindingHandlers.orderable.compare(right_val, left_val);
} else {
return ko.bindingHandlers.orderable.compare(left_val, right_val);
}
});
}
},
init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
//get provided options
var collection = valueAccessor().collection;
var field = valueAccessor().field;
//add a few observables to ViewModel to track order field and direction
if (viewModel[collection].orderField == undefined) {
viewModel[collection].orderField = ko.observable();
}
if (viewModel[collection].orderDirection == undefined) {
viewModel[collection].orderDirection = ko.observable("asc");
}
var defaultField = valueAccessor().defaultField;
var defaultDirection = valueAccessor().defaultDirection || "asc";
if (defaultField) {
viewModel[collection].orderField(field);
viewModel[collection].orderDirection(defaultDirection);
ko.bindingHandlers.orderable.sort(viewModel, collection, field);
}
//set order observables on table header click
$(element).click(function (e) {
e.preventDefault();
//flip sort direction if current sort field is clicked again
if (viewModel[collection].orderField() == field) {
if (viewModel[collection].orderDirection() == "asc") {
viewModel[collection].orderDirection("desc");
} else {
viewModel[collection].orderDirection("asc");
}
}
viewModel[collection].orderField(field);
});
//order records when observables changes, so ordering can be changed programmatically
viewModel[collection].orderField.subscribe(function () {
ko.bindingHandlers.orderable.sort(viewModel, collection, field);
});
viewModel[collection].orderDirection.subscribe(function () {
ko.bindingHandlers.orderable.sort(viewModel, collection, field);
});
},
update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
//get provided options
var collection = valueAccessor().collection;
var field = valueAccessor().field;
var isOrderedByThisField = viewModel[collection].orderField() == field;
//apply css binding programmatically
ko.bindingHandlers.css.update(
element,
function () {
return {
sorted: isOrderedByThisField,
asc: isOrderedByThisField && viewModel[collection].orderDirection() == "asc",
desc: isOrderedByThisField && viewModel[collection].orderDirection() == "desc"
};
},
allBindingsAccessor,
viewModel,
bindingContext
);
}
};