Skip to content

Commit 386326f

Browse files
committed
fixes #32 - introduce full edit URL
1 parent 0a0ece9 commit 386326f

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.github/workflows/xlog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
--activitypub.username=app \
5252
--activitypub.summary="Xlog is a static site generator for digital gardening written in Go. It serves markdown files as HTML and allows editing files online. It focuses on enriching markdown files and surfacing implicit links between pages." \
5353
--og.domain xlog.emadelsaid.com \
54-
--github.repo https://github.com/emad-elsaid/xlog
54+
--github.url https://github.com/emad-elsaid/xlog/edit/master/docs
5555
mv docs/* .
5656
rm *.md
5757
chmod -R 0777 .

extensions/github/main.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ import (
44
"flag"
55
"fmt"
66
"html/template"
7-
"net/url"
87

98
. "github.com/emad-elsaid/xlog"
109
)
1110

11+
var editUrl string
1212
var repo string
1313
var branch string
1414

1515
func init() {
16-
flag.StringVar(&repo, "github.repo", "", "Github repository to use for 'edit on Github' quick action e.g https://github.com/emad-elsaid/xlog")
17-
flag.StringVar(&branch, "github.branch", "master", "Github repository branch to use for 'edit on Github' quick action")
16+
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")
1819
RegisterQuickCommand(quickCommands)
1920
}
2021

2122
func quickCommands(p Page) []Command {
22-
if len(repo) == 0 {
23+
if len(repo) == 0 && len(editUrl) == 0 {
2324
return nil
2425
}
2526

@@ -37,7 +38,11 @@ func (e editOnGithub) Name() string {
3738
return "Edit on Github"
3839
}
3940
func (e editOnGithub) Link() string {
40-
return fmt.Sprintf("%s/edit/%s/%s", repo, branch, url.PathEscape(e.page.FileName()))
41+
if len(editUrl) > 0 {
42+
return fmt.Sprintf("%s/%s", editUrl, e.page.FileName())
43+
} else {
44+
return fmt.Sprintf("%s/edit/%s/%s", repo, branch, e.page.FileName())
45+
}
4146
}
4247
func (e editOnGithub) OnClick() template.JS {
4348
return ""

0 commit comments

Comments
 (0)