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
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
redeploy:
runs-on: ubuntu-latest
if: >
if: >
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push'
steps:
Expand All @@ -23,4 +23,4 @@ jobs:
-H "Content-Type: application/json" \
-H "X-Hub-Signature-256: sha256=$hash" \
-d @payload.json \
${{ secrets.WEBHOOK_URL }}
${{ secrets.WEBHOOK_URL }}
1 change: 0 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-yaml
args: [--unsafe]
- id: end-of-file-fixer
- id: trailing-whitespace
- id: detect-private-key
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.10.6
hooks:
- id: uv-lock
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.4
hooks:
- id: ruff-check
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.24.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ['@commitlint/config-conventional']
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ Personal website that includes a portfolio and a blog. Made with [Django](https:
### Dependencies
- ``pyproject.toml``
- ``package.json``
- ``.pre-commit-config.yaml`` (Git hooks)

#### Installation
- ``uv sync [--group dev]``
- ``npm install``
- ``uvx pre-commit install`` (Git hooks)

### Environment variables
#### Always required
Expand Down Expand Up @@ -46,9 +48,10 @@ Personal website that includes a portfolio and a blog. Made with [Django](https:

## File structure
### Python imports
1. Third-party libraries
2. Python standard library
3. Custom modules
1. Python standard library
2. Third-party libraries
3. Local modules
> See: [PEP 8](https://peps.python.org/pep-0008/#imports)

### Django project apps
- ``api``: REST API.
Expand Down
2 changes: 1 addition & 1 deletion api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class Meta:
'project_download_url',
'image_url',
'date',
]
]
2 changes: 1 addition & 1 deletion api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

urlpatterns = [
path('project/<int:id>/', views.get_project),
]
]
8 changes: 4 additions & 4 deletions assets/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ $md-breakpoint: map-get($grid-breakpoints, "md");
@media (min-width: $md-breakpoint) {
padding-top: 3rem;
}

.heading-anchor {
text-decoration: none;

&:hover {
text-decoration: underline;
}
}

.badge {
&:hover {
box-shadow: 0 1px 2px 1px rgba(0, 0, 0, 0.15);
Expand Down Expand Up @@ -215,7 +215,7 @@ $md-breakpoint: map-get($grid-breakpoints, "md");
margin-bottom: 0.75rem;
color: $body-color;
}

.card-subtitle {
letter-spacing: 0.075em;
}
Expand Down Expand Up @@ -291,4 +291,4 @@ $md-breakpoint: map-get($grid-breakpoints, "md");

--bs-btn-active-bg: #{darken($white-accent, 15%)};
--bs-btn-active-border-color: #{darken($white-accent, 15%)};
}
}
2 changes: 1 addition & 1 deletion assets/htmx_global.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
window.htmx = require('htmx.org');
window.htmx = require('htmx.org');
2 changes: 1 addition & 1 deletion assets/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'bootstrap/dist/js/bootstrap.bundle.min.js';
import './base.scss';
import 'htmx.org/dist/htmx.min.js';
import './htmx_global.js';
import './htmx_global.js';
2 changes: 1 addition & 1 deletion core/utils/turnstile_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def validate_turnstile(token, secret, remoteip=None):
}
if remoteip:
data['remoteip'] = remoteip

