Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging new features and changes #142

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.pdf
!compiled/*.pdf
.vscode
result
out/
80 changes: 35 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,42 @@
# latex-yearly-planner

PDF planner designed for e-ink devices.

See [discussions](https://github.com/kudrykv/latex-yearly-planner/discussions) for available planners and their variations.

### Documentation work in progress
I am planning to write more documentation on how to use it and build it on your own.
Spoiler alert: it won't be easy.
Anyhow, more info on this will come.
PDF planner designed for e-ink devices.
Fork of original project by https://github.com/kudrykv

## New Features/Changes
Note: Currently, some of these new features are currently designed for the "breadcrumb" variation of the planner, not the "mos" version.
The "mos" version might not work correctly currently.
1. Option to add multiple Journal pages per day.
2. Option to customize Reflect page contents (spots for Journal location and uploaded status)
3. Option to hide the name of the month above the mini calendar on Daily pages to allow room for more hours on the schedule
4. Option to add a title to the first/Cover page
5. Option to add a key/legend to the Year page (used to indicate which days have a certain property, such as days with journal entries, by using the highlighter feature on the tablet)
6. Added margin and formatting YAML file specific for Remarkable Paper Pro tablet

## Quick Start Guide
Here are the steps to quickly get the project up and running.

* Note: if you are here just for the planners you can find pre-generated
planners in [2022-2032 Planners Discussions](https://github.com/kudrykv/latex-yearly-planner/discussions/57).

For the tinkerers, read on.
Here are the steps to quickly get the project up and running.
See the `compiled` directory, and also [discussions](https://github.com/kudrykv/latex-yearly-planner/discussions) for prebuilt planners and their variations.

The following was tested with [POP_OS 22.04.1 LTS](https://pop.system76.com/) under [Virtualbox](https://www.virtualbox.org/) version 6.1

### Install Dependencies
### Building Your Own Planner (on Windows)
#### Install Dependencies
1. [Go Language](https://go.dev/dl/)
2. [LaTex](https://miktex.org/download) & [PDFLaTeX](https://www.latex-project.org/get/)
3. From the project directory, run the following command after updating
'PLANNER_YEAR' below. This should generate the PDF in the 'out' directory.
<code>PLANNER_YEAR=2022 \
PASSES=1 \
CFG="cfg/base.yaml,cfg/template_breadcrumb.yaml,cfg/sn_a5x.breadcrumb.default.yaml" \
NAME="sn_a5x.breadcrumb.default" \
./single.sh</code>

[Source](https://github.com/kudrykv/latex-yearly-planner/discussions/34#discussioncomment-3128344)

4. Check the "out" directory for the 'pdf' planner. To move it to your device
, follow the manufacturer's instructions on how to load a PDF on your device.

If you encounter any problems related to '.sty' files you likely need to
install some Latex related dependencies. Copying the error and search using
your favorite search engine should get you on track to resolving the
dependency issues. All the best!

### Alternative install
2. LaTeX via [MiKTeX](https://miktex.org/howto/install-miktex)

#### Instructions
1. See instructions here for a detailed overview of configuration options and build steps: [How to Build Planner Files for Windows Users…Step-by-Step #94](https://github.com/kudrykv/latex-yearly-planner/discussions/94)
2. You can also run the `compile_planner.bat` script, just replace the directory with your own, and update the .yaml files and xelatex filename according to the instructions above.
3. Check the `out` directory for the generated planner PDF. To move it to your device, follow the manufacturer's instructions on how to load a PDF on your device.

## Preview examples
![01_annual](https://github.com/user-attachments/assets/a3cbc19a-b38c-473e-8a9d-b958e387497e)
![01_annual_key](https://github.com/user-attachments/assets/bdbf3b33-30ea-4704-b9fe-69c82c274456)
![02_quarterly](https://github.com/user-attachments/assets/044ef1b4-a9aa-4e2b-9d53-f6511d7d605b)
![03_monthly](https://github.com/user-attachments/assets/437c9c47-ea99-4047-a3c4-a73204e81e8b)
![04_weekly](https://github.com/user-attachments/assets/e9e0ef82-e66a-432a-81ec-89ff590b5c7b)
![05_daily](https://github.com/user-attachments/assets/1218b4c6-92bc-4123-baa0-580b96a1283c)
![06_daily_reflect](https://github.com/user-attachments/assets/08dbb57e-d141-43bb-a04b-f5ac3886401b)
![06_daily_reflect_extended](https://github.com/user-attachments/assets/34c4f5cc-001d-44d9-8db1-3d08285de3f6)
![07_daily_notes](https://github.com/user-attachments/assets/5c8abd17-4f49-4484-9244-b43e6963ae59)
![08_notes_index](https://github.com/user-attachments/assets/ac1a6563-bc11-4a59-be15-db33d4284fae)
![09_notes](https://github.com/user-attachments/assets/c7f63cea-2b3c-401d-8d5a-c43bc05397d3)

Instead of installing the dependencies manually, this repository is defined as a Nix flake which specifies fixed versions of all the required dependencies.

1. [Install Nix](https://nixos.org/download.html)
2. Build a planner pdf using `nix build`
3. Or, if you want to develop the code, enter a shell with all the dependencies present using `nix develop`

# Preview examples
<img src="https://github.com/kudrykv/latex-yearly-planner/blob/main/examples/pictures/sn_a5x.planner/01_annual.png" width="419"><img src="https://github.com/kudrykv/latex-yearly-planner/blob/main/examples/pictures/sn_a5x.planner/02_quarter.png" width="419"><img src="https://github.com/kudrykv/latex-yearly-planner/blob/main/examples/pictures/sn_a5x.planner/03_month.png" width="419"><img src="https://github.com/kudrykv/latex-yearly-planner/blob/main/examples/pictures/sn_a5x.planner/04_week.png" width="419"><img src="https://github.com/kudrykv/latex-yearly-planner/blob/main/examples/pictures/sn_a5x.planner/05_day.png" width="419"><img src="https://github.com/kudrykv/latex-yearly-planner/blob/main/examples/pictures/sn_a5x.planner/06_day_notes.png" width="419"><img src="https://github.com/kudrykv/latex-yearly-planner/blob/main/examples/pictures/sn_a5x.planner/07_day_reflect.png" width="419"><img src="https://github.com/kudrykv/latex-yearly-planner/blob/main/examples/pictures/sn_a5x.planner/08_todos_index.png" width="419"><img src="https://github.com/kudrykv/latex-yearly-planner/blob/main/examples/pictures/sn_a5x.planner/09_todos_page.png" width="419"><img src="https://github.com/kudrykv/latex-yearly-planner/blob/main/examples/pictures/sn_a5x.planner/10_notes_index.png" width="419"><img src="https://github.com/kudrykv/latex-yearly-planner/blob/main/examples/pictures/sn_a5x.planner/11_notes_page.png" width="419">
216 changes: 196 additions & 20 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app

import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
Expand Down Expand Up @@ -90,17 +89,32 @@ func action(c *cli.Context) error {
return fmt.Errorf("modules of modules must have some modules")
}

allLen := len(mom[0])
for _, mods := range mom {
if len(mods) != allLen {
return errors.New("some modules are not aligned")
}
}
// For daily_reflect pages, handle the special case of main + extended pages
if file.Name == "daily_reflect" && len(mom) == 2 {
numDays := len(mom[0]) // Number of days from the main reflect pages
for i := 0; i < numDays; i++ {
// First, process the main reflection page for this day
if err = t.Execute(wr, mom[0][i].Tpl, mom[0][i]); err != nil {
return fmt.Errorf("execute template: %w", err)
}

for i := 0; i < allLen; i++ {
for j, mod := range mom {
if err = t.Execute(wr, mod[i].Tpl, mod[i]); err != nil {
return fmt.Errorf("execute %s on %s: %w", file.RenderBlocks[j].FuncName, mod[i].Tpl, err)
// Then process any extended pages for this day
dayIndex := i * cfg.Layout.Numbers.DailyReflectExtra
for j := 0; j < cfg.Layout.Numbers.DailyReflectExtra && dayIndex+j < len(mom[1]); j++ {
if err = t.Execute(wr, mom[1][dayIndex+j].Tpl, mom[1][dayIndex+j]); err != nil {
return fmt.Errorf("execute template: %w", err)
}
}
}
} else {
// For all other pages, process normally
for i := 0; i < len(mom[0]); i++ {
for j, mod := range mom {
if i < len(mod) {
if err = t.Execute(wr, mod[i].Tpl, mod[i]); err != nil {
return fmt.Errorf("execute %s on %s: %w", file.RenderBlocks[j].FuncName, mod[i].Tpl, err)
}
}
}
}
}
Expand Down Expand Up @@ -132,15 +146,16 @@ func RootFilename(pathconfig string) string {
type Composer func(cfg config.Config, tpls []string) (page.Modules, error)

var ComposerMap = map[string]Composer{
"title": compose.Title,
"annual": compose.Annual,
"quarterly": compose.Quarterly,
"monthly": compose.Monthly,
"weekly": compose.Weekly,
"daily": compose.Daily,
"daily_reflect": compose.DailyReflect,
"daily_notes": compose.DailyNotes,
"notes_indexed": compose.NotesIndexed,
"title": compose.Title,
"annual": compose.Annual,
"quarterly": compose.Quarterly,
"monthly": compose.Monthly,
"weekly": compose.Weekly,
"daily": compose.Daily,
"daily_reflect": compose.DailyReflect,
"daily_notes": compose.DailyNotes,
"notes_indexed": compose.NotesIndexed,
"daily_reflect_extended": compose.DailyReflectExtended,
}

func filterUniqueModules(array []page.Module) []page.Module {
Expand All @@ -156,3 +171,164 @@ func filterUniqueModules(array []page.Module) []page.Module {

return filtered
}

// package app

// import (
// "bytes"
// "fmt"
// "io/ioutil"
// "os"
// "strings"

// "github.com/kudrykv/latex-yearly-planner/app/components/page"
// "github.com/kudrykv/latex-yearly-planner/app/compose"
// "github.com/kudrykv/latex-yearly-planner/app/config"
// "github.com/kudrykv/latex-yearly-planner/app/tpls"
// "github.com/urfave/cli/v2"
// )

// const (
// fConfig = "config"
// pConfig = "preview"
// )

// func New() *cli.App {
// return &cli.App{
// Name: "plannergen",

// Writer: os.Stdout,
// ErrWriter: os.Stderr,

// Flags: []cli.Flag{
// &cli.PathFlag{Name: fConfig, Required: true},
// &cli.BoolFlag{Name: pConfig, Required: false},
// },

// Action: action,
// }
// }

// func action(c *cli.Context) error {
// var (
// fn Composer
// ok bool
// cfg config.Config
// err error
// )

// preview := c.Bool(pConfig)

// pathConfigs := strings.Split(c.Path(fConfig), ",")
// if cfg, err = config.New(pathConfigs...); err != nil {
// return fmt.Errorf("config new: %w", err)
// }

// wr := &bytes.Buffer{}

// t := tpls.New()

// if err = t.Document(wr, cfg); err != nil {
// return fmt.Errorf("tex document: %w", err)
// }

// if err = ioutil.WriteFile("out/"+RootFilename(pathConfigs[len(pathConfigs)-1]), wr.Bytes(), 0600); err != nil {
// return fmt.Errorf("ioutil write file: %w", err)
// }

// for _, file := range cfg.Pages {
// wr.Reset()

// var mom []page.Modules
// for _, block := range file.RenderBlocks {
// if fn, ok = ComposerMap[block.FuncName]; !ok {
// return fmt.Errorf("unknown func " + block.FuncName)
// }

// modules, err := fn(cfg, block.Tpls)

// // Only one page per unique module if preview flag is enabled
// if preview {
// modules = filterUniqueModules(modules)
// }

// if err != nil {
// return fmt.Errorf("%s: %w", block.FuncName, err)
// }

// mom = append(mom, modules)
// }

// if len(mom) == 0 {
// return fmt.Errorf("modules of modules must have some modules")
// }

// allLen := len(mom[0])

// // Commenting out for now to accomodate having the same renderblock containing both 1 page reflect and multipage reflect_extra modules
// // for _, mods := range mom {
// // if len(mods) != allLen {
// // return errors.New("some modules are not aligned")
// // }
// // }

// for i := 0; i < allLen; i++ {
// for j, mod := range mom {
// if err = t.Execute(wr, mod[i].Tpl, mod[i]); err != nil {
// return fmt.Errorf("execute %s on %s: %w", file.RenderBlocks[j].FuncName, mod[i].Tpl, err)
// }
// }
// }

// if err = ioutil.WriteFile("out/"+file.Name+".tex", wr.Bytes(), 0600); err != nil {
// return fmt.Errorf("ioutil write file: %w", err)
// }
// }

// return nil
// }

// func RootFilename(pathconfig string) string {
// if idx := strings.LastIndex(pathconfig, "/"); idx >= 0 {
// pathconfig = pathconfig[idx+1:]
// }

// if strings.HasSuffix(pathconfig, ".yml") {
// pathconfig = pathconfig[:len(pathconfig)-len(".yml")]
// }

// if strings.HasSuffix(pathconfig, ".yaml") {
// pathconfig = pathconfig[:len(pathconfig)-len(".yaml")]
// }

// return pathconfig + ".tex"
// }

// type Composer func(cfg config.Config, tpls []string) (page.Modules, error)

// var ComposerMap = map[string]Composer{
// "title": compose.Title,
// "annual": compose.Annual,
// "quarterly": compose.Quarterly,
// "monthly": compose.Monthly,
// "weekly": compose.Weekly,
// "daily": compose.Daily,
// "daily_reflect": compose.DailyReflect,
// "daily_notes": compose.DailyNotes,
// "notes_indexed": compose.NotesIndexed,
// "daily_reflect_extended": compose.DailyReflectExtended,
// }

// func filterUniqueModules(array []page.Module) []page.Module {
// filtered := make([]page.Module, 0)
// found := map[string]bool{}

// for _, val := range array {
// if _, present := found[val.Tpl]; !present {
// filtered = append(filtered, val)
// found[val.Tpl] = true
// }
// }

// return filtered
// }
Loading