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

Added grid option and changed font #147

Open
wants to merge 1 commit 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
9 changes: 8 additions & 1 deletion app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ type Config struct {
Year int `env:"PLANNER_YEAR"`
WeekStart time.Weekday
Dotted bool
Blank bool
Grid bool
CalAfterSchedule bool
ClearTopRightCorner bool
AMPMTime bool
AddLastHalfHour bool

Pages Pages

Font Font
Layout Layout
}

Expand Down Expand Up @@ -59,6 +61,7 @@ type RenderBlock struct {
type Colors struct {
Gray string
LightGray string
VeryLightGray string
}

type Layout struct {
Expand Down Expand Up @@ -109,6 +112,10 @@ type Margin struct {
Right string `env:"PLANNER_LAYOUT_PAPER_MARGIN_RIGHT"`
}

type Font struct {
Family string
}

func New(pathConfigs ...string) (Config, error) {
var (
bts []byte
Expand Down
8 changes: 7 additions & 1 deletion cfg/base.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
weekstart: 1
ampmtime: false
dotted: true
dotted: false
blank: false
grid: true
calafterschedule: false
addlasthalfhour: true

font:
family: "Helvetica"

layout:
paper:
width: 15.6cm
Expand Down Expand Up @@ -57,3 +62,4 @@ layout:
colors:
gray: gray
lightgray: gray!50
verylightgray: gray!20
2 changes: 1 addition & 1 deletion tpls/_common_03_monthly.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{- template "monthTabularV2.tpl" dict "Month" .Body.Month "Large" true -}}
\medskip

{{ if $.Cfg.Dotted -}}
{{ if or $.Cfg.Dotted $.Cfg.Blank $.Cfg.Grid -}}
\myUnderline{Notes}
\vbox to 0pt{\myMash[\myMonthlySpring]{20}{\myNumDotWidthFull}}
{{- else -}}
Expand Down
4 changes: 4 additions & 0 deletions tpls/_common_04_weekly.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{{ if $.Cfg.Dotted -}}
{{ template "_common_04_weekly_dotted.tpl" dict "Cfg" .Cfg "Body" .Body }}
{{- else if $.Cfg.Blank -}}
{{ template "_common_04_weekly_blank.tpl" dict "Cfg" .Cfg "Body" .Body }}
{{- else if $.Cfg.Grid -}}
{{ template "_common_04_weekly_grid.tpl" dict "Cfg" .Cfg "Body" .Body }}
{{- else -}}
{{ template "_common_04_weekly_lined.tpl" dict "Cfg" .Cfg "Body" .Body }}
{{- end }}
29 changes: 29 additions & 0 deletions tpls/_common_04_weekly_blank.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- $days := .Body.Week.Days -}}
{{- $day1 := index $days 0 -}}
{{- $day2 := index $days 1 -}}
{{- $day3 := index $days 2 -}}
{{- $day4 := index $days 3 -}}
{{- $day5 := index $days 4 -}}
{{- $day6 := index $days 5 -}}
{{- $day7 := index $days 6 -}}

\parbox{\myLenTriCol}{\myUnderline{ {{- $day1.WeekLink -}} }}%
\hspace{\myLenTriColSep}%
\parbox{\myLenTriCol}{\myUnderline{ {{- $day2.WeekLink -}} }}%
\hspace{\myLenTriColSep}%
\parbox{\myLenTriCol}{\myUnderline{ {{- $day3.WeekLink -}} }}
\myMash{\myNumWeeklyLines}{\myNumDotWidthFull}
\vfill

\parbox{\myLenTriCol}{\myUnderline{ {{- $day4.WeekLink -}} }}%
\hspace{\myLenTriColSep}%
\parbox{\myLenTriCol}{\myUnderline{ {{- $day5.WeekLink -}} }}%
\hspace{\myLenTriColSep}%
\parbox{\myLenTriCol}{\myUnderline{ {{- $day6.WeekLink -}} }}
\myMash{\myNumWeeklyLines}{\myNumDotWidthFull}
\vfill

\parbox{\myLenTriCol}{ \myUnderline{ {{- $day7.WeekLink -}} }}%
\hspace{\myLenTriColSep}%
\parbox{\dimexpr2\myLenTriCol+\myLenTriColSep}{\myUnderline{Notes\myDummyQ}}
\myMash{\myNumWeeklyLines}{\myNumDotWidthFull}
29 changes: 29 additions & 0 deletions tpls/_common_04_weekly_grid.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- $days := .Body.Week.Days -}}
{{- $day1 := index $days 0 -}}
{{- $day2 := index $days 1 -}}
{{- $day3 := index $days 2 -}}
{{- $day4 := index $days 3 -}}
{{- $day5 := index $days 4 -}}
{{- $day6 := index $days 5 -}}
{{- $day7 := index $days 6 -}}

