Skip to content

Commit

Permalink
Merge pull request #235 from django-daiquiri/webpack
Browse files Browse the repository at this point in the history
Webpack
  • Loading branch information
jochenklar authored May 21, 2024
2 parents 5ae2a14 + 39172bd commit a0716ee
Show file tree
Hide file tree
Showing 43 changed files with 7,597 additions and 4 deletions.
49 changes: 49 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module.exports = {
'root': true,
'globals': {
'gettext': true,
'ngettext': true,
'interpolate': true,
'process': true,
'require': true
},
'env': {
'browser': true,
'es2021': true,
'node': true
},
'extends': [
'eslint:recommended',
'plugin:react/recommended'
],
'overrides': [],
'parserOptions': {
'ecmaVersion': 'latest',
'sourceType': 'module'
},
'plugins': [
'react'
],
'ignorePatterns': ['**/static/**/*.js'],
'rules': {
'indent': 'off',
'no-empty-pattern': 'off',
'linebreak-style': [
'error',
'unix'
],
'quotes': [
'error',
'single'
],
'semi': [
'error',
'never'
]
},
'settings': {
'react': {
'version': 'detect'
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ __pycache__/
/htmlcov
/env
/venv
/node_modules

build
dist
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v21
8 changes: 8 additions & 0 deletions daiquiri/auth/assets/js/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { createRoot } from 'react-dom/client'

import App from './users/App'

createRoot(
document.getElementById('app')
).render(<App />)
7 changes: 7 additions & 0 deletions daiquiri/auth/assets/js/users/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

const App = () => {
return <span>👍</span>
}

export default App
15 changes: 15 additions & 0 deletions daiquiri/auth/templates/auth/new/users.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends 'core/new/wide.html' %}
{% load static %}

{% block js %}
{{ block.super }}
<script src="{% static 'auth/dist/js/users.js' %}" defer></script>
{% endblock %}

{% block wide %}

<h1>User management</h1>

<div id="app" class="users"></div>

{% endblock %}
3 changes: 2 additions & 1 deletion daiquiri/auth/urls_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from rest_framework import routers

from .views import UsersView
from .views import UsersView, NewUsersView
from .viewsets import ProfileViewSet, GroupViewSet


Expand All @@ -15,6 +15,7 @@
urlpatterns = [
# user management
path('users/', UsersView.as_view(), name='users'),
path('users/new/', NewUsersView.as_view(), name='users_new'),

# rest api
path('api/', include(router.urls)),
Expand Down
5 changes: 5 additions & 0 deletions daiquiri/auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ def get_context_data(self, **kwargs):
return context


class NewUsersView(ModelPermissionMixin, CSRFViewMixin, TemplateView):
template_name = 'auth/new/users.html'
permission_required = 'daiquiri_auth.view_profile'


class PasswordChangeView(AllauthPasswordChangeView):

success_url = reverse_lazy('account_change_password_done')
Expand Down
8 changes: 8 additions & 0 deletions daiquiri/contact/assets/js/messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { createRoot } from 'react-dom/client'

import App from './messages/App'

createRoot(
document.getElementById('app')
).render(<App />)
7 changes: 7 additions & 0 deletions daiquiri/contact/assets/js/messages/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

const App = () => {
return <span>👍</span>
}

export default App
15 changes: 15 additions & 0 deletions daiquiri/contact/templates/contact/new/messages.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends 'core/new/wide.html' %}
{% load static %}

{% block js %}
{{ block.super }}
<script src="{% static 'contact/dist/js/messages.js' %}" defer></script>
{% endblock %}

{% block wide %}

<h1>Contact messages</h1>

<div id="app" class="messages"></div>

{% endblock %}
3 changes: 2 additions & 1 deletion daiquiri/contact/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import include, path
from rest_framework import routers

from .views import MessagesView, contact
from .views import MessagesView, contact, NewMessagesView
from .viewsets import ContactMessageViewSet, StatusViewSet

app_name = 'contact'
Expand All @@ -13,6 +13,7 @@
urlpatterns = [
path('', contact, name='contact'),
path('messages/', MessagesView.as_view(), name='messages'),
path('messages/new/', NewMessagesView.as_view(), name='messages_new'),

# rest api
path('api/', include(router.urls)),
Expand Down
5 changes: 5 additions & 0 deletions daiquiri/contact/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ def contact(request):
class MessagesView(ModelPermissionMixin, CSRFViewMixin, TemplateView):
template_name = 'contact/messages.html'
permission_required = 'daiquiri_contact.view_contactmessage'


class NewMessagesView(ModelPermissionMixin, CSRFViewMixin, TemplateView):
template_name = 'contact/new/messages.html'
permission_required = 'daiquiri_contact.view_contactmessage'
Binary file added daiquiri/core/assets/img/daiquiri.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added daiquiri/core/assets/img/daiquiri32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added daiquiri/core/assets/img/favicon.ico
Binary file not shown.
Binary file added daiquiri/core/assets/img/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions daiquiri/core/assets/js/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'bootstrap'
2 changes: 2 additions & 0 deletions daiquiri/core/assets/js/utils/baseUrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// take the baseurl from the <head> of the django template
export default document.querySelector('meta[name="baseurl"]').content.replace(/\/+$/, '')
3 changes: 3 additions & 0 deletions daiquiri/core/assets/scss/base.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import '~bootstrap/scss/bootstrap';

@import 'layout';
3 changes: 3 additions & 0 deletions daiquiri/core/assets/scss/layout.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
h1 {
margin-top: 20px;
}
29 changes: 29 additions & 0 deletions daiquiri/core/templates/core/new/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% load static %}<!DOCTYPE html>
<html>

<head>

{% include 'core/new/base_head.html' %}

{% block css %}
<link rel="stylesheet" href="{% static 'core/dist/css/base.css' %}" />
{% endblock %}

{% block js %}
<script src="{% static 'core/dist/js/base.js' %}" defer></script>
{% endblock %}

</head>

<body>

{% include 'core/new/base_navigation.html' %}

{% block content %}{% endblock %}

{% include 'core/new/base_footer.html' %}

{% if not debug %}{% include 'core/base_analytics.html' %}{% endif %}
</body>

</html>
Empty file.
14 changes: 14 additions & 0 deletions daiquiri/core/templates/core/new/base_head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% load static %}

<title>{{ request.site.name }}</title>

<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

<meta property="og:title" content="{{ request.site.name }}" />
<meta property="og:url" content="{{ request.site.domain }}" />

<meta name='baseurl' content="{% url 'home' %}" />
<meta name='staticurl' content="{% static '' %}" />

<link rel="shortcut icon" href="{% static 'core/img/favicon.png' %}" type="image/png" />
18 changes: 18 additions & 0 deletions daiquiri/core/templates/core/new/base_navigation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="{% url 'home' %}">{{ request.site.name }}</a>
<button
class="navbar-toggler" 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>
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">

</li>
</ul>
</div>
</div>
</nav>
10 changes: 10 additions & 0 deletions daiquiri/core/templates/core/new/wide.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends 'core/new/base.html' %}
{% block content %}

