Skip to content

Commit fbc6051

Browse files
committed
Add setup
1 parent 27bd8a7 commit fbc6051

File tree

4 files changed

+99
-3
lines changed

4 files changed

+99
-3
lines changed

docs/tasks/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ title: Working with manifests
66
There are a number of common tasks when working with manifests.
77
The way you accomplish each task is specific to the language you're using, although at a high level the process is similar.
88

9+
- [Preliminary setup](./setup.mdx)
910
- [Reading manifest data](./read.mdx)
1011
- [Getting resources from a manifest](./get-resources.mdx)
1112
- [Building a manifest](./build.mdx)
1213
- [Writing a manifest](./write.mdx)
13-
- [Signing a manifest](./sign.mdx)
14+
- [Signing a manifest](./sign.mdx)

docs/tasks/setup.mdx

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
id: setup
3+
title: Setup
4+
hide_table_of_contents: true
5+
---
6+
7+
import Tabs from '@theme/Tabs';
8+
import TabItem from '@theme/TabItem';
9+
10+
<Tabs groupId="programming-lang">
11+
12+
{' '}
13+
<TabItem value="js" label="JavaScript" default>
14+
This is how to setup the JavaScript library.
15+
</TabItem>
16+
17+
<TabItem value="python" label="Python" default>
18+
This is how to setup the Python library.
19+
20+
```python
21+
# Import the C2PA Python package
22+
from c2pa import *
23+
24+
# Import standard general-purpose packages
25+
import os
26+
import io
27+
import logging
28+
import json
29+
import base64
30+
31+
# Import web packages used in example implementation
32+
from flask import Flask, request, abort
33+
from flask_cors import CORS
34+
from waitress import serve
35+
36+
# Import AWS SDK package (to use KMS)
37+
import boto3
38+
```
39+
40+
</TabItem>
41+
42+
<TabItem value="node" label="Node.js">
43+
This is how to setup the Node.js library.
44+
45+
```js
46+
import { createC2pa } from 'c2pa-node';
47+
import { readFile } from 'node:fs/promises';
48+
49+
const c2pa = createC2pa();
50+
```
51+
52+
</TabItem>
53+
54+
<TabItem value="cpp" label="C++">
55+
56+
```cpp
57+
#include <iostream>
58+
#include <fstream>
59+
#include <string>
60+
#include <vector>
61+
#include <stdexcept>
62+
#include <openssl/evp.h>
63+
#include <openssl/pem.h>
64+
#include <openssl/err.h>
65+
#include "c2pa.hpp"
66+
#include "test_signer.hpp"
67+
#include <nlohmann/json.hpp>
68+
69+
// this example uses nlohmann json for parsing the manifest
70+
using json = nlohmann::json;
71+
using namespace std;
72+
namespace fs = std::filesystem;
73+
using namespace c2pa;
74+
```
75+
76+
</TabItem>
77+
78+
<TabItem value="rust" label="Rust">
79+
This is how to setup the Rust library.
80+
81+
```rust
82+
use std::{
83+
io::{Cursor, Write},
84+
process::{Command, Stdio},
85+
};
86+
87+
use anyhow::Result;
88+
use c2pa::{settings::load_settings_from_str, Builder, CallbackSigner, SigningAlg};
89+
```
90+
91+
</TabItem>
92+
93+
</Tabs>

docs/tasks/sign.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import TabItem from '@theme/TabItem';
1111
This is how to sign a manifest using Python.
1212
</TabItem>
1313

14-
{' '}
15-
1614
<TabItem value="node" label="Node.js">
1715
This is how to sign a manifest using Node.js.
1816
</TabItem>

sidebars.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ const sidebars = {
6767
link: { type: 'doc', id: 'tasks/working-manifests' },
6868
collapsed: true,
6969
items: [
70+
{
71+
type: 'doc',
72+
id: 'tasks/setup',
73+
},
7074
{
7175
type: 'doc',
7276
id: 'tasks/read',

0 commit comments

Comments
 (0)