Merge remote-tracking branch 'origin/master'

This commit is contained in:
Martin Mahner 2019-12-08 23:08:13 +01:00
commit e39662ab32
15 changed files with 211 additions and 221 deletions

1
.github/FUNDING.yml vendored Normal file
View file

@ -0,0 +1 @@
github: bartTC

View file

@ -1,8 +1,8 @@
Changelog Changelog
========= =========
3.4 (master) 3.4 (2019-12-08)
------------ ----------------
- Dropped support for Python 3.4. - Dropped support for Python 3.4.
- Dropped support for Python 3.5. - Dropped support for Python 3.5.
@ -26,10 +26,10 @@ Changelog
- New "Slim" view that displays the highlighted snippet without header, - New "Slim" view that displays the highlighted snippet without header,
options etc, and can be iframed. options etc, and can be iframed.
- Forced line-break for superlongwordsthatwouldexceedthecanvas. - Forced line-break for superlongwordsthatwouldexceedthecanvas.
- Local development is no longer centered around ``pipenv`` and is rather using - Local development is no longer centered around ``pipenv``, instead it's using
docker-compose or the classic virtualenv based setups. docker-compose or the classic virtualenv based setups.
- Error pages are now correctly translated. - Error pages are now correctly translated.
- Testsuite now uses pytest. - Testsuite and Tox uses pytest instead of a homebrewed testrunner.
3.3.1 (2019-08-04): 3.3.1 (2019-08-04):
------------------- -------------------

View file

@ -1,7 +1,6 @@
include README.rst include README.rst
include LICENSE include LICENSE
include CHANGELOG.rst include CHANGELOG.rst
include runtests.py
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

@ -17,7 +17,7 @@ test: ## Run Django tests
.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 \ autoflake --remove-all-unused-imports --ignore-init-module-imports --remove-unused-variables \
--exclude "**/migrations/*,dpaste/settings/local.py" -r dpaste --in-place --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
@ -27,7 +27,7 @@ docs: ## Compile the documentation
.PHONY: watch-docs .PHONY: watch-docs
docs-watch: ## Compile the documentation and watch for changes docs-watch: ## Compile the documentation and watch for changes
docker-compose run --rm app sphinx-autobuild docs docs/_build/html docker-compose run -p 8000:8000 --rm app sphinx-autobuild -H 0 -p 8000 docs docs/_build/html
.PHONY: css .PHONY: css
css: ## Compile SCSS files css: ## Compile SCSS files

View file

@ -35,33 +35,5 @@ please create an *Issue* there.
⚠️ dpaste requires at a minimum Python 3.6 and Django 2.2. ⚠️ dpaste requires at a minimum Python 3.6 and Django 2.2.
Run dpaste using Docker:
========================
Docker images are in `Docker Hub`_.
You can try the latest of dpaste using Docker. This will store the snippet
database in a SQLite file in a Docker volume:
.. code:: bash
$ docker run --rm -p 8000:8000 barttc/dpaste:latest
If you want to run it in production-like environments, it's encouraged to
use an external database. See the example below for all available options,
specifically ``DATABASE_URL``:
.. code:: bash
$ docker run --rm --name db1 --detach postgres:latest
$ docker run --rm -p 12345:12345 \
--link db1 \
-e DATABASE_URL=postgres://postgres@db1:5432/postgres \
-e DEBUG=True \
-e SECRET_KEY=very-secret-key \
-e PORT=12345 \
barttc/dpaste:latest
.. _dpaste.de: https://dpaste.de/ .. _dpaste.de: https://dpaste.de/
.. _pastebin: https://en.wikipedia.org/wiki/Pastebin .. _pastebin: https://en.wikipedia.org/wiki/Pastebin
.. _Docker Hub: https://hub.docker.com/r/barttc/dpaste

View file

@ -1,5 +1,8 @@
============ ===
API Endpoint API
===
API endpoint
============ ============
dpaste provides a simple API endpoint to create new snippets. All you need to dpaste provides a simple API endpoint to create new snippets. All you need to
@ -99,13 +102,13 @@ do is a simple ``POST`` request to the API endpoint, usually ``/api/``:
:statuscode 400: One of the above form options was invalid, :statuscode 400: One of the above form options was invalid,
the response will contain a meaningful error message. the response will contain a meaningful error message.
.. hint:: If yuo have a standalone installation and your API returns .. hint:: If you have a standalone installation and your API returns
``https://dpaste.de/`` as the domain, you need to adjust the setting ``https://dpaste-base-url.example.org`` as the domain, you need to adjust
``BASE_URL`` property. See :ref:`settings`. the setting ``get_base_url`` property. See :ref:`settings`.
Third party API integration into editors Third party API integration
======================================== ===========================
subdpaste subdpaste
a Sublime Editor plugin: https://github.com/bartTC/SubDpaste a Sublime Editor plugin: https://github.com/bartTC/SubDpaste

View file

