From fbb0b392e23067c0379a9dcb75b086c13b29600d Mon Sep 17 00:00:00 2001 From: Arkadiusz Adamski Date: Thu, 3 Oct 2024 21:48:40 +0200 Subject: [PATCH 1/5] chore: add `ruff` to automate and unify formating and linting --- .github/workflows/ruff.yml | 10 ++++++++++ .gitignore | 3 ++- .vscode/extensions.json | 5 +++++ README.md | 9 +++++++++ cardie/authentication/admin.py | 1 - cardie/authentication/tests.py | 1 - cardie/authentication/views.py | 2 +- cardie/main/management/commands/cleartempcards.py | 2 +- cardie/main/migrations/0010_migrate_card_v0_to_v1.py | 1 - cardie/main/models.py | 1 - cardie/main/tests.py | 1 - cardie/main/views.py | 1 - requirements-dev.txt | 1 + 13 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/ruff.yml create mode 100644 .vscode/extensions.json create mode 100644 requirements-dev.txt diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000..326977c --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,10 @@ +name: Ruff +on: [ push, pull_request ] +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: chartboost/ruff-action@v1 + with: + path: './cardie' diff --git a/.gitignore b/.gitignore index 72dcb08..2107c8b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ cardie/db.sqlite3 __pycache__ django.log -.env \ No newline at end of file +.env +.ruff_cache diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..3ff560f --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "charliermarsh.ruff" + ] +} diff --git a/README.md b/README.md index 8b0ca97..8872a85 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Activate the virtual environment using the command for your system (Linux is use ```bash source ./.venv/bin/activate pip install -r requirements.txt +pip install -r requirements-dev.txt ``` Copy the `.env.example` file to a new file called `.env`. @@ -98,6 +99,14 @@ Set the following global environment variables: - `DEBUG` -> `False` - `DATABASE_URL` -> `${db.DATABASE_URL}` (This works on DigitalOcean, this may not work on every hosting provider) +## Development +### ruff +This project uses [`ruff`](https://docs.astral.sh/ruff/) to lint and format the code. +You can run the following command to lint and format the code. +```bash +ruff check cardie --fix +``` +For VS Code users, you can install the `ruff` extension to get linting and formatting on save. ## Contributing Please see [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how you can contribute to Cardie diff --git a/cardie/authentication/admin.py b/cardie/authentication/admin.py index 8c38f3f..b97a94f 100644 --- a/cardie/authentication/admin.py +++ b/cardie/authentication/admin.py @@ -1,3 +1,2 @@ -from django.contrib import admin # Register your models here. diff --git a/cardie/authentication/tests.py b/cardie/authentication/tests.py index 7ce503c..4929020 100644 --- a/cardie/authentication/tests.py +++ b/cardie/authentication/tests.py @@ -1,3 +1,2 @@ -from django.test import TestCase # Create your tests here. diff --git a/cardie/authentication/views.py b/cardie/authentication/views.py index e8568dd..7dfcf6f 100644 --- a/cardie/authentication/views.py +++ b/cardie/authentication/views.py @@ -1,4 +1,4 @@ -from django.shortcuts import render, HttpResponse +from django.shortcuts import HttpResponse from django.contrib.auth.hashers import make_password, check_password from authentication.models import User diff --git a/cardie/main/management/commands/cleartempcards.py b/cardie/main/management/commands/cleartempcards.py index 327e4d6..809a92f 100644 --- a/cardie/main/management/commands/cleartempcards.py +++ b/cardie/main/management/commands/cleartempcards.py @@ -1,4 +1,4 @@ -from django.core.management.base import BaseCommand, CommandError +from django.core.management.base import BaseCommand from main.models import TempCard from django.utils import timezone import datetime diff --git a/cardie/main/migrations/0010_migrate_card_v0_to_v1.py b/cardie/main/migrations/0010_migrate_card_v0_to_v1.py index 129d14e..d03937a 100644 --- a/cardie/main/migrations/0010_migrate_card_v0_to_v1.py +++ b/cardie/main/migrations/0010_migrate_card_v0_to_v1.py @@ -1,7 +1,6 @@ # Generated by Django 5.0.3 on 2024-09-09 23:31 from django.db import migrations -import json def migrate_json_data(apps, schema_editor): Card = apps.get_model('main', 'Card') diff --git a/cardie/main/models.py b/cardie/main/models.py index a5e5c2c..a90cc97 100644 --- a/cardie/main/models.py +++ b/cardie/main/models.py @@ -1,4 +1,3 @@ -from colorfield.fields import ColorField from django.db import models from authentication.models import User import uuid diff --git a/cardie/main/tests.py b/cardie/main/tests.py index 7ce503c..4929020 100644 --- a/cardie/main/tests.py +++ b/cardie/main/tests.py @@ -1,3 +1,2 @@ -from django.test import TestCase # Create your tests here. diff --git a/cardie/main/views.py b/cardie/main/views.py index d5c1222..de37109 100644 --- a/cardie/main/views.py +++ b/cardie/main/views.py @@ -1,5 +1,4 @@ import json -import os from authentication.models import User from authentication.views import sign_in diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..a01a612 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1 @@ +ruff==0.6.8 From f7ecbe27e439e2ce35e861bbf23396b24b731cc6 Mon Sep 17 00:00:00 2001 From: Vineet Date: Wed, 2 Oct 2024 19:43:30 +0530 Subject: [PATCH 2/5] Close Issue 53: Update from cursor to pointer on the Homepage --- cardie/static/main/ui.css | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cardie/static/main/ui.css b/cardie/static/main/ui.css index aacc607..ac8c97f 100644 --- a/cardie/static/main/ui.css +++ b/cardie/static/main/ui.css @@ -75,6 +75,7 @@ .ui_button_large:hover:enabled { scale: 1.05; + cursor: pointer; } .ui_button_large:active:enabled { @@ -150,6 +151,7 @@ .ui_button_icon:hover:enabled { scale: 1.1; + cursor: pointer; } .ui_button_icon:active:enabled { @@ -190,6 +192,7 @@ .ui_button_smallicon:hover:enabled { scale: 1.05; + cursor: pointer; } .ui_button_smallicon:active:enabled { @@ -229,6 +232,7 @@ .ui_button_small:hover:enabled { scale: 1.05; + cursor: pointer; } .ui_button_small:active:enabled { @@ -630,4 +634,4 @@ .ui_link_generic:visited { color: var(--default-text-color); text-decoration: none; -} \ No newline at end of file +} From 08905203584bac0a822f714d839a0ec29c7f3660 Mon Sep 17 00:00:00 2001 From: Arkadiusz Adamski Date: Fri, 4 Oct 2024 21:03:34 +0200 Subject: [PATCH 3/5] chore: add djlint and reformat templates --- .djlintrc | 4 + README.md | 7 + cardie/main/templates/authentication.html | 112 +++++--- cardie/main/templates/base.html | 29 ++- cardie/main/templates/card.html | 25 +- cardie/main/templates/card_view.html | 38 +-- cardie/main/templates/dialogs/print.html | 38 +-- cardie/main/templates/editor.html | 243 +++++++++++------- .../main/templates/editor/font_selector.html | 44 ++-- .../main/templates/editor/items_editor.html | 60 +++-- cardie/main/templates/footer.html | 34 ++- cardie/main/templates/home.html | 154 ++++++----- cardie/main/templates/index.html | 101 ++++---- cardie/main/templates/privacy.html | 46 ++-- cardie/main/templates/ui.html | 78 +++--- requirements-dev.txt | 1 + 16 files changed, 585 insertions(+), 429 deletions(-) create mode 100644 .djlintrc create mode 100644 requirements-dev.txt diff --git a/.djlintrc b/.djlintrc new file mode 100644 index 0000000..73726fb --- /dev/null +++ b/.djlintrc @@ -0,0 +1,4 @@ +{ + "max_line_length": "180" +} + diff --git a/README.md b/README.md index 8b0ca97..5cc8e80 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Activate the virtual environment using the command for your system (Linux is use ```bash source ./.venv/bin/activate pip install -r requirements.txt +pip install -r requirements-dev.txt ``` Copy the `.env.example` file to a new file called `.env`. @@ -98,6 +99,12 @@ Set the following global environment variables: - `DEBUG` -> `False` - `DATABASE_URL` -> `${db.DATABASE_URL}` (This works on DigitalOcean, this may not work on every hosting provider) +## Development +### djlint +This project uses `djlint` to lint the templates. You can run this using the following command +```bash +djlint cardie --reformat +``` ## Contributing Please see [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how you can contribute to Cardie diff --git a/cardie/main/templates/authentication.html b/cardie/main/templates/authentication.html index 1706352..851c35d 100644 --- a/cardie/main/templates/authentication.html +++ b/cardie/main/templates/authentication.html @@ -1,58 +1,89 @@ {% extends "base.html" %} - {% load static %} - {% block head_title %}Authentication{% endblock %} - {% block stylesheets %} - - - + + {% endblock %} - - {% block body %}
{% csrf_token %} - - - - - -
- + + + + + + +
+
+

+ Create Account +

+
+ + + + + + + + +
+
+ Privacy Policy +
+ +
{% endblock %} - {% block scripts %} - {% endblock %} diff --git a/cardie/main/templates/base.html b/cardie/main/templates/base.html index e1d4910..003c530 100644 --- a/cardie/main/templates/base.html +++ b/cardie/main/templates/base.html @@ -2,34 +2,37 @@ - {% block head_scripts %}{% endblock head_scripts %} - + {% block head_scripts %} + {% endblock head_scripts %} - - - + + - + {% block stylesheets %}{% endblock %} - - - + - Cardie | {% block head_title %}{% endblock %} + Cardie | + {% block head_title %}{% endblock %} + - {% block body %}{% endblock %} {% include "footer.html" %} - - {% block scripts %}{% endblock %} diff --git a/cardie/main/templates/card.html b/cardie/main/templates/card.html index 3301ec6..23ab104 100644 --- a/cardie/main/templates/card.html +++ b/cardie/main/templates/card.html @@ -1,24 +1,17 @@
-
-

username

pronouns

- -
- -
-
+
-

Back of card

@@ -26,14 +19,14 @@
- - +

All Items

- -
- -
- +
-
\ No newline at end of file +
+
diff --git a/cardie/main/templates/card_view.html b/cardie/main/templates/card_view.html index 6f182ce..c87dca5 100644 --- a/cardie/main/templates/card_view.html +++ b/cardie/main/templates/card_view.html @@ -1,16 +1,15 @@ {% extends "base.html" %} - {% load static %} - {% block head_title %}Card{% endblock %} - {% block stylesheets %} - - - + + {% endblock %} - {% block body %}
@@ -20,28 +19,29 @@

Created by username

- - -
- {% include "card.html" %} -
- +
{% include "card.html" %}
-

Created with Cardie. You can to save this card for later and to make your own.

+

+ Created with Cardie. You can + + to save this card for later and to make your own. +

-
-

Hello {{ username }}

+

+ Hello {{ username }} + +

-
-

This card is owned by you

+

+ This card is owned by you +

{% endblock %} - {% block scripts %} diff --git a/cardie/main/templates/dialogs/print.html b/cardie/main/templates/dialogs/print.html index c95c963..31953e3 100644 --- a/cardie/main/templates/dialogs/print.html +++ b/cardie/main/templates/dialogs/print.html @@ -1,25 +1,29 @@ - +

Print Card

- +
- - - - + +

Puts a total of 4 cards on one page, fronts and backs. After you print the page you can cut and glue the two halves together.

-
-

A layout of 8 cards per two pages. Print them both and select double sided (and flip on the long edge) or print the first page, put the paper back in the printer and print the second page again.

+

+ A layout of 8 cards per two pages. Print them both and select double sided (and flip on the long edge) or print the first page, put the paper back in the printer and print the second page again. +

- - -
\ No newline at end of file + +
diff --git a/cardie/main/templates/editor.html b/cardie/main/templates/editor.html index 317ce2b..05094da 100644 --- a/cardie/main/templates/editor.html +++ b/cardie/main/templates/editor.html @@ -1,144 +1,195 @@ {% extends "base.html" %} - {% load static %} - {% block head_title %}Editor{% endblock %} - {% block head_scripts %} - + {% endblock %} - {% block stylesheets %} - - + - - - - -{%endblock %} - + + + +{% endblock %} {% block body %}
- - -

Editor

+ + +

Editor

-
- +

Untitled Card

by {{ username }}

- -

Loading...

+

+ Loading... +

-
-

Layout

+

+ Layout +

- - - + + +
-
-

Details

-
- - -
- - {% include "editor/font_selector.html" %} - -
-

Colors

+

+ Details +

- -

Background color

- -

Accent color

- -

Text color

- -
- - {% include "editor/items_editor.html" %} - -
- -
- {% include "card.html" %} - -
- -
- - - - -
- -
-

or to save and share this card.

-
- -
- -
-
+ + + +
- -
-
- - -
- -
+ {% include "editor/font_selector.html" %} +
+

+ Colors +

+
+

Background color

+ + +

Accent color

+ + +

Text color

+ + +
+{% include "editor/items_editor.html" %} +
+
+ {% include "card.html" %} +
+
+ + + +
- -
-
-

Name Card

- -
- - - +
+

+ + or + + to save and share this card. +

+
+
+
+
+
+
+
+ + + +
+
+
+
+
+

Name Card

+
- - {% include "dialogs/print.html" %} - -
+ + + +
+{% include "dialogs/print.html" %} +
{% endblock %} - {% block scripts %} - - - - - {% endblock %} diff --git a/cardie/main/templates/editor/font_selector.html b/cardie/main/templates/editor/font_selector.html index 7e71c27..77eb654 100644 --- a/cardie/main/templates/editor/font_selector.html +++ b/cardie/main/templates/editor/font_selector.html @@ -1,40 +1,48 @@ -
-

Font Style

+
+

+ Font Style +

-

- +
- - -
+
- - +
-
- \ No newline at end of file + diff --git a/cardie/main/templates/editor/items_editor.html b/cardie/main/templates/editor/items_editor.html index 52a4c76..a3ae55b 100644 --- a/cardie/main/templates/editor/items_editor.html +++ b/cardie/main/templates/editor/items_editor.html @@ -1,31 +1,56 @@ -
-

Items

+
+

+ Items +

-
- - - +
- - \ No newline at end of file + diff --git a/cardie/main/templates/footer.html b/cardie/main/templates/footer.html index 767f5bb..ced8974 100644 --- a/cardie/main/templates/footer.html +++ b/cardie/main/templates/footer.html @@ -1,29 +1,39 @@ {% load static %} - diff --git a/cardie/main/templates/home.html b/cardie/main/templates/home.html index 3c77f41..fbfacfb 100644 --- a/cardie/main/templates/home.html +++ b/cardie/main/templates/home.html @@ -1,98 +1,114 @@ {% extends "base.html" %} - {% load static %} - {% block head_title %}Home{% endblock %} - {% block stylesheets %} - + {% endblock %} - {% block body %}
-
- - +
- +
-
- -
+
- - - + +
-
-

My Wallet

+

+ My Wallet +

Your wallet is where all of the cards you saved appear. You can save cards by going to the link for a card and pressing "Save this card"

-

You don't have any cards saved yet! Once you do, they will appear here for you to find later.

-
-

My Cards

+

+ My Cards +

This is where all of the cards you've designed appear

- +
-
- -
- - - -
- -
- - -
-

Rename Card

- -
- - - -
- - -
-

Delete Card

- -
- -

Are you sure you want to delete this Card? This action is irreversible.

- - -
- -
-{% endblock %} - -{% block scripts %} - - -{% endblock %} +
+
+ + + +
+ +
+ +
+

Rename Card

+ +
+ + + +
+ +
+

Delete Card

+ +
+

Are you sure you want to delete this Card? This action is irreversible.

+ + +
+
+ {% endblock %} + {% block scripts %} + + + {% endblock %} diff --git a/cardie/main/templates/index.html b/cardie/main/templates/index.html index 711a0a3..bac9904 100644 --- a/cardie/main/templates/index.html +++ b/cardie/main/templates/index.html @@ -1,77 +1,80 @@ {% extends "base.html" %} - {% load static %} - {% block head_title %}Index{% endblock %} - {% block stylesheets %} - + {% endblock %} - {% block body %}
- -
- - + +
- - +
- -

Welcome to

- +

An open source business card designer and sharing platform

-
- - - + + +
-
-
- - -
-

Create a Card

-
    -
  • Add your name, title or pronouns to the top section
  • -
  • Add text information like your phone number, email, and more
  • -
  • You can also add links to any of your other online presences, like social accounts or links to your other work.
  • -
-
-
- -
- - -
-

Editor

-
    -
  • Add information and link items to your card
  • -
  • You can customize those items with a icon selector
  • -
  • Once you're finished, copy a link to your card so you can share it with anyone
  • -
-
+ + +
+

Create a Card

+
    +
  • Add your name, title or pronouns to the top section
  • +
  • Add text information like your phone number, email, and more
  • +
  • You can also add links to any of your other online presences, like social accounts or links to your other work.
  • +
- - {% endblock %} - - {% block scripts %} +
+
+ + +
+

Editor

+
    +
  • Add information and link items to your card
  • +
  • You can customize those items with a icon selector
  • +
  • Once you're finished, copy a link to your card so you can share it with anyone
  • +
+
+
+{% endblock %} +{% block scripts %} - - + - - - + + - You're not really supposed to be here... - - - - - + + + + -

Header Text

Header Text Left

Subheader Text

@@ -32,45 +39,36 @@

Smaller Subheader Text

Body Text

Description Text

- - - +

Information status box

-

Warning status box

-

Critical status box

- - - -
- -
- -
- -
-
-

Front of card

-
- -
-

Back of card

-
+ + +
+
+
+
+
+

Front of card

- - {% include "footer.html" %} - - - - +
+

Back of card

+
+
+ {% include "footer.html" %} + + + diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..ad04b75 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1 @@ +djlint==1.35.2 From 914ce2a5287e58a806564b800e4ff47e96866a9f Mon Sep 17 00:00:00 2001 From: nfoert Date: Fri, 4 Oct 2024 18:18:14 -0400 Subject: [PATCH 4/5] Add missing cursor CSS to ui_button_grid --- cardie/static/main/ui.css | 1 + 1 file changed, 1 insertion(+) diff --git a/cardie/static/main/ui.css b/cardie/static/main/ui.css index ac8c97f..486c6c3 100644 --- a/cardie/static/main/ui.css +++ b/cardie/static/main/ui.css @@ -113,6 +113,7 @@ .ui_button_grid:hover:enabled { scale: 1.05; + cursor: pointer; } .ui_button_grid:active:enabled { From 6bc05f63f8832c7d69574222a2e3cfb8483aa337 Mon Sep 17 00:00:00 2001 From: nfoert Date: Fri, 4 Oct 2024 20:15:33 -0400 Subject: [PATCH 5/5] Fix issue with unnecessary tags Make some adjustments to .djlintrc Create task for djlint --- .djlintrc | 4 +- .vscode/tasks.json | 10 ++ cardie/main/templates/authentication.html | 102 +++++++------ cardie/main/templates/editor.html | 173 +++++++++++----------- cardie/main/templates/home.html | 49 +++--- cardie/main/templates/ui.html | 29 ++-- 6 files changed, 186 insertions(+), 181 deletions(-) diff --git a/.djlintrc b/.djlintrc index 73726fb..b895850 100644 --- a/.djlintrc +++ b/.djlintrc @@ -1,4 +1,6 @@ { - "max_line_length": "180" + "max_line_length": "180", + "max_blank_lines": 1, + "profile": "django" } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 681f74c..bf1348e 100755 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -64,6 +64,16 @@ "panel": "new" }, "problemMatcher": [] + }, + { + "label": "Format Django templats with djlint", + "type": "shell", + "command": "source .venv/bin/activate && djlint cardie --reformat", + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] } ] } \ No newline at end of file diff --git a/cardie/main/templates/authentication.html b/cardie/main/templates/authentication.html index 851c35d..c8468e0 100644 --- a/cardie/main/templates/authentication.html +++ b/cardie/main/templates/authentication.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load static %} {% block head_title %}Authentication{% endblock %} + {% block stylesheets %} {% endblock %} + {% block body %}
{% csrf_token %} @@ -31,59 +33,55 @@ type="text" class="ui_input_generic" placeholder="Username"> - - - - - -
-
-

