Convert into a proper Python package

This commit is contained in:
Andrey Golovizin 2020-02-07 22:18:18 +01:00
parent ec175fe0c6
commit c975ca6f19
22 changed files with 59 additions and 0 deletions

1
src/mysite/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
node_modules

0
src/mysite/__init__.py Normal file
View file

21
src/mysite/__main__.py Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

4185
src/mysite/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

17
src/mysite/package.json Normal file
View file

@ -0,0 +1,17 @@
{
"name": "pybtex-css",
"version": "1.0.0",
"description": "Pybtex CSS",
"dependencies": {},
"devDependencies": {
"@fullhuman/postcss-purgecss": "^1.2.0",
"cssnano": "^4.1.10",
"postcss-cli": "^6.1.3",
"tailwindcss": "^1.1.2"
},
"scripts": {
"build": "postcss -o static/style.css static-src/style.css"
},
"author": "Andrey Golovizin",
"license": "MIT"
}

View file

@ -0,0 +1,23 @@
const purgecss = require('@fullhuman/postcss-purgecss')({
// Specify the paths to all of the template files in your project
content: [
'templates/**/*.html',
// etc.
],
whitelist: ['highlighted'],
// Include any special characters you're using in this regular expression
// defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || []
})
module.exports = {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
// purgecss,
require('cssnano')({
preset: 'default',
}),
]
}

232
src/mysite/settings.py Normal file
View file

