Skip to content

Commit

Permalink
config for Markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmurilo75 committed Mar 9, 2022
1 parent 31b513f commit 835c22b
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 67 deletions.
11 changes: 11 additions & 0 deletions .idea/runConfigurations/docker_compose_up.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions .idea/runConfigurations/docker_compose_up_django.xml

This file was deleted.

4 changes: 3 additions & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# though not all of them may be available with every OS.
# In Windows, this must be set to your system time zone.
TIME_ZONE = "WET"
TIME_ZONE = "Europe/Lisbon"
# https://docs.djangoproject.com/en/dev/ref/settings/#language-code
LANGUAGE_CODE = "en-us"
# https://docs.djangoproject.com/en/dev/ref/settings/#site-id
Expand Down Expand Up @@ -76,6 +76,7 @@
LOCAL_APPS = [
"pycon_portugal_2022.users",
# Your stuff: custom apps go here
"pycon_portugal_2022.site",
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
Expand Down Expand Up @@ -179,6 +180,7 @@
"django.template.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"pycon_portugal_2022.users.context_processors.allauth_settings",
"pycon_portugal_2022.site.context_processors.links",
],
},
}
Expand Down
13 changes: 8 additions & 5 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
from django.views import defaults as default_views
from django.views.generic import TemplateView

from pycon_portugal_2022.site.views import default_view

urlpatterns = [
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
path(
"about/", TemplateView.as_view(template_name="pages/about.html"), name="about"
),

# Django Admin, use {% url 'admin:index' %}
path(settings.ADMIN_URL, admin.site.urls),
# User management
path("users/", include("pycon_portugal_2022.users.urls", namespace="users")),
path("accounts/", include("allauth.urls")),
# Your stuff: custom urls includes go here
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
path("", default_view),
path("<slug:menu>/", default_view),
path("<slug:menu>/<slug:submenu>/", default_view),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


if settings.DEBUG:
Expand Down
Empty file.
10 changes: 10 additions & 0 deletions pycon_portugal_2022/site/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _


class SiteConfig(AppConfig):
name = "pycon_portugal_2022.site"
verbose_name = _("SitePackage")

def ready(self):
pass
61 changes: 61 additions & 0 deletions pycon_portugal_2022/site/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

def links(request):
return {
'home': '/home/',
'site_menu': {
'Talks': {
'dropdown': 'true',
'submenu': {
'Schedule': '/talks/schedule/',
'Cfp': '/talks/cfp/',
'Selection process': '/talks/selection_process/',
},
},
'Information': {
'dropdown': 'true',
'submenu': {
'Venue': '/information/venue/',
'Swag bag': '/information/swag_bag/',
'Grants': '/information/grants/',
'Django girls': '/information/django_girls/',
'Sprints': '/information/sprints/',
'Announcements': '/information/announcements/',
},
},
'Sponsors': {
'dropdown': 'true',
'submenu': {
'Sponsors': '/sponsors/sponsors/',
'Contributors': '/sponsors/contributors/',
'Sponsorship': '/sponsors/sponsorship/',
},
},
'Conduct': {
'dropdown': 'true',
'submenu': {
'Code of conduct': '/conduct/code_of_conduct/',
'Response guide': '/conduct/response_guide/',
'Privacy guide': '/conduct/privacy_guide/',
},
},
'Jobs': {
'dropdown': 'false',
'href': '/jobs/',
},
'About': {
'dropdown': 'true',
'submenu': {
'Tickets': '/about/tickets/',
'Contact': '/about/contact/',
'Credits': '/about/credits/',
},
},
},
'social_media': {
'twitter': 'https://twitter.com/',
'slack': 'https://slack.com/',
'youtube': 'https://youtube.com/',
'linkedin': 'https://linked.in/',
'github': 'https://github.com/pyconpt/2022/',
}
}
Empty file.
24 changes: 24 additions & 0 deletions pycon_portugal_2022/site/templatetags/markdown_extras.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django import template
from django.template.defaultfilters import stringfilter

import markdown as md

register = template.Library()


@register.filter()
@stringfilter
def markdown(value):
r = {}
f = open(value, 'r')
f = f.read()
m = md.Markdown(extensions = [
'extra',
'nl2br',
'sane_lists',
'meta',
'toc',
])
r['html'] = m.convert(f)
r['meta'] = m.Meta
return r
29 changes: 29 additions & 0 deletions pycon_portugal_2022/site/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.shortcuts import render
from os import walk

from config.settings.base import APPS_DIR


def default_view(request, menu='home', submenu=None):
path = APPS_DIR.__str__() + '/content/' + menu + ('/' + submenu if submenu else '')
page = ''
ctx = {}
files = []

for dirpath, dirname, filenames in walk(path):
files.extend(filenames)
break

ctx['files'] = []
for f in sorted(files):
content = '%s/%s' % (path, f)
ctx['files'].append(content)

if menu == 'home':
page += 'pages/' + menu
elif len(files) == 0:
page += '404'
else:
page += 'pages/' + 'default'

return render(request, page + '.html', ctx)
44 changes: 0 additions & 44 deletions pycon_portugal_2022/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,50 +36,6 @@

<body>

<div class="mb-1">
<nav class="navbar navbar-expand-md navbar-light bg-light">
<div class="container-fluid">
<button class="navbar-toggler navbar-toggler-right" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="{% url 'home' %}">PyCon Portugal 2022</a>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="{% url 'home' %}">Home <span class="visually-hidden">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'about' %}">About</a>
</li>
{% if request.user.is_authenticated %}
<li class="nav-item">
{# URL provided by django-allauth/account/urls.py #}
<a class="nav-link" href="{% url 'users:detail' request.user.username %}">{% translate "My Profile" %}</a>
</li>
<li class="nav-item">
{# URL provided by django-allauth/account/urls.py #}
<a class="nav-link" href="{% url 'account_logout' %}">{% translate "Sign Out" %}</a>
</li>
{% else %}
{% if ACCOUNT_ALLOW_REGISTRATION %}
<li class="nav-item">
{# URL provided by django-allauth/account/urls.py #}
<a id="sign-up-link" class="nav-link" href="{% url 'account_signup' %}">{% translate "Sign Up" %}</a>
</li>
{% endif %}
<li class="nav-item">
{# URL provided by django-allauth/account/urls.py #}
<a id="log-in-link" class="nav-link" href="{% url 'account_login' %}">{% translate "Sign In" %}</a>
</li>
{% endif %}
</ul>
</div>
</div>
</nav>

</div>

<div class="container">

{% if messages %}
Expand Down
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ django-allauth==0.49.0 # https://github.com/pennersr/django-allauth
django-crispy-forms==1.14.0 # https://github.com/django-crispy-forms/django-crispy-forms
crispy-bootstrap5==0.6 # https://github.com/django-crispy-forms/crispy-bootstrap5
django-redis==5.2.0 # https://github.com/jazzband/django-redis
Markdown==3.3.6

0 comments on commit 835c22b

Please sign in to comment.