Skip to content

Commit

Permalink
change default format to .md, to align with Obsidian
Browse files Browse the repository at this point in the history
  • Loading branch information
skatkov committed Sep 20, 2023
1 parent 1dc4cbc commit 3eda93a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Run following commands in a terminal:
- Editor could be changed by setting $EDITOR global variable. (default: nano)
- Directory for journal could be changed by setting $STOIC_DIR global variable. (default: ~/Journal/)
- Provide file template through $STOIC_TEMPLATE global variable.
- Provide new extension format through $STOIC_EXT global variables. (default: txt)
- Provide new extension format through $STOIC_EXT global variables. (default: md)

```
export EDITOR="neovim"
Expand Down
2 changes: 1 addition & 1 deletion internal/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

const DEFAULT_EDITOR = "nano"
const DEFAULT_DIRECTORY = "~/Journal/"
const DEFAULT_EXTENSION = "txt"
const DEFAULT_EXTENSION = "md"

type Context interface {
Directory() string
Expand Down
8 changes: 4 additions & 4 deletions internal/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ func TestFiles(t *testing.T) {
test_folder := strings.TrimSuffix(current_dir, "/internal") + "/test/data"

ctx := NewContext(test_folder+"/journal_with_entry", "", "", "")
assert.Equal(t, []string{test_folder + "/journal_with_entry/" + "2022-jan-01.txt"}, ctx.Files())
assert.Equal(t, []string{test_folder + "/journal_with_entry/" + "2022-jan-01.md"}, ctx.Files())

ctx = NewContext(test_folder+"/journal_with_entry", "md", "", "")
ctx = NewContext(test_folder+"/journal_with_entry", "txt", "", "")
assert.Empty(t, ctx.Files())

ctx = NewContext(test_folder+"/journal_with_various_entries", "md", "", "")
Expand All @@ -31,7 +31,7 @@ func TestNewContext(t *testing.T) {
homeDir, _ := user.Current()

assert.Equal(t, homeDir.HomeDir+"/Journal/", ctx.Directory())
assert.Equal(t, "txt", ctx.FileExtension())
assert.Equal(t, "md", ctx.FileExtension())
assert.Equal(t, "nano", ctx.Editor())
assert.Equal(t, "", ctx.Template())
}
Expand All @@ -41,7 +41,7 @@ func TestNewContextWithEditor(t *testing.T) {
}

func TestNewContextWithExtension(t *testing.T) {
assert.Equal(t, "md", NewContext("", "md", "", "").FileExtension())
assert.Equal(t, "txt", NewContext("", "txt", "", "").FileExtension())
}

func TestNewContextWithDirectory(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions internal/entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ func TestNewEntry(t *testing.T) {

homeDir, _ := user.Current()

assert.Equal(t, homeDir.HomeDir+"/Journal/2020-jan-01.txt", e.Filepath())
assert.Equal(t, homeDir.HomeDir+"/Journal/2020-jan-01.md", e.Filepath())
}

func TestNewEntryWithExtension(t *testing.T) {
tm, _ := time.Parse("2006-Jan-02", "2020-Jan-01")
ctx := NewContext("", "md", "", "")
ctx := NewContext("", "txt", "", "")
e := NewEntry(ctx, tm)

homeDir, _ := user.Current()

assert.Equal(t, homeDir.HomeDir+"/Journal/2020-jan-01.md", e.Filepath())
assert.Equal(t, homeDir.HomeDir+"/Journal/2020-jan-01.txt", e.Filepath())
}

func TestNewEntryWithDirectory(t *testing.T) {
Expand All @@ -35,5 +35,5 @@ func TestNewEntryWithDirectory(t *testing.T) {

homeDir, _ := user.Current()

assert.Equal(t, homeDir.HomeDir+"/Journal/test/2020-jan-01.txt", e.Filepath())
assert.Equal(t, homeDir.HomeDir+"/Journal/test/2020-jan-01.md", e.Filepath())
}
File renamed without changes.

0 comments on commit 3eda93a

Please sign in to comment.