Commit: 67b20bc73f66850952910b4300eeecc04ff7bbac
Parent: e6497360da36f49727e2eed52ec311b7bd2d0c56
Author: Vi Grey
Date: 2024-04-29 09:52 UTC
Summary: Save commit pages to txt files
Added:
- -t and --txtoutpath flags
Fixed:
- RSS feed data
Changed:
- Commit pages are now txt files instead of gmi files
- Formatting in CHANGELOG.txt
CHANGELOG.txt | 60 +++++++++++++++++++++++++++---------------------------------
docs/muninn.man | 16 ++++++++--------
src/flags.go | 33 +++++++++++++++++++++++----------
src/gmi.go | 49 ++++++++++++++++++++-----------------------------
src/muninn.go | 12 +++++++++++-
src/rss.go | 20 ++++++--------------
6 files changed, 95 insertions(+), 95 deletions(-)
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 348fbe3..cdc61f1 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,6 +1,20 @@
# Change Log
All notable changes to this project will be documented in this file.
+
+## [0.1.18] - 2024-04-29
+
+### Added
+- -t and --txtoutpath flags
+
+### Fixed
+- RSS feed data
+
+### Changed
+- Commit pages are now txt files instead of gmi files
+- Formatting in CHANGELOG.txt
+
+
## [0.1.17] - 2024-04-29
### Fixed
@@ -41,54 +55,46 @@ All notable changes to this project will be documented in this file.
## [0.1.13] - 2023-11-03
### Added
-
- --excludefiles flag
## [0.1.12] - 2023-11-03
### Changed
-
- Put Parent back in last RSS feed of maxcommit
## [0.1.11] - 2023-11-03
### Fixed
-
- maxCommits check compared to repoCommits len
## [0.1.10] - 2023-11-03
### Added
-
- --maxcommits flag
- max commits functionality for repo pages
### Changed
-
- Replace "Commits:" with datestamp
## [0.1.9] - 2023-09-21
### Added
-
- --repository flag
## [0.1.8] - 2023-09-15
### Changed
-
- Use regex for README and LICENSE file detection
## [0.1.7] - 2023-09-15
### Changed
-
- Remove all \r in commit subject and message
- Remove all newlines at end of commit message
@@ -96,152 +102,140 @@ All notable changes to this project will be documented in this file.
## [0.1.6] - 2023-09-14
### Changed
-
- Remove newlines between commit subject and message
## [0.1.5] - 2023-09-14
### Changed
-
- Git commit summary handling for newlines
## [0.1.4] - 2023-09-14
### Changed
-
- Set commit summaries in commit pages to blockquotes (but not commit message title)
## [0.1.3] - 2023-09-14
### Fixed
-
- escaping in Commit Summary of RSS feed
## [0.1.2] - 2023-09-13
### Fixed
-
- escaping in Commit and Parent fields of RSS feeds
## [0.1.1] - 2023-09-13
### Fixed
-
- escaping in RSS feeds
## [0.1.0] - 2023-09-12
### Removed
-
- All html generation code to focus on gemtext only
## [0.0.14] - 2023-07-08
### Changed
-
- Use git/repo/index.html and git/repo/index.gmi instead of git/repo.html and git/repo.gmi
+
## [0.0.13] - 2023-07-08
### Changed
-
- Use git/index.html and git/index.gmi instead of git.html and git.gmi
+
## [0.0.12] - 2023-05-09
### Added
-
- --stylesheetpath flag to point to stylesheet on HTTP server
- used for + characters in diffs in HTML
- used for - characters in diffs in HTML
+
## [0.0.11] - 2023-05-06
### Added
-
- --mastodon flag to make a rel="me" link for verifying git.html page on mastodon
- Example with --go-input and --mastodon in --help output
- LICENSE.txt and README.txt file options for LICENSE and README links
### Fixed
-
- Set correct version number in muninn.go
+
## [0.0.10] - 2023-05-04
### Changed
-
- If git commit subject is blank, use "Commit " as RSS item title, where is the hash of the commit
+
## [0.0.9] - 2023-05-04
### Changed
-
- git clone line in gmi files is now a link
### Fixed
-
- RSS Feed link in gmi files is now in the correct spot
- RSS Feed link in gmi files is now feed.xml instead of feex.xml
+
## [0.0.8] - 2023-05-04
### Fixed
-
- Using name attribute in go-import meta tag
+
## [0.0.7] - 2023-05-04
### Added
-
- Optional "go-import" meta tags
+
## [0.0.6] - 2023-05-04
### Added
-
- Commit hash, parent commit hash, and author to RSS item description
### Changed
-
- Use git commit subject instead of hash in RSS item titles
+
## [0.0.5] - 2023-05-03
### Fixed
-
- Replace newlines in RSS feed git commit messages with then newline
+
## [0.0.4] - 2023-05-03
### Added
-
- RSS feeds in git repos for commits
+
## [0.0.3] - 2023-05-03
### Fixed
-
- Use `git diff` instead of `git show` in getDiffFileData
+
## [0.0.2] - 2023-05-03
### Fixed
-
- Make Gemtext files safer by placing a space in front of some of the inputs
- Make Gemtext files safer by removing newlines in some of the inputs
- Have only 1 blank line between repos instead of 2 in git.gmi file
+
## [0.0.1] - 2023-05-02
### Added
-
- Initial release
-
diff --git a/docs/muninn.man b/docs/muninn.man
index 364dfce..e6700af 100644
--- a/docs/muninn.man
+++ b/docs/muninn.man
@@ -26,34 +26,34 @@ Directory Path to repositories
Number of commits to show in repo page (0 will show all commits)
.TP
\fB-o\fR, \fB--outpath\fR <\fIpath\fR>
-Directory path for static pages
+Directory path for gemtext files
.TP
\fB-r\fR, \fB--repository\fR <\fIname\fR>
Specify single repository to create directory for (root index.gmi will still contain all git repositories)
.TP
-\fB-s\fR, \fB--stylesheetpath\fR <\fIpath\fR>
-HTTP path for stylesheet
+\fB-t\fR, \fB--textoutpath\fR <\fIpath\fR>
+Directory path for commit txt files (defaults to --outpath value)
.TP
\fB--version\fR
Print version information and exit
.SH EXAMPLES
.SY muninn
--i /git -o /tmp/muninn -h git.example.com -b /repos -m 8
+-i /git -o /tmp/muninn -t /tmp/txt -d git.example.com -b /repos -m 8
.YS
.IP
-(This example generates repo browsing files for the repos in /git on the host machine and stores the statically generated files in /tmp/muninn. The host is git.example.com and the repos would be browsable at git.example.com/repos/, which should be the same location as others can pull the git repos using git. Only up to the last 8 commits for each repo will be shown.)
+(This example generates repo browsing files for the repos in /git on the host machine and stores the gemtext files in /tmp/muninn and the commit txt files in /tmp/txt. The host is git.example.com and the repos would be browsable at git.example.com/repos/, which should be the same location as others can pull the git repos using git. Only up to the last 8 commits for each repo will be shown.)
.SY muninn
--i /git -o /tmp/muninn -h git.example.com -b /repos
+-i /git -o /tmp/muninn -d git.example.com -b /repos
.YS
.IP
(This example generates repo browsing files for the repos in /git on the host machine and stores the statically generated files in /tmp/muninn. The host is git.example.com and the repos would be browsable at git.example.com/repos/, which should be the same location as others can pull the git repos using git.)
.SY muninn
--i /git -o /tmp/muninn -h git.example.com -b /repos -r repo1
+-i /git -o /tmp/muninn -d git.example.com -b /repos -r repo1
.YS
.IP
(This example generates repo browsing files for the repo1 in /git on the host machine and stores the statically generated files in /tmp/muninn. The host is git.example.com and the repos would be browsable at git.example.com/repos/, which should be the same location as others can pull the git repos using git.)
.SY muninn
--i /repos -o /tmp/out -h example.com
+-i /repos -o /tmp/out -d example.com
.YS
.IP
(This example generates repo browsing files for the repos in /repos on the host machine and stores the statically generated files in /tmp/out. The host is example.com and the repos would be browsable at example.com/, which should be the same location as others can pull the get repos using git.)
diff --git a/src/flags.go b/src/flags.go
index 4055a00..77777e2 100644
--- a/src/flags.go
+++ b/src/flags.go
@@ -12,6 +12,7 @@ var (
maxCommits int
inPath string
outPath string
+ txtOutPath string
basePath string
host string
linksExcludeExtension bool
@@ -43,6 +44,15 @@ func handleFlags(args []string) (err error) {
if inPath == "" {
inPath = args[x]
}
+ case "--txtoutpath", "-t":
+ x++
+ if x == len(args) {
+ err = errors.New(fmt.Sprintf("muninn: flag `%s` missing value\nUse `muninn --help` for details", arg))
+ return
+ }
+ if txtOutPath == "" {
+ txtOutPath = args[x]
+ }
case "--outpath", "-o":
x++
if x == len(args) {
@@ -124,36 +134,39 @@ Options:
-i, --inpath Directory Path to repositories
-m, --maxcommits Number of commits to show in repo
page (0 will show all commits)
- -o, --outpath Directory path for static pages
+ -o, --outpath Directory path for gemtext files
-r, --repository Specify single repository to create
directory for (root index.gmi will
still contain all git repositories)
+ -t, --txtoutpath Directory path for commit txt files
+ (defaults to --outputh value)
--version Print version information and exit
Examples:
- %s -i /git -o /tmp/muninn -h git.example.com -b /repos -m 8
+ %s -i /git -o /tmp/muninn -t /tmp/txt -d git.example.com -b /repos \\
+ -m 8
(This example generates repo browsing files for the repos in /git
- on the host machine and stores the statically generated files in
- /tmp/muninn. The host is git.example.com and the repos would be
- browsable at git.example.com/repos/, which should be the same
- location as others can pull the git repos using git. Only up to
- the last 8 commits for each repo will be shown.)
+ on the host machine and stores the gemtext files in /tmp/muninn and
+ the commit txt files in /tmp/txt. The host is git.example.com and
+ the repos would be browsable at git.example.com/repos/, which
+ should be the same location as others can pull the git repos using
+ git. Only up to the last 8 commits for each repo will be shown.)
- %s -i /git -o /tmp/muninn -h git.example.com -b /repos
+ %s -i /git -o /tmp/muninn -d git.example.com -b /repos
(This example generates repo browsing files for the repos in /git
on the host machine and stores the statically generated files in
/tmp/muninn. The host is git.example.com and the repos would be
browsable at git.example.com/repos/, which should be the same
location as others can pull the git repos using git.)
- %s -i /git -o /tmp/muninn -h git.example.com -b /repos -r repo1
+ %s -i /git -o /tmp/muninn -d git.example.com -b /repos -r repo1
(This example generates repo browsing files for the repo1 in /git
on the host machine and stores the statically generated files in
/tmp/muninn. The host is git.example.com and the repos would be
browsable at git.example.com/repos/, which should be the same
location as others can pull the git repos using git.)
- %s -i /repos -o /tmp/out -h example.com
+ %s -i /repos -o /tmp/out -d example.com
(This example generates repo browsing files for the repos in
/repos on the host machine and stores the statically generated
files in /tmp/out. The host is example.com and the repos would
diff --git a/src/gmi.go b/src/gmi.go
index bb501fd..6362dea 100644
--- a/src/gmi.go
+++ b/src/gmi.go
@@ -107,7 +107,7 @@ func writeCommitLogGMI(repo repo, repoCommits []repoCommit) {
commitsLogFile.Write([]byte("## Commits\n\n"))
}
for x := 0; x < maxCommitsLen; x++ {
- commitsLogFile.Write([]byte(fmt.Sprintf("=> %s.gmi %s - %s\n",
+ commitsLogFile.Write([]byte(fmt.Sprintf("=> %s.txt %s - %s\n",
removeNewLines(filepath.Join(basePath, repo.name, "commit",
repoCommits[x].hash)),
repoCommits[x].time.UTC().Format("2006-01-02"),
@@ -195,52 +195,43 @@ func writeRepoFilesGMI(repo repo, repoFiles []repoFile) {
}
func writeCommitFilesGMI(repo repo, repoCommits []repoCommit) {
- if err := os.MkdirAll(filepath.Join(outPath, "git", repo.name, "commit"),
+ commitFileBase := outPath
+ if txtOutPath != "" {
+ commitFileBase = txtOutPath
+ }
+ if err := os.MkdirAll(filepath.Join(commitFileBase, "git", repo.name, "commit"),
0755); err == nil {
maxCommitsLen := len(repoCommits)
if maxCommits > 0 && maxCommits < maxCommitsLen {
maxCommitsLen = maxCommits
}
for x := 0; x < maxCommitsLen; x++ {
- if commitFile, err := os.OpenFile(filepath.Join(outPath, "git",
- repo.name, "commit", repoCommits[x].hash+".gmi"),
+ if commitFile, err := os.OpenFile(filepath.Join(commitFileBase, "git",
+ repo.name, "commit", repoCommits[x].hash+".txt"),
+
os.O_WRONLY|os.O_CREATE, 0644); err == nil {
defer commitFile.Close()
lastCommit := getBaseCommit()
if x < len(repoCommits)-1 {
lastCommit = repoCommits[x+1]
}
- commitFile.Write([]byte(fmt.Sprintf("# %s - Commit %s\n\n",
- removeNewLines(repo.name), repoCommits[x].hash)))
- commitFile.Write(getRepoGMIHeader(repo))
- commitFile.Write([]byte(fmt.Sprintf("## Commit %s\n\n",
+ commitFile.Write([]byte(fmt.Sprintf("Commit: %s\n",
repoCommits[x].hash)))
- commitFile.Write([]byte(fmt.Sprintf("=> %s.gmi Commit: %s\n",
- removeNewLines(filepath.Join(basePath, repo.name, "commit",
- repoCommits[x].hash)), repoCommits[x].hash)))
if x < maxCommitsLen-1 {
- commitFile.Write([]byte(fmt.Sprintf("=> %s.gmi Parent: %s\n",
- removeNewLines(filepath.Join(basePath, repo.name, "commit",
- lastCommit.hash)), removeNewLines(lastCommit.hash))))
+ commitFile.Write([]byte(fmt.Sprintf("Parent: %s\n",
+ removeNewLines(lastCommit.hash))))
}
- commitFile.Write([]byte(fmt.Sprintf("* Author: %s\n",
+ commitFile.Write([]byte(fmt.Sprintf("Author: %s\n",
removeNewLines(repoCommits[x].author))))
- commitFile.Write([]byte(fmt.Sprintf("* Date: %s\n",
+ commitFile.Write([]byte(fmt.Sprintf("Date: %s\n",
repoCommits[x].time.UTC().Format(
"2006-01-02 15:04 UTC"))))
- commitFile.Write([]byte("* Summary: "))
- commitFile.Write(bytes.ReplaceAll(
- getCommitMessage(repoCommits[x], repo.path),
- []byte("\n"), []byte("\n> ")))
- commitFile.Write([]byte("\n\n```\n "))
- commitFile.Write(bytes.ReplaceAll(
- getDiffStats(lastCommit, repoCommits[x], repo.path),
- []byte("\n"), []byte("\n ")))
- commitFile.Write([]byte("\n```\n\n```\n "))
- commitFile.Write(bytes.ReplaceAll(
- getDiffFileData(lastCommit, repoCommits[x], repo.path),
- []byte("\n"), []byte("\n ")))
- commitFile.Write([]byte("\n```\n"))
+ commitFile.Write([]byte("Summary: "))
+ commitFile.Write(getCommitMessage(repoCommits[x], repo.path))
+ commitFile.Write([]byte("\n\n"))
+ commitFile.Write(getDiffStats(lastCommit, repoCommits[x], repo.path))
+ commitFile.Write([]byte("\n\n"))
+ commitFile.Write(getDiffFileData(lastCommit, repoCommits[x], repo.path))
}
}
}
diff --git a/src/muninn.go b/src/muninn.go
index 1d7b90c..c90b108 100644
--- a/src/muninn.go
+++ b/src/muninn.go
@@ -10,7 +10,7 @@ import (
const (
PROGRAM = "muninn"
- VERSION = "0.1.17"
+ VERSION = "0.1.18"
)
func init() {
@@ -29,6 +29,16 @@ func main() {
}
func writeGitReposGmi(repoList []repo) {
+ if txtOutPath != "" {
+ if err := os.MkdirAll(filepath.Join(txtOutPath, "git"),
+ 0755); err != nil {
+ return
+ }
+ }
+ if err := os.MkdirAll(filepath.Join(outPath, "git"),
+ 0755); err != nil {
+ return
+ }
if err := os.MkdirAll(filepath.Join(outPath, "git"),
0755); err != nil {
return
diff --git a/src/rss.go b/src/rss.go
index 57f2f67..59530bb 100644
--- a/src/rss.go
+++ b/src/rss.go
@@ -15,29 +15,21 @@ func writeRSSFeedBottom(f *os.File) {
}
func writeRSSFeedTop(f *os.File, repo repo) {
- extension := ".gmi"
- if linksExcludeExtension {
- extension = ""
- }
f.Write([]byte(fmt.Sprintf(`
%s Commits
- gemini://%s
+ gemini://%s/index.gmi
%sCommits for Git Repository %s
`,
escapeHTMLContent(repo.name),
- escapeHTMLContent(filepath.Join(host, basePath, repo.name+extension)),
+ escapeHTMLContent(filepath.Join(host, basePath, repo.name)),
time.Now().UTC().Format(time.RFC1123Z),
escapeHTMLContent(repo.name))))
}
func writeCommitsRSSFeed(repo repo, repoCommits []repoCommit) {
- extension := ".gmi"
- if linksExcludeExtension {
- extension = ""
- }
if err := os.MkdirAll(filepath.Join(outPath, "git", repo.name), 0755); err != nil {
return
}
@@ -58,15 +50,15 @@ func writeCommitsRSSFeed(repo repo, repoCommits []repoCommit) {
}
f.Write([]byte(fmt.Sprintf(` %s
- gemini://%s
- gemini://%s
+ gemini://%s.txt
+ gemini://%s.txt%s\n",
repoCommits[x].hash)))