Skip to content

Commit

Permalink
merge codex v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jcv8000 authored Oct 13, 2023
2 parents 2a082df + 36a20a6 commit bf3530a
Show file tree
Hide file tree
Showing 30 changed files with 2,180 additions and 1,389 deletions.
28 changes: 22 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,51 @@ If you want to contribute your own translation/language, first fork the reposito

The first object in the file is a `Locale` type which defines all of the text variables used in the app. You don't need to change this at all.

You will need to add the locale name of your translation to `SupportedLocales`. For example if you were adding Spanish (Mexico) you would add ` | "es_MX";` to the end of the line:
You will need to add the locale name of your translation to `supportedLocales`. For example if you were adding Spanish (Mexico) you would add `"es_MX"` to the array:

<table><tr><th>Before</th><th>After</th></tr><tr><td>

```ts
export const supportedLocales = ["en_US"] as const;
// ^^^^^^^
```

</td><td>

```ts
export type SupportedLocales = "en_US";
export const supportedLocales = ["en_US", "es_MX"] as const;
// ^^^^^^^^^^^^^^^^
```

to
</td></tr></table>

The next line generates a type from the array (you don't have to change this):

```ts
export type SupportedLocales = "en_US" | "es_MX";
export type SupportedLocales = (typeof supportedLocales)[number]; // would be: "en_US" | "es_MX"
```

Then, the last object in the file is `export const locales`. Select the entire `en_US: { ... }` object and copy/paste it below:

<table><tr><th>Before</th><th>After</th></tr><tr><td>

```ts
export const locales: Record<SupportedLocales, Locale> = {
en_US: { ... }
};
```

to
</td><td>

```ts
export const locales: Record<SupportedLocales, Locale> = {
en_US: { ... },
es_MX: { ... }
es_MX: { ... } // New translation
};
```

</td></tr></table>

Then you can go through the new object and change the strings to your own translation.

Finally, create a pull request on the original repository with your new changes.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: jcv8000
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
135 changes: 68 additions & 67 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "codex",
"private": true,
"version": "2.0.0-beta.0",
"version": "2.0.0",
"description": "Note-taking app for programmers and CS students",
"author": {
"name": "Josh Vickery",
Expand All @@ -22,93 +22,94 @@
"typecheck": "tsc && tsc -p packages/renderer/tsconfig.json"
},
"dependencies": {
"@electron/remote": "^2.0.10",
"@electron/remote": "^2.0.12",
"@emotion/react": "^11.11.1",
"@lukeed/uuid": "^2.0.1",
"@mantine/core": "^6.0.17",
"@mantine/dropzone": "^6.0.17",
"@mantine/form": "^6.0.17",
"@mantine/hooks": "^6.0.17",
"@mantine/modals": "^6.0.17",
"@mantine/notifications": "^6.0.17",
"@tabler/icons": "^2.30.0",
"@tabler/icons-webfont": "^2.30.0",
"@tiptap/core": "^2.0.4",
"@tiptap/extension-code-block": "^2.0.4",
"@tiptap/extension-code-block-lowlight": "^2.0.4",
"@tiptap/extension-color": "^2.0.4",
"@tiptap/extension-focus": "^2.0.4",
"@tiptap/extension-font-family": "^2.0.4",
"@tiptap/extension-heading": "^2.0.4",
"@tiptap/extension-highlight": "^2.0.4",
"@tiptap/extension-image": "^2.0.4",
"@tiptap/extension-link": "^2.0.4",
"@tiptap/extension-placeholder": "^2.0.4",
"@tiptap/extension-subscript": "^2.0.4",
"@tiptap/extension-superscript": "^2.0.4",
"@tiptap/extension-table": "^2.0.4",
"@tiptap/extension-table-cell": "^2.0.4",
"@tiptap/extension-table-header": "^2.0.4",
"@tiptap/extension-table-row": "^2.0.4",
"@tiptap/extension-task-item": "^2.0.4",
"@tiptap/extension-task-list": "^2.0.4",
"@tiptap/extension-text-align": "^2.0.4",
"@tiptap/extension-text-style": "^2.0.4",
"@tiptap/extension-typography": "^2.0.4",
"@tiptap/extension-underline": "^2.0.4",
"@tiptap/pm": "^2.0.4",
"@tiptap/react": "^2.0.4",
"@tiptap/starter-kit": "^2.0.4",
"@mantine/core": "^6.0.21",
"@mantine/dropzone": "^6.0.21",
"@mantine/form": "^6.0.21",
"@mantine/hooks": "^6.0.21",
"@mantine/modals": "^6.0.21",
"@mantine/notifications": "^6.0.21",
"@tabler/icons": "^2.39.0",
"@tabler/icons-webfont": "^2.39.0",
"@tiptap/core": "^2.1.12",
"@tiptap/extension-code": "^2.1.12",
"@tiptap/extension-code-block": "^2.1.12",
"@tiptap/extension-code-block-lowlight": "^2.1.12",
"@tiptap/extension-color": "^2.1.12",
"@tiptap/extension-focus": "^2.1.12",
"@tiptap/extension-font-family": "^2.1.12",
"@tiptap/extension-heading": "^2.1.12",
"@tiptap/extension-highlight": "^2.1.12",
"@tiptap/extension-image": "^2.1.12",
"@tiptap/extension-link": "^2.1.12",
"@tiptap/extension-placeholder": "^2.1.12",
"@tiptap/extension-subscript": "^2.1.12",
"@tiptap/extension-superscript": "^2.1.12",
"@tiptap/extension-table": "^2.1.12",
"@tiptap/extension-table-cell": "^2.1.12",
"@tiptap/extension-table-header": "^2.1.12",
"@tiptap/extension-table-row": "^2.1.12",
"@tiptap/extension-task-item": "^2.1.12",
"@tiptap/extension-task-list": "^2.1.12",
"@tiptap/extension-text-align": "^2.1.12",
"@tiptap/extension-text-style": "^2.1.12",
"@tiptap/extension-typography": "^2.1.12",
"@tiptap/extension-underline": "^2.1.12",
"@tiptap/pm": "^2.1.12",
"@tiptap/react": "^2.1.12",
"@tiptap/starter-kit": "^2.1.12",
"@treverix/custom-electron-titlebar": "^4.2.0",
"d3": "^7.8.5",
"electron-context-menu": "^3.6.1",
"electron-is-dev": "^2.0.0",
"electron-log": "^4.4.8",
"fuse.js": "^6.6.2",
"highlight.js": "^11.8.0",
"katex": "^0.16.8",
"lowlight": "^2.9.0",
"mathlive": "^0.95.1",
"palettey": "^1.0.3",
"highlight.js": "^11.9.0",
"katex": "^0.16.9",
"lowlight": "^3.1.0",
"mathlive": "^0.95.5",
"palettey": "^1.0.4",
"react-lowlight": "^3.0.0",
"sanitize-filename": "^1.6.3",
"semver": "^7.5.4",
"tiptap-markdown": "^0.8.2",
"validator": "^13.9.0"
"validator": "^13.11.0"
},
"devDependencies": {
"@babel/plugin-transform-react-jsx": "^7.22.5",
"@babel/plugin-transform-react-jsx": "^7.22.15",
"@preact/compat": "^17.1.2",
"@preact/preset-vite": "^2.5.0",
"@types/d3": "^7.4.0",
"@types/katex": "^0.16.2",
"@types/node": "^16.18.39",
"@types/node-fetch": "^2.6.4",
"@types/react": "^18.2.18",
"@types/react-dom": "^18.2.7",
"@types/semver": "^7.5.0",
"@types/validator": "^13.9.0",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"@vitejs/plugin-react": "^4.0.4",
"electron": "^22.3.18",
"electron-builder": "^24.6.3",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-react": "^7.33.1",
"@types/d3": "^7.4.1",
"@types/katex": "^0.16.3",
"@types/node": "^16.18.58",
"@types/node-fetch": "^2.6.6",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"@types/semver": "^7.5.3",
"@types/validator": "^13.11.2",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"@vitejs/plugin-react": "^4.1.0",
"electron": "^22.3.27",
"electron-builder": "^24.6.4",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"node-fetch": "^2.6.12",
"preact": "^10.16.0",
"prettier": "^3.0.1",
"node-fetch": "^2.7.0",
"preact": "10.17.1",
"prettier": "^3.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^5.0.1",
"sass": "^1.64.2",
"typescript": "^5.1.6",
"vite": "^4.4.8",
"rimraf": "^5.0.5",
"sass": "^1.69.3",
"typescript": "^5.2.2",
"vite": "^4.4.11",
"vite-plugin-static-copy": "^0.17.0",
"vite-tsconfig-paths": "^4.2.0",
"vite-tsconfig-paths": "^4.2.1",
"wait-on": "^7.0.1"
}
}
34 changes: 32 additions & 2 deletions packages/common/Locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ export type Locale = {
changelogs: string;
about: string;
};
shellDialogs: {
open_external_link: {
title: string;
yes: string;
cancel: string;
trust_domain: string;
};
};
mutateModals: {
edit_modal_title: (itemName: string) => string;
new_page_modal_title: (parentName: string) => string;
Expand Down Expand Up @@ -169,6 +177,7 @@ export type Locale = {
inline_code: string;
superscript: string;
subscript: string;
link: string;
align_left: string;
align_right: string;
align_center: string;
Expand Down Expand Up @@ -236,10 +245,16 @@ export type Locale = {
edit: string;
insert: string;
};
linkModal: {
cancel: string;
create_link: string;
url: string;
};
};
};

