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
5322be32
authored
Apr 18, 2022
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Initial commit
parents
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
index.html
js/main.js
index.html
0 → 100644
View file @
5322be32
<!doctype html>
<html>
<head>
<meta
charset=
"utf-8"
>
<title>
Navegador SOLID
</title>
</head>
<body>
<h1>
Navegador SOLID
</h1>
<div
id=
"login"
>
<button>
Iniciar sesión
</button>
</div>
<div
id=
"logout"
>
Has iniciado sesión como
<strong
id=
"user"
></strong>
.
<button
id=
"logoutButton"
>
Cerrar sesión
</button>
<h2>
Perfil
</h2>
<input
id=
"webid"
size=
"60"
>
<button
id=
"view"
>
Mostrar
</button>
<p>
<label>
Nombre:
</label>
<span
id=
"fullName"
></span>
</p>
<p
id=
"photo"
></p>
</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>
js/main.js
0 → 100644
View file @
5322be32
/* ------------------------------------
* Gestión de sesiones
* ------------------------------------ */
$
(
'#login button'
).
click
(()
=>
popupLogin
());
$
(
'#logout #logoutButton'
).
click
(()
=>
solid
.
auth
.
logout
());
/* Login */
async
function
popupLogin
()
{
let
session
=
await
solid
.
auth
.
currentSession
();
let
popupUri
=
'https://solidcommunity.net/common/popup.html'
;
if
(
!
session
)
session
=
await
solid
.
auth
.
popupLogin
({
popupUri
});
}
solid
.
auth
.
trackSession
(
session
=>
{
const
loggedIn
=
!!
session
;
$
(
'#login'
).
toggle
(
!
loggedIn
);
$
(
'#logout'
).
toggle
(
loggedIn
);
if
(
session
)
{
$
(
'#user'
).
text
(
session
.
webId
);
if
(
!
$
(
'#webid'
).
val
())
$
(
'#webid'
).
val
(
session
.
webId
);
}
});
/* ------------------------------------
* Recuperación de datos
* ------------------------------------ */
// 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#'
);
// Creamos un almacén y le asociamos un lector RDF
const
store
=
$rdf
.
graph
();
const
fetcher
=
new
$rdf
.
Fetcher
(
store
);
$
(
'#view'
).
click
(
async
function
()
{
// Cargamos los datos a partir del WebID
const
person
=
$
(
'#webid'
).
val
();
await
fetcher
.
load
(
person
);
showPersonalData
(
person
);
});
// Información personal
function
showPersonalData
(
person
)
{
// Mostramos tres campos del perfil
const
fullName
=
store
.
any
(
$rdf
.
sym
(
person
),
VCARD
(
'fn'
));
const
photoUrl
=
store
.
any
(
$rdf
.
sym
(
person
),
VCARD
(
'hasPhoto'
));
$
(
'#fullName'
).
text
(
fullName
&&
fullName
.
value
);
$
(
'#photo'
).
html
(
$
(
'<img>'
).
attr
(
'src'
,
photoUrl
&&
photoUrl
.
value
).
attr
(
'width'
,
'200px'
));
}
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