Skip to content
Merged
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
11 changes: 8 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
work-goals: [{arg: "--work-goals", suffix: ""}, {arg: "--no-work-goals", suffix: "-no-work-goals"}]
daily-pages: [{arg: "--daily-pages", suffix: ""}, {arg: "--no-daily-pages", suffix: "-no-daily"}]
weekly-pages: [{arg: "--weekly-pages", suffix: ""}, {arg: "--no-weekly-pages", suffix: "-no-weekly"}]
journal-pages:
- {arg: "--journals-per-page=0", suffix: ""}
- {arg: "--journals-per-page=1", suffix: "-full-pg-journal"}
- {arg: "--journals-per-page=2", suffix: "-half-pg-journal"}
- {arg: "--journals-per-page=4", suffix: "-quarter-pg-journal"}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -42,12 +47,12 @@ jobs:
- name: Install playwright browsers
run: playwright install
- name: Build planner pages
run: npm run build -- ${{ matrix.date-ranges.arg }} ${{ matrix.personal-goals.arg }} ${{ matrix.work-goals.arg }} ${{ matrix.daily-pages.arg }} ${{ matrix.weekly-pages.arg }} --file-suffix="-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}"
run: npm run build -- ${{ matrix.date-ranges.arg }} ${{ matrix.personal-goals.arg }} ${{ matrix.work-goals.arg }} ${{ matrix.daily-pages.arg }} ${{ matrix.weekly-pages.arg }} ${{ matrix.journal-pages.arg }} --file-suffix="-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}"
- name: Upload planner pdf to artifacts
uses: actions/upload-artifact@v3
with:
name: planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}.pdf
path: dest/planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}.pdf
name: planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}.pdf
path: dest/planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}.pdf
deploy:
needs: build
runs-on: ubuntu-latest
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ jobs:
work-goals: [{arg: "--work-goals", suffix: ""}, {arg: "--no-work-goals", suffix: "-no-work-goals"}]
daily-pages: [{arg: "--daily-pages", suffix: ""}, {arg: "--no-daily-pages", suffix: "-no-daily"}]
weekly-pages: [{arg: "--weekly-pages", suffix: ""}, {arg: "--no-weekly-pages", suffix: "-no-weekly"}]
journal-pages:
- {arg: "--journals-per-page=0", suffix: ""}
- {arg: "--journals-per-page=1", suffix: "-full-pg-journal"}
- {arg: "--journals-per-page=2", suffix: "-half-pg-journal"}
- {arg: "--journals-per-page=4", suffix: "-quarter-pg-journal"}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -34,9 +39,9 @@ jobs:
- name: Install playwright browsers
run: playwright install
- name: Build planner pages
run: npm run build -- ${{ matrix.date-ranges.arg }} ${{ matrix.personal-goals.arg }} ${{ matrix.work-goals.arg }} ${{ matrix.daily-pages.arg }} ${{ matrix.weekly-pages.arg }} --file-suffix="-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}"
run: npm run build -- ${{ matrix.date-ranges.arg }} ${{ matrix.personal-goals.arg }} ${{ matrix.work-goals.arg }} ${{ matrix.daily-pages.arg }} ${{ matrix.weekly-pages.arg }} ${{ matrix.journal-pages.arg }} --file-suffix="-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}"
- name: Upload planner pdf to artifacts
uses: actions/upload-artifact@v3
with:
name: planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}.pdf
path: dest/planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}.pdf
name: planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}.pdf
path: dest/planner-${{ matrix.date-ranges.suffix }}${{ matrix.daily-pages.suffix }}${{ matrix.weekly-pages.suffix }}${{ matrix.personal-goals.suffix }}${{ matrix.work-goals.suffix }}${{ matrix.journal-pages.suffix }}.pdf
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ iPad app goodnotes 5.
- Daily pages with a hyperlinked mini calendar and week.
- Annual/Monthly/Weekly personal goals (hyperlinked on each page with the target symbol in the bottom right corner).
- Monthly/Weekly work goals (hyperlinked with briefcase symbol in bottom right corner of monthly/weekly pages).
- Journal pages that can be a full page, half page, or quarter page.
- Lots of hyperlinking. If it seems like it should direct to another page, it probably does.

### Screen shots
Expand Down Expand Up @@ -51,6 +52,10 @@ iPad app goodnotes 5.

