From fec083d502f4d0480b27caec9b609e548883102e Mon Sep 17 00:00:00 2001 From: Cats1337 Date: Wed, 22 Feb 2023 23:36:19 -0500 Subject: [PATCH 1/3] GitHub account button --- package.json | 35 +++++++++++++++++++++++++++-------- src/activity.ts | 12 ++++++++++++ src/constants.ts | 3 +++ src/util.ts | 3 +++ 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 0145bd43a4..162f9417e0 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,13 @@ { - "name": "discord-vscode", - "displayName": "Discord Presence", + "name": "cats-discord-vscode", + "displayName": "Cats Discord Presence", "version": "5.8.0", "description": "Update your discord status with a rich presence.", "private": true, "author": { + "name": "Cats" + }, + "originalAuthor": { "name": "iCrawl", "email": "icrawltogo@gmail.com" }, @@ -68,12 +71,12 @@ }, "discord.detailsEditing": { "type": "string", - "default": "Editing {file_name}", + "default": "Editing", "description": "Custom string for the details section of the rich presence\n\t- '{empty}' will be replaced with an empty space.\n\t- '{file_name}' will be replaced with the current file name.\n\t- '{dir_name}' will get replaced with the folder name that has the current file.\n\t- '{full_dir_name}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{workspace_folder}' will be replaced with the currently accessed workspace folder, if any.\n\t- '{workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - WorkspaceFolder'\n\t- '{current_column}' will get replaced with the current column of the current line.\n\t- '{current_line}' will get replaced with the current line number.\n\t- '{total_lines}' will get replaced with the total line number.\n\t- '{file_size}' will get replaced with the current file's size.\n\t- '{git_repo_name}' will be replaced with the active Git repository name (from the git URL)\n\t- '{git_branch}' will be replaced with the current active branch name." }, "discord.detailsDebugging": { "type": "string", - "default": "Debugging {file_name}", + "default": "Debugging", "description": "Custom string for the details section of the rich presence when debugging\n\t- '{empty}' will be replaced with an empty space.\n\t- '{file_name}' will be replaced with the current file name.\n\t- '{dir_name}' will get replaced with the folder name that has the current file.\n\t- '{full_dir_name}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{workspace_folder}' will be replaced with the currently accessed workspace folder, if any.\n\t- '{workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - WorkspaceFolder'\n\t- '{current_column}' will get replaced with the current column of the current line.\n\t- '{current_line}' will get replaced with the current line number.\n\t- '{total_lines}' will get replaced with the total line number.\n\t- '{file_size}' will get replaced with the current file's size.\n\t- '{git_repo_name}' will be replaced with the active Git repository name (from the git URL)\n\t- '{git_branch}' will be replaced with the current active branch name." }, "discord.lowerDetailsIdling": { @@ -83,12 +86,12 @@ }, "discord.lowerDetailsEditing": { "type": "string", - "default": "Workspace: {workspace}", + "default": "Workspace:", "description": "Custom string for the state section of the rich presence\n\t- '{empty}' will be replaced with an empty space.\n\t- '{file_name}' will be replaced with the current file name.\n\t- '{dir_name}' will get replaced with the folder name that has the current file.\n\t- '{full_dir_name}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{workspace_folder}' will be replaced with the currently accessed workspace folder, if any.\n\t- '{workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - WorkspaceFolder'\n\t- '{current_column}' will get replaced with the current column of the current line.\n\t- '{current_line}' will get replaced with the current line number.\n\t- '{total_lines}' will get replaced with the total line number.\n\t- '{file_size}' will get replaced with the current file's size.\n\t- '{git_repo_name}' will be replaced with the active Git repository name (from the git URL)\n\t- '{git_branch}' will be replaced with the current active branch name." }, "discord.lowerDetailsDebugging": { "type": "string", - "default": "Debugging: {workspace}", + "default": "Debugging:", "description": "Custom string for the state section of the rich presence when debugging\n\t- '{empty}' will be replaced with an empty space.\n\t- '{file_name}' will be replaced with the current file name.\n\t- '{dir_name}' will get replaced with the folder name that has the current file.\n\t- '{full_dir_name}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{workspace_folder}' will be replaced with the currently accessed workspace folder, if any.\n\t- '{workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - WorkspaceFolder'\n\t- '{current_column}' will get replaced with the current column of the current line.\n\t- '{current_line}' will get replaced with the current line number.\n\t- '{total_lines}' will get replaced with the total line number.\n\t- '{file_size}' will get replaced with the current file's size.\n\t- '{git_repo_name}' will be replaced with the active Git repository name (from the git URL)\n\t- '{git_branch}' will be replaced with the current active branch name." }, "discord.lowerDetailsNoWorkspaceFound": { @@ -136,7 +139,7 @@ }, "discord.removeLowerDetails": { "type": "boolean", - "default": false, + "default": true, "description": "Removes the lower details" }, "discord.removeTimestamp": { @@ -146,13 +149,28 @@ }, "discord.removeRemoteRepository": { "type": "boolean", - "default": false, + "default": true, "description": "Removes the View Repository button" }, "discord.idleTimeout": { "type": "number", "default": 0, "description": "Time (in seconds) to clear the presence when idling. 0 (the default) means no clearing" + }, + "discord.gitHubButtonURL": { + "type": "string", + "default": "https://github.com/", + "description": "Custom string URL for the github button" + }, + "discord.gitHubButton": { + "type": "string", + "default": "GitHub", + "description": "Custom string for the github button name" + }, + "discord.removeGitHubButton": { + "type": "boolean", + "default": false, + "description": "Adds a button to the rich presence that opens your github" } } } @@ -186,6 +204,7 @@ "bufferutil": "^4.0.6", "dayjs": "^1.11.3", "discord-rpc": "^4.0.1", + "generator-code": "^1.7.3", "lodash-es": "^4.17.21", "tslib": "^2.4.0", "utf-8-validate": "^5.0.9" diff --git a/src/activity.ts b/src/activity.ts index a3544565ec..3f5e651bf3 100644 --- a/src/activity.ts +++ b/src/activity.ts @@ -171,6 +171,9 @@ export async function activity(previous: ActivityPayload = {}) { const removeDetails = config[CONFIG_KEYS.RemoveDetails]; const removeLowerDetails = config[CONFIG_KEYS.RemoveLowerDetails]; const removeRemoteRepository = config[CONFIG_KEYS.RemoveRemoteRepository]; + const gitHubButtonURL = config[CONFIG_KEYS.GitHubButtonURL]; + const gitHubButton = config[CONFIG_KEYS.GitHubButton]; + const removeGitHubButton = config[CONFIG_KEYS.RemoveGitHubButton]; const git = await getGit(); @@ -212,6 +215,15 @@ export async function activity(previous: ActivityPayload = {}) { } } +// enable or disable GitHub button + if(!removeGitHubButton){ + state = { + ...state, + buttons: [{ label: gitHubButton, url: gitHubButtonURL }], + }; + } + + if (window.activeTextEditor) { const largeImageKey = resolveFileIcon(window.activeTextEditor.document); const largeImageText = config[CONFIG_KEYS.LargeImage] diff --git a/src/constants.ts b/src/constants.ts index 84ddb8b0ff..7156a47099 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -58,4 +58,7 @@ export const enum CONFIG_KEYS { RemoveTimestamp = 'removeTimestamp', RemoveRemoteRepository = 'removeRemoteRepository', IdleTimeout = 'idleTimeout', + GitHubButtonURL = 'gitHubButtonURL', + GitHubButton = 'gitHubButton', + RemoveGitHubButton = 'removeGitHubButton', } diff --git a/src/util.ts b/src/util.ts index 9bd24dfd22..e881dad692 100644 --- a/src/util.ts +++ b/src/util.ts @@ -27,6 +27,9 @@ type WorkspaceExtensionConfiguration = WorkspaceConfiguration & { removeTimestamp: boolean; removeRemoteRepository: boolean; idleTimeout: number; + gitHubButtonURL: string; + gitHubButton: string; + removeGitHubButton: boolean; }; export function getConfig() { From f218a36dfb272d7b133b4d151384da694ccf4781 Mon Sep 17 00:00:00 2001 From: Cats <42129397+Cats1337@users.noreply.github.com> Date: Wed, 22 Feb 2023 23:39:05 -0500 Subject: [PATCH 2/3] 5.8.0 -> 5.8.1 --- package.json | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 162f9417e0..f1e5ea74b9 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,10 @@ { - "name": "cats-discord-vscode", - "displayName": "Cats Discord Presence", - "version": "5.8.0", + "name": "discord-vscode", + "displayName": "Discord Presence", + "version": "5.8.1", "description": "Update your discord status with a rich presence.", "private": true, "author": { - "name": "Cats" - }, - "originalAuthor": { "name": "iCrawl", "email": "icrawltogo@gmail.com" }, From c96959f9a5ba45b58f45fce9db060f5d2da363dc Mon Sep 17 00:00:00 2001 From: Cats <42129397+Cats1337@users.noreply.github.com> Date: Wed, 22 Feb 2023 23:40:46 -0500 Subject: [PATCH 3/3] Forgot I removed some default attributes --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index f1e5ea74b9..91de4208c8 100644 --- a/package.json +++ b/package.json @@ -68,12 +68,12 @@ }, "discord.detailsEditing": { "type": "string", - "default": "Editing", + "default": "Editing {file_name}", "description": "Custom string for the details section of the rich presence\n\t- '{empty}' will be replaced with an empty space.\n\t- '{file_name}' will be replaced with the current file name.\n\t- '{dir_name}' will get replaced with the folder name that has the current file.\n\t- '{full_dir_name}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{workspace_folder}' will be replaced with the currently accessed workspace folder, if any.\n\t- '{workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - WorkspaceFolder'\n\t- '{current_column}' will get replaced with the current column of the current line.\n\t- '{current_line}' will get replaced with the current line number.\n\t- '{total_lines}' will get replaced with the total line number.\n\t- '{file_size}' will get replaced with the current file's size.\n\t- '{git_repo_name}' will be replaced with the active Git repository name (from the git URL)\n\t- '{git_branch}' will be replaced with the current active branch name." }, "discord.detailsDebugging": { "type": "string", - "default": "Debugging", + "default": "Debugging {file_name}", "description": "Custom string for the details section of the rich presence when debugging\n\t- '{empty}' will be replaced with an empty space.\n\t- '{file_name}' will be replaced with the current file name.\n\t- '{dir_name}' will get replaced with the folder name that has the current file.\n\t- '{full_dir_name}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{workspace_folder}' will be replaced with the currently accessed workspace folder, if any.\n\t- '{workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - WorkspaceFolder'\n\t- '{current_column}' will get replaced with the current column of the current line.\n\t- '{current_line}' will get replaced with the current line number.\n\t- '{total_lines}' will get replaced with the total line number.\n\t- '{file_size}' will get replaced with the current file's size.\n\t- '{git_repo_name}' will be replaced with the active Git repository name (from the git URL)\n\t- '{git_branch}' will be replaced with the current active branch name." }, "discord.lowerDetailsIdling": { @@ -83,12 +83,12 @@ }, "discord.lowerDetailsEditing": { "type": "string", - "default": "Workspace:", + "default": "Workspace: {workspace}", "description": "Custom string for the state section of the rich presence\n\t- '{empty}' will be replaced with an empty space.\n\t- '{file_name}' will be replaced with the current file name.\n\t- '{dir_name}' will get replaced with the folder name that has the current file.\n\t- '{full_dir_name}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{workspace_folder}' will be replaced with the currently accessed workspace folder, if any.\n\t- '{workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - WorkspaceFolder'\n\t- '{current_column}' will get replaced with the current column of the current line.\n\t- '{current_line}' will get replaced with the current line number.\n\t- '{total_lines}' will get replaced with the total line number.\n\t- '{file_size}' will get replaced with the current file's size.\n\t- '{git_repo_name}' will be replaced with the active Git repository name (from the git URL)\n\t- '{git_branch}' will be replaced with the current active branch name." }, "discord.lowerDetailsDebugging": { "type": "string", - "default": "Debugging:", + "default": "Debugging: {workspace}", "description": "Custom string for the state section of the rich presence when debugging\n\t- '{empty}' will be replaced with an empty space.\n\t- '{file_name}' will be replaced with the current file name.\n\t- '{dir_name}' will get replaced with the folder name that has the current file.\n\t- '{full_dir_name}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{workspace_folder}' will be replaced with the currently accessed workspace folder, if any.\n\t- '{workspace_and_folder} will be replaced with the currently accessed workspace and workspace folder like this: 'Workspace - WorkspaceFolder'\n\t- '{current_column}' will get replaced with the current column of the current line.\n\t- '{current_line}' will get replaced with the current line number.\n\t- '{total_lines}' will get replaced with the total line number.\n\t- '{file_size}' will get replaced with the current file's size.\n\t- '{git_repo_name}' will be replaced with the active Git repository name (from the git URL)\n\t- '{git_branch}' will be replaced with the current active branch name." }, "discord.lowerDetailsNoWorkspaceFound": { @@ -136,7 +136,7 @@ }, "discord.removeLowerDetails": { "type": "boolean", - "default": true, + "default": false, "description": "Removes the lower details" }, "discord.removeTimestamp": { @@ -146,7 +146,7 @@ }, "discord.removeRemoteRepository": { "type": "boolean", - "default": true, + "default": false, "description": "Removes the View Repository button" }, "discord.idleTimeout": {