-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SLEEP + general docs update + more introduction content (#57)
* big docs update * fix sleep link * separate sustainability header * better into and reword * clean up terms and other places * add intro, overview, troubleshooting. update more content * minor change to force new deploy * more words * more updates and some pictures * wordsmith intro to be more about dat uniqueness * syncing & publishing * add link files description * add new gifs * change overview to remove tutorial * add wip tutorial content * update build with dat * add http file
- Loading branch information
Showing
20 changed files
with
675 additions
and
188 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
{ | ||
"Dat": { | ||
"Introduction": "modules/dat.md", | ||
"How Dat Works": "how-dat-works.md", | ||
"Terminology": "terms.md", | ||
"FAQ": "faq.md" | ||
"Using Dat": { | ||
"Introduction": "intro.md", | ||
"Dat Concepts": "overview.md", | ||
"Command Line": "modules/dat.md", | ||
"FAQ": "faq.md", | ||
"Troubleshooting": "troubleshooting.md", | ||
"Terminology": "terms.md" | ||
}, | ||
"Cookbook": { | ||
"On a Server": "cookbook/server.md", | ||
"Getting Started": "cookbook/tutorial.md", | ||
"Sharing files over HTTP": "cookbook/http.md", | ||
"Running a Dat Server": "cookbook/server.md", | ||
"In the Browser": "cookbook/browser.md", | ||
"Under the Hood": "cookbook/diy-dat.md" | ||
"Using Dat in JS Apps": "cookbook/diy-dat.md", | ||
"Using Hyperdrive FS": "cookbook/using-fs.md" | ||
}, | ||
"Ecosystem": { | ||
"Dat Technology": { | ||
"Overview": "ecosystem.md", | ||
"SLEEP": "sleep.md", | ||
"Hyperdrive": "modules/hyperdrive.md", | ||
"Hypercore": "modules/hypercore.md" | ||
"dat-node": "modules/dat-node.md", | ||
"hyperdrive": "modules/hyperdrive.md", | ||
"hypercore": "modules/hypercore.md", | ||
"hyperdiscovery": "modules/hyperdiscovery.md" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Sharing files over HTTP | ||
|
||
The Dat command line comes with a built in HTTP server. This is a cool demo because we can also see how version history works! The `--http` option works for files you are sharing *or* downloading. | ||
|
||
(If you don't have dat command line installed, run `npm install -g dat`, or [see more info](intro#installation).) | ||
|
||
## Serve over HTTP | ||
|
||
Serve dat files on http by adding the `--http` option. For example, you can sync an existing dat: | ||
|
||
``` | ||
❯ dat sync --http | ||
dat://778f8d955175c92e4ced5e4f5563f69bfec0c86cc6f670352c457943666fe639 | ||
Sharing dat: 2 files (1.4 MB) | ||
Serving files over http at http://localhost:8080 | ||
2 connections | Download 0 B/s Upload 0 B/s | ||
``` | ||
|
||
Now visit [http://localhost:8080]() to see the files in your browser! The default http port is 8080. You should see a directory listing: | ||
|
||
<img src="/assets/cli-http.png" alt="Dat HTTP viewer"/> | ||
|
||
If your dat has an `index.html` page, that will be shown instead. | ||
|
||
You can combine Dat's http support with our server tools to create a live updating website or place to share files publicly. | ||
|
||
## Built-in Versioning | ||
|
||
As you may know, Dat automatically versions all files. The HTTP display is an easy way to view version history: | ||
|
||
**Use [localhost:8080/?version=2]() to view a specific version.** | ||
|
||
## Live reloading | ||
|
||
The Dat http viewer also comes with live reloading. If it detects a new version it will automatically reload with the new directory listing or page (as long as you aren't viewing a specific version in the url). | ||
|
||
## Sparse Downloading | ||
|
||
Dat supports *sparse*, or partial downloads, of datasets. This is really useful if you only want a single file from a large dat. Unfortunately, we haven't quite built a user interface for this into our applications. So you can hack around it! | ||
|
||
This will allow you to download a single file from a larger dat, without downloading metadata or any other files. | ||
|
||
First, start downloading our demo dat, make sure you include both the flags (`--http`, `--sparse`). | ||
|
||
``` | ||
❯ dat dat://778f8d955175c92e4ced5e4f5563f69bfec0c86cc6f670352c457943666fe639 ./demo --http --sparse | ||
Cloning: 2 files (1.4 MB) | ||
Serving files over http at http://localhost:8080 | ||
3 connections | Download 0 B/s Upload 0 B/s | ||
``` | ||
|
||
The `--sparse` option tells Dat to only download files you specifically request. See how it works: | ||
|
||
1. Check out your `./demo` folder, it should be empty. | ||
2. [Open the Dat](http://localhost:8080) in your browser. | ||
3. Click on a file to download. | ||
4. It should be in your folder now! | ||
|
||
Pretty cool! You can use this hack to download only specific files or even older versions of files (if they've been saved somewhere). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Getting Started with Dat | ||
|
||
In this tutorial we will go through the two main ways to use Dat, sharing data and downloading data. If possible, this is great to go through with a partner to see how Dat works across computers. Get Dat [installed](intro#installation) and get started! | ||
|
||
Dat Desktop makes it easy for anyone to get started using Dat with user-friendly interface. If you are comfortable with the command line then you can install dat via npm. You can always switch apps later and keep your dats the same. Dat can share your files to anyone, it does not matter how they are using Dat. | ||
|
||
## Command Line Tutorial | ||
|
||
### Downloading Data | ||
|
||
We made a demo folder we made just for this exercise. Inside the demo folder is a `dat.json` file and a gif. We shared these files via Dat and now you can download them with our dat key! | ||
|
||
Similar to git, you do download somebody's dat by running `dat clone <link>`. You can also specify the directory: | ||
|
||
``` | ||
❯ dat clone dat://778f8d955175c92e4ced5e4f5563f69bfec0c86cc6f670352c457943666fe639 ~/Downloads/dat-demo | ||
dat v13.5.0 | ||
Created new dat in /Users/joe/Downloads/dat-demo/.dat | ||
Cloning: 2 files (1.4 MB) | ||
2 connections | Download 614 KB/s Upload 0 B/s | ||
dat sync complete. | ||
Version 4 | ||
``` | ||
|
||
This will download our demo files to the `~/downloads/dat-demo` folder. These files are being shared by a server over Dat (to ensure high availability) but you may connect to any number of users also hosting the content. | ||
|
||
You can also also view the files online: [datproject.org/778f8d955175c92e4ced5e4f5563f69bfec0c86cc6f670352c457943666fe639](https://datproject.org/778f8d955175c92e4ced5e4f5563f69bfec0c86cc6f670352c457943666fe639/). datproject.org can download files over Dat and display them on http as long as someone is hosting it. The website temporarily caches data for any visited links (do not view your dat on datproject.org if you do not want us caching your data). | ||
|
||
### Sharing Data | ||
|
||
We'll be creating a dat from a folder on your computer. If you are with a friend you can sync these files to their computer. Otherwise you can view them online via datproject.org to see how viewing a dat online works. | ||
|
||
Find a folder on your computer to share. Any kind of files work with Dat but for now, make sure it's something you want to share with your friends. Dat can handle all sorts of files (Dat works with really big folders too!). We like cat pictures. | ||
|
||
First, you can create a new dat inside that folder. Using the `dat create` command also walks us through making a `dat.json` file: | ||
|
||
``` | ||
❯ dat create | ||
Welcome to dat program! | ||
You can turn any folder on your computer into a Dat. | ||
A Dat is a folder with some magic. | ||
``` | ||
|
||
This will create a new (empty) dat. Dat will print a link, share this link to give others access to view your files. | ||
|
||
Once we have our dat, run `dat share` to scan your files and sync them to the network. Share the link with your friend to instantly start downloading files. | ||
|
||
You can also try viewing your files online. Go to [datproject.org](https://datproject.org/explore) and enter your link to preview on the top right. *(Some users, including me when writing this, may have trouble connecting to datproject.org initially. Don't be alarmed! It is something we are working on. Thanks.)* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Using the Hyperdrive FS | ||
|
||
[Hyperdrive](https://github.com/mafintosh/hyperdrive), the core file system module in dat, exposes an API that mimics the Node fs API. This allows you to create modules that act on hyperdrive or a regular fs with the same API. We have several modules that we make use of this custom fs, such as [mirror-folder](https://github.com/mafintosh/mirror-folder). | ||
|
||
Mirror folder can copy a regular directory to another regular directory: | ||
|
||
```js | ||
var mirror = require('mirror-folder') | ||
|
||
mirror('/source', '/dest', function (err) { | ||
console.log('mirror complete') | ||
}) | ||
``` | ||
|
||
You can also copy a folder to an archive (this is how we do importing in Dat): | ||
|
||
```js | ||
var archive = hyperdrive('/dir') | ||
mirror('/source', {name: '/', fs: archive}, function (err) { | ||
console.log('mirror complete') | ||
}) | ||
``` | ||
|
||
### Creating Custom FS Modules | ||
|
||
To create a module that uses a custom fs, you can default to the regular `fs` but also accept `fs` as an argument. For example, to print a file you could write this function: | ||
|
||
```js | ||
function printFile(file, fs) { | ||
if (!fs) fs = require('fs') | ||
|
||
fs.readFile(file, 'utf-8', function (err, data) { | ||
console.log(data) | ||
}) | ||
} | ||
``` | ||
|
||
Then you could use this to print a file from a regular fs: | ||
|
||
```js | ||
printFile('/data/hello-world.txt') | ||
``` | ||
|
||
Or from a hyperdrive archive: | ||
|
||
```js | ||
var archive = hyperdrive('/data') | ||
printFile('/hello-world.txt', archive) // pass archive as the fs! | ||
``` | ||
|
||
## Modules! | ||
|
||
See more examples of custom-fs modules: | ||
|
||
* [mirror-folder](https://github.com/mafintosh/mirror-folder) - copy files from one fs to another fs (regular or custom) | ||
* [count-files](https://github.com/joehand/count-files) - count files in regular or custom fs. | ||
* [ftpfs](https://github.com/maxogden/ftpfs) - custom fs for FTPs | ||
* [bagit-fs](https://github.com/joehand/bagit-fs) - custom fs module for the BagIt spec. |
Oops, something went wrong.