Skip to content

Commit

Permalink
A new start
Browse files Browse the repository at this point in the history
  • Loading branch information
langningchen committed Oct 25, 2024
0 parents commit 710a760
Show file tree
Hide file tree
Showing 680 changed files with 70,108 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
out
dist
node_modules
.vscode-test/
*.vsix
pnpm-lock.yaml
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable-pre-post-scripts = true
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
27 changes: 27 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"search.exclude": {
"out": true
},
"typescript.tsc.autoDetect": "off",
"cSpell.words": [
"autorefresh",
"chtml",
"clike",
"codicon",
"codicons",
"CYEZOI",
"foldcode",
"foldgutter",
"mathjax",
"newoj",
"pdoc",
"pdocs",
"ppcount",
"problemset",
"psdict",
"psdoc",
"rdoc",
"realname"
],
"explorer.excludeGitIgnore": true
}
18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Change Log

All notable changes to the "cyezoi" extension will be documented in this file.

## [Unreleased]

- Initial release
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# CYEZOI README

CYEZOI is an extension that can help user get and submit problems without opening the browser.

## Features

TODO

## Requirements

Users using this extension should have [an CYEZOI account](https://newoj.cyezoi.com).

## Extension Settings

This extension contributes the following settings:

* `myExtension.enable`: Enable/disable this extension.
* `myExtension.thing`: Set to `blah` to do something.

## Known Issues

None

## Release Notes

Users appreciate release notes as you update your extension.

### 1.0.0

Initial release of ...

### 1.0.1

Fixed issue #.

### 1.1.0

Added features X, Y, and Z.
28 changes: 28 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";

export default [{
files: ["**/*.ts"],
}, {
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 2022,
sourceType: "module",
},

rules: {
"@typescript-eslint/naming-convention": ["warn", {
selector: "import",
format: ["camelCase", "PascalCase"],
}],

curly: "warn",
eqeqeq: "warn",
"no-throw-literal": "warn",
semi: "warn",
},
}];
110 changes: 110 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"name": "cyezoi",
"displayName": "CYEZOI Helper",
"description": "",
"version": "0.0.1",
"engines": {
"vscode": "^1.94.0"
},
"categories": [
"Other"
],
"activationEvents": [],
"main": "./out/extension.js",
"contributes": {
"views": {
"explorer": [
{
"id": "cyezoi",
"name": "CYEZOI"
}
]
},
"treeView": [
{
"id": "cyezoi",
"name": "CYEZOI"
}
],
"commands": [
{
"command": "cyezoi.login",
"title": "CYEZOI: Login"
},
{
"command": "cyezoi.openOutput",
"title": "CYEZOI: Open Output"
},
{
"command": "cyezoi.logout",
"title": "CYEZOI: Logout"
},
{
"command": "cyezoi.refreshProblemTree",
"title": "CYEZOI: Refresh Problem Tree",
"icon": {
"light": "res/icons/refresh-light.svg",
"dark": "res/icons/refresh-dark.svg"
}
},
{
"command": "cyezoi.openProblem",
"title": "CYEZOI: Open Problem"
},
{
"command": "cyezoi.submitProblem",
"title": "CYEZOI: Submit Problem",
"icon": {
"light": "res/icons/send-light.svg",
"dark": "res/icons/send-dark.svg"
}
},
{
"command": "cyezoi.openSubmission",
"title": "CYEZOI: Open Submission"
}
],
"menus": {
"view/title": [
{
"command": "cyezoi.refreshProblemTree",
"when": "view == cyezoi",
"group": "navigation"
}
],
"view/item/context": [
{
"command": "cyezoi.submitProblem",
"when": "viewItem == problem",
"group": "inline"
}
]
}
},
"scripts": {
"vscode:prepublish": "pnpm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "pnpm run compile && pnpm run lint",
"lint": "eslint src",
"test": "vscode-test"
},
"devDependencies": {
"@types/mocha": "^10.0.8",
"@types/node": "20.x",
"@types/vscode": "^1.94.0",
"@types/ws": "^8.5.12",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@vscode/test-cli": "^0.0.10",
"@vscode/test-electron": "^2.4.1",
"eslint": "^9.11.1",
"typescript": "^5.6.2"
},
"dependencies": {
"@vscode/codicons": "^0.0.36",
"hydrooj": "^4.16.1",
"marked": "^14.1.3",
"ws": "^8.18.0"
}
}
Binary file added res/fonts/hydro-icons.woff2
Binary file not shown.
22 changes: 22 additions & 0 deletions res/html/problem.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">

<head>
<style>
@font-face {
font-family: 'hydro-icons';
src: url('{{hydroIconsFile}}') format('woff2');
font-weight: normal;
font-style: normal;
}
</style>
{{staticFiles}}
</head>

<body>
<h1 id="title">Loading...</h1>
<vscode-button disabled icon="check" id="submitProblem">Submit</vscode-button>
<div id="problem"></div>
</body>

</html>
62 changes: 62 additions & 0 deletions res/html/problem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const vscode = window.acquireVsCodeApi();
window.MathJax = {
tex: {
inlineMath: [['$', '$']],
displayMath: [['$$', '$$']],
},
};

window.addEventListener('DOMContentLoaded', () => {
const title = document.getElementById('title');
const submitProblem = document.getElementById('submitProblem');
const problem = document.getElementById('problem');
window.addEventListener('message', event => {
const message = event.data;
switch (message.command) {
case 'notFound':
problem.innerHTML = 'Problem not found';
break;
case 'problem':
title.innerText = '#' + message.data.problemId + '. ' + message.data.title;
submitProblem.addEventListener('click', () => {
vscode.postMessage({ command: 'submitProblem', problemId: message.data.problemId });
});
submitProblem.disabled = false;
problem.innerHTML = message.data.markdownContent.zh;
window.MathJax.typeset();
const pre = problem.getElementsByTagName('pre');
const editors = [];
for (let i = 0; i < pre.length; i++) {
const code = pre[i].innerText.trim();
const codeElement = document.createElement('div');
const copyButton = document.createElement('vscode-button');
copyButton.innerText = 'Copy';
copyButton.onclick = () => {
navigator.clipboard.writeText(code);
copyButton.innerText = 'Copied';
copyButton.disabled = true;
setTimeout(() => {
copyButton.innerText = 'Copy';
copyButton.disabled = false;
}, 1000);
};
codeElement.appendChild(copyButton);
const editorElement = document.createElement('div');
codeElement.appendChild(editorElement);
editors.push(window.CodeMirror(editorElement, {
autoRefresh: true,
value: code,
readOnly: true,
theme: 'material',
}));
pre[i].parentNode.replaceChild(codeElement, pre[i]);
}
for (let i = 0; i < editors.length; i++) {
editors[i].setSize('100%', 'auto');
}
break;
default:
break;
}
});
});
Loading

0 comments on commit 710a760

Please sign in to comment.