diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fef13ef..98bea0e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,13 +1,25 @@
-# You can override the included template(s) by including variable overrides
-# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
-# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
-# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
-# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
-# Note that environment variables can be set in several places
-# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
+image: alpine:latest
+
stages:
- test
+- deploy
+
+before_script: |
+ apk update
+ apk add python3
+
sast:
stage: test
include:
- template: Security/SAST.gitlab-ci.yml
+
+pages:
+ stage: deploy
+ script: |
+ python3 ./Build.py
+ artifacts:
+ paths:
+ - public
+ rules:
+ - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
+
diff --git a/Source/ApiTransform.js b/Source/ApiTransform.js
index 8c6853b..f028f7b 100644
--- a/Source/ApiTransform.js
+++ b/Source/ApiTransform.js
@@ -3,6 +3,11 @@ var TransSchemas = {
Account: {
"__": "Author",
"url": "Url",
+ "avatar": "Picture",
+ "header": "Banner",
+ },
+ Instance: {
+ "thumbnail": "Banner",
},
Status: {
"__": "Note",
@@ -13,14 +18,31 @@ var TransSchemas = {
},
},
};
+var TransSchemas_ = {
+ "Note": {
+ "Author": {
+ "Mastodon": "Status.account"
+ },
+ "Content": {
+ "Mastodon": "Status.content"
+ },
+ "Url": {
+ "Mastodon": "Status.url"
+ },
+ },
+};
var TransParsers = {
Mastodon: {
Account(Data) {
- return JsonTransform(Data, TransSchemas.Mastodon.Author, TransSchemas.Mastodon);
+ return JsonTransformA(Data, TransSchemas.Mastodon.Author, TransSchemas.Mastodon);
+ },
+ Instance(Data) {
+ return JsonTransformA(Data, TransSchemas.Mastodon.Instance, TransSchemas.Mastodon);
},
Status(Data) {
- return JsonTransform(Data, TransSchemas.Mastodon.Status, TransSchemas.Mastodon);
+ return JsonTransformA(Data, TransSchemas.Mastodon.Status, TransSchemas.Mastodon);
+ // return JsonTransformB({Status: Data}, TransSchemas_, TransSchemas_.Note, 'Mastodon');
},
},
};
diff --git a/Source/Friendiiverse.html b/Source/Friendiiverse.html
index 87f7209..4b46da8 100644
--- a/Source/Friendiiverse.html
+++ b/Source/Friendiiverse.html
@@ -25,6 +25,8 @@ var UseFakeApi = true;
No Script!
+
+
diff --git a/Source/Main.js b/Source/Main.js
index 53849d2..3eb4e6d 100644
--- a/Source/Main.js
+++ b/Source/Main.js
@@ -49,22 +49,22 @@ function ApiCall(Data, Proc) {
var Status = String(this.status);
if (Data.Call) {
Data.Call(this);
- }
+ };
if (HttpCodeGood(this.status)) {
+ LogDebug([this.status, this.responseText], 'l');
if (Data.CallFine) {
Data.CallFine(this);
};
- LogDebug([this.status, this.responseText], 'l');
} else {
+ LogDebug([this.status, this.responseText], 'e');
if (Data.CallFail) {
Data.CallFail(this);
};
- LogDebug([this.status, this.responseText], 'e');
};
};
if (Data.Target == 'Mastodon') {
Req.open('GET', `${MastodonUrl}/api/v1/${Data.Method}`, true);
- };
+ } else
if (Data.Target == 'Friendica') {
Req.open('GET', `${FriendicaUrl}/api/${Data.Method}.json`, true);
Req.setRequestHeader('Authorization', `Basic ${btoa(FriendicaCredentials)}`);
@@ -89,7 +89,7 @@ function DisplayFriendicaTimeline(Timeline) {
function FetchMastodon(Proc) {
ApiCall({Target: "Mastodon", Method: "timelines/public", CallFine: function(Res){
- var Notes = [ TransParsers.Mastodon.Status( JSON.parse(Res.responseText)[0] ) ];
+ var Notes = TransParsers.Mastodon.Status(JSON.parse(Res.responseText));
LogDebug(Notes, 'l');
CurrTasks[Proc[0]].Return(Notes);
}}, Proc);
@@ -97,9 +97,12 @@ function FetchMastodon(Proc) {
function FillTimeline(Notes) {
Notes.forEach(function(Note){
- TimelineView.innerHTML += `
+ TimelineView.innerHTML += `
`;
});
diff --git a/Source/Style.css b/Source/Style.css
index 8d00da5..b1fae92 100644
--- a/Source/Style.css
+++ b/Source/Style.css
@@ -20,7 +20,11 @@ footer {
white-space: break-spaces;
}
-.NoteView {
+.Note {
border: 4px solid purple;
margin: 12px;
}
+
+.Note > .Author.Picture {
+ width: 64px;
+}
diff --git a/Source/Utils.js b/Source/Utils.js
index 2cfd7da..cd7eee3 100644
--- a/Source/Utils.js
+++ b/Source/Utils.js
@@ -21,7 +21,19 @@ function LogDebug(Data, Status) {
};
// Transform JSON tree into a new using a template schema
-function JsonTransform(TreeOld, SchemaCurr, SchemaRoot) {
+// DEVNOTE: Unsafe, should check for colliding "__" keys from input tree and act accordingly
+function JsonTransformA(TreesOld, SchemaCurr, SchemaRoot) {
+ if (Array.isArray(TreesOld)) {
+ var ListNew = [];
+ ForceList(TreesOld).forEach(function(TreeOld){
+ ListNew.push(JsonTransformCycleA(TreeOld, SchemaCurr, SchemaRoot));
+ });
+ return ListNew;
+ } else {
+ return JsonTransformCycleA(TreesOld, SchemaCurr, SchemaRoot);
+ };
+};
+function JsonTransformCycleA(TreeOld, SchemaCurr, SchemaRoot) {
var TreeNew = {};
Object.keys(TreeOld).forEach(function(KeyOld){
var Content = TreeOld[KeyOld];
@@ -29,19 +41,23 @@ function JsonTransform(TreeOld, SchemaCurr, SchemaRoot) {
if (typeof(Content) == 'object' && Content !== null) {
if (Array.isArray(Content)) {
// Lists
- var ListNew = [];
+ /* var ListNew = [];
Content.forEach(function(Value){
ListNew.push(JsonTransform(Value, KeyNew));
});
- TreeNew[KeyNew] = ListNew;
+ TreeNew[KeyNew] = ListNew;*/
} else {
// Dicts
- if (!KeyNew.__) {
- KeyNew.__ = KeyOld;
+ // Strange bug, in this context we can't assign new value to child of the object, we use a variable
+ NameKeyNew = KeyNew.__;
+ if (!NameKeyNew) {
+ NameKeyNew = KeyOld;
+ };
+ TreeNew[NameKeyNew] = JsonTransformA(Content, SchemaRoot[NameKeyNew], SchemaRoot);
+ if (NameKeyNew !== KeyOld) {
+ TreeNew[SchemaRoot[NameKeyNew].__] = TreeNew[NameKeyNew];
+ delete TreeNew[NameKeyNew];
};
- TreeNew[KeyNew.__] = JsonTransform(Content, SchemaRoot[KeyNew.__], SchemaRoot);
- TreeNew[SchemaRoot[KeyNew.__].__] = TreeNew[KeyNew.__];
- delete TreeNew[KeyNew.__];
};
} else {
// Values
@@ -50,3 +66,13 @@ function JsonTransform(TreeOld, SchemaCurr, SchemaRoot) {
});
return TreeNew;
};
+function JsonTransformB(TreesOld, Schema, Node, Source) {
+
+};
+function JsonTransformCycleB(TreeOld, Schema, Node, Source) {
+ var TreeNew = {};
+ Object.keys(Node).forEach(function(KeyOld){
+ console.log(KeyOld)
+ });
+ return TreeNew;
+};