@ -82,11 +82,6 @@ try:
import sphinx_rtd_theme import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme" html_theme = "sphinx_rtd_theme"
html_theme_path = ["_themes", ] html_theme_path = ["_themes", ]
html_theme_options = {
'logo_only': True,
'display_version': False,
}
html_logo = "docs/_static/logo.svg"
except ImportError: except ImportError:
html_theme = 'alabaster' html_theme = 'alabaster'

View file

@ -8,15 +8,11 @@ Documentation
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
standalone_installation installation
project_installation testing
management_commands management_commands
settings settings
api api
.. toctree::
:maxdepth: 2
changelog changelog
.. _dpaste.de: https://dpaste.de/ .. _dpaste.de: https://dpaste.de/

139
docs/installation.rst Normal file
View file

@ -0,0 +1,139 @@
.. _installation:
============
Installation
============
There are various ways to install and deploy dpaste. See the guides below:
dpaste with Docker
==================
dpaste Docker images are available to pull from the `Docker Hub`_.
Quickstart to run a dpaste container image:
.. code:: bash
$ docker run --rm -p 8000:8000 barttc/dpaste:latest
The dpaste image serves the project using uWSGi and is ready for production-like
environments. However it's encouraged to use an external database to store the
data. See the example below for all available options, specifically
``DATABASE_URL``:
.. code:: bash
$ docker run --rm --name db1 --detach postgres:latest
$ docker run --rm -p 12345:12345 \
--link db1 \
-e DATABASE_URL=postgres://postgres@db1:5432/postgres \
-e DEBUG=True \
-e SECRET_KEY=very-secret-key \
-e PORT=12345 \
barttc/dpaste:latest
.. _Docker Hub: https://hub.docker.com/r/barttc/dpaste
Integration into an existing Django project
===========================================
Install the latest dpaste release in your environment. This will install all
necessary dependencies of dpaste as well:
.. code-block:: bash
$ pip install dpaste
Add ``dpaste.apps.dpasteAppConfig`` to your ``INSTALLED_APPS`` list:
.. code-block:: python
INSTALLED_APPS = (
'django.contrib.sessions',
# ...
'dpaste.apps.dpasteAppConfig',
)
Add ``dpaste`` and the (optiona) ``dpaste_api`` url patterns:
.. code-block:: python
urlpatterns = patterns('',
# ...
url(r'my-pastebin/', include('dpaste.urls.dpaste')),
url(r'my-pastebin/api/', include('dpaste.urls.dpaste_api')),
)
Finally, migrate the database schema:
.. code-block:: bash
$ manage.py migrate dpaste
dpaste with docker-compose for local development
================================================
The project's preferred way for local development is docker-compose:
.. code:: bash
$ docker-compose up
This will open the Django runserver on http://127.0.0.1:8000. Changes to the
code are automatically reflected in the Docker container and the runserver
will reload automatically.
Upon first run you will need to migrate the database. Do that in a separate
terminal window:
.. code:: bash
$ docker-compose run --rm app ./manage.py migrate
dpaste with virtualenv for local development
============================================
If you prefer the classic local installation using Virtualenv then you can
do so. There's no magic involved.
Example:
.. code:: bash
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install -e .[dev]
$ ./manage.py migrate
$ ./manage.py runserver
CSS and Javascript development
==============================
Static files are stored in the ``client/`` directory and must get compiled
and compressed before being used on the website.
.. code:: bash
$ npm install
There are some helper scripts you can invoke with ``make``
make js
Compile only JS files.
make css
Compile only CSS files.
make css-watch
Same as ``build-css`` but it automatically watches for changes in the
CSS files and re-compiles it.
After compilation the CSS and JS files are stored in ``dpaste/static/``
where they are picked up by Django (and Django's collectstatic command).
.. note::
These files are not commited to the project repository, however they are
part of the pypi wheel package, since users couldn't compile those once
they are within Python's site-packages.

View file

@ -1,49 +0,0 @@
.. _project_installation:
====================
Project Installation
====================
.. important:: This documentation describes the installation of dpaste
into an existing Django project. If you want to run the application
standalone, see :ref:`standalone_installation`.
.. note:: Misaka, the Markdown renderer used in dpaste may need "dev" packages
for compilation on Debian based Linux distributions. Install it with
``sudo apt install python3.6-dev``.
Install the latest dpaste release in your environment. This will install all
necessary dependencies of dpaste as well:
.. code-block:: bash
$ pip install dpaste
Add ``dpaste.apps.dpasteAppConfig`` to your ``INSTALLED_APPS`` list:
.. code-block:: python
INSTALLED_APPS = (
'django.contrib.sessions',
# ...
'dpaste.apps.dpasteAppConfig',
)
Add ``dpaste`` and the (optiona) ``dpaste_api`` url patterns:
.. code-block:: python
urlpatterns = patterns('',
# ...
url(r'my-pastebin/', include('dpaste.urls.dpaste')),
url(r'my-pastebin/api/', include('dpaste.urls.dpaste_api')),
)
Finally, migrate the database schema:
.. code-block:: bash
$ manage.py migrate dpaste

View file

@ -1,8 +1,8 @@
.. _settings: .. _settings:
========================== ========
Settings and Configuration Settings
========================== ========
When dpaste is installed as a standalone service or integrated into an existing When dpaste is installed as a standalone service or integrated into an existing
project there are various settings you can override to adjust dpaste's project there are various settings you can override to adjust dpaste's

View file

@ -1,114 +0,0 @@
.. _standalone_installation:
==============================================
Standalone Installation (or local development)
==============================================
.. important:: This documentation describes the installation of dpaste
as a standalone project, primarily for local development. If you want
to integrate the application into your existing Django project, see
:ref:`project_installation`.
The project uses Docker for local development. Start it with:
.. code:: bash
$ make up
Or if you're more familiar with docker-compose
.. code:: bash
$ docker-compose run --rm app ./manage.py migrate
$ docker-compose up
This will open the Django runserver on http://127.0.0.1:8000. Changes to the
code are automatically reflected in the Docker container and the runserver
will reload automatically.
Local development using virtualenv
==================================
If you prefer the classic local installation using Virtualenv then you can
do so. There's nothing magic involved:
.. code:: bash
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install -e .[dev]
CSS and Javascript development
==============================
Both [S]CSS and Javascript files need to be compiled and compressed.
Install the necessary node dependencies first:
.. code:: bash
$ npm install
There are some helper scripts you can invoke with ``make``
``npm js``
Compile only JS files.
``npm css``
Compile only CSS files.
``make css-watch``
Same as ``build-css`` but it automatically watches for changes in the
CSS files and re-compiles it.
``make docs``
Compile this documentation. The result will be in ``docs/_build/html``.
``make docs-watch``
Same as ``docs`` but it automatically watches for changes in the
documentation files and re-compiles the docs.
.. note:: See ``make help`` for the full and most recent list of
helper scripts.
Testing with Tox
================
dpaste is continuously tested online with Travis_. You can also run the test
suite locally with tox_. Tox automatically tests the project against multiple
Python and Django versions.
Similar to ``pipenv`` it's useful to have tox installed globally:
.. code-block:: bash
$ pip install tox
Then simply call it from the project directory.
.. code-block:: bash
$ cd dpaste/
$ tox
.. code-block:: text
:caption: Example tox output:
$ tox
py35-django-111 create: /tmp/tox/dpaste/py35-django-111
SKIPPED:InterpreterNotFound: python3.5
py36-django-111 create: /tmp/tox/dpaste/py36-django-111
py36-django-111 installdeps: django>=1.11,<1.12
py36-django-111 inst: /tmp/tox/dpaste/dist/dpaste-3.0a1.zip
...................
----------------------------------------------------------------------
Ran 48 tests in 1.724s
OK
SKIPPED: py35-django-111: InterpreterNotFound: python3.5
SKIPPED: py35-django-20: InterpreterNotFound: python3.5
py36-django-111: commands succeeded
py36-django-20: commands succeeded
congratulations :)
.. _Travis: https://travis-ci.org/bartTC/dpaste
.. _tox: http://tox.readthedocs.org/en/latest/

