mirror of
https://github.com/AxioDL/axiodl-www.git
synced 2026-07-11 06:19:06 -07:00
Cleaned up codebase, implemented Link model
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
{% for category in categories %}
|
||||
{% with category.get_children as boards %}
|
||||
{% with None as board %}
|
||||
<div class="card bg-light border-dark mb-3">
|
||||
<div class="card bg-dark border-dark mb-3">
|
||||
<div class="card-header bg-dark text-light">
|
||||
<div class="card-title"><h1 class="text-light font-weight-bold">{{ category.name }}</h1></div>
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="card border-dark">
|
||||
<div class="card bg-dark border-dark">
|
||||
<div class="card-header bg-dark text-light">
|
||||
<div class="card-title">New Topic</div>
|
||||
</div>
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="card border-dark">
|
||||
<div class="card bg-dark border-dark">
|
||||
<div class="card-header bg-dark text-light">
|
||||
<div class="card-title">New Topic</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="card-body bg-light border-dark">
|
||||
<form method="post" class="mb-4">
|
||||
{% csrf_token %}
|
||||
{% include 'includes/form.html' %}
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
|
||||
{% for post in topic.posts.all %}
|
||||
<div id="{{ post.pk }}"
|
||||
class="card mb-2 {% if forloop.first %} {% if is_paginated == False or page_obj.number == 1 %}mb-4 border-dark{% else %} mb-2 {% endif %}{% endif %}">
|
||||
class="card bg-dark mb-2 {% if forloop.first %} {% if is_paginated == False or page_obj.number == 1 %}mb-4 border-dark{% else %} mb-2 {% endif %}{% endif %}">
|
||||
{% if forloop.first %}
|
||||
<div class="card-header text-white bg-dark py-2 px-3">{{ topic.subject }}</div>
|
||||
{% endif %}
|
||||
<div class="card-body p-3">
|
||||
<div class="card-body bg-light border-dark p-3">
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
<img src="{{ post.created_by|gravatar }}" alt="{{ post.created_by.username }}" class="w-100">
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
from django.contrib import admin
|
||||
from .models import Page
|
||||
from .models import Page, Link
|
||||
from .forms.PageForm import PageForm, PageFormAdmin
|
||||
|
||||
|
||||
fields = ['image_tag']
|
||||
|
||||
admin.site.register(Page, PageFormAdmin)
|
||||
admin.site.register(Link)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# Generated by Django 2.2.3 on 2019-07-10 03:11
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pages', '0002_auto_20190709_1035'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Link',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('text', models.CharField(max_length=100)),
|
||||
('link', models.URLField()),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Link(models.Model):
|
||||
text = models.CharField(max_length=100)
|
||||
link = models.URLField()
|
||||
|
||||
def __str__(self):
|
||||
return self.text
|
||||
@@ -33,4 +33,3 @@ class Page(models.Model):
|
||||
return mark_safe('<img src="/media/images/%s" width="150" height="150" />' % self.logo)
|
||||
|
||||
image_tag.short_description = 'Image'
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
from .Page import Page
|
||||
from .Link import Link
|
||||
+21
-14
@@ -37,9 +37,9 @@
|
||||
{% get_main_page as main_page %}
|
||||
{% with "/pages/"|add:main_page.slug|add:"/" as path %}
|
||||
{% if path == request.path or request.path == '' or request.path == '/' %}
|
||||
<a href="{{ path }}" class="btn btn-outline-secondary">Main Page</a>
|
||||
<a href="{{ path }}" class="nav-link">Main Page</a>
|
||||
{% else %}
|
||||
<a href="{{ path }}" class="btn btn-primary bg-light text-dark">Main Page</a>
|
||||
<a href="{{ path }}" class="nav-link">Main Page</a>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
@@ -49,10 +49,9 @@
|
||||
{% if page.is_mainpage == False %}
|
||||
{% with "/pages/"|add:page.slug|add:"/" as path %}
|
||||
{% if path == request.path %}
|
||||
<a href="#" class="btn btn-outline-secondary">{{ page.page_name }}</a>
|
||||
<a href="#" class="nav-link">{{ page.page_name }}</a>
|
||||
{% else %}
|
||||
<a href="{{ path }}"
|
||||
class="btn btn-primary bg-light text-dark">{{ page.page_name }}</a>
|
||||
<a href="{{ path }}" class="nav-link">{{ page.page_name }}</a>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
@@ -60,18 +59,28 @@
|
||||
{% endfor %}
|
||||
{% if boards_installed %}
|
||||
{% if '/boards/' in request.path %}
|
||||
<a href="#" class="btn btn-outline-secondary">Forums</a>
|
||||
<a href="#" class="text-light nav-link">Forums</a>
|
||||
{% else %}
|
||||
<a href="{% url 'board.index' %}"
|
||||
class="btn btn-primary bg-light text-dark">Forums</a>
|
||||
<a href="{% url 'board.index' %}" class="text-light nav-link">Forums</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<a href="{% url 'pages.list' %}"
|
||||
class="btn btn-primary bg-light text-dark">Page list</a>
|
||||
<a href="{% url 'pages.list' %}" class="text-light nav-link">Page list</a>
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="siteLinks" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="false">Site Links</a>
|
||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="userMenu">
|
||||
{% get_links as links %}
|
||||
{% for link in links %}
|
||||
<a class="dropdown-item" href="{{ link.link }}">{{ link.text }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
{% if user.is_authenticated %}
|
||||
<ul class="navbar-nav ml-auto btn btn-secondary btn-sm">
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="userMenu" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="false">{{ user.username }}</a>
|
||||
@@ -140,14 +149,12 @@
|
||||
$('.ui.dropdown').dropdown();
|
||||
</script>
|
||||
{% block javascript %}{% endblock %}
|
||||
<div class="footer py-1 bg-dark text-white-50">
|
||||
<div class="container text-center">
|
||||
<div class="footer py-1 bg-dark text-white-50 text-center" style="z-index:20">
|
||||
<small style="font-size:1.0em">Copyleft <span class="copy-left" ;>©</span> AxioDL, written in <a
|
||||
href="https://python.org/">Python</a> using <a href="https://www.djangoproject.com/">Django</a>.
|
||||
The source code for this website is available on our gitlab instance <a
|
||||
href="https://gitlab.axiodl.com/AxioDL/axiodl-www">here</a>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,19 +1,29 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load form_tags widget_tweaks martortags %}
|
||||
|
||||
{% block title %}Start a New Topic{% endblock %}
|
||||
{% block title %}{% if '/new' in request.path %}Create a new Page{% else %}Edit Page{% endif %}{% endblock %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
<li class="breadcrumb-item"><a href="{% url 'home' %}">Index</a></li>
|
||||
{% if '/new' in request.path %}
|
||||
<li class="breadcrumb-item active">New page</li>
|
||||
{% else %}
|
||||
<li class="breadcrumb-item active">Edit page</li>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-11 col-md-11 col-sm-11">
|
||||
<div class="card border-dark">
|
||||
<div class="card bg-dark border-dark">
|
||||
<div class="card-header bg-dark text-light">
|
||||
<div class="card-title">New Page</div>
|
||||
<div class="card-title">
|
||||
{% if '/new' in request.path %}
|
||||
New Page
|
||||
{% else %}
|
||||
Edit Page
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" enctype="multipart/form-data" novalidate>
|
||||
{% csrf_token %}
|
||||
@@ -24,7 +34,7 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="card-body">
|
||||
<div class="card-body bg-light">
|
||||
<!-- Page name -->
|
||||
{{ form.page_name.label_tag }}
|
||||
{% render_field form.page_name class=form.page_name|input_class %}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
{% block breadcrumb-base %}<br/>{% endblock %}
|
||||
{% block content %}
|
||||
{% if page %}
|
||||
<div class="card border-dark">
|
||||
<div class="card bg-dark border-dark">
|
||||
<div class="card-header bg-dark border-dark text-light">
|
||||
<div class="row">
|
||||
{% if page.logo %}
|
||||
@@ -33,7 +33,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="card-body bg-light border-dark">
|
||||
{{ page.content|safe_markdown }}
|
||||
</div>
|
||||
<div class="card-footer bg-dark">
|
||||
|
||||
@@ -5,7 +5,7 @@ from pygments import highlight
|
||||
from pygments.lexers import get_lexer_by_name
|
||||
from pygments.formatters import HtmlFormatter
|
||||
|
||||
from ..models import Page
|
||||
from ..models import Page, Link
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@@ -20,6 +20,11 @@ def get_pages(*args, **kwargs):
|
||||
return Page.objects.all()
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def get_links(*args, **kwargs):
|
||||
return Link.objects.all()
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def has_perm(user, perm):
|
||||
return user.has_perm(perm)
|
||||
|
||||
+15
-16
@@ -6,24 +6,23 @@ django-betterforms==1.2
|
||||
django-bootstrap-form==3.4
|
||||
django-compressor==2.3
|
||||
django-formtools==2.1
|
||||
django-gitlab-auth==0.1.1
|
||||
django-jet==1.0.8
|
||||
django-sass-processor==0.7.3
|
||||
django-widget-tweaks==1.4.5
|
||||
feedparser==5.2.1
|
||||
idna==2.8
|
||||
libsass==0.19.2
|
||||
Markdown==3.1.1
|
||||
martor==1.4.1
|
||||
mistune==0.8.4
|
||||
Pillow==6.1.0
|
||||
Pygments==2.4.2
|
||||
pytz==2019.1
|
||||
PyYAML==5.1.1
|
||||
rcssmin==1.0.6
|
||||
requests==2.22.0
|
||||
rjsmin==1.1.0
|
||||
six==1.12.0
|
||||
South==1.0.2
|
||||
sqlparse==0.3.0
|
||||
idna>=2.8
|
||||
libsass>=0.19.2
|
||||
Markdown>=3.1.1
|
||||
martor>=1.4.1
|
||||
mistune>=0.8.4
|
||||
Pillow>=6.1.0
|
||||
Pygments>=2.4.2
|
||||
pytz>=2019.1
|
||||
PyYAML>=5.1.1
|
||||
rcssmin>=1.0.6
|
||||
requests>=2.22.0
|
||||
rjsmin>=1.1.0
|
||||
six>=1.12.0
|
||||
South>=1.0.2
|
||||
sqlparse>=0.3.0
|
||||
urllib3==1.25.3
|
||||
|
||||
@@ -41,7 +41,6 @@ INSTALLED_APPS = [
|
||||
'django.contrib.humanize',
|
||||
|
||||
# external
|
||||
'autoslug',
|
||||
'widget_tweaks',
|
||||
'martor',
|
||||
'sass_processor',
|
||||
|
||||
Reference in New Issue
Block a user