@ -0,0 +1,232 @@
import os # isort:skip
gettext = lambda s: s
DATA_DIR = os.path.dirname(os.path.dirname(__file__))
"""
Django settings for mysite project.
Generated by 'django-admin startproject' using Django 2.2.9.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '15-d*6bl(@+jfo92@=67vi1ohx%3e&^l98*bo*v$$+ms%!l(!!'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
ROOT_URLCONF = 'mysite.urls'
WSGI_APPLICATION = 'mysite.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = 'ru'
TIME_ZONE = 'Europe/Prague'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
STATIC_ROOT = os.path.join(DATA_DIR, 'static')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'mysite', 'static'),
)
SITE_ID = 1
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'mysite', 'templates'),],
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.i18n',
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.template.context_processors.media',
'django.template.context_processors.csrf',
'django.template.context_processors.tz',
'sekizai.context_processors.sekizai',
'django.template.context_processors.static',
'cms.context_processors.cms_settings'
],
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader'
],
},
},
]
MIDDLEWARE = [
'cms.middleware.utils.ApphookReloadMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware'
]
INSTALLED_APPS = [
'absolute',
'aldryn_forms',
'aldryn_forms.contrib.email_notifications',
'captcha',
'cms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.sessions',
'django.contrib.sitemaps',
'django.contrib.sites',
'django.contrib.staticfiles',
'djangocms_admin_style',
'djangocms_file',
'djangocms_googlemap',
'djangocms_icon',
'djangocms_link',
'djangocms_picture',
'djangocms_snippet',
'djangocms_style',
'djangocms_text_ckeditor',
'djangocms_video',
'easy_thumbnails',
'emailit',
'filer',
'menus',
'sekizai',
'treebeard',
'mysite'
]
LANGUAGES = (
## Customize this
('ru', gettext('ru')),
)
CMS_LANGUAGES = {
## Customize this
1: [
{
'code': 'ru',
'name': gettext('ru'),
'redirect_on_fallback': True,
'public': True,
'hide_untranslated': False,
},
],
'default': {
'redirect_on_fallback': True,
'public': True,
'hide_untranslated': False,
},
}
CMS_TEMPLATES = (
## Customize this
('fullwidth.html', 'Fullwidth'),
('sidebar_left.html', 'Sidebar Left'),
('sidebar_right.html', 'Sidebar Right')
)
CMS_PERMISSION = False
CMS_PLACEHOLDER_CONF = {}
DATABASES = {
'default': {
'CONN_MAX_AGE': 0,
'ENGINE': 'django.db.backends.sqlite3',
'HOST': 'localhost',
'NAME': 'project.db',
'PASSWORD': '',
'PORT': '',
'USER': ''
}
}
THUMBNAIL_PROCESSORS = (
'easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
'easy_thumbnails.processors.filters'
)
DJANGOCMS_PICTURE_RESPONSIVE_IMAGES = True
DJANGOCMS_PICTURE_RESPONSIVE_IMAGES_VIEWPORT_BREAKPOINTS = [300, 400, 576, 768]
DEFAULT_FROM_EMAIL = 'noreply@sologoc.com'

View file

@ -0,0 +1,115 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
html {
font-size: 12pt;
}
p {
@apply leading-normal mt-2 mb-2;
}
h1, h2, h3, h4, h5, h6 {
@apply font-bold;
}
h1 {
@apply text-4xl mt-6;
}
h2 {
@apply text-3xl mt-4;
}
h3 {
@apply text-2xl mt-2;
}
h4 {
@apply text-xl mt-1;
}
.content {
float: left;
width: 80%;
}
.sidebar {
float: left;
width: 20%;
}
/* Menu Items */
#page-nav ul {
@apply m-0 p-0 list-none;
}
#page-nav ul li {
@apply inline-block p-3 text-lg;
}
#page-nav ul li a {
@apply text-white no-underline;
}
#page-nav ul li.selected {
@apply bg-green-600;
}
/* [ON SMALL SCREENS] */
@media screen and (max-width: 768px){
/* Show Hamburger */
#page-nav label {
display: inline-block;
/* color: #fff; */
/* background: #a02620; */
font-style: normal;
font-size: 1.2em;
padding: 10px;
}
/* Break down menu items into vertical */
#page-nav ul li {
display: block;
}
#page-nav ul li {
border-top: 1px solid #22543D;
}
/* Toggle show/hide menu on checkbox click */
#page-nav ul {
display: none;
}
#page-nav input:checked ~ ul {
display: block;
}
}
.contact-form fieldset {
border: none;
padding: 1em 0 0 0;
}
.contact-form fieldset p {
@apply inline-block text-red-700;
}
.contact-form textarea::placeholder, .contact-form input::placeholder {
@apply text-gray-700;
}
.contact-form input, .contact-form textarea {
@apply w-full border border-gray-600 p-2;
}
.contact-form textarea {
@apply h-64;
}
.contact-form label {
@apply hidden;
}
.contact-form button {
@apply p-2 bg-green-800 text-white rounded mt-2;
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,21 @@
module.exports = {
theme: {
fontFamily: {
sans: ['-apple-system', 'BlinkMacSystemFont', 'Segoe UI', 'Helvetica Neue', 'Noto Sans', 'Roboto', 'Verdana', 'sans-serif', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'],
serif: ['Noto Serif', 'Georgia', 'Cambria', 'Times New Roman', 'Times', 'serif'],
mono: ['Menlo', 'Monaco', 'Noto Sans Mono', 'Source Code Pro', 'Consolas', 'Courier New', 'Liberation Mono', 'monospace']
},
listStyleType: {
none: 'none',
disc: 'disc',
decimal: 'decimal',
circle: 'circle'
},
screens: {
'sm': '640px',
// => @media (min-width: 640px) { ... }
'lg': '900px',
}
}
}

View file

@ -0,0 +1,26 @@
{% load cms_tags menu_tags sekizai_tags %}
<!doctype html>
<html>
<head>
<title>{% block title %}This is my new project home page{% endblock title %}</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="/static/style.css" rel="stylesheet">
{% render_block "css" %}
</head>
<body>
{% cms_toolbar %}
<div class="container mx-auto">
<h1>Инженер-строитель В.&#8239Н.&#8239Головизин</h1>
<nav id="page-nav" class="bg-green-800 block mt-6 mb-6">
<label for="hamburger" class="hidden">&#9776;</label>
<input type="checkbox" id="hamburger" class="hidden"/>
<ul class="nav">
{% show_menu 0 100 100 100 %}
</ul>
</nav>
{% block content %}{% endblock content %}
</div>
{% render_block "js" %}
</body>
</html>

View file

@ -0,0 +1,8 @@
{% extends "base.html" %}
{% load cms_tags %}
{% block title %}{% page_attribute "page_title" %}{% endblock title %}
{% block content %}
{% placeholder "content" %}
{% endblock content %}

View file

@ -0,0 +1,13 @@
{% extends "base.html" %}
{% load cms_tags %}
{% block title %}{% page_attribute "page_title" %}{% endblock title %}
{% block content %}
<div class="sidebar">
{% placeholder "sidebar" %}
</div>
<div class="content">
{% placeholder "content" %}
</div>
{% endblock content %}

View file

@ -0,0 +1,13 @@
{% extends "base.html" %}
{% load cms_tags %}
{% block title %}{% page_attribute "page_title" %}{% endblock title %}
{% block content %}
<div class="content">
{% placeholder "content" %}
</div>
<div class="sidebar">
{% placeholder "sidebar" %}
</div>
{% endblock content %}

30
src/mysite/urls.py Normal file
View file

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
from cms.sitemaps import CMSSitemap
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.sitemaps.views import sitemap
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.static import serve
admin.autodiscover()
urlpatterns = [
url(r'^sitemap\.xml$', sitemap,
{'sitemaps': {'cmspages': CMSSitemap}}),
]
urlpatterns += [
url(r'^admin/', admin.site.urls), # NOQA
url(r'^captcha/', include('captcha.urls')),
url(r'^', include('cms.urls')),
]
# This is only needed when using runserver.
if settings.DEBUG:
urlpatterns = [
url(r'^media/(?P<path>.*)$', serve,
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
] + staticfiles_urlpatterns() + urlpatterns

16
src/mysite/wsgi.py Normal file
View file

@ -0,0 +1,16 @@
"""
WSGI config for mysite project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
application = get_wsgi_application()

View file

@ -0,0 +1,10 @@
Metadata-Version: 1.0
Name: strojnadzor
Version: 0.0.1
Summary: Strojnadzor site
Home-page: https://golovizin.ru/
Author: Andrey Golovizin
Author-email: ag@sologoc.com
License: AGPLv3
Description: UNKNOWN
Platform: platform-independent

View file

@ -0,0 +1,18 @@
.envrc
.gitignore
requirements.nix
requirements.txt
requirements_frozen.txt
requirements_override.nix
setup.py
shell.nix
src/mysite/__init__.py
src/mysite/__main__.py
src/mysite/settings.py
src/mysite/urls.py
src/mysite/wsgi.py
src/strojnadzor.egg-info/PKG-INFO
src/strojnadzor.egg-info/SOURCES.txt
src/strojnadzor.egg-info/dependency_links.txt
src/strojnadzor.egg-info/entry_points.txt
src/strojnadzor.egg-info/top_level.txt

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,3 @@
[console_scripts]
strojnadzor-admin = mysite.__main__:main

View file

@ -0,0 +1 @@
mysite