Skip to content

Commit 016ec04

Browse files
committed
feat: add supporters page
Signed-off-by: Frost Ming <me@frostming.com>
1 parent f0c36e7 commit 016ec04

File tree

11 files changed

+205
-4
lines changed

11 files changed

+205
-4
lines changed

pycon/settings/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
INSTALLED_APPS = [
2727
"base",
2828
"home",
29+
"supporter",
2930
"search",
3031
"bakery",
3132
"wagtailbakery",

pycon/static/css/pycon.css

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ a:hover {
4747
border-bottom-color: #ffd43b;
4848
}
4949

50+
main {
51+
margin: 0 10px;
52+
}
53+
54+
@media (min-width: 1200px) {
55+
main {
56+
margin: 0 auto;
57+
width: 1200px;
58+
}
59+
}
60+
5061
.content {
5162
overflow: hidden;
5263
}
@@ -206,10 +217,26 @@ footer i {
206217
background-color: #ffffff;
207218
border-radius: 10px;
208219
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 0 20px rgba(0, 0, 0, 0.05);
209-
padding: 2rem;
210220
position: relative;
221+
padding: 1rem;
211222
z-index: 1;
212-
max-width: 1200px;
213-
margin: 0 auto;
214223
}
215224

225+
@media (min-width: 992px) {
226+
.card {
227+
padding: 1rem 2rem;
228+
}
229+
}
230+
231+
.title {
232+
border: 2px solid #4B8BBE; /* Python blue */
233+
background-color: #FFD43B; /* Python yellow */
234+
color: white; /* White text */
235+
text-shadow: 2px 2px 0 #4B8BBE; /* Python blue outline */
236+
padding: 20px;
237+
margin-bottom: 20px;
238+
display: inline-block;
239+
font-weight: bold;
240+
border-radius: 10px; /* Rounded corners */
241+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Subtle shadow */
242+
}

pycon/templates/components/navbar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% get_site_root as site_root %}
44
<ul>
55
<li><a href="{% pageurl site_root %}" class="nav-link">首页</a></li>
6-
<li><a href="#" class="nav-link">赞助</a></li>
6+
<li><a href="/2024/supporter" class="nav-link">赞助</a></li>
77
<li><a href="https://jsj.top/f/Ej6XBX" class="nav-link">演讲</a></li>
88
<li><a href="https://jsj.top/f/BYWgq6" class="nav-link">志愿者</a></li>
99
</ul>

supporter/__init__.py

Whitespace-only changes.

supporter/blocks.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from wagtail.blocks import (
2+
CharBlock,
3+
ListBlock,
4+
RichTextBlock,
5+
StreamBlock,
6+
StructBlock,
7+
URLBlock,
8+
)
9+
from wagtail.images.blocks import ImageChooserBlock
10+
11+
12+
class SupporterBlock(StructBlock):
13+
name = CharBlock(required=True)
14+
description = CharBlock(required=False)
15+
logo = ImageChooserBlock(required=False)
16+
url = URLBlock(required=False)
17+
18+
19+
class SupporterListBlock(StructBlock):
20+
heading = CharBlock(required=True)
21+
supporters = ListBlock(SupporterBlock())
22+
23+
class Meta:
24+
template = "supporter/blocks/supporter-list.html"
25+
26+
27+
class SupporterStreamBlock(StreamBlock):
28+
paragraph = RichTextBlock(required=False)
29+
supporters = ListBlock(SupporterListBlock())

