More cleanup and more helper

This commit is contained in:
Martin Mahner 2019-12-08 12:47:39 +01:00
parent 5b01abbf82
commit d8e3d62f29
4 changed files with 23 additions and 24 deletions

View file

@ -2,7 +2,6 @@ include README.rst
include LICENSE include LICENSE
include CHANGELOG.rst include CHANGELOG.rst
include runtests.py include runtests.py
include tox.ini
exclude dpaste/settings/local.py exclude dpaste/settings/local.py
recursive-include dpaste/templates * recursive-include dpaste/templates *
recursive-include dpaste/static * recursive-include dpaste/static *

View file

@ -10,23 +10,24 @@ define N # newline
endef endef
# The Djangos ------------------------------------------------------------------
.PHONY: start
start: ## Start the webserver and migrate db if necessary
docker-compose run --rm app ./manage.py migrate
docker-compose up
.PHONY: test .PHONY: test
test: ## Run Django tests test: ## Run Django tests
docker-compose run --rm app pytest dpaste/ docker-compose run --rm app pytest dpaste/
.PHONY: code-cleanup .PHONY: code-cleanup
code-cleanup: ## Black and isort the Python codebase code-cleanup: ## Black and isort the Python codebase
autoflake --remove-all-unused-imports --ignore-init-module-imports --remove-unused-variables \
--exclude "**/migrations/*,dpaste/settings/local.py" -r dpaste
isort -rc dpaste isort -rc dpaste
black --line-length=80 --exclude='/(migrations)/' dpaste black --line-length=80 --exclude='/(migrations)/' dpaste
# The Frontendos (run inside of a docker container) ---------------------------- .PHONY: docs
docs: ## Compile the documentation
docker-compose run --rm app sphinx-build docs docs/_build/html
.PHONY: watch-docs
docs-watch: ## Compile the documentation and watch for changes
docker-compose run --rm app sphinx-autobuild docs docs/_build/html
.PHONY: css .PHONY: css
css: ## Compile SCSS files css: ## Compile SCSS files
@ -34,22 +35,12 @@ css: ## Compile SCSS files
.PHONY: css-watch .PHONY: css-watch
css-watch: ## Compile JS files css-watch: ## Compile JS files
npx sassz --watch client/scss/dpaste.scss:build/dpaste.css npx sass --watch client/scss/dpaste.scss:build/dpaste.css
.PHONY: js .PHONY: js
js: ## Compile JS files js: ## Compile JS files
npx uglifyjs --compress="drop_console=true,ecma=6" --mangle="toplevel" --output=dpaste/static/dpaste.js client/js/dpaste.js npx uglifyjs --compress="drop_console=true,ecma=6" --mangle="toplevel" --output=dpaste/static/dpaste.js client/js/dpaste.js
# Helper -----------------------------------------------------------------------
.PHONY: docs
docs: ## Compile the documentation
sphinx-build docs docs/_build/html
.PHONY: watch-docs
docs-watch: ## Compile the documentation and watch for changes
sphinx-autobuild docs docs/_build/html
.PHONY: release-docker .PHONY: release-docker
release-docker: release-docker:
set -ex set -ex
@ -57,6 +48,17 @@ release-docker:
docker build --build-arg BUILD_EXTRAS=production -t barttc/dpaste:latest . docker build --build-arg BUILD_EXTRAS=production -t barttc/dpaste:latest .
@echo -e "\n\n💫 All fine. Now do: docker push barttc/dpaste:latest" @echo -e "\n\n💫 All fine. Now do: docker push barttc/dpaste:latest"
.PHONY: release-pypi
release-pypi:
set -ex
docker-compose run --rm app pytest dpaste/
rm -rf ./node_modules
npm ci
make css
make js
python setup.py sdist && python setup.py bdist_wheel --universal
@echo -e "\n\n💫 All fine. Now do: twine upload dist/* --sign"
.PHONY: help .PHONY: help
help: help:
@echo -e "Available make commands:" @echo -e "Available make commands:"

View file

@ -101,7 +101,7 @@ DATABASES = {
# If this project installation was built with production settings, # If this project installation was built with production settings,
# add that webserver right away. # add that webserver right away.
try: try:
import django_webserver import django_webserver # noqa
INSTALLED_APPS.append("django_webserver") INSTALLED_APPS.append("django_webserver")
sys.stdout.write( sys.stdout.write(

View file

@ -204,9 +204,7 @@ class SnippetRawView(SnippetDetailView):
def render_to_response(self, context, **response_kwargs): def render_to_response(self, context, **response_kwargs):
if config.RAW_MODE_PLAIN_TEXT: if config.RAW_MODE_PLAIN_TEXT:
return self.render_plain_text(config, **response_kwargs) return self.render_plain_text(config, **response_kwargs)
return super().render_to_response( return super().render_to_response(context, **response_kwargs)
context, **response_kwargs
)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs) ctx = super().get_context_data(**kwargs)