Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
buckhalt committed Mar 14, 2024
2 parents 6ffd463 + ed22379 commit 08fc289
Show file tree
Hide file tree
Showing 23 changed files with 115 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const WorkInProgress = () => {
return (
<PopoutBox
title="Work in Progress"
iconClassName="bg-accent"
className="bg-success/10 [--link:var(--success)]"
iconClassName="bg-white"
icon={
<Image
src="/images/work-in-progress.svg"
Expand Down
3 changes: 3 additions & 0 deletions apps/documentation/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const SidebarItemBase = z.object({
export const SidebarPageSchema = SidebarItemBase.extend({
type: z.literal('page'),
sourceFile: z.string(),
navOrder: z.number().nullable(),
});

export type SidebarPage = z.infer<typeof SidebarPageSchema>;
Expand All @@ -38,6 +39,7 @@ export type SidebarPage = z.infer<typeof SidebarPageSchema>;

export const baseSidebarFolder = SidebarItemBase.extend({
type: z.literal('folder'),
navOrder: z.number().nullable(),
expanded: z.boolean().optional(),
});

Expand Down Expand Up @@ -85,6 +87,7 @@ export const MetadataFileSchema = z.object({
localeLabels: z.record(z.string(), z.string()).optional(),
localeIndexFiles: z.record(z.string(), z.string()).optional(),
isExpanded: z.boolean().optional(),
navOrder: z.number().optional(),
});

export type MetadataFile = z.infer<typeof MetadataFileSchema>;
Expand Down
34 changes: 34 additions & 0 deletions apps/documentation/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export function Sidebar({ className }: { className?: string }) {
const typedSidebarData = sidebarData as TSideBar;

const formattedSidebarData = typedSidebarData[locale]![project]!.children;
// const sortedSidebarItems = sortSidebarItems(formattedSidebarData);

return (
<nav className={cn('flex w-full grow flex-col pl-4', className)}>
Expand All @@ -220,3 +221,36 @@ export function Sidebar({ className }: { className?: string }) {
</nav>
);
}

// function sortSidebarItems(
// formattedSidebarData: Record<string, TSidebarFolder | SidebarPage>,
// ) {
// const objectItems = Object.values(formattedSidebarData);
// const objectKeys = Object.keys(formattedSidebarData);

// objectItems.sort((a, b) => {
// if (a.navOrder !== null && b.navOrder !== null) {
// return a.navOrder - b.navOrder;
// } else if (a.navOrder !== null) {
// return -1;
// } else if (b.navOrder !== null) {
// return 1;
// } else {
// return a.label.localeCompare(b.label);
// }
// });

// // Recursively sort folder children
// const sortedItems = items.map((item) => {
// if (item.type === 'folder') {
// const folderPages = Object.values(item.children);
// const folderSlug = Object.keys(item.children)[0];
// item.children[folderSlug!] = sortSidebarItems(folderPages).find(
// (i) => i.label === item.label,
// ) as TSidebarFolder;
// }
// return item;
// });

// return sortedItems;
// }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Installation Guide
nav_order: 3
navOrder: 3
last_modified_at: 2021-02-10
wip: false
toc: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"en": "Getting Started"
},
"isExpanded": true,
"slug": "getting-started"
"slug": "getting-started",
"navOrder": 1
}
2 changes: 1 addition & 1 deletion apps/documentation/docs/desktop/index.en.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Desktop and Tablet Software
wip: false
toc: false
nav_order: 1
navOrder: 1
hidden: true
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Citing the Software
wip: false
nav_order: 6
navOrder: 6
---

We ask you to please cite us in publications or presentations that are created from any research, clinical, educational, or other applicable use of the Network Canvas Suite or any of its components. Through your citation of the software, we are able to measure its impact and track the ways in which it is being used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Frequently Asked Questions
wip: false
toc: true
nav_order: 5
navOrder: 5
---

## What is Network Canvas?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Project Overview
nav_order: 2
navOrder: 2
last_modified_at: 2020-12-14
wip: false
toc: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
nav_order: 2
navOrder: 2
title: Building a protocol using Architect
toc: true
---
Expand Down
3 changes: 2 additions & 1 deletion apps/documentation/docs/desktop/tutorials/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"en": "index.en.mdx"
},
"slug": "tutorials",
"isExpanded": true
"isExpanded": true,
"navOrder": 2
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
nav_order: 1
navOrder: 1
title: Using Interviewer
wip: false
toc: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
nav_order: 3
navOrder: 3
title: Protocol and Data Workflows without Server
wip: false
toc: true
Expand Down
2 changes: 1 addition & 1 deletion apps/documentation/docs/fresco/deployment/advanced.en.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ After deploying your Fresco instance, you will need to create an administrator a

<TipBox danger>

For security, you have **_30 minutes_** from when the app is deployed to create a user account. If this time elapses without a user account being created, your configuration will expire. To redeploy, follow our guide to [reset your database](../troubleshooting#instance-expired---reset-your-database).
To ensure the security of your deployment, you have **30 minutes** from when the app is deployed to create a user account. If this time elapses without a user account being created, your configuration will expire. To redeploy, follow our guide to [reset your database](../troubleshooting#instance-expired---reset-your-database).

</TipBox>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Cloud Pricing
date: 12th March 2024
nav_order: 6
navOrder: 6
wip: false
---

Expand All @@ -24,4 +24,3 @@ For specific information on Vercel's Postgres Database Storage pricing, you can
- **Upgrade Option**: If you require additional storage or features, you can upgrade to 100GB of storage for $10/month.

For more information on UploadThing's pricing plans and features, you can visit their [pricing page.](https://uploadthing.com/pricing)

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ To use Fresco, you need to set up an administrator account which will enable you

<TipBox danger>

For security, you have **_30 minutes_** from when the app is deployed to create a user account. If this time elapses without a user account being created, your configuration will expire. To redeploy, follow our guide to [reset your database](../troubleshooting#instance-expired---reset-your-database).
To ensure the security of your deployment, you have **30 minutes** from when the app is deployed to create a user account. If this time elapses without a user account being created, your configuration will expire. To redeploy, follow our guide to [reset your database](../troubleshooting#instance-expired---reset-your-database).

</TipBox>

Expand Down
2 changes: 1 addition & 1 deletion apps/documentation/docs/fresco/deployment/guide.en.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,6 @@ After deploying your Fresco instance, you will need to create an administrator a

<TipBox danger>

For security, you have **_30 minutes_** from when the app is deployed to create a user account. If this time elapses without a user account being created, your configuration will expire. To redeploy, follow our guide to [reset your database](../troubleshooting#instance-expired---reset-your-database).
To ensure the security of your deployment, you have **30 minutes** from when the app is deployed to create a user account. If this time elapses without a user account being created, your configuration will expire. To redeploy, follow our guide to [reset your database](../troubleshooting#instance-expired---reset-your-database).

</TipBox>
7 changes: 4 additions & 3 deletions apps/documentation/docs/fresco/deployment/upgrading.en.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
title: Upgrading Fresco
date: 12th March 2024
nav_order: 5
navOrder: 5
wip: false
---

Fresco is Alpha software and will be continuously improved. As we release new versions of Fresco, you can upgrade your deployed instance using this guide.

## When to Upgrade

You are responsible for upgrading your own instance of Fresco. We recommend upgrading your instance of Fresco when a new version is released. This will ensure that you have the latest features and bug fixes. You can check for new releases in the following places:

- **Network Canvas User Community**: We will notify users of new releases on our [community forum](https://community.networkcanvas.com/).
Expand All @@ -27,12 +28,12 @@ Vercel will automatically begin redeploying your Fresco instance. This process w
For more information on how to sync your fork, see the [GitHub documentation](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork).

## Versioning

Fresco uses a combination of [semantic versioning](https://semver.org/) and GitHub commit hashes (a.k.a. the ["SHA" or "hash"](https://docs.github.com/en/get-started/learning-about-github/github-glossary#commit)) to manage releases.

This version information is accessible from several places:

- **Main Dashboard**: You can find the version number of your Fresco instance on the main dashboard in the top left corner.
- **Settings**: You can find the version number and SHA of your Fresco instance on the **Settings** page of your dashboard.
- **GitHub**: You can find the SHA of your Fresco instance on your GitHub repository.
- **Exported Data**: The version number and SHA of your Fresco instance are included in the exported data within the ego file. This information is useful for tracking the version of Fresco used to collect data.


6 changes: 3 additions & 3 deletions apps/documentation/docs/fresco/sandbox.en.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Sandbox
wip: false
nav_order: 3
navOrder: 3
date: 13th March 2024
---

Expand All @@ -13,7 +13,7 @@ There are no restrictions on the use of the sandbox, but we will periodically re

<TipBox danger>

Any protocol files uploaded will be visible to all users of the sandbox. Please be mindful of the data you upload.
Any protocol files uploaded will be visible to all users of the sandbox. Please be mindful of the data you upload.

**Under no circumstances should real study or participant data be uploaded.**

Expand All @@ -24,4 +24,4 @@ Any protocol files uploaded will be visible to all users of the sandbox. Please
To access the sandbox, visit [https://fresco-sandbox.networkcanvas.com/](https://fresco-sandbox.networkcanvas.com/) and use the following credentials:

- **username**: `admin`
- **password**: `Administrator1!`
- **password**: `Administrator1!`
10 changes: 5 additions & 5 deletions apps/documentation/docs/fresco/troubleshooting.en.mdx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
title: Troubleshooting
date: 12th March 2024
nav_order: 3
navOrder: 3
---

## Deployment Build Errors and Fixes
You may encounter errors during deployment. Below are some common errors and their solutions to help you troubleshoot effectively.

You may encounter errors during deployment. Below are some common errors and their solutions to help you troubleshoot effectively.

### Invalid API Key Error

![Invalid API Key Console Error](/assets/img/fresco-images/deploy-error2.png)
![Invalid API Key Console Error](/assets/img/fresco-images/deploy-error2.png)

This error means that you provided an incorrect environment variable. Make sure to enter the environment variable value correctly. You must enter the value that starts after `=` symbol
(e.g: `UPLOADTHING_APP_ID=5q5ybg9dwg`, here `UPLOADTHING_APP_ID` is the key of variable and `5q5ybg9dwg` is the value. You should always enter the value.)
This error means that you provided an incorrect environment variable. Make sure to enter the environment variable value correctly. You must enter the value that starts after `=` symbol
(e.g: `UPLOADTHING_APP_ID=5q5ybg9dwg`, here `UPLOADTHING_APP_ID` is the key of variable and `5q5ybg9dwg` is the value. You should always enter the value.)

## Instance Expired - Reset your Database

Expand Down
2 changes: 1 addition & 1 deletion apps/documentation/lib/docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const FrontmatterSchema = z.object({
lastUpdated: z.string().optional(),
hidden: z.boolean().optional(),
wip: z.boolean().optional(),
nav_order: z.number().optional(),
navOrder: z.number().optional(),
toc: z.boolean().optional().default(true),
// interfaces
image: z.string().optional(), // Path to hero image
Expand Down
33 changes: 7 additions & 26 deletions apps/documentation/lib/helper_functions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { existsSync, readFileSync } from 'node:fs';
import { join, sep } from 'node:path';
import type fs from 'node:fs';
import matter from 'gray-matter';
import type matter from 'gray-matter';
import rehypeStringify from 'rehype-stringify';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
Expand All @@ -12,6 +12,7 @@ import type {
SidebarFolder,
SidebarPage,
SidebarProject,
TSidebarFolder,
} from '~/app/types';
import { MetadataFileSchema } from '~/app/types';
import { env } from '../env.mjs';
Expand Down Expand Up @@ -182,6 +183,7 @@ export const createFolderEntry = (
expanded: metadata.isExpanded ?? false,
sourceFile,
label: metadata.localeLabels?.[locale] ?? file.name,
navOrder: metadata.navOrder ?? null,
children: {},
};
};
Expand All @@ -198,35 +200,20 @@ export const createPageEntry = (
matterResult: matter.GrayMatterFile<string>,
): SidebarPage => {
const title = matterResult.data?.title as string | undefined;
const navOrder = matterResult.data?.navOrder as number | undefined;
const sourceFile = join(file.path, file.name).replace(process.cwd(), '');

return {
type: 'page',
sourceFile,
label: title ?? file.name,
navOrder: navOrder ?? null,
};
};

/**
* Given a file, return the nav_order from the frontmatter, or Infinity if it
* doesn't exist.
*
* @param file {fs.Dirent}
* @returns {number}
*/
export const getOrder = (file: fs.Dirent): number => {
if (!file.isDirectory()) {
const path = join(file.path, file.name);
const markdownFile = readFileSync(path, 'utf-8');
const { data } = matter(markdownFile);
return (data.nav_order as number) ?? Infinity;
}
return Infinity;
};

/**
* Given a list of files, sort them based on whether they are directories, and
* then based on their nav_order or file name if nav_order is not present.
* Given a list of files, sort them based on whether they are directories,
* and by ascending depth.
*
* @param files {fs.Dirent[]}
* @returns {fs.Dirent[]}
Expand All @@ -237,10 +224,4 @@ export const sortDirectoryListing = (files: fs.Dirent[]) =>
const depthB = b.name.split('/').length; // Get depth of directory/file B

return depthA - depthB; // Sort by ascending depth (shallowest to deepest)

// // compare based on nav_order or file name if nav_order is not present
// const orderA = getOrder(a);
// const orderB = getOrder(b);

// return orderA - orderB || a.name.localeCompare(b.name);
});
Loading

0 comments on commit 08fc289

Please sign in to comment.