|
7 | 7 | clip "github.com/atotto/clipboard"
|
8 | 8 | cp "github.com/otiai10/copy"
|
9 | 9 | watcher "github.com/radovskyb/watcher"
|
| 10 | + github "github.com/google/go-github/v49/github" |
10 | 11 | wailsruntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
11 | 12 | "io"
|
12 | 13 | "io/ioutil"
|
@@ -50,6 +51,15 @@ type WatcherInfo struct {
|
50 | 51 | SigName string
|
51 | 52 | }
|
52 | 53 |
|
| 54 | +type GitHubRepos struct { |
| 55 | + Name string `json:"name"` |
| 56 | + URL string `json:"url"` |
| 57 | + Stars int `json:"stars"` |
| 58 | + Owner string `json:"owner"` |
| 59 | + ID int64 `json:"id"` |
| 60 | + Description string `json:"description"` |
| 61 | +} |
| 62 | + |
53 | 63 | // NewApp creates a new App application struct
|
54 | 64 | func NewApp() *App {
|
55 | 65 | return &App{}
|
@@ -395,3 +405,43 @@ func (b *App) GetOSName() string {
|
395 | 405 | }
|
396 | 406 | return result
|
397 | 407 | }
|
| 408 | + |
| 409 | +func (b *App) GetGitHubThemes() []GitHubRepos { |
| 410 | + var result []GitHubRepos |
| 411 | + client := github.NewClient(nil) |
| 412 | + topics, _, err := client.Search.Repositories(context.Background(), "in:topic modalfilemanager in:topic theme", nil) |
| 413 | + if err == nil { |
| 414 | + total := *topics.Total; |
| 415 | + result = make([]GitHubRepos, total, total) |
| 416 | + for i := 0; i<total; i++ { |
| 417 | + result[i].ID = *topics.Repositories[i].ID |
| 418 | + result[i].Name = *topics.Repositories[i].Name |
| 419 | + result[i].Owner = *topics.Repositories[i].Owner.Login |
| 420 | + result[i].URL = *topics.Repositories[i].CloneURL |
| 421 | + result[i].Stars = *topics.Repositories[i].StargazersCount |
| 422 | + result[i].Description = *topics.Repositories[i].Description |
| 423 | + } |
| 424 | + } |
| 425 | + return result |
| 426 | +} |
| 427 | + |
| 428 | +func (b *App) GetGitHubScripts() []GitHubRepos { |
| 429 | + var result []GitHubRepos |
| 430 | + client := github.NewClient(nil) |
| 431 | + topics, _, err := client.Search.Repositories(context.Background(), "in:topic modalfilemanager in:topic V2 in:topic extension", nil) |
| 432 | + if err == nil { |
| 433 | + total := *topics.Total; |
| 434 | + result = make([]GitHubRepos, total, total) |
| 435 | + for i := 0; i<total; i++ { |
| 436 | + result[i].ID = *topics.Repositories[i].ID |
| 437 | + result[i].Name = *topics.Repositories[i].Name |
| 438 | + result[i].Owner = *topics.Repositories[i].Owner.Login |
| 439 | + result[i].URL = *topics.Repositories[i].CloneURL |
| 440 | + result[i].Stars = *topics.Repositories[i].StargazersCount |
| 441 | + result[i].Description = *topics.Repositories[i].Description |
| 442 | + } |
| 443 | + } |
| 444 | + return result |
| 445 | +} |
| 446 | + |
| 447 | + |
0 commit comments