dayone2md

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 22 Imported by: 0

README

DayOne To Markdown

Export DayOne databases to Markdown files.

Usage

Export the archive from DayOne.

Usage:
  dayone2md [OPTIONS]

Application Options:
  -j, --journal=      journal name to export
  -i, --input=        input file, either the DayOne.sqlite database file or the export zip file
  -o, --output=       output directory
  -t, --template=     name of the template to use, either the path the external template file or the name of a built-in template: main or
                      full (default: main)
  -g, --group         group entries by day, one file per day, multiple entries per file
  -r, --reverse       reverse chronological sort order for entries within a file
      --keep-orphans  do not remove files at destination that lack a matching entry at the source
      --version       print version and exit
  -v, --verbose       show verbose output, list multiple times for even more verbose output

Help Options:
  -h, --help          Show this help message

development

make lint-fix
make lint
make install

similar projects

Production Ready (the last 80%)

  • update readme with features list
  • license
  • github repo
  • blog post, Twitter
  • publish doc to kwo.dev
  • goreleaser

TODO

  • abstract destination behind an interface, add memory impl for testing
  • fill out database entity fields
  • attempt to use alternative sqlite lib
  • move cmd to package, move lib to day2onemd
  • rewrite dayone entry links
  • read directly from database
  • separate out first line of each entry as title
  • add option to alter sort order within day when grouped by day
  • add flag to group entries by day (for me the default)
  • add full date-time to full template frontmatter
  • exclude weather and location from metadata footer when they are not available
  • bugfix date in footer - looks like UTC not local
  • extract directly from zip without exploding first
  • multiple entries on same day
  • option to use own template
  • use 1.21 slog
  • remove orphans (--keep-orphans to prevent)
  • conditional write for photos and entries based on SHA hash
  • add location, weather, moonphase, etc to frontmatter
  • inplace update of iA directory
  • options to not add tags to bottom

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(ctx context.Context, opts Options) error

Convert export DayOne entries to markdown.

Types

type Entry

type Entry struct {
	CreationDate        time.Time `json:"creationDate"`
	ModifiedDate        time.Time `json:"modifiedDate"`
	Date                time.Time `json:"-"` // CreationDate with timezone applied
	TimeZone            string    `json:"timeZone"`
	Duration            int       `json:"duration"`
	Pinned              bool      `json:"isPinned"`
	Starred             bool      `json:"starred"`
	AllDay              bool      `json:"isAllDay"`
	UUID                string    `json:"uuid"`
	Title               string    `json:"-"` // calculated
	Text                string    `json:"text"`
	Tags                []string  `json:"tags,omitempty"`
	Photos              []Photo   `json:"photos,omitempty"`
	Location            *Location `json:"location,omitempty"`
	Weather             *Weather  `json:"weather,omitempty"`
	EditingTime         float64   `json:"editingTime,omitempty"`
	CreationDevice      string    `json:"creationDevice,omitempty"`
	CreationDeviceType  string    `json:"creationDeviceType,omitempty"`
	CreationDeviceModel string    `json:"creationDeviceModel,omitempty"`
	CreationOSName      string    `json:"creationOSName,omitempty"`
	CreationOSVersion   string    `json:"creationOSVersion,omitempty"`
}

type Journal

type Journal struct {
	Metadata *Metadata `json:"metadata"`
	Entries  []Entry   `json:"entries"`
}

type Location

type Location struct {
	Label     string  `json:"userLabel"`
	Address   string  `json:"placeName"`
	City      string  `json:"localityName"`
	State     string  `json:"administrativeArea"`
	Country   string  `json:"country"`
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Altitude  float64 `json:"altitude"`
}

type Metadata

type Metadata struct {
	Version string `json:"version"`
}

type Options

type Options interface {
	GetJournalName() string
	GetInputLocation() string
	GetOutputDirectory() string
	GetTemplate() string
	IsGroupByDay() bool
	IsSortReverse() bool
	IsRemoveOrphans() bool
}

type Photo

type Photo struct {
	Date                 string    `json:"date"`
	Filename             string    `json:"filename"`
	FileSize             int       `json:"fileSize"`
	Height               int       `json:"height"`
	Identifier           string    `json:"identifier"`
	IsSketch             bool      `json:"isSketch"`
	MD5                  string    `json:"md5"`
	Type                 string    `json:"type"`
	Width                int       `json:"width"`
	AppleCloudIdentifier string    `json:"appleCloudIdentifier,omitempty"`
	CameraMake           string    `json:"cameraMake,omitempty"`
	CameraModel          string    `json:"cameraModel,omitempty"`
	CreationDevice       string    `json:"creationDevice,omitempty"`
	Duration             int       `json:"duration,omitempty"`
	ExposureBiasValue    int       `json:"exposureBiasValue,omitempty"`
	Favorite             bool      `json:"favorite,omitempty"`
	FocalLength          string    `json:"focalLength,omitempty"`
	FStop                string    `json:"fnumber,omitempty"`
	LensMake             string    `json:"lensMake,omitempty"`
	LensModel            string    `json:"lensModel,omitempty"`
	Location             *Location `json:"location,omitempty"`
	OrderInEntry         int       `json:"orderInEntry,omitempty"`
}

type Weather

type Weather struct {
	Conditions         string    `json:"conditionsDescription"`
	MoonPhase          float64   `json:"moonPhase"`
	MoonPhaseCode      string    `json:"moonPhaseCode"`
	PressureMB         float64   `json:"pressureMB"`
	RelativeHumidity   int       `json:"relativeHumidity"`
	SunriseDate        time.Time `json:"sunriseDate"`
	SunsetDate         time.Time `json:"sunsetDate"`
	TemperatureCelsius float64   `json:"temperatureCelsius"`
	VisibilityKM       float64   `json:"visibilityKM"`
	WeatherCode        string    `json:"weatherCode"`
	WeatherServiceName string    `json:"weatherServiceName"`
	WindBearing        int       `json:"windBearing"`
	WindSpeedKPH       float64   `json:"windSpeedKPH"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL