Skip to content

Commit fa88cc7

Browse files
committed
remove github repo and branch
1 parent ea803a9 commit fa88cc7

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

docs/Upgrading.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ If you were a user for v1 and would like to upgrade to v2 please take the follow
99
* Your extension can now check for `xlog.Config.Readonly` instead of `xlog.READONLY` during initialization (extension `Init()`)
1010
* `Get/Post/Delete/..etc` doesn't accept middlewares parameters anymore
1111
* The version extension has been removed as it was incomplete. if you are running xlog on the same directory that has `.versions` subdirectories you can remove them by running `rm -rf *.versions`
12+
* `github.repo` and `github.branch` are removed in favor of `github.url` which is the full URL of the editing. so it should work with other git online editors

extensions/github/main.go

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,33 @@ import (
99
)
1010

1111
var editUrl string
12-
var repo string
13-
var branch string
1412

1513
func init() {
1614
flag.StringVar(&editUrl, "github.url", "", "Repository url for 'edit on Github' quick action e.g https://github.com/emad-elsaid/xlog/edit/master/docs")
17-
flag.StringVar(&repo, "github.repo", "", "[Deprecated] Github repository to use for 'edit on Github' quick action e.g https://github.com/emad-elsaid/xlog")
18-
flag.StringVar(&branch, "github.branch", "master", "[Deprecated] Github repository branch to use for 'edit on Github' quick action")
1915
RegisterExtension(Github{})
2016
}
2117

2218
type Github struct{}
2319

2420
func (Github) Name() string { return "github" }
25-
func (Github) Init() { RegisterQuickCommand(quickCommands) }
26-
27-
func quickCommands(p Page) []Command {
28-
if len(repo) == 0 && len(editUrl) == 0 {
29-
return nil
21+
func (Github) Init() {
22+
if len(editUrl) == 0 {
23+
return
3024
}
3125

26+
RegisterQuickCommand(quickCommands)
27+
}
28+
29+
func quickCommands(p Page) []Command {
3230
return []Command{editOnGithub{page: p}}
3331
}
3432

3533
type editOnGithub struct {
3634
page Page
3735
}
3836

39-
func (e editOnGithub) Icon() string { return "fa-brands fa-github" }
40-
func (e editOnGithub) Name() string { return "Edit on Github" }
41-
func (e editOnGithub) Link() string {
42-
if len(editUrl) > 0 {
43-
return fmt.Sprintf("%s/%s", editUrl, e.page.FileName())
44-
} else {
45-
return fmt.Sprintf("%s/edit/%s/%s", repo, branch, e.page.FileName())
46-
}
47-
}
37+
func (e editOnGithub) Icon() string { return "fa-brands fa-github" }
38+
func (e editOnGithub) Name() string { return "Edit on Github" }
39+
func (e editOnGithub) Link() string { return fmt.Sprintf("%s/%s", editUrl, e.page.FileName()) }
4840
func (e editOnGithub) OnClick() template.JS { return "" }
4941
func (e editOnGithub) Widget() template.HTML { return "" }

0 commit comments

Comments
 (0)