<main class="container">
<section class="wide">
{% block wide %}{% endblock %}
</section>
</main>

{% endblock %}
8 changes: 8 additions & 0 deletions daiquiri/query/assets/js/examples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { createRoot } from 'react-dom/client'

import App from './examples/App'

createRoot(
document.getElementById('app')
).render(<App />)
7 changes: 7 additions & 0 deletions daiquiri/query/assets/js/examples/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

const App = () => {
return <span>👍</span>
}

export default App
8 changes: 8 additions & 0 deletions daiquiri/query/assets/js/jobs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { createRoot } from 'react-dom/client'

import App from './jobs/App'

createRoot(
document.getElementById('app')
).render(<App />)
7 changes: 7 additions & 0 deletions daiquiri/query/assets/js/jobs/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

const App = () => {
return <span>👍</span>
}

export default App
8 changes: 8 additions & 0 deletions daiquiri/query/assets/js/query.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { createRoot } from 'react-dom/client'

import App from './query/App'

createRoot(
document.getElementById('app')
).render(<App />)
7 changes: 7 additions & 0 deletions daiquiri/query/assets/js/query/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

const App = () => {
return <span>👍</span>
}

export default App
Empty file.
Empty file.
Empty file.
20 changes: 20 additions & 0 deletions daiquiri/query/templates/query/new/examples.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends 'core/new/wide.html' %}
{% load static %}

{% block css %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'query/dist/css/examples.css' %}" />
{% endblock %}

{% block js %}
{{ block.super }}
<script src="{% static 'query/dist/js/examples.js' %}" defer></script>
{% endblock %}

{% block wide %}

<h1>Example queries</h1>

<div id="app" class="examples"></div>

{% endblock %}
20 changes: 20 additions & 0 deletions daiquiri/query/templates/query/new/jobs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends 'core/new/wide.html' %}
{% load static %}

{% block css %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'query/dist/css/jobs.css' %}" />
{% endblock %}

{% block js %}
{{ block.super }}
<script src="{% static 'query/dist/js/jobs.js' %}" defer></script>
{% endblock %}

{% block wide %}

<h1>Query jobs</h1>

<div id="app" class="jobs"></div>

{% endblock %}
20 changes: 20 additions & 0 deletions daiquiri/query/templates/query/new/query.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends 'core/new/wide.html' %}
{% load static %}

{% block css %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'query/dist/css/query.css' %}" />
{% endblock %}

{% block js %}
{{ block.super }}
<script src="{% static 'query/dist/js/query.js' %}" defer></script>
{% endblock %}

{% block wide %}

<h1>Query interface</h1>

<div id="app" class="query"></div>

{% endblock %}
Loading

0 comments on commit a0716ee

Please sign in to comment.