![Weekly work goals](https://user-images.githubusercontent.com/8276147/203632936-8860454b-5de8-4c1d-9826-5b426bd2bee1.png)

#### Journal pages

![Quarter sized pages](https://user-images.githubusercontent.com/8276147/204024505-c29a0b34-8696-42ab-adcd-89d52204c3bb.png)

## Using the generator locally

### Prerequisites
Expand Down Expand Up @@ -84,8 +89,8 @@ technique, set margins to none and enable background images.
#### Optional Arguments

```
usage: Python Planner Generator [-h] [--start-time START_TIME] [--end-time END_TIME] [--file-suffix FILE_SUFFIX] [--work-goals | --no-work-goals]
[--personal-goals | --no-personal-goals] [--daily-pages | --no-daily-pages] [--weekly-pages | --no-weekly-pages]
usage: Python Planner Generator [-h] [--start-time START_TIME] [--end-time END_TIME] [--file-suffix FILE_SUFFIX] [--work-goals | --no-work-goals] [--personal-goals | --no-personal-goals]
[--daily-pages | --no-daily-pages] [--weekly-pages | --no-weekly-pages] [--journals-per-page {0,1,2,4}]
start end

GoodNotes 5 Optimized PDF Planner
Expand All @@ -105,4 +110,5 @@ options:
--personal-goals, --no-personal-goals
--daily-pages, --no-daily-pages
--weekly-pages, --no-weekly-pages
--journals-per-page {0,1,2,4}
```
83 changes: 66 additions & 17 deletions src/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def build_planner(pages, j2_env: j2.Environment):
return j2_env.get_template('full_planner.html.j2') \
.render(pages=pages)

def build_daily_pages(start: date, end: date, start_t: datetime, end_t: datetime, j2_env: j2.Environment):
def build_daily_pages(start: date, end: date, start_t: datetime, end_t: datetime, goals, j2_env: j2.Environment):
def build_daily_page(inp_date, j2_template: j2.Template, times):
mini_cal = mini_calendar_dates(inp_date.month, inp_date.year)
return j2_template.render(date=inp_date, times=times, mini_cal=mini_cal)
Expand All @@ -58,17 +58,24 @@ def build_daily_page(inp_date, j2_template: j2.Template, times):

times = [(start_t + timedelta(hours=i)).strftime('%-I %p').lower() for i in range(num_hours)]

journal_link = False

for i in range(num_days + 1):
cur_date = start + timedelta(days=i)

if goals['journal'] > 0:
journal_link = cur_date.strftime('%Y-%m-%d-journal')

content = build_daily_page(cur_date, daily_template, times)
day_templates[cur_date.strftime('%Y-%m-%d')] = frame_template.render(
content=content,
id=cur_date.strftime('%Y-%m-%d')
id=cur_date.strftime('%Y-%m-%d'),
journal_link=journal_link
)

return day_templates

def build_weekly_pages(start: date, end: date, start_t: datetime, end_t: datetime, work_goals: bool, personal_goals: bool, j2_env: j2.Environment):
def build_weekly_pages(start: date, end: date, start_t: datetime, end_t: datetime, goals, j2_env: j2.Environment):
def build_weekly_page(inp_monday, j2_template: j2.Template, times):
days = []
for i in range(7):
Expand All @@ -85,26 +92,31 @@ def build_weekly_page(inp_monday, j2_template: j2.Template, times):

goal_link = False
work_goal_link = False
journal_link = False

while cur_monday < end:
if work_goals:
if goals['work']:
work_goal_link = f"{cur_monday.strftime('%Y-W%W')}-work-goals"

if personal_goals:
if goals['personal']:
goal_link = f"{cur_monday.strftime('%Y-W%W')}-goals"

if goals['journal'] > 0:
journal_link = f"{max(cur_monday, start).strftime('%Y-%m-%d')}-journal"

content = build_weekly_page(cur_monday, weekly_template, times)
week_templates[cur_monday.strftime('%Y-W%W')] = frame_template.render(
content=content,
id=cur_monday.strftime('%Y-W%W'),
goal_link=goal_link,
work_goal_link=work_goal_link
work_goal_link=work_goal_link,
journal_link=journal_link
)
cur_monday += timedelta(days=7)

return week_templates

def build_monthly_pages(start: date, end: date, work_goals: bool, personal_goals: bool, j2_env: j2.Environment):
def build_monthly_pages(start: date, end: date, goals, j2_env: j2.Environment):
def build_monthly_page(cur_month, j2_template: j2.Template):
return j2_template.render(month=cur_month, mini_cal=mini_calendar_dates(cur_month.month, cur_month.year))

Expand All @@ -115,26 +127,31 @@ def build_monthly_page(cur_month, j2_template: j2.Template):

work_goal_link = False
goal_link = False
journal_link = False

while cur_month <= end:
if work_goals:
if goals['work']:
work_goal_link = f"{cur_month.strftime('%Y-%m')}-work-goals"

if personal_goals:
if goals['personal']:
goal_link = f"{cur_month.strftime('%Y-%m')}-goals"

if goals['journal'] > 0:
journal_link = f"{cur_month.strftime('%Y-%m-%d-journal')}"

content = build_monthly_page(cur_month, monthly_template)
month_templates[cur_month.strftime('%Y-%m')] = frame_template.render(
content=content,
id=cur_month.strftime('%Y-%m'),
goal_link=goal_link,
work_goal_link=work_goal_link
work_goal_link=work_goal_link,
journal_link=journal_link
)
cur_month += relativedelta(months=+1)

return month_templates

def build_annual_pages(start_year, end_year, work_goals: bool, personal_goals: bool, j2_env: j2.Environment):
def build_annual_pages(start_year, end_year, goals, j2_env: j2.Environment):
def build_annual_page(year, j2_template: j2.Template):
mini_cal_list = []
for i in range(12):
Expand All @@ -149,12 +166,12 @@ def build_annual_page(year, j2_template: j2.Template):
goal_link = False

for year in range(start_year, end_year + 1):
if work_goals:
if goals['work']:
# placeholder for when annual goals are implemented
# work_goal_link = f'{year}-work-goals'
work_goal_link = False

if personal_goals:
if goals['personal']:
goal_link = f'{year}-goals'

content = build_annual_page(year, annual_template)
Expand Down Expand Up @@ -266,6 +283,28 @@ def build_weekly_work_goal_page(first, j2_template: j2.Template):

return weekly_templates

def build_daily_journal(start: date, end: date, journals_per_page: int, j2_env: j2.Environment):
def build_journal_page(inp_date, j2_template: j2.Template):
days = []
for i in range(journals_per_page):
days.append(inp_date + timedelta(days=i))
return j2_template.render(days=days, journals_per_page=journals_per_page, lines={1: 24, 2: 24, 4: 10})

num_days = (end - start).days
journal_templates = {}
daily_template = j2_env.get_template('journal_pages.html.j2')
frame_template = j2_env.get_template('frame.html.j2')

for i in range(0, num_days + 1, journals_per_page):
cur_date = start + timedelta(days=i)
content = build_journal_page(cur_date, daily_template)
journal_templates[cur_date.strftime('%Y-%m-%d-journal-page')] = frame_template.render(
content=content,
id=cur_date.strftime('%Y-%m-%d-journal-page')
)

return journal_templates

if __name__ == "__main__":
parser = ArgumentParser(prog='Python Planner Generator',
description='GoodNotes 5 Optimized PDF Planner')
Expand All @@ -279,6 +318,7 @@ def build_weekly_work_goal_page(first, j2_template: j2.Template):
parser.add_argument('--personal-goals', action=BooleanOptionalAction, default=True)
parser.add_argument('--daily-pages', action=BooleanOptionalAction, default=True)
parser.add_argument('--weekly-pages', action=BooleanOptionalAction, default=True)
parser.add_argument('--journals-per-page', default=0, type=int, choices=[0, 1, 2, 4])

args = parser.parse_args()

Expand All @@ -295,16 +335,22 @@ def build_weekly_work_goal_page(first, j2_template: j2.Template):
start_time = datetime(2022, 12, 26, args.start_time, 0, 0)
end_time = datetime(2022, 12, 26, args.end_time, 0, 0)

goals = {
'work': args.work_goals,
'personal': args.personal_goals,
'journal': args.journals_per_page
}

pages = []

pages.extend(build_annual_pages(start_date.year, end_date.year, args.work_goals, args.personal_goals, env).values())
pages.extend(build_monthly_pages(start_date, end_date, args.work_goals, args.personal_goals, env).values())
pages.extend(build_annual_pages(start_date.year, end_date.year, goals, env).values())
pages.extend(build_monthly_pages(start_date, end_date, goals, env).values())

if args.weekly_pages:
pages.extend(build_weekly_pages(start_date, end_date, start_time, end_time, args.work_goals, args.personal_goals, env).values())
pages.extend(build_weekly_pages(start_date, end_date, start_time, end_time, goals, env).values())

if args.daily_pages:
pages.extend(build_daily_pages(start_date, end_date, start_time, end_time, env).values())
pages.extend(build_daily_pages(start_date, end_date, start_time, end_time, goals, env).values())

if args.personal_goals:
pages.extend(build_annual_goal_pages(start_date.year, end_date.year, env).values())
Expand All @@ -319,6 +365,9 @@ def build_weekly_work_goal_page(first, j2_template: j2.Template):
if args.weekly_pages:
pages.extend(build_weekly_work_goal_pages(start_date, end_date, env).values())

if args.journals_per_page > 0:
pages.extend(build_daily_journal(start_date, end_date, args.journals_per_page, env).values())

planner = build_planner(pages, env)

generate_html(planner, f'./dest/index{args.file_suffix}.html')
Expand Down
2 changes: 1 addition & 1 deletion src/templates/daily.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

<div class="flex flex-col">
<div class="daily-heading"><div class="mx-auto">notes</div></div>
{% for i in range(15 - ((mini_cal|length) // 7 % 5)) %}
{% for i in range(14 - ((mini_cal|length) // 7 % 5)) %}
<div class="h-5mm border-b border-slate-800"></div>
{% endfor %}
<div class="daily-heading"><div class="mx-auto">
Expand Down
3 changes: 3 additions & 0 deletions src/templates/frame.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{{ content|safe }}
</div>
<div class="absolute bottom-0 right-0 text-slate-300 text-2xl pr-6">
{% if journal_link %}
<a href="#{{ journal_link }}"><i class="fa-solid fa-book pl-2"></i></a>
{% endif %}
{% if goal_link %}
<a href="#{{ goal_link }}"><i class="fa-solid fa-bullseye pl-2"></i></a>
{% endif %}
Expand Down
45 changes: 45 additions & 0 deletions src/templates/journal_pages.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<div>
{% if journals_per_page == 1 %}
<div class="grid grid-cols-2 gap-4">
<div class="flex flex-col" id="{{ days[0].strftime('%Y-%m-%d-journal') }}">
<div class="h-10mm pl-4 flex items-end">
<div class="text-4xl font-playfair font-bold flex justify-between flex-grow pb-2 items-end">
<a href="#{{ days[0].strftime('%Y-%m-%d')}}">{{ days[0].strftime('%-d %B %Y, %A').lower() }}</a>
<a href="#{{ days[0].strftime('%Y-W%W')}}">{{ days[0].strftime('W%-W').lower() }}</a>
</div>
</div>
<div class="border-y border-slate-800 h-5mm flex items-center">
{% include "snippets/journal_icons.html" %}
</div>
{% for i in range(lines[journals_per_page]) %}
<div class="border-b border-slate-800 h-5mm"></div>
{% endfor %}
</div>
<div>
<div class="h-5mm"></div>
{% for i in range(lines[journals_per_page] + 2) %}
<div class="border-b border-slate-800 h-5mm"></div>
{% endfor %}
</div>
</div>
{% elif journals_per_page == 2 or journals_per_page == 4 %}
<div class="grid grid-cols-2 gap-4">
{% for day in days %}
<div class="flex flex-col" id="{{ day.strftime('%Y-%m-%d-journal') }}">
<div class="h-10mm pl-4 flex items-end">
<div class="text-4xl font-playfair font-bold flex justify-between flex-grow pb-2 items-end">
<a href="#{{ day.strftime('%Y-%m-%d')}}">{{ day.strftime('%-d %B %Y, %A').lower() }}</a>
<a href="#{{ day.strftime('%Y-W%W')}}">{{ day.strftime('W%-W').lower() }}</a>
</div>
</div>
<div class="border-y border-slate-800 h-5mm flex items-center">
{% include "snippets/journal_icons.html" %}
</div>
{% for i in range(lines[journals_per_page]) %}
<div class="border-b border-slate-800 h-5mm"></div>
{% endfor %}
</div>
{% endfor %}
</div>
{% endif %}
</div>
18 changes: 18 additions & 0 deletions src/templates/snippets/journal_icons.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="flex-grow grid grid-cols-2">
<div class="flex-grow flex justify-around border-r-2 border-slate-800 text-xl">
<i class="fa-regular fa-face-smile"></i>
<i class="fa-regular fa-face-grin-beam"></i>
<i class="fa-regular fa-face-grimace"></i>
<i class="fa-regular fa-face-tired"></i>
<i class="fa-regular fa-face-frown"></i>
<i class="fa-regular fa-face-sad-cry"></i>
</div>
<div class="flex-grow flex justify-around text-xl">
<i class="fa-solid fa-sun"></i>
<i class="fa-solid fa-cloud-sun"></i>
<i class="fa-solid fa-cloud"></i>
<i class="fa-solid fa-cloud-showers-heavy"></i>
<i class="fa-solid fa-cloud-bolt"></i>
<i class="fa-solid fa-snowflake"></i>
</div>
</div>