49
docs/testing.rst Normal file
View file

@ -0,0 +1,49 @@
.. _testing:
=======
Testing
=======
Testing with Tox
================
dpaste is continuously tested online with Travis_. You can also run the test
suite locally with tox_. Tox automatically tests the project against multiple
Python and Django versions.
.. code-block:: bash
$ pip install tox
Then simply call it from the project directory.
.. code-block:: bash
$ cd dpaste/
$ tox
.. code-block:: text
:caption: Example tox output:
$ tox
py35-django-111 create: /tmp/tox/dpaste/py35-django-111
SKIPPED:InterpreterNotFound: python3.5
py36-django-111 create: /tmp/tox/dpaste/py36-django-111
py36-django-111 installdeps: django>=1.11,<1.12
py36-django-111 inst: /tmp/tox/dpaste/dist/dpaste-3.0a1.zip
...................
----------------------------------------------------------------------
Ran 48 tests in 1.724s
OK
SKIPPED: py35-django-111: InterpreterNotFound: python3.5
SKIPPED: py35-django-20: InterpreterNotFound: python3.5
py36-django-111: commands succeeded
py36-django-20: commands succeeded
congratulations :)
.. _Travis: https://travis-ci.org/bartTC/dpaste
.. _tox: http://tox.readthedocs.org/en/latest/

View file

@ -1,4 +1,4 @@
VERSION = (3, 4, "a0") VERSION = (3, 4)
__version__ = "{major}.{minor}{rest}".format( __version__ = "{major}.{minor}{rest}".format(
major=VERSION[0], major=VERSION[0],

View file

@ -165,7 +165,6 @@ class dpasteAppConfig(AppConfig):
... ...
""" """
from dpaste.highlight import PlainCodeHighlighter from dpaste.highlight import PlainCodeHighlighter
from jsx.lexer import JsxLexer
return [ return [
(self.PLAIN_CODE_SYMBOL, "Plain Code", PlainCodeHighlighter), (self.PLAIN_CODE_SYMBOL, "Plain Code", PlainCodeHighlighter),