Skip to content

Commit 2a3c817

Browse files
committed
- added ability to hide searchbar
- added section that explains what token permissions are needed
1 parent 2979487 commit 2a3c817

File tree

2 files changed

+69
-27
lines changed

2 files changed

+69
-27
lines changed

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@ Obsidian GitHub Issues is a plugin for the Obsidian note-taking app that enables
99
- **Rich Preview:** View a comprehensive preview of the embedded issues, including their status, comments, assignees, labels, and other relevant details. This feature helps you quickly gain context and stay informed about the progress of your issues.
1010

1111
## Installation
12+
13+
### Prerequisites
14+
Before installing the Obsidian GitHub Issues plugin, you need to generate a Personal Access Token (PAT) for your GitHub account. This token is used to authenticate your Obsidian app with GitHub and enable the plugin to access your GitHub repositories. To generate a PAT, follow these steps:
15+
16+
- Navigate to your GitHub account settings.
17+
- Click on the "Developer Settings" tab.
18+
- Select "Personal Access Tokens" from the sidebar.
19+
- Click on the "Generate New Token (classic)" button.
20+
- Give it a name and an expiration date.
21+
- The token needs the following permissions:
22+
- If you want to use the plugin with public and private repositories, you need to select the following permissions:
23+
- repo (Full control of private repositories)
24+
- If you only want to use the plugin with public repositories, you need to select the following permissions:
25+
- public_repo (Access public repositories)
26+
- Click on the "Generate Token" button.
27+
- Copy the generated token and save it somewhere safe.
28+
- **Note:** This token is only displayed once. If you lose it, you will have to generate a new one.
29+
30+
### Install from Obsidian
31+
1232
To install the Obsidian GitHub Issues plugin, follow these steps:
1333

1434
- Open Obsidian and navigate to the "Community Plugins" section in the settings.
@@ -17,4 +37,11 @@ To install the Obsidian GitHub Issues plugin, follow these steps:
1737
- Click the "Install" button next to the plugin name.
1838
- Once the installation is complete, open the plugin settings and enter your GitHub Username and Personal Access Token
1939

40+
### Install from GitHub
41+
42+
To install the Obsidian GitHub Issues plugin from GitHub, follow these steps:
2043

44+
- Download the latest release of the plugin from the GitHub repository
45+
- Extract the contents of the zip file into your Obsidian vault's plugins folder.
46+
- Open the plugin settings and enter your GitHub Username and Personal Access Token
47+
- Reload Obsidian to activate the plugin.

main.ts

+42-27
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ interface MyPluginSettings {
1919
username: string;
2020
password: string
2121
issue_appearance: IssueAppearance;
22+
show_searchbar: boolean;
2223
}
2324

2425
const DEFAULT_SETTINGS: MyPluginSettings = {
2526
username: '',
2627
password: '',
27-
issue_appearance: IssueAppearance.DEFAULT
28+
issue_appearance: IssueAppearance.DEFAULT,
29+
show_searchbar: true
2830
}
2931

3032
export default class MyPlugin extends Plugin {
@@ -95,32 +97,33 @@ export default class MyPlugin extends Plugin {
9597
refreshButton.style.left = "3px"
9698
refreshButton.style.top = "3px"
9799

98-
const searchfield = el.createEl("input")
99-
searchfield.setAttribute("type", "text")
100-
searchfield.setAttribute("placeholder", "Search Titles, Labels,...")
101-
searchfield.style.backgroundColor = "inherit";
102-
searchfield.style.width = "80%"
103-
searchfield.style.marginTop = "10px"
104-
searchfield.style.height = "30px"
105-
searchfield.style.boxShadow = 'none'
106-
searchfield.style.padding = '10px'
107-
searchfield.style.alignItems = 'center'
108-
searchfield.style.justifyContent = 'center'
109-
searchfield.style.cursor = "pointer"
110-
111-
searchfield.addEventListener("input", () => {
112-
//go through the children of "el" and hide all that don't match the search if the search is empty show all
113-
const search = searchfield.value.toLowerCase()
114-
el.childNodes.forEach((child) => {
115-
if(child instanceof HTMLElement){
116-
if(child.innerText.toLowerCase().includes(search)){
117-
child.style.display = "flex"
118-
} else if (child !== refreshButton && child !== searchfield){
119-
child.style.display = "none"
100+
if(this.settings.show_searchbar) {
101+
const searchfield = el.createEl("input")
102+
searchfield.setAttribute("type", "text")
103+
searchfield.setAttribute("placeholder", "Search Titles, Labels,...")
104+
searchfield.style.backgroundColor = "inherit";
105+
searchfield.style.width = "80%"
106+
searchfield.style.marginTop = "10px"
107+
searchfield.style.height = "30px"
108+
searchfield.style.boxShadow = 'none'
109+
searchfield.style.padding = '10px'
110+
searchfield.style.alignItems = 'center'
111+
searchfield.style.justifyContent = 'center'
112+
113+
searchfield.addEventListener("input", () => {
114+
//go through the children of "el" and hide all that don't match the search if the search is empty show all
115+
const search = searchfield.value.toLowerCase()
116+
el.childNodes.forEach((child) => {
117+
if (child instanceof HTMLElement) {
118+
if (child.innerText.toLowerCase().includes(search)) {
119+
child.style.display = "flex"
120+
} else if (child !== refreshButton && child !== searchfield) {
121+
child.style.display = "none"
122+
}
120123
}
121-
}
122-
})
123-
});
124+
})
125+
}); searchfield.style.cursor = "pointer"
126+
}
124127

125128
refreshButton.addEventListener("mouseenter", () => {
126129
refreshButton.style.background = "var(--background-modifier-hover)"
@@ -333,13 +336,25 @@ class GithubIssuesSettings extends PluginSettingTab {
333336
.addDropdown(dropdown => dropdown
334337
.addOption(IssueAppearance.DEFAULT, "Default")
335338
.addOption(IssueAppearance.COMPACT, "Compact")
336-
.setValue("default")
339+
.setValue(this.plugin.settings.issue_appearance)
337340
.onChange(async (value: IssueAppearance) => {
338341
console.log("Appearance: " + value)
339342
this.plugin.settings.issue_appearance = value;
340343
await this.plugin.saveSettings()
341344
//TODO trigger a rerender of the issues
342345
}));
346+
new Setting(containerEl)
347+
.setName("Show Searchbar")
348+
.setDesc("Show a searchbar above the issues in the embed.")
349+
.addToggle(toggle => toggle
350+
.setValue(this.plugin.settings.show_searchbar)
351+
.onChange(async (value) => {
352+
console.log("Show Searchbar: " + value)
353+
this.plugin.settings.show_searchbar = value;
354+
await this.plugin.saveSettings()
355+
//TODO trigger a rerender of the issues
356+
357+
}));
343358
}
344359
}
345360

0 commit comments

Comments
 (0)