|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <title>CommitCode Options</title> |
| 6 | + <link rel="stylesheet" href="./index.css"> |
| 7 | +</head> |
| 8 | +<body> |
| 9 | + <div class="container"> |
| 10 | + <header> |
| 11 | + <h1>CommitCode Settings</h1> |
| 12 | + <p>Configure your GitHub connection and synchronization preferences.</p> |
| 13 | + </header> |
| 14 | + |
| 15 | + <main> |
| 16 | + <section class="card"> |
| 17 | + <h2>GitHub Connection</h2> |
| 18 | + |
| 19 | + <button id="open-setup-modal" class="btn btn-secondary" style="margin-bottom: 20px; width: 100%;">ℹ️ How to configure CommitCode (Setup Guide)</button> |
| 20 | + |
| 21 | + <div class="form-group"> |
| 22 | + <label for="pat">Personal Access Token (PAT)</label> |
| 23 | + <input type="password" id="pat" placeholder="ghp_xxxxxxxxxxxxxxxxxxxx"> |
| 24 | + <small>Needs <strong>Contents: Read and write</strong> permission on a fine-grained token. Stored securely in local storage.</small> |
| 25 | + </div> |
| 26 | + |
| 27 | + <div class="form-group"> |
| 28 | + <label for="repo">Repository</label> |
| 29 | + <input type="text" id="repo" placeholder="username/repository"> |
| 30 | + </div> |
| 31 | + |
| 32 | + <div class="test-connection-wrapper"> |
| 33 | + <button id="test-connection-btn" class="btn btn-secondary">Test Connection</button> |
| 34 | + <span id="test-status"></span> |
| 35 | + </div> |
| 36 | + </section> |
| 37 | + |
| 38 | + <section class="card"> |
| 39 | + <h2>Sync Preferences</h2> |
| 40 | + |
| 41 | + <div class="form-group"> |
| 42 | + <label for="folder-structure">Folder Structure</label> |
| 43 | + <select id="folder-structure"> |
| 44 | + <option value="Difficulty">Difficulty (e.g. Medium/two-sum_v1.cpp)</option> |
| 45 | + <option value="Topic">Topic (e.g. Array/two-sum_v1.cpp)</option> |
| 46 | + <option value="Language">Language (e.g. python/two-sum_v1.py)</option> |
| 47 | + <option value="Number">Number (e.g. 0001/two-sum_v1.cpp)</option> |
| 48 | + <option value="Flat">Flat (e.g. two-sum_v1.cpp)</option> |
| 49 | + </select> |
| 50 | + </div> |
| 51 | + |
| 52 | + <div class="form-group"> |
| 53 | + <label for="version-mode">Version Mode</label> |
| 54 | + <select id="version-mode"> |
| 55 | + <option value="versioned">Versioned (Keep all submissions: _v1, _v2)</option> |
| 56 | + <option value="overwrite">Overwrite (Replace the same file each time)</option> |
| 57 | + </select> |
| 58 | + <small>Versioned keeps a full history of your submissions as separate files. Overwrite updates a single file in place to reduce clutter.</small> |
| 59 | + </div> |
| 60 | + </section> |
| 61 | + |
| 62 | + <div class="actions"> |
| 63 | + <span id="save-status"></span> |
| 64 | + <button id="save-btn" class="btn btn-primary">Save Settings</button> |
| 65 | + </div> |
| 66 | + </main> |
| 67 | + </div> |
| 68 | + <div id="setup-modal" class="modal"> |
| 69 | + <div class="modal-content setup-modal-content"> |
| 70 | + <span class="modal-close" id="setup-modal-close">×</span> |
| 71 | + <h2>How to Configure CommitCode</h2> |
| 72 | + |
| 73 | + <ol> |
| 74 | + <li> |
| 75 | + <strong>Create a NEW, empty repository</strong> specifically for CommitCode (e.g. <code>leetcode-solutions</code>). |
| 76 | + Do NOT point it at an existing personal repo. CommitCode will write files directly into the repo root or configured folders and could clutter or conflict with existing content. |
| 77 | + </li> |
| 78 | + <li> |
| 79 | + Generate a correctly-scoped fine-grained Personal Access Token (PAT): |
| 80 | + <ul> |
| 81 | + <li>Click on your GitHub profile and go to <strong>Settings</strong>.<br><img src="./assets/Settings.png" class="instruction-img"></li> |
| 82 | + <li>Under access, click <strong>Credentials</strong>.<br><img src="./assets/Credentials.png" class="instruction-img"></li> |
| 83 | + <li>Click on <strong>"Fine-grained personal access token"</strong>.<br><img src="./assets/PAT.png" class="instruction-img"></li> |
| 84 | + <li>Click on <strong>"Generate new token"</strong>.<br><img src="./assets/Generate New Token.png" class="instruction-img"></li> |
| 85 | + <li>Enter a token name, like <code>commitcode token</code>.</li> |
| 86 | + <li>Under <strong>Expiration date</strong>, you can set it to no expiration, otherwise after expiry you'll have to manually change it.</li> |
| 87 | + <li>Under <strong>Repository access</strong>, click <strong>"Only select repositories"</strong> and then select the newly created repo.<br><img src="./assets/Select Repository Access.png" class="instruction-img"></li> |
| 88 | + <li>Under <strong>Permissions</strong>, click <strong>"Add Permissions"</strong>, and add <strong>"Contents"</strong>.<br><img src="./assets/Content Permission.png" class="instruction-img"></li> |
| 89 | + <li>Change access of contents from read only to <strong>"read and write"</strong>. <strong>Every other permission should stay at "No access"</strong>.<br><img src="./assets/Read and Write.png" class="instruction-img"></li> |
| 90 | + <li>Click on <strong>Generate token</strong>, and copy the token (it can be seen only once).</li> |
| 91 | + </ul> |
| 92 | + </li> |
| 93 | + <li> |
| 94 | + Paste the token in the PAT section below, and write the repo name in the Repository field in the format: <code>username/repo-name</code>. |
| 95 | + </li> |
| 96 | + <li> |
| 97 | + Click <strong>"Test Connection"</strong> before saving, then select your sync preferences. |
| 98 | + </li> |
| 99 | + </ol> |
| 100 | + <div class="security-note"> |
| 101 | + <strong>Security Note:</strong> Your token is stored locally on your device via <code>chrome.storage.local</code>. It is never transmitted anywhere except directly to GitHub's API. This relies on your OS's disk encryption rather than any custom encryption by CommitCode. |
| 102 | + </div> |
| 103 | + </div> |
| 104 | + </div> |
| 105 | + <script type="module" src="./index.ts"></script> |
| 106 | +</body> |
| 107 | +</html> |
0 commit comments