supporter/migrations/0001_initial.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generated by Django 5.1.1 on 2024-10-08 09:55
2+
3+
import django.db.models.deletion
4+
import wagtail.fields
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
initial = True
11+
12+
dependencies = [
13+
('wagtailcore', '0094_alter_page_locale'),
14+
]
15+
16+
operations = [
17+
migrations.CreateModel(
18+
name='SupporterPage',
19+
fields=[
20+
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
21+
('body', wagtail.fields.StreamField([('paragraph', 0), ('supporters', 8)], block_lookup={0: ('wagtail.blocks.RichTextBlock', (), {'required': False}), 1: ('wagtail.blocks.CharBlock', (), {'required': True}), 2: ('wagtail.blocks.CharBlock', (), {'required': False}), 3: ('wagtail.images.blocks.ImageChooserBlock', (), {'required': False}), 4: ('wagtail.blocks.URLBlock', (), {'required': False}), 5: ('wagtail.blocks.StructBlock', [[('name', 1), ('description', 2), ('logo', 3), ('url', 4)]], {}), 6: ('wagtail.blocks.ListBlock', (5,), {}), 7: ('wagtail.blocks.StructBlock', [[('heading', 1), ('supporters', 6)]], {}), 8: ('wagtail.blocks.ListBlock', (7,), {})}, help_text='Add supporters to the page.')),
22+
],
23+
options={
24+
'abstract': False,
25+
},
26+
bases=('wagtailcore.page',),
27+
),
28+
]

supporter/migrations/__init__.py

Whitespace-only changes.

supporter/models.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from wagtail.admin.panels import FieldPanel
2+
from wagtail.fields import StreamField
3+
from wagtail.models import Page
4+
5+
from supporter.blocks import SupporterStreamBlock
6+
7+
# Create your models here.
8+
9+
10+
class SupporterPage(Page):
11+
parent_page_types = ["home.HomePage"]
12+
13+
body = StreamField(
14+
SupporterStreamBlock(),
15+
use_json_field=True,
16+
help_text="Add supporters to the page.",
17+
)
18+
19+
content_panels = Page.content_panels + [
20+
FieldPanel("body"),
21+
]

supporter/static/css/supporter.css

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
3+
.supporter-list {
4+
background-color: #f8f8f8;
5+
border: 2px solid #4B8BBE;
6+
border-radius: 10px;
7+
padding: 20px;
8+
margin-top: 20px;
9+
}
10+
11+
.supporter-list h2 {
12+
color: #4B8BBE;
13+
font-size: 24px;
14+
margin-bottom: 20px;
15+
text-align: center;
16+
}
17+
18+
.supporter-list ul {
19+
display: flex;
20+
flex-wrap: wrap;
21+
justify-content: center;
22+
}
23+
24+
.supporter-list .supporter {
25+
background-color: white;
26+
border: 1px solid #ddd;
27+
border-radius: 5px;
28+
margin: 10px;
29+
padding: 15px;
30+
width: 240px;
31+
text-align: center;
32+
transition: transform 0.2s, box-shadow 0.2s;
33+
}
34+
35+
.supporter-list .supporter:hover {
36+
transform: translateY(-5px);
37+
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
38+
}
39+
40+
.supporter-list .supporter img {
41+
max-width: 100%;
42+
height: auto;
43+
margin-bottom: 10px;
44+
}
45+
46+
.supporter-list .supporter-info p {
47+
margin: 5px 0;
48+
}
49+
50+
.supporter-list .supporter-info p:first-child {
51+
font-weight: bold;
52+
color: #4B8BBE;
53+
}
54+
55+
.block-supporters ul {
56+
list-style-type: none;
57+
padding: 0;
58+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{% load wagtailcore_tags wagtailimages_tags %}
2+
3+
<div class="supporter-list">
4+
<h2>{{ self.heading }}</h2>
5+
<ul>
6+
{% for supporter in self.supporters %}
7+
<li class="supporter">
8+
<a href="{{ supporter.url }}" target="_blank">
9+
{% if supporter.logo %}
10+
{% image supporter.logo width-240 %}
11+
{% endif %}
12+
<div class="supporter-info">
13+
<p>{{ supporter.name }}</p>
14+
</div>
15+
</a>
16+
</li>
17+
{% endfor %}
18+
</ul>
19+
</div>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{% extends "base.html" %}
2+
{% load static %}
3+
{% load wagtailcore_tags %}
4+
5+
{% block extra_css %}
6+
<link rel="stylesheet" href="{% static 'css/supporter.css' %}">
7+
{% endblock %}
8+
9+
{% block content %}
10+
<main>
11+
<h1 class="title">{{ page.title }}</h1>
12+
<div class="card">
13+
<div class="card-body">
14+
{{ page.body }}
15+
</div>
16+
</div>
17+
</main>
18+
{% endblock %}

0 commit comments

Comments
 (0)