Skip to content

Commit

Permalink
fix: properly sync pages, support longer posts
Browse files Browse the repository at this point in the history
Fixed an issue where the same pages would be synced over and over again,
started to support longer posts (but... it's stil bad right now sorry!)
  • Loading branch information
jaredallard committed May 31, 2024
1 parent 44f28e8 commit 6a7c102
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,24 @@ This is ALPHA software and has the following limitations:
* Make sure you're logged in!
* [dayone2](https://dayoneapp.com/guides/tips-and-tutorials/command-line-interface-cli)
* [rmc](https://github.com/ricklupton/rmc)
* `brew install imagemagick inkscape`

### From Source

* [mise](https://mise.jdx.dev)

## Configuration

Create a `.env` file with the following options:

```bash
# Name of the notebook to sync into Dayone.
DOCUMENT_NAME="Journal"
```

Run the latest release, or build from source `mise run build` into
`./bin/`. It'll automatically walk you through Remarkable's auth system.

## License

GPL-3.0
5 changes: 5 additions & 0 deletions cmd/remarkabledayone/remarkabledayone.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func main() {
os.Exit(1)
}

if os.Getenv("ENV") == "development" {
handler.SetLevel(charmlog.DebugLevel)
log.Debug("debug logging enabled")
}

syncer, err := syncer.New(log, cfg)
if err != nil {
log.With("error", err).Error("failed to create syncer")
Expand Down
8 changes: 4 additions & 4 deletions internal/rm/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func RenderRmToPng(src, dest string) error {
}
defer os.RemoveAll(tmpDir)

svgFile := filepath.Join(tmpDir, "output.svg")
outputFile := svgFile + ".png"
pdfFile := filepath.Join(tmpDir, "output.pdf")
outputFile := pdfFile + ".png"
cmds := [][]string{
{"rmc", "--version"},
{"rmc", "-t", "svg", src, "-o", svgFile},
{"qlmanage", "-t", "-s", "1000", "-o", tmpDir, svgFile},
{"rmc", "-t", "pdf", src, "-o", pdfFile},
{"convert", "-verbose", "-density", "150", "-trim", pdfFile, "-quality", "100", "-flatten", "-sharpen", "0x1.0", outputFile},
}
for _, cmd := range cmds {
cmd := exec.Command(cmd[0], cmd[1:]...)
Expand Down
3 changes: 2 additions & 1 deletion internal/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (s *Syncer) Sync() error {
pagesHM[p.ID] = struct{}{}

if _, ok := s.state.SyncedPages[p.ID]; ok {
s.log.Debug("page already synced", "page", p.ID)
continue
}

Expand Down Expand Up @@ -116,7 +117,7 @@ func (s *Syncer) Sync() error {
}

s.log.With("pages", len(needToSync)).Info("syncing pages")
for p := range needToSync {
for _, p := range needToSync {
page := doc.Zip.Pages[p]
s.log.With("page", page.ID).Info("syncing page")

Expand Down

0 comments on commit 6a7c102

Please sign in to comment.