- Create Account -

-
- - - - - - - - -
-
- Privacy Policy -
-
-
+ + + +
+
+

+ Create Account +

+
+ + + + + +
+
+ Privacy Policy +
+
+
{% endblock %} + {% block scripts %} {% endblock %} + {% block stylesheets %} @@ -19,6 +21,7 @@ type="text/css" href="{% static '/main/editor_print.css' %}"> {% endblock %} + {% block body %}
@@ -78,102 +81,96 @@ id="editor_main_settings_details_primary" placeholder="Primary text" data-tippy-content="Perfect for your name or username"> - + +
+ {% include "editor/font_selector.html" %} +
+

+ Colors +

+
+

Background color

+ +

Accent color

+ +

Text color

+ +
+ {% include "editor/items_editor.html" %} +
+
+ {% include "card.html" %} +
+
+ + + + +
+
+

+ + or + + to save and share this card. +

+
+
+
+
+
+
+
- -
- {% include "editor/font_selector.html" %} -
-

- Colors -

-
-

Background color

- - -

Accent color

- - -

Text color

- - -
-{% include "editor/items_editor.html" %} -
-
- {% include "card.html" %} -
-
- - - - -
-
-

- - or - - to save and share this card. -

+ id="editor-iconselector-top-search" + placeholder="Search for an icon"> + +
+
-
-
-
-
-
-
+
+
+

