solid 0.2.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 55

Solid #

Solid allows use of Tim Berners-Lee's new platform for a decentralized web, Solid, from within dart.

This package includes the solid library, and some of rdflib.

Installation #

Install Solid from pub:

dependencies:
    solid: ^0.2.3

Include solid-auth-client.bundle.js in your HTML before your dart file.

<script src="solid-auth-client.bundle.js"></script>
<script src="main.dart.js"></script>

You can find solid-auth-client.bundle.js here.

if you're also using RDFLib, make sure to include rdflib.min.js.

In your dart code, import

import 'package:solid/solid.dart' as solid;

To use RDFLib, import

import 'package:solid/rdflib.dart' as $rdf;

Warning: In the future, rdflib may be moved to its own package.

Follow the Official Solid Documentation!

Differences from JavaScript #

Currently, logging in from JavaScript is written as

solid.auth.popupLogin({popupUri:'popup.html'});

Whereas in Dart, you write

solid.Auth.popupLogin(solid.LoginOptions(popupUri:'popup.html'));

RDFLib Differences #

Due issues with JavaScript Promise Interop, when using Fetcher.load, it must be wrapped in promiseToFuture (dart:html).

For example, in JavaScript, you write:

await fetcher.load(person);

In dart, you write:

await promiseToFuture(fetcher.load(person));

0.2.3 #

  • Fixed example/README.md

0.2.2 #

  • Formatted Files using dartfmt.
  • Added example/README.md

0.2.1 #

  • Started Adding Documentation. Only certain methods are documented.

0.2.0 #

  • Added package:solid/rdflib.dart.

0.1.3 #

  • Improved Pub listing with a longer description, and an example file.

0.1.2 #

  • Proper instructions in README.md for usage.

0.1.1 #

  • Fixes in README.md and CHANGELOG.md.

0.1.0 #

  • Initial version, Only including solid.auth.

example/README.md

Examples #

Auth Example #

auth.dart contains an example authentication app:

import 'dart:html';
import 'package:solid/solid.dart' as solid;

void main() {

  solid.Auth.trackSession((session) {
    querySelector('#login').style.display = session != null ? 'none' : 'block';
    querySelector('#logout').style.display = session == null ? 'none' : 'block';
    querySelector('#user').innerHtml = session.webId;
  });

  querySelector('#loginButton').onClick.listen((MouseEvent event) {
    print('button click');
    solid.Auth.popupLogin(solid.LoginOptions(popupUri:'popup.html'));
  });

  querySelector('#logoutButton').onClick.listen((MouseEvent event) {
    solid.Auth.logout();
  });

}

Auth and Rdflib Example #

auth-rdflib.dart contains an example of getting the signed in users data.

import 'dart:html';
import 'package:solid/solid.dart' as solid;
import 'package:solid/rdflib.dart' as $rdf;

void main() {

  solid.Auth.trackSession((session) {
    querySelector('#login').style.display = session != null ? 'none' : 'block';
    querySelector('#logout').style.display = session == null ? 'none' : 'block';
    querySelector('#user').innerHtml = session.webId;
    if (session != null) {
      InputElement user = querySelector('#user');
      user.value = session.webId;
    }
  });

  querySelector('#loginButton').onClick.listen((MouseEvent event) {
    print('button click');
    solid.Auth.popupLogin(solid.LoginOptions(popupUri:'popup.html'));
  });

  querySelector('#logoutButton').onClick.listen((MouseEvent event) {
    solid.Auth.logout();
  });

  final FOAF = $rdf.Namespace('http://xmlns.com/foaf/0.1/');
  querySelector('#view').onClick.listen((MouseEvent event) async {
    final store = $rdf.graph();
    final fetcher = $rdf.Fetcher(store);

    SpanElement user = querySelector('#user');
    final person = user.text;

    await promiseToFuture(fetcher.load(person));
    String fullName = store.any($rdf.sym(person), FOAF('name')).value;
    querySelector('#fullName').text = fullName;
  });

}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  solid: ^0.2.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:solid/solid.dart';
  
Version Uploaded Documentation Archive
0.2.3 Feb 18, 2019 Go to the documentation of solid 0.2.3 Download solid 0.2.3 archive
0.2.2 Feb 18, 2019 Go to the documentation of solid 0.2.2 Download solid 0.2.2 archive
0.2.1 Feb 18, 2019 Go to the documentation of solid 0.2.1 Download solid 0.2.1 archive
0.2.0 Feb 18, 2019 Go to the documentation of solid 0.2.0 Download solid 0.2.0 archive
0.1.3 Sep 30, 2018 Go to the documentation of solid 0.1.3 Download solid 0.1.3 archive
0.1.2 Sep 30, 2018 Go to the documentation of solid 0.1.2 Download solid 0.1.2 archive
0.1.1 Sep 30, 2018 Go to the documentation of solid 0.1.1 Download solid 0.1.1 archive
0.1.0 Sep 30, 2018 Go to the documentation of solid 0.1.0 Download solid 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
11
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
55
Learn more about scoring.

We analyzed this package on Apr 25, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: web, other

Primary library: package:solid/solid.dart with components: js.

Health suggestions

Format lib/rdflib.dart.

Run dartfmt to format lib/rdflib.dart.

Format lib/solid.dart.

Run dartfmt to format lib/solid.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
js ^0.6.0 0.6.1+1
Dev dependencies
build_runner ^0.10.0
build_web_compilers ^0.4.0