\parbox{\myLenTriCol}{\myUnderline{ {{- $day1.WeekLink -}} }}%
\hspace{\myLenTriColSep}%
\parbox{\myLenTriCol}{\myUnderline{ {{- $day2.WeekLink -}} }}%
\hspace{\myLenTriColSep}%
\parbox{\myLenTriCol}{\myUnderline{ {{- $day3.WeekLink -}} }}
\myMash{\myNumWeeklyLines}{\myNumDotWidthFull}
\vfill

\parbox{\myLenTriCol}{\myUnderline{ {{- $day4.WeekLink -}} }}%
\hspace{\myLenTriColSep}%
\parbox{\myLenTriCol}{\myUnderline{ {{- $day5.WeekLink -}} }}%
\hspace{\myLenTriColSep}%
\parbox{\myLenTriCol}{\myUnderline{ {{- $day6.WeekLink -}} }}
\myMash{\myNumWeeklyLines}{\myNumDotWidthFull}
\vfill

\parbox{\myLenTriCol}{ \myUnderline{ {{- $day7.WeekLink -}} }}%
\hspace{\myLenTriColSep}%
\parbox{\dimexpr2\myLenTriCol+\myLenTriColSep}{\myUnderline{Notes\myDummyQ}}
\myMash{\myNumWeeklyLines}{\myNumDotWidthFull}
16 changes: 11 additions & 5 deletions tpls/_common_07_daily_notes.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{{ if $.Cfg.Dotted -}} \vskip-.5\myLenLineHeightButLine\myMash{\myNumDotHeightFull}{\myNumDotWidthFull} {{- else -}}
\vbox to \dimexpr\textheight-\pagetotal-\myLenLineHeightButLine\relax {%
\leaders\hbox to \linewidth{\textcolor{\myColorGray}{\rule{0pt}{\myLenLineHeightButLine}\hrulefill}}\vfil
}
{{end}}
{{- if $.Cfg.Dotted -}}
\vskip-.5\myLenLineHeightButLine\myMash{\myNumDotHeightFull}{\myNumDotWidthFull}
{{- else if $.Cfg.Blank -}}
\vskip\textheight minus \pagetotal
{{- else if $.Cfg.Grid -}}
\vskip-.5\myLenLineHeightButLine\myMash{\myNumDotHeightFull}{\myNumDotWidthFull}
{{- else -}}
\vbox to \dimexpr\textheight-\pagetotal-\myLenLineHeightButLine\relax {%
\leaders\hbox to \linewidth{\textcolor{\myColorGray}{\rule{0pt}{\myLenLineHeightButLine}\hrulefill}}\vfil
}
{{- end}}
16 changes: 11 additions & 5 deletions tpls/_common_09_notes.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{{ if $.Cfg.Dotted -}} \vskip-.5\myLenLineHeightButLine\myMash{\myNumDotHeightFull}{\myNumDotWidthFull} {{- else -}}
\vbox to \dimexpr\textheight-\pagetotal-\myLenLineHeightButLine\relax {%
\leaders\hbox to \linewidth{\textcolor{\myColorGray}{\rule{0pt}{\myLenLineHeightButLine}\hrulefill}}\vfil
}
{{end}}
{{- if $.Cfg.Dotted -}}
\vskip-.5\myLenLineHeightButLine\myMash{\myNumDotHeightFull}{\myNumDotWidthFull}
{{- else if $.Cfg.Blank -}}
\vskip\textheight minus \pagetotal
{{- else if $.Cfg.Grid -}}
\vskip-.5\myLenLineHeightButLine\myMash{\myNumDotHeightFull}{\myNumDotWidthFull}
{{- else -}}
\vbox to \dimexpr\textheight-\pagetotal-\myLenLineHeightButLine\relax {%
\leaders\hbox to \linewidth{\textcolor{\myColorGray}{\rule{0pt}{\myLenLineHeightButLine}\hrulefill}}\vfil
}
{{- end}}
5 changes: 4 additions & 1 deletion tpls/document.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\documentclass[9pt]{extarticle}
\documentclass[8pt]{extarticle}

