Skip to content

Commit

Permalink
write/indexing fixes for group & artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
holycrab13 committed Jan 31, 2025
1 parent c38cbaa commit fb1127e
Show file tree
Hide file tree
Showing 30 changed files with 343 additions and 943 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.detectIndentation": true
}
4 changes: 2 additions & 2 deletions public/dist/main.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions public/js/page-controller/profile-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ function ProfileController($scope, $http) {

$scope.putProfile = function (accountName) {

var accountJsonLd = AppJsonFormatter.createAccountData(DATABUS_RESOURCE_BASE_URL,
accountName,
var accountUri = `${DATABUS_RESOURCE_BASE_URL}/${accountName}`;
var accountJsonLd = AppJsonFormatter.createAccountData(
accountUri,
accountName,
null,
null);
Expand Down Expand Up @@ -183,8 +184,9 @@ function ProfileController($scope, $http) {
return;
}

var accountJsonLd = AppJsonFormatter.createAccountData(DATABUS_RESOURCE_BASE_URL,
$scope.auth.info.accountName,
var accountUri = `${DATABUS_RESOURCE_BASE_URL}/${$scope.auth.info.accountName}`;
var accountJsonLd = AppJsonFormatter.createAccountData(
accountUri,
$scope.editData.label,
$scope.editData.about,
$scope.editData.imageUrl);
Expand Down
14 changes: 6 additions & 8 deletions public/js/utils/app-json-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ const JsonldUtils = require("./jsonld-utils");
*/
class AppJsonFormatter {

static createAccountData(resourceBaseUrl, accountName, accountLabel, accountStatus, accountImage) {
static createAccountData(accountUri, accountLabel, accountStatus, accountImage) {

var accountUri = `${resourceBaseUrl}/${accountName}`;
var personUri = `${resourceBaseUrl}/${accountName}${DatabusConstants.WEBID_THIS}`;
var personUri = `${accountUri}${DatabusConstants.WEBID_THIS}`;

var accountJsonLd = {};

Expand All @@ -34,12 +33,10 @@ class AppJsonFormatter {
}


accountJsonLd[DatabusUris.JSONLD_GRAPH] = [
return [
accountGraph,
personGraph
];

return accountJsonLd;
}

static formatGroupData(graphs) {
Expand Down Expand Up @@ -74,12 +71,13 @@ class AppJsonFormatter {
static formatAccountData(graphs) {
var result = {};

var profileGraph = JsonldUtils.getTypedGraph(graphs, DatabusUris.FOAF_PERSONAL_PROFILE_DOCUMENT);
var accountGraph = JsonldUtils.getTypedGraph(graphs, DatabusUris.DATABUS_ACCOUNT);
var personGraph = JsonldUtils.getTypedGraph(graphs, DatabusUris.FOAF_PERSON);

result.uri = profileGraph[DatabusUris.JSONLD_ID];
result.uri = accountGraph[DatabusUris.JSONLD_ID];
result.accountName = DatabusUtils.uriToResourceName(result.uri);
result.label = JsonldUtils.getProperty(personGraph, DatabusUris.FOAF_NAME);
result.about = JsonldUtils.getProperty(personGraph, DatabusUris.FOAF_STATUS);
result.webIds = [];
result.searchExtensions = [];

Expand Down
13 changes: 0 additions & 13 deletions public/js/utils/databus-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,19 +503,6 @@ class DatabusUtils {
return errorList;
}

static validateNamespace(uri, accountName) {

var baseURL = process.env.DATABUS_RESOURCE_BASE_URL;

if (!uri.startsWith(process.env.DATABUS_RESOURCE_BASE_URL)) {
throw new ApiError(`Identifier <${uri}> does not start with the resource base url <${baseURL}> of this Databus.`, 400);
}

var namespacePrefix = `${baseURL}/${accountName}/`;
if (!uri.startsWith(namespacePrefix)) {
throw new ApiError(`Identifier <${uri}> does not start with the expected namespace prefix <${namespacePrefix}>.`, 403);
}
}
}

module.exports = DatabusUtils;
23 changes: 18 additions & 5 deletions public/js/utils/jsonld-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class JsonldUtils {
result[DatabusUris.JSONLD_ID] = uri;
return result;
}

static getTypedGraph(graphs, graphType) {

for (var g in graphs) {
Expand Down Expand Up @@ -139,14 +139,27 @@ class JsonldUtils {
return obj[0];
}

static getFirstObjectUri(graph, key) {
var obj = graph[key];
static getFirstObjectUri(graph, property) {
// Get the object
const obj = graph[property];

if (obj == undefined || obj.length < 1) {
// Not found -> null
if (!obj) {
return null;
}

// If it is an array...
if (Array.isArray(obj)) {
for (const item of obj) {
if (item && typeof item === 'object' && DatabusUris.JSONLD_ID in item) {
return item[DatabusUris.JSONLD_ID];
}
}
} else if (typeof obj === 'object' && DatabusUris.JSONLD_ID in obj) {
return obj[DatabusUris.JSONLD_ID];
}

return obj[0][DatabusUris.JSONLD_ID];
return null;
}
}

Expand Down
2 changes: 1 addition & 1 deletion public/templates/404.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%- include('header') -%>
<div>
<section class="hero is-medium-small databus-banner is-none">
<section class="hero is-medium-small databus-banner is-none" style="height: initial;">
<div class="hero-body">
<div class="container has-text-left">
<div style="display: flex; align-items: center; height: 160px;">
Expand Down
3 changes: 2 additions & 1 deletion public/templates/artifact.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@
<a ng-href="{{ utils.getPathname(version.version) }}">{{ version.version }}</a>
</td>
<td>{{ utils.formatDate(version.date) }}</td>
<td class="is-hidden-touch"><a href="{{ version.license }}">{{ version.license }}</a></td>
<td class="is-hidden-touch"><a href="{{ version.license }}">{{ version.license
}}</a></td>
</tr>
</tbody>
</table>
Expand Down
Loading

0 comments on commit fb1127e

Please sign in to comment.