Skip to content

Commit

Permalink
📝 Move website documentation's db/ directory to docs/ in this repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ewen-lbh committed Apr 22, 2024
1 parent a6f28c9 commit 1b04c4e
Show file tree
Hide file tree
Showing 51 changed files with 2,416 additions and 15 deletions.
4 changes: 3 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ install:
chmod +x ~/.local/bin/ortfodb

docs:
mkdir -p docs manpages
mkdir -p docs/commands manpages
./ortfodb makedocs
mv docs/*.md docs/commands/
cp CHANGELOG.md docs/changelog.md

render-demo-gif:
#!/usr/bin/env bash
Expand Down
3 changes: 0 additions & 3 deletions docs/README.md

This file was deleted.

106 changes: 106 additions & 0 deletions docs/building.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
next: false
---

# Running ortfo/db

## Building your database

Make sure that ortfodb in [installed](/db/getting-started.md#installation).

Open up a terminal, and run the following:

::: code-group

```sh [Regular mode]
ortfodb build database.json
```

```sh [Scattered mode]
ortfodb --scattered build database.json
```

:::

You should get the following output:

```ansi
 Writing default configuration file at ortfodb.yaml
 Warning default configuration assumes that your projects
live in /mnt/datacore/projects/ortfo/website.
Change this with projects at in the generated configuration file
 Info No configuration file found. The default configuration was used.
 Finished compiling to database.json
```

Subsequent runs of this command will be faster as long as you re-use the output file: ortfo/db will only recompile the projects that have changed since the last run.

Notice the warning. If you ran the previous command from the directory that contains all of your projects, you should be fine. But if you ran it from somwhere else, you'll probably want to change that `projects at` setting it's talking about to point it to where your projects are.


## Tweaking the configuration file

Open up `ortfodb.yaml` in your favorite text editor.

It should look a little like this:

```yaml
extract colors:
enabled: true
extract: []
default files: []
make gifs:
enabled: false
file name template: ""
make thumbnails:
enabled: true
sizes:
- 100
- 400
- 600
- 1200
input file: ""
file name template: <work id>/<block id>@<size>.webp
build metadata file: .lastbuild.yaml
media:
at: media/
scattered mode folder: .ortfo
tags:
repository: ""
technologies:
repository: ""
projects at: /home/you
```
The config file that ortfo/db generated for you has mostly sensible defaults. The most important things to check are:
`projects at`
: The path to the directory that contains all of your projects

`media.at`
: Where to copy all the media files you reference in your description.md files, as well as the [generated thumbnails](/db/thumbnails)

Most other options relate to certain features, you'll find documentation about them in the pages relating to the features themselves.

::: tip TODO
TODO: Document the whole config file in one place
:::

## What now?

Congrats, you've setup ortfo/db!

Next steps:

What to know all the data contained in your database?
: Check out [the database format](/db/database-format.md)

Want to learn more about the different features ortfo/db has to offer?
: Check out the [features page](/db/features.md)

Wanna integrate ortfo/db with a static site generator?
: See the [Static site generator exporters](/db/exporters/static-site-generators.md)

Curious about how ortfo/db is used to actually make a portfolio site?
: Check out [the repository](https://github.com/ewen-lbh/portfolio) for [my own portfolio](https://ewen.works), which is (of course) built with ortfo/db.
: You can also see how [net7](https://github.com/inp-net) uses ortfo/db to keep their [projects page](https://net7.dev/realisation.html) up to date: see [the repository](https://git.inpt.fr/net7/website/-/tree/master?ref_type=heads) (warning: french ahead)
Empty file added docs/caching.md
Empty file.
11 changes: 11 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
editLink: false
---


<script setup>
import { data } from './changelog.data.js'
console.log(data)
</script>

<main v-html="data[0].html"></main>
70 changes: 70 additions & 0 deletions docs/client-libraries-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
export async function getRustVersion(localFilename = "") {
try {
const version = await fetch(`https://crates.io/api/v1/crates/ortfodb`)
.then((res) => res.json())
.then((data) => data.crate.max_version)
console.info(`Got Rust version from crates.io API: ${version}`)
return version
} catch (error) {
if (localFilename) {
const fs = await import("node:fs")
console.error(`Failed to get Rust version from crates.io API: ${error}`)
console.info(`Falling back to reading from ortfodb Cargo.toml file`)
const contents = fs.readFileSync(localFilename, "utf-8")
return contents.match(/version = "(.+)"/)[1]
} else {
throw error
}
}
}

export async function getGemVersion(localFilename = "") {
try {
const version = await fetch(
`https://rubygems.org/api/v1/versions/ortfodb/latest.json`
)
.then((res) => res.json())
.then((data) => data.version)

console.info(`Got RubyGem version from API: ${version}`)
return version
} catch (error) {
if (localFilename) {
const fs = await import("node:fs")
console.error(`Failed to get RubyGem version from API: ${error}`)
console.info(
`Falling back to reading from ortfodb submodule version.rb file`
)
const contents = fs.readFileSync(localFilename, "utf-8")
return contents.match(/VERSION = "(.+)"/)[1]
} else {
throw error
}
}
}

export async function getGoVersion(localFilename) {
const packageName = "github.com/ortfo/db"

try {
const response = await fetch(
`https://proxy.golang.org/${packageName}/@latest`
)
const data = await response.json()
if (data.Version) {
console.info(`Got Go version from proxy.golang.org: ${data.Version}`)
return data.Version
} else {
throw new Error(`Version not found for package ${packageName}`)
}
} catch (error) {
console.info(`Falling back to reading from local file ${localFilename}`)
const contents = fs.readFileSync(localFilename, "utf-8")
const match = contents.match(/const Version = "(.+)"/)
if (match) {
return match[1]
} else {
throw new Error(`Version not found in ${localFilename}`)
}
}
}
18 changes: 18 additions & 0 deletions docs/client-libraries.data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { getGemVersion, getGoVersion, getRustVersion } from "./client-libraries-versions"

export default {
watch: [
"ortfodb/packages/ruby/lib/ortfodb/version.rb",
"ortfodb/packages/rust/Cargo.toml",
"ortfodb/meta.go"
],
async load(watchedFiles) {
return {
versions: {
gem: await getGemVersion(watchedFiles[0]),
rust: await getRustVersion(watchedFiles[1]),
go: await getGoVersion(watchedFiles[2]),
},
}
},
}
Loading

0 comments on commit 1b04c4e

Please sign in to comment.