\usepackage{geometry}
\usepackage[table]{xcolor}
Expand All @@ -24,6 +24,9 @@
\usepackage{adjustbox}
\usepackage{multido}

\usepackage{fontspec}
\setmainfont{ {{- .Cfg.Font.Family -}} }

\hypersetup{
{{- if not .Cfg.Debug.ShowLinks}}hidelinks=true{{end -}}
}
Expand Down
33 changes: 30 additions & 3 deletions tpls/macro.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
\newcommand{\myDailySpring}{ {{- $lengths.DailySpring -}} }
\newcommand{\myColorGray}{ {{- .Cfg.Layout.Colors.Gray -}} }
\newcommand{\myColorLightGray}{ {{- .Cfg.Layout.Colors.LightGray -}} }
\newcommand{\myColorVeryLightGray}{ {{- .Cfg.Layout.Colors.VeryLightGray -}} }

\newcommand{\myLinePlain}{\hrule width \linewidth height \myLenLineThicknessDefault}
\newcommand{\myLineThick}{\hrule width \linewidth height \myLenLineThicknessThick}
Expand All @@ -69,19 +70,45 @@
\newcommand{\myUnderline}[1]{#1\vskip1mm\myLineThick\par}
\newcommand{\myLineColor}[1]{\textcolor{#1}{\myLinePlain}}
\newcommand{\myLineGray}{\myLineColor{\myColorGray}}
\newcommand{\myLineVeryLightGray}{\myLineColor{\myColorVeryLightGray}}
\newcommand{\myLineLightGray}{\myLineColor{\myColorLightGray}}
\newcommand{\myLineGrayVskipBottom}{\myLineGray\vskip\myLenLineHeightButLine}
\newcommand{\myLineGrayVskipTop}{\vskip\myLenLineHeightButLine\myLineGray}

\newcommand{\myTodo}{\myLineHeightButLine$\square$\myLinePlain}
\newcommand{\myTodoLineGray}{\myLineHeightButLine$\square$\myLineGray}

\newcommand{\myDotGrid}[2]{\leavevmode\multido{\dC=0mm+5mm}{#1}{\multido{\dR=0mm+5mm}{#2}{\put(\dR,\dC){\circle*{0.1}}}}}
\newcommand{\myDotGrid}[2]{%
\leavevmode
\multido{\dC=0mm+5mm}{#1}{%
\multido{\dR=0mm+5mm}{#2}{%
\put(\dR,\dC){\circle*{0.1}}%
}%
}%
}
\newcommand{\myGridPattern}[2]{%
\leavevmode
\setlength{\fboxrule}{0.0005pt}% % Set line thickness for the squares
\multido{\dC=0mm+5mm}{#1}{% % Vertical spacing (increased to 7mm)
\multido{\dR=0mm+5mm}{#2}{% % Horizontal spacing (increased to 7mm)
\put(\dR,\dC){\textcolor{\myColorVeryLightGray}{%
\makebox(0,0){\framebox(5mm,5mm){}}% % Hollow square, centered at intersection
}}%
}%
}%
}

\newcommand{\myMash}[3][]{
{{- if $.Cfg.Dotted -}} \vskip\myLenLineHeightButLine#1\myDotGrid{#2}{#3} {{- else -}} \Repeat{#2}{\myLineGrayVskipTop} {{- end -}}
{{- if $.Cfg.Dotted -}}
\vskip\myLenLineHeightButLine#1\myDotGrid{#2}{#3}
{{- else if $.Cfg.Blank -}}
\vskip#2\myLenLineHeightButLine
{{- else if $.Cfg.Grid -}}
\vskip\myLenLineHeightButLine#1\myGridPattern{#2}{#3}
{{- else -}}
\Repeat{#2}{\myLineGrayVskipTop}
{{- end -}}
}

\newcommand{\remainingHeight}{%
\ifdim\pagegoal=\maxdimen
\dimexpr\textheight-9.4pt\relax
Expand Down