export type SupportedLocales = "en_US";
export const supportedLocales = ["en_US"] as const;
export type SupportedLocales = (typeof supportedLocales)[number];

export const locales: Record<SupportedLocales, Locale> = {
en_US: {
Expand Down Expand Up @@ -333,7 +348,8 @@ export const locales: Record<SupportedLocales, Locale> = {
"You can nest folders inside of folders",
"You can make a page top-level by dragging it to an empty part of the sidebar",
'Edit your save.json and try setting a page\'s "color" property to "rainbow"',
"Contribute your own language to Codex on the GitHub repository (see CONTRIBUTING.md)"
"Contribute your own language to Codex on the GitHub repository (see CONTRIBUTING.md)",
"Open links in your notes by holding Control (or Cmd) and clicking on it"
],
favorites: "Favorites"
},
Expand All @@ -351,6 +367,14 @@ export const locales: Record<SupportedLocales, Locale> = {
changelogs: "Changelogs",
about: "About"
},
shellDialogs: {
open_external_link: {
title: "Are you sure you want to open this link?",
yes: "Yes",
cancel: "Cancel",
trust_domain: "Always trust this domain"
}
},
mutateModals: {
edit_modal_title: (itemName: string) => `Edit ${itemName}`,
new_page_modal_title: (parentName) => `New Page in ${parentName}`,
Expand Down Expand Up @@ -430,6 +454,7 @@ export const locales: Record<SupportedLocales, Locale> = {
inline_code: "Inline Code",
superscript: "Superscript",
subscript: "Subscript",
link: "Link",
align_left: "Align Left",
align_right: "Align Right",
align_center: "Align Center",
Expand Down Expand Up @@ -497,6 +522,11 @@ export const locales: Record<SupportedLocales, Locale> = {
cancel: "Cancel",
edit: "Edit",
insert: "Insert"
},
linkModal: {
cancel: "Cancel",
create_link: "Create Link",
url: "URL"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/common/Prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class EditorPrefs {
spellcheck = true;
zoom = 1.0;
openPDFonExport = true;
recentCodeLangs: string[] = [];
}

class MiscPrefs {
Expand Down
8 changes: 8 additions & 0 deletions packages/common/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ export class TypedIpcMain {
isRunningUnderARM64Translation = (callback: () => boolean) => {
ipcMain.handle("IS_RUNNING_UNDER_ARM64_TRANSLATION", callback);
};

onOpenExternalLink = (callback: (href: string) => void) => {
ipcMain.on("OPEN_EXTERNAL_LINK", (e, args) => callback(args[0]));
};
}

export class TypedIpcRenderer {
Expand Down Expand Up @@ -231,4 +235,8 @@ export class TypedIpcRenderer {
isRunningUnderARM64Translation = () => {
return ipcRenderer.invoke("IS_RUNNING_UNDER_ARM64_TRANSLATION");
};

openExternalLink = (href: string) => {
ipcRenderer.send("OPEN_EXTERNAL_LINK", [href]);
};
}
27 changes: 12 additions & 15 deletions packages/main/createWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,25 @@ import contextMenu from "electron-context-menu";
import { Prefs } from "common/Prefs";
import { locales } from "common/Locales";
import nodeFetch from "node-fetch";
import { compare } from "semver";
import { lt } from "semver";
import escape from "validator/lib/escape";
import log from "electron-log";

async function checkForUpdates(window: BrowserWindow) {
app.commandLine.appendSwitch("disable-http-cache");

const resp = await nodeFetch("https://jcv8000.github.io/codex/latestversion.txt");
const onlineVersion = await resp.text();
try {
const resp = await nodeFetch("https://api.github.com/repos/jcv8000/Codex/releases");
const body = (await resp.json()) as any[];

if (onlineVersion != undefined && import.meta.env.VITE_APP_VERSION != undefined)
if (compare(onlineVersion, import.meta.env.VITE_APP_VERSION) != 0) {
window.webContents.send("UPDATE_AVAILABLE", [escape(onlineVersion)]);
const latest = body[0].tag_name as string;

// if (process.platform === "win32") {
// window.once("focus", () => window.flashFrame(false));
// window.flashFrame(true);
// }

// if (process.platform === "darwin") {
// app.dock.bounce("critical");
// }
}
if (latest != undefined && import.meta.env.VITE_APP_VERSION != undefined)
if (lt(import.meta.env.VITE_APP_VERSION, latest))
window.webContents.send("UPDATE_AVAILABLE", [escape(latest)]);
} catch (e) {
log.info("Unable to check for updates");
}
}

export function createWindow(prefs: Prefs) {
Expand Down
Loading

0 comments on commit bf3530a

Please sign in to comment.