Name Card

+ +
- - -
-
-
-
-
-

Name Card

-
- - - -
-{% include "dialogs/print.html" %} -
+ {% include "dialogs/print.html" %} +
{% endblock %} + {% block scripts %} diff --git a/cardie/main/templates/home.html b/cardie/main/templates/home.html index fbfacfb..01c30f3 100644 --- a/cardie/main/templates/home.html +++ b/cardie/main/templates/home.html @@ -86,29 +86,28 @@ - - - - -
-

Delete Card

- -
-

Are you sure you want to delete this Card? This action is irreversible.

- - -
-
- {% endblock %} - {% block scripts %} - - - {% endblock %} + + +
+

Delete Card

+ +
+

Are you sure you want to delete this Card? This action is irreversible.

+ + +
+
+ {% endblock %} + {% block scripts %} + + + {% endblock %} diff --git a/cardie/main/templates/ui.html b/cardie/main/templates/ui.html index 6be0475..68733bc 100644 --- a/cardie/main/templates/ui.html +++ b/cardie/main/templates/ui.html @@ -55,20 +55,19 @@

Critical status box

- -
-
-
-
-
-

Front of card

+
+
+
+
+
+

Front of card

+
+
+

Back of card

+
-
-

Back of card

-
-
- {% include "footer.html" %} - - - + {% include "footer.html" %} + + +