Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Arturo Montejo Ráez
/
solid2022
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
afba5979
authored
Apr 25, 2022
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
sesión 2 iniciada
parent
2824c794
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
5 deletions
index.html
js/main.js
index.html
View file @
afba5979
<!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
js/main.js
View file @
afba5979
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment