Skip to content

Commit a6d5ddd

Browse files
Open Cursorless org webpage as default if no url is provided
1 parent a580d78 commit a6d5ddd

File tree

14 files changed

+61
-37
lines changed

14 files changed

+61
-37
lines changed

packages/common/src/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const CURSORLESS_ORG_URL = "https://www.cursorless.org";
2+
export const DOCS_URL = `${CURSORLESS_ORG_URL}/docs`;
3+
export const GITHUB_URL = "https://github.com/cursorless-dev/cursorless";

packages/common/src/errors.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { DOCS_URL } from "./constants";
2+
13
export class UnsupportedLanguageError extends Error {
24
constructor(languageId: string) {
35
super(
4-
`Language '${languageId}' is not implemented yet; See https://www.cursorless.org/docs/contributing/adding-a-new-language/`,
6+
`Language '${languageId}' is not implemented yet; See ${DOCS_URL}/contributing/adding-a-new-language`,
57
);
68
this.name = "UnsupportedLanguageError";
79
}

packages/common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from "./constants";
12
export * from "./cursorlessCommandIds";
23
export * from "./cursorlessSideBarIds";
34
export * from "./Debouncer";

packages/cursorless-engine/src/generateSpokenForm/generateSpokenForm.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
SpokenFormMapKeyTypes,
1010
SpokenFormType,
1111
} from "@cursorless/common";
12-
import { camelCaseToAllDown } from "@cursorless/common";
12+
import { camelCaseToAllDown, DOCS_URL } from "@cursorless/common";
1313
import type { SpokenFormMap } from "../spokenForms/SpokenFormMap";
1414
import { NoSpokenFormError } from "./NoSpokenFormError";
1515
import type { SpokenFormComponent } from "./SpokenFormComponent";
@@ -310,11 +310,9 @@ function constructSpokenForms(component: SpokenFormComponent): string[] {
310310
helpInfo =
311311
"this is a private spoken form currently only for internal experimentation";
312312
} else if (component.spokenForms.requiresTalonUpdate) {
313-
helpInfo =
314-
"please update talon to the latest version (see https://www.cursorless.org/docs/user/updating/)";
313+
helpInfo = `please update talon to the latest version (see ${DOCS_URL}/user/updating)`;
315314
} else {
316-
helpInfo =
317-
"please see https://www.cursorless.org/docs/user/customization/ for more information";
315+
helpInfo = `please see ${DOCS_URL}/user/customization/ for more information`;
318316
}
319317

320318
throw new NoSpokenFormError(

packages/cursorless-org/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
},
3131
"dependencies": {
3232
"@cursorless/cheatsheet": "workspace:*",
33+
"@cursorless/common": "workspace:*",
3334
"@mdx-js/loader": "3.1.0",
3435
"@mdx-js/react": "3.1.0",
3536
"@next/mdx": "15.3.3",

packages/cursorless-org/src/components/BaseSocial.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { CURSORLESS_ORG_URL } from "@cursorless/common";
12
import {
2-
BASE_URL,
33
VIDEO_SHARE_THUMBNAIL_HEIGHT,
44
VIDEO_SHARE_THUMBNAIL_URL,
55
VIDEO_SHARE_THUMBNAIL_WIDTH,
@@ -24,7 +24,7 @@ export default function BaseSocial({
2424
thumbnailWidth = VIDEO_SHARE_THUMBNAIL_WIDTH,
2525
thumbnailHeight = VIDEO_SHARE_THUMBNAIL_HEIGHT,
2626
}: Props) {
27-
const url = `${BASE_URL}/${relativeUrl}`;
27+
const url = `${CURSORLESS_ORG_URL}/${relativeUrl}`;
2828

2929
return (
3030
<>
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { CURSORLESS_ORG_URL } from "@cursorless/common";
2+
13
export const DESCRIPTION = "Voice coding at the speed of thought";
24
export const TITLE = `Cursorless: ${DESCRIPTION}`;
3-
export const BASE_URL = "https://cursorless.org/";
4-
export const VIDEO_SHARE_THUMBNAIL_URL = `${BASE_URL}video-share-thumbnail.jpg`;
5+
export const VIDEO_SHARE_THUMBNAIL_URL = `${CURSORLESS_ORG_URL}/video-share-thumbnail.jpg`;
56
export const VIDEO_SHARE_THUMBNAIL_WIDTH = "1280";
67
export const VIDEO_SHARE_THUMBNAIL_HEIGHT = "720";
78
export const YOUTUBE_SLUG = "5mAzHGM2M0k";

packages/cursorless-org/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"references": [
2424
{
2525
"path": "../cheatsheet"
26+
},
27+
{
28+
"path": "../common"
2629
}
2730
],
2831
"exclude": ["node_modules"]

packages/cursorless-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { getCursorlessApi } from "@cursorless/vscode-common";
21
import type { ScopeTypeInfo } from "@cursorless/common";
3-
import { sleep } from "@cursorless/common";
2+
import { DOCS_URL, sleep } from "@cursorless/common";
3+
import { getCursorlessApi } from "@cursorless/vscode-common";
4+
import { stat, unlink, writeFile } from "fs/promises";
45
import * as sinon from "sinon";
56
import { assertCalledWithScopeInfo } from "./assertCalledWithScopeInfo";
6-
import { stat, unlink, writeFile } from "fs/promises";
77

88
/**
99
* Tests that the scope provider correctly reports custom spoken forms
@@ -152,8 +152,7 @@ const squareMissing: ScopeTypeInfo = {
152152
scopeType: { type: "surroundingPair", delimiter: "squareBrackets" },
153153
spokenForm: {
154154
isPrivate: false,
155-
reason:
156-
"paired delimiter with id squareBrackets; please update talon to the latest version (see https://www.cursorless.org/docs/user/updating/)",
155+
reason: `paired delimiter with id squareBrackets; please update talon to the latest version (see ${DOCS_URL}/user/updating)`,
157156
requiresTalonUpdate: true,
158157
type: "error",
159158
},
@@ -195,8 +194,7 @@ const lambdaCustom: ScopeTypeInfo = {
195194
scopeType: { type: "anonymousFunction" },
196195
spokenForm: {
197196
isPrivate: false,
198-
reason:
199-
"simple scope type type with id anonymousFunction; please see https://www.cursorless.org/docs/user/customization/ for more information",
197+
reason: `simple scope type type with id anonymousFunction; please see ${DOCS_URL}/user/customization for more information`,
200198
requiresTalonUpdate: false,
201199
type: "error",
202200
},
@@ -218,8 +216,7 @@ const statementMissing: ScopeTypeInfo = {
218216
scopeType: { type: "statement" },
219217
spokenForm: {
220218
isPrivate: false,
221-
reason:
222-
"simple scope type type with id statement; please update talon to the latest version (see https://www.cursorless.org/docs/user/updating/)",
219+
reason: `simple scope type type with id statement; please update talon to the latest version (see ${DOCS_URL}/user/updating)`,
223220
requiresTalonUpdate: true,
224221
type: "error",
225222
},

packages/cursorless-vscode/src/ScopeTreeProvider.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
} from "@cursorless/common";
77
import {
88
CURSORLESS_SCOPE_TREE_VIEW_ID,
9+
DOCS_URL,
910
ScopeSupport,
1011
disposableFrom,
1112
serializeScopeType,
@@ -146,9 +147,7 @@ export class ScopeTreeProvider implements TreeDataProvider<MyTreeItem> {
146147

147148
if (result === HOW_BUTTON_TEXT) {
148149
await this.vscodeApi.env.openExternal(
149-
URI.parse(
150-
"https://www.cursorless.org/docs/user/updating/#updating-the-talon-side",
151-
),
150+
URI.parse(`${DOCS_URL}/user/updating/#updating-the-talon-side`),
152151
);
153152
} else if (result === DONT_SHOW_AGAIN_BUTTON_TEXT) {
154153
await this.context.globalState.update(
@@ -238,8 +237,8 @@ class ScopeSupportTreeItem extends TreeItem {
238237
} else {
239238
label = "-";
240239
tooltip = scopeTypeInfo.spokenForm.requiresTalonUpdate
241-
? "Requires Talon update; see [update instructions](https://www.cursorless.org/docs/user/updating/#updating-the-talon-side)"
242-
: "Spoken form disabled; see [customization docs](https://www.cursorless.org/docs/user/customization/#talon-side-settings)";
240+
? `Requires Talon update; see [update instructions](${DOCS_URL}/user/updating/#updating-the-talon-side)`
241+
: `Spoken form disabled; see [customization docs](${DOCS_URL}/user/customization/#talon-side-settings)`;
243242
}
244243

245244
super(
@@ -296,7 +295,7 @@ class ScopeSupportTreeItem extends TreeItem {
296295
const scopeTypeType = uriEncodeHashId(
297296
serializeScopeType(this.scopeTypeInfo.scopeType),
298297
);
299-
this.url = `https://www.cursorless.org/docs/user/languages/${languageId}#${scopeTypeType}`;
298+
this.url = `${DOCS_URL}/user/languages/${languageId}#${scopeTypeType}`;
300299
this.contextValue = "scopeVisualizerTreeItem";
301300
}
302301
}

0 commit comments

Comments
 (0)