Skip to content

Commit

Permalink
Merge pull request #147 from kraanzu/develop
Browse files Browse the repository at this point in the history
v2.0.2
  • Loading branch information
kraanzu authored Oct 19, 2023
2 parents aab5e5a + 9161399 commit 447424d
Show file tree
Hide file tree
Showing 12 changed files with 487 additions and 341 deletions.
106 changes: 106 additions & 0 deletions .github/workflows/app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
push:
branches: [ "main", "develop"]
pull_request:
branches: [ "main", "develop" ]

permissions:
contents: read

jobs:
windows-build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install pyinstaller
- name: Package app with pyinstaller
run: |
python -c "with open('dooit.py', 'w') as f: f.write('from dooit.__init__ import main\nmain()\n')"
pyinstaller --clean -F dooit.py --add-data=dooit/utils/default_config.py:dooit/utils/
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.0
with:
name: dooit-windows
path: ./dist/dooit.exe
- name: Rename final file
run: cp ./dist/dooit.exe ./dist/windows-dooit.exe
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ./dist/windows-dooit.exe

linux-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install pyinstaller
- name: Package app with pyinstaller
run: |
python -c "with open('dooit.py', 'w') as f: f.write('from dooit.__init__ import main\nmain()\n')"
pyinstaller --clean -F dooit.py --add-data=dooit/utils/default_config.py:dooit/utils/
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.0
with:
name: dooit-linux
path: ./dist/dooit
- name: Rename final file
run: cp ./dist/dooit ./dist/linux-dooit
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: linux-dooit
files: ./dist/linux-dooit

macOS-build:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install pyinstaller
- name: Package app with pyinstaller
run: |
python -c "with open('dooit.py', 'w') as f: f.write('from dooit.__init__ import main\nmain()\n')"
pyinstaller --clean -F dooit.py --add-data=dooit/utils/default_config.py:dooit/utils/
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.0
with:
name: dooit-macos
path: ./dist/dooit
- name: Rename final file
run: cp ./dist/dooit ./dist/macos-dooit
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: mac-dooit
files: ./dist/macos-dooit
11 changes: 5 additions & 6 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install poetry
- name: Build package
run: python -m build
run: poetry build
- name: Configure TOKEN
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
run: poetry Publish
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# test
# dooit stuf
test.py
todos
sample_todo.yaml

# VSCODE
.vscode/
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# 2.0.2

### Added
- Add `DATE_FORMAT` and `TIME_FORMAT` to allow users to customize due date https://github.com/kraanzu/dooit/issues/141 (Also [see this](https://github.com/kraanzu/dooit/wiki/Configuration#general))

# 2.0.1

### Added
Expand Down
2 changes: 1 addition & 1 deletion dooit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse
from importlib.metadata import version
from .ui.tui import Dooit
from dooit.ui.tui import Dooit


def main():
Expand Down
19 changes: 10 additions & 9 deletions dooit/ui/screens/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ class BaseScreen(Screen):
Base screen with function to resolve `Key` event to str
"""

PRINTABLE = (
"0123456789"
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ "
SPACE_CHARACTERS = (
"\u0020\u00a0\u1680\u202f\u205f\u3000"
"\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b"
)

def resolve_key(self, event: events.Key) -> str:
return (
event.character
if (event.character and (event.character in self.PRINTABLE))
else event.key
)
if not event.character:
return event.key

if event.is_printable or event.character in self.SPACE_CHARACTERS:
return event.character

return event.key
11 changes: 11 additions & 0 deletions dooit/ui/screens/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ async def on_key(self, event: events.Key) -> None:
event.stop()

key = self.resolve_key(event)
await self.send_keypress(key)

async def send_keypress(self, key: str):
if self.bar.status == "SEARCH":
return await self.query_one(Searcher).keypress(key)

Expand Down Expand Up @@ -84,6 +87,14 @@ async def mount_dashboard(self) -> None:
await self.clear_right()
await self.mount(EmptyWidget(), after=self.query_one(WorkspaceTree))

@on(events.Paste)
async def paste_texts(self, event: events.Paste) -> None:
event.prevent_default()
event.stop()
if not event.text:
return
await self.send_keypress(f"events.Paste:{event.text}")

@on(ApplySort)
async def apply_sort(self, event: ApplySort) -> None:
await self.query_one(event.query, expect_type=Tree).apply_sort(
Expand Down
34 changes: 24 additions & 10 deletions dooit/ui/widgets/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
TODOS = config_man.get("TODO")
WORKSPACES = config_man.get("WORKSPACE")


RED = config_man.get("red")
YELLOW = config_man.get("yellow")
GREEN = config_man.get("green")
ORANGE = config_man.get("orange")

DATE_FORMAT = config_man.get("DATE_FORMAT")
TIME_FORMAT = config_man.get("TIME_FORMAT")

DATE_MAX_WIDTH = 17


Expand Down Expand Up @@ -102,20 +106,30 @@ def draw(self) -> str:
icon = TODOS["due_icon"]
style = getattr(self.screen, "date_style")

if style == "classic":
due: datetime = getattr(self.model, f"_{self._property}")._value

if self.is_editing:
value = super().draw()
if not value or value == "none":
return ""
else:
due: datetime = getattr(self.model, f"_{self._property}")._value
if not due:
return ""
if style == "classic":
if not due:
return ""

time = due.time()
if time.hour == time.minute == 0:
value = due.strftime(DATE_FORMAT)
else:
value = due.strftime(f"{DATE_FORMAT} {TIME_FORMAT}")

else:
if not due:
return ""

now = datetime.now()
if not due.hour:
due = due.replace(day=due.day + 1)
now = datetime.now()
if not due.hour:
due = due.replace(day=due.day + 1)

value = self.timedelta_to_words(due - now)
value = self.timedelta_to_words(due - now)

return self._colorize_by_status(icon) + value

Expand Down
19 changes: 9 additions & 10 deletions dooit/ui/widgets/simple_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@ async def keypress(self, key: str) -> None:
"""
Handles Keypresses
"""
if key == "space":
key = " "

if key == "enter":
await self.stop_edit()

Expand Down Expand Up @@ -239,13 +236,15 @@ async def keypress(self, key: str) -> None:
await self._insert_text("\t")

# COPY-PASTA
elif key == "ctrl+v":
try:
await self._insert_text()
except Exception:
return

if len(key) == 1:
# elif key == "ctrl+v":
# try:
# await self._insert_text()
# except Exception:
# return
elif key.startswith('events.Paste:'):
await self._insert_text(key[13:])

elif len(key) == 1:
await self._insert_text(key)

self.refresh(layout=True)
Expand Down
2 changes: 2 additions & 0 deletions dooit/utils/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def get_username():
YANK_COLOR = blue
SAVE_ON_ESCAPE = False
USE_DAY_FIRST = True
DATE_FORMAT = "%d %h"
TIME_FORMAT = "%H:%M"

#################################
# DASHBOARD #
Expand Down
Loading

0 comments on commit 447424d

Please sign in to comment.