try:
response = requests.post(url, data=data, timeout=10)
response.raise_for_status()
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
services:
portfolio:
build:
build:
context: .
dockerfile: Dockerfile
target: development
command: >
command: >
sh -c "
npm run dev &&
python manage.py migrate &&
Expand Down
2 changes: 1 addition & 1 deletion home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class BlogPostAdmin(admin.ModelAdmin):
fieldsets = [
('Post content',
('Post content',
{'fields': ['post_title', 'slug', 'preview_text', 'post_body']}
),
('Date information', {'fields': ['date_published']}),
Expand Down
18 changes: 9 additions & 9 deletions home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def is_about_content(self):
@property
def sorted_tags(self):
return self.tags.all().order_by('name')

@property
def url(self):
if self.slug:
return reverse('home:blog_post_by_slug', kwargs={'slug': self.slug})
return reverse('home:blog_post_by_id', kwargs={'id': self.id})

def save(self, *args, **kwargs):
if not self.preview_text:
soup = BeautifulSoup(self.post_body, 'html.parser')
Expand Down Expand Up @@ -83,15 +83,15 @@ def __str__(self):
return self.skill_title

def level_text(self):
if self.skill_level == 1:
if self.skill_level == 1:
return "Basic knowledge"
elif self.skill_level == 2:
elif self.skill_level == 2:
return "Novice"
elif self.skill_level == 3:
elif self.skill_level == 3:
return "Intermediate"
elif self.skill_level == 4:
elif self.skill_level == 4:
return "Advanced"
elif self.skill_level == 5:
elif self.skill_level == 5:
return "Expert"


Expand All @@ -113,7 +113,7 @@ class Project(models.Model):

def __str__(self):
return self.project_title

@property
def sorted_tags(self):
return self.tags.all().order_by('name')
Expand All @@ -130,7 +130,7 @@ class Experience(models.Model):

def __str__(self):
return f"{self.position} at {self.employer}"

@property
def sorted_tags(self):
return self.tags.all().order_by('name')
Expand Down
2 changes: 1 addition & 1 deletion home/templates/home/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ <h1 class="mb-3 mb-md-4">Blog</h1>
window.scrollTo({top: 0, behavior: 'smooth'});
});
</script>
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion home/templates/home/blog_post.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ <h1 class="mb-2">{{post.post_title}}</h1>
</div>
</div>
</div>
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion home/templates/home/partials/blog_post_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ <h5 class="">
</a>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion home/templates/home/partials/blog_post_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
{% endfor %}
<div class="col-12">
{% include 'home/partials/pagination.html' with page=posts hx_target="#blog-post-list" %}
</div>
</div>
2 changes: 1 addition & 1 deletion home/templates/home/partials/credential_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ <h6 class="card-subtitle">{{credential.name}}</h6>
{% endif %}
</div>
</div>
</div>
</div>
6 changes: 3 additions & 3 deletions home/templates/home/partials/pagination.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<nav>
<ul class="pagination justify-content-center">
<li class="page-item {% if page.number == 1 %}disabled{% endif %}">
<a class="page-link"
<a class="page-link"
hx-get="?{{ params }}{{ params|yesno:'&,' }}page=1"
hx-target="{{ hx_target }}"
hx-push-url="true"
Expand All @@ -20,7 +20,7 @@
</li>
{% endif %}
<li class="page-item active">
<a class="page-link"
<a class="page-link"
hx-get="?{{ params }}{{ params|yesno:'&,' }}page={{ page.number }}"
hx-target="{{ hx_target }}"
hx-push-url="true"
Expand All @@ -47,4 +47,4 @@
</a>
</li>
</ul>
</nav>
</nav>
6 changes: 3 additions & 3 deletions home/templates/home/partials/project_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ <h6 class="card-subtitle text-body-secondary">{{ project.project_role }}</h6>
</p>
<div class="d-flex flex-wrap gap-2 mt-auto">
{% for tag in project.sorted_tags %}
<a
<a
hx-get="?tag={{tag.slug}}"
hx-target="{{ hx_target }}"
hx-push-url="true"
href="?tag={{tag.slug}}"
href="?tag={{tag.slug}}"
class="badge text-bg-secondary"
><i class="{{tag.fa_css}}"></i> {{tag.name}}
</a>
Expand Down Expand Up @@ -57,4 +57,4 @@ <h6 class="card-subtitle text-body-secondary">{{ project.project_role }}</h6>
</div>
{% endif %}
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion home/templates/home/partials/project_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
{% endfor %}
<div class="col-12">
{% include 'home/partials/pagination.html' with page=projects hx_target="#project-list" %}
</div>
</div>
2 changes: 1 addition & 1 deletion home/templates/home/projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ <h1 class="mb-3 mb-md-4">Projects</h1>
window.scrollTo({top: 0, behavior: 'smooth'});
});
</script>
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion home/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def setUp(self):
)
BlogPost.objects.create(
date_published=datetime.now(),
post_title="Post with 51 words",
post_title="Post with 51 words",
post_body="<div>" + ("word " * 51).strip() + "</div>",
)
BlogPost.objects.create(
Expand Down
2 changes: 1 addition & 1 deletion portfolio/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CustomAdminSite(admin.AdminSite):
@property
def site_title(self):
return f'{getattr(config, 'BRAND')} Admin'

@property
def site_header(self):
return self.site_title
Expand Down
2 changes: 1 addition & 1 deletion portfolio/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class CustomAdminConfig(AdminConfig):
default_site = 'portfolio.admin.CustomAdminSite'
default_site = 'portfolio.admin.CustomAdminSite'
8 changes: 4 additions & 4 deletions portfolio/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='.localhost', cast=Csv())

# FIXING CSRF ISSUE
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# https://stackoverflow.com/a/71482883/1615284
# FIXING CSRF ISSUE
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# https://stackoverflow.com/a/71482883/1615284
# https://docs.djangoproject.com/en/5.1/ref/settings/#secure-proxy-ssl-header

USE_X_FORWARDED_HOST = True
Expand Down Expand Up @@ -250,5 +250,5 @@
'Global': ('BRAND', 'EMAIL', 'DEFAULT_CURRENCY'),
'Links': ('GITHUB_URL', 'LINKEDIN_URL', 'UPWORK_URL', 'RESUME_URL', 'KOFI_URL', 'PAYPAL_URL'),
'Hero Section': ('HERO_HEADING', 'HERO_SUBHEADING'),
'Sponsors': ('SPONSOR_DURATION', 'SPONSOR_DONATION_URL', 'SPONSOR_MESSAGE_MINIMUM_CONTRIBUTION'),
'Sponsors': ('SPONSOR_DURATION', 'SPONSOR_DONATION_URL', 'SPONSOR_MESSAGE_MINIMUM_CONTRIBUTION'),
}
2 changes: 1 addition & 1 deletion sponsors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Sponsorship(models.Model):

def __str__(self):
return f"{self.name}, {self.amount}, {self.currency}, {self.start_date} - {self.expiration_date}, {self.platform}"

@property
def display_eligible(self):
# TODO determine eligibility for other currencies
Expand Down
2 changes: 1 addition & 1 deletion sponsors/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Meta:
'is_public',
'timestamp',
]

def create(self, validated_data):
start_date = validated_data.get('start_date')
expiration_date = start_date + timedelta(days=getattr(config, 'SPONSOR_DURATION'))
Expand Down
Loading