sesión 2 iniciada

parent 2824c794
Showing with 83 additions and 5 deletions
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Navegador SOLID</title>
</head>
<head>
<meta charset="utf-8">
<title>Navegador SOLID</title>
</head>
<style>
body {
max-width: 800px;
margin: 0 auto;
}
body,
input,
button {
font: 11pt/1.3 "Helvetiva Neue", Helvetica, Arial, sans-serif;
}
button,
label {
font-weight: bold;
}
#profile {
width: 400px;
}
dt {
font-weight: bold;
clear: left;
float: left;
}
dt:after {
content: ': ';
}
a {
color: #7c4dff;
border-bottom: 1px solid;
cursor: pointer;
}
a:hover {
color: #9b79fc;
}
</style>
<body>
<h1>Navegador SOLID</h1>
<div id="login">
......@@ -22,10 +65,15 @@
<h2>Contactos</h2>
<ul id="friends"></ul>
<h2>POD</h2>
<input id="container" size="60" /> <button id="updateContainer">Actualizar</button>
<ul id="items"></ul>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://solid.github.io/solid-auth-client/dist/solid-auth-client.bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/rdflib@1.1.0/dist/rdflib.min.js"></script>
<script src="js/main.js"></script>
</body>
</html>
</html>
\ No newline at end of file
......@@ -27,12 +27,14 @@ solid.auth.trackSession(session => {
// Establecemos espacios de nombres
const FOAF = $rdf.Namespace('http://xmlns.com/foaf/0.1/');
const VCARD = $rdf.Namespace('http://www.w3.org/2006/vcard/ns#');
const LDP = $rdf.Namespace('http://www.w3.org/ns/ldp#');
// Creamos un almacén y le asociamos un lector RDF
const store = $rdf.graph();
const fetcher = new $rdf.Fetcher(store);
$('#view').click(() => showProfile());
$('#updateContainer').click(() => showContainer($('#container').val()));
/* --------------
Mostramos información del perfil referenciado por la WebID
......@@ -43,6 +45,9 @@ async function showProfile() {
await fetcher.load(person);
showPersonalData(person);
showFriends(person);
var patt = /https:\/\/[^\/]+\//;
const rootContainer = patt.exec(person) + 'public/';
showContainer(rootContainer);
}
// Información personal
......@@ -71,4 +76,27 @@ async function showFriends(person) {
.click(() => $('#webid').val(friend.value))
.click(() => showProfile(friend.value))));
});
}
/* -----------------------------------------------
Contenido del POD (navegable)
*/
async function showContainer(container) {
// Cargamos datos desde el POD
await fetcher.load(container);
$('#container').val(container);
// Mostramos elementos
const items = store.each($rdf.sym(container), LDP('contains'));
$('#items').empty();
items.forEach(async (item) => {
if (item.value[item.value.length - 1] == '/')
element = $('<a>').text(decodeURI(item.value))
.click(() => $('#container').val(item.value))
.click(() => showContainer(item.value));
else
element = $('<a>').text(decodeURI(item.value))
.attr('href', item.value)
.attr('target', 'blank');
$('#items').append($('<li>').append(element));
});
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment