Initial commit

Migrating from the old docs, to the new one build using mkdocs.
This commit is contained in:
Darren Nathanael 2021-12-27 01:57:42 -05:00
commit 1066dba9c1
No known key found for this signature in database
GPG Key ID: 68E257B232008FF8
7 changed files with 1011 additions and 0 deletions

50
docs/api.md Normal file
View File

@ -0,0 +1,50 @@
# API
## API endpoint
---
dpaste provides a simple API endpoint to create new snippets. All you need to do is a simple `POST` request to the API endpoint, usually `/api/`:
### POST/api/
Create a new Snippet on this dpaste installation. It returns the full URL that snippet was created.
**Example request:**
```bash
$ curl -X POST -F "format=url" -F "content=ABC" https:/dpaste.de/api/
Host: dpaste.de
User-Agent: curl/7.54.0
Accept: */*
```
**Example response:**
```bash
{
"lexer": "python",
"url": "https://dpaste.de/EBKU",
"content": "ABC"
}
```
**Form Parameters**
- **content** (required) The UTF-8 encoded string you want to paste.
- **lexer** (optional) The lexer string key used for highlighting. See the `CODE_FORMATTER` property in [Settings](https://docs.dpaste.org/settings/) for a full list of choices. Default: `_code`.
- **format** -
(optional) The format of the API response. Choices are:
- `default` — Returns a full qualified URL wrapped in quotes. Example: `"https://dpaste.de/xsWd"`
- `url` — Returns the full qualified URL to the snippet, without surrounding quotes, but with a line break. Example: `https://dpaste.de/xsWd\n`
- `json` — Returns a JSON object containing the URL, lexer and content of the the snippet. Example:
{
"url": "https://dpaste.de/xsWd",
"lexer": "python",
"content": "The text body of the snippet."
}
<!-- !TODO: add more example -->

19
docs/index.md Normal file
View File

@ -0,0 +1,19 @@
# Documentation
---
![dpaste image](https://img.shields.io/pypi/v/dpaste.svg)
![building](https://travis-ci.org/bartTC/dpaste.svg?branch=master)
![Code Quality](https://api.codacy.com/project/badge/Grade/185cfbe9b4b447e59a40f816c4a5ebf4)
----
📖 Full documentation on [https://docs.dpaste.org](https://docs.dpaste.org)
dpaste is a [pastebin](https://en.wikipedia.org/wiki/Pastebin) application written in [Python](https://www.python.org/) using the [Django](https://www.djangoproject.com/) framework. You can find a live installation on [dpaste.org.](https://dpaste.org)
The project is intended to run standalone as any regular Django Project, but it's also possible to install it into an existing project as a typical Django application.
![svg mockups](https://cdn.darrennathanael.com/assets/dpaste/dpaste.svg)
The code is open source and available on Github: [https://github.com/bartTC/dpaste](https://github.com/bartTC/dpaste). If you found bugs, have problems or ideas with the project or the website installation, please create an *Issue* there.
⚠️ dpaste requires at a minimum Python 3.6 and Django 2.2.

115
docs/installation.md Normal file
View File

@ -0,0 +1,115 @@
# 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.](https://hub.docker.com/r/barttc/dpaste)
Quickstart to run a dpaste container image:
```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 its encouraged to use an external database to store the data. See the example below for all available options, specifically `DATABASE_URL`:
```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=super-secure-key \
-e PORT=12345 \
barttc/dpaste:latest
```
## Integration into an existing Django project
---
Install the latest dpaste release in your environment. This will install all necessary dependencies of dpaste as well:
```bash
$ pip install dpaste
```
Add `dpaste.apps.dpasteAppConfig` to your `INSTALLED_APPS` list:
```python
INSTALLED_APPS = (
'django.contrib.sessions',
# ...
'dpaste.apps.dpasteAppConfig',
)
```
Add `dpaste` and the (optional) `dpaste_api` url patterns:
```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:
```bash
$ manage.py migrate dpaste
```
## dpaste with docker-compose for local development
---
The projects preferred way for local development is docker-compose:
```bash
$ docker-compose up
```
This will open the Django runserver on [http://127.0.0.1:8000](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:
```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. Theres no magic involved.
Example:
```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.
```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 Djangos collectstatic command).
!!! note "Note"
These files are not commited to the project repository, however they are part of the pypi wheel package, since users couldnt compile those once they are within Pythons site-packages.

View File

@ -0,0 +1,33 @@
# Management Commands
## Purge expired snippets
---
Snippets are removed as soon as they exceed their expiration date and get fetched by a client, however if they never get fetched this isnt triggered. dpaste ships with a management command `cleanup_snippets` that removes these expired snippets.
Its sufficient to run it daily.
To run it locally do:
```bash
$ pipenv run ./managepy cleanup_snippets
```
### Options
**`--dry-run`**
Does not actually delete the snippets. This is useful for local testing.
### Setup a Crontab
A crontab line might look like:
```c
1 20 * * * /srv/dpaste.de/pipenv run manage.py cleanup_snippets > /dev/null
```
!!! note "Note"
If you use the *database* session backend, you may also need to setup a crontab that removes the expired entries from the session database.
See the related [Django Documentation](https://docs.djangoproject.com/en/2.0/ref/django-admin/#django-admin-clearsessions) for details.

682
docs/settings.md Normal file
View File

@ -0,0 +1,682 @@
# Settings
When dpaste is installed as a standalone service or integrated into an existing project there are various settings you can override to adjust dpastes behavior.
To do so, you need to override dpastes AppConfig. This is a feature [introduced in Django 1.9](https://docs.djangoproject.com/en/1.9/ref/applications/) and allows you to set settings more programmatically.
See Current AppConfig with default values for a full list of settings and functions you can override.
## Example for your custom AppConfig:
---
```python
# settings.py
from dpaste.apps import dpasteAppConfig
class MyBetterDpasteAppConfig(dpasteAppConfig):
SLUG_LENGTH = 8
LEXER_DEFAULT = 'js'
# ...
INSTALLED_APPS = [
'myproject.settings.MyBetterDpasteAppConfig',
]
```
## Current AppConfig with default values
---
This is the file content of `dpaste/apps.py`:
```python
from django.apps import AppConfig, apps
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
class dpasteAppConfig(AppConfig):
name = "dpaste"
verbose_name = "dpaste"
# The application title used throughout the user interface.
APPLICATION_NAME = "dpaste"
# This content is loaded in the <head> section of each template.
# You can use it to add any HTML tags, specifically custom CSS styles.
# This may can give you an easier way to adjust the UI to your needs
# than having to add a template folder, plus custom template, plus
# css static file etc.
#
# Example:
#
# EXTRA_HEAD_HTML = """
# <style type="text/css">
# header{ background-color: red; }
# .btn { background-color: blue; border: 3px solid yellow; }
# </style>
# """
EXTRA_HEAD_HTML = ""
# HTML content injected in the About page
EXTRA_POST_ABOUT = ""
# HTML content injeted after the "New snippet" form
EXTRA_POST_NEW = ""
# HTML content injected at the end of every form
EXTRA_POST_FORM = ""
# Integer. Length of the random slug for each new snippet. In the rare
# case an existing slug is generated again, the length will increase by
# one more character.
SLUG_LENGTH = 4
# String. A string of characters which are used to create the random slug.
# This is intentionally missing l and I as they look too similar with
# sans-serif fonts.
SLUG_CHOICES = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ1234567890"
# String. The lexer key that is pre-selected in the dropdown. Note that
# this is only used if the user has not saved a snippet before, otherwise
LEXER_DEFAULT = "python"
# Integer. Maximum number of bytes per snippet.
MAX_CONTENT_LENGTH = 250 * 1024 * 1024
# A tuple of seconds and a descriptive string used in the lexer
# expiration dropdown. Example::
#
# from django.utils.translation import gettext_lazy as _
# DPASTE_EXPIRE_CHOICES = (
# (3600, _('In one hour')),
# (3600 * 24 * 7, _('In one week')),
# (3600 * 24 * 30, _('In one month')),
# (3600 * 24 * 30 * 12 * 100, _('100 Years')),
# )
#
# **Infinite snippets** are supported. You can keep snippets forever when
# you set the choice key to ``never``. The management command will ignore
# these snippets::
#
# from django.utils.translation import gettext_lazy as _
# DPASTE_EXPIRE_CHOICES = (
# (3600, _('In one hour')),
# ('never', _('Never')),
# )
EXPIRE_CHOICES = (
("onetime", _("One-Time snippet")),
(3600, _("Expire in one hour")),
(3600 * 24 * 7, _("Expire in one week")),
(3600 * 24 * 30, _("Expire in one month")),
("never", _("Never Expire")),
)
# Default value for ``EXPIRE_CHOICES``
EXPIRE_DEFAULT = 3600 * 24 * 7
# **One-Time snippets** are supported. One-Time snippets are automatically
# deleted once a defined view count has reached (Default: ``2``). To
# enable one-time snippets you have to add a choice ``onetime`` to the
# expire choices::
#
# from django.utils.translation import gettext_lazy as _
# DPASTE_EXPIRE_CHOICES = (
# ('onetime', _('One-Time snippet')),
# (3600, _('In one hour')),
# (3600 * 24 * 7, _('In one week')),
# (3600 * 24 * 30, _('In one month')),
# )
#
# You can also set the maximum view count after what the snippet gets
# deleted. The default is ``2``. One view is from the author, one view
# is from another user.
ONETIME_LIMIT = 2
# Disable "view Raw" mode.
RAW_MODE_ENABLED = True
# If enabled, the "raw View" mode will display the snippet content as
# plain text rather rendered in a template.
RAW_MODE_PLAIN_TEXT = True
# Lexers which have wordwrap enabled by default
LEXER_WORDWRAP = ("rst",)
# Key names of the default text and code lexer.
PLAIN_TEXT_SYMBOL = "_text"
PLAIN_CODE_SYMBOL = "_code"
@property
def TEXT_FORMATTER(self):
"""
Choices list with all "Text" lexer. Prepend keys with an underscore
so they don't accidentally clash with a Pygments Lexer name.
Each list contains a lexer tuple of:
(Lexer key,
Lexer Display Name,
Lexer Highlight Class)
If the Highlight Class is not given, PygmentsHighlighter is used.
"""
from dpaste.highlight import (
PlainTextHighlighter,
MarkdownHighlighter,
RestructuredTextHighlighter,
)
return [
(self.PLAIN_TEXT_SYMBOL, "Plain Text", PlainTextHighlighter),
("_markdown", "Markdown", MarkdownHighlighter),
("_rst", "reStructuredText", RestructuredTextHighlighter),
]
@property
def CODE_FORMATTER(self):
"""
Choices list with all "Code" Lexer. Each list
contains a lexer tuple of:
(Lexer key,
Lexer Display Name,
Lexer Highlight Class)
If the Highlight Class is not given, PygmentsHighlighter is used.
To get a current list of available lexers in Pygements do:
>>> from pygments import lexers
>>> sorted([(i[1][0], i[0]) for i in lexers.get_all_lexers()])
[('abap', 'ABAP'),
('abnf', 'ABNF'),
('ada', 'Ada'),
...
"""
from dpaste.highlight import PlainCodeHighlighter
return [
(self.PLAIN_CODE_SYMBOL, "Plain Code", PlainCodeHighlighter),
# ('abap', 'ABAP'),
# ('abnf', 'ABNF'),
# ('ada', 'Ada'),
# ('adl', 'ADL'),
# ('agda', 'Agda'),
# ('aheui', 'Aheui'),
# ('ahk', 'autohotkey'),
# ('alloy', 'Alloy'),
# ('ampl', 'Ampl'),
# ('antlr', 'ANTLR'),
# ('antlr-as', 'ANTLR With ActionScript Target'),
# ('antlr-cpp', 'ANTLR With CPP Target'),
# ('antlr-csharp', 'ANTLR With C# Target'),
# ('antlr-java', 'ANTLR With Java Target'),
# ('antlr-objc', 'ANTLR With ObjectiveC Target'),
# ('antlr-perl', 'ANTLR With Perl Target'),
# ('antlr-python', 'ANTLR With Python Target'),
# ('antlr-ruby', 'ANTLR With Ruby Target'),
# ('apacheconf', 'ApacheConf'),
# ('apl', 'APL'),
("applescript", "AppleScript"),
("arduino", "Arduino"),
# ('as', 'ActionScript'),
# ('as3', 'ActionScript 3'),
# ('aspectj', 'AspectJ'),
# ('aspx-cs', 'aspx-cs'),
# ('aspx-vb', 'aspx-vb'),
# ('asy', 'Asymptote'),
# ('at', 'AmbientTalk'),
# ('autoit', 'AutoIt'),
# ('awk', 'Awk'),
# ('basemake', 'Base Makefile'),
("bash", "Bash"),
("bat", "Batchfile"),
# ('bbcode', 'BBCode'),
# ('bc', 'BC'),
# ('befunge', 'Befunge'),
# ('bib', 'BibTeX'),
# ('blitzbasic', 'BlitzBasic'),
# ('blitzmax', 'BlitzMax'),
# ('bnf', 'BNF'),
# ('boo', 'Boo'),
# ('boogie', 'Boogie'),
# ('brainfuck', 'Brainfuck'),
# ('bro', 'Bro'),
# ('bst', 'BST'),
# ('bugs', 'BUGS'),
("c", "C"),
# ('c-objdump', 'c-objdump'),
# ('ca65', 'ca65 assembler'),
# ('cadl', 'cADL'),
# ('camkes', 'CAmkES'),
# ('capdl', 'CapDL'),
# ('capnp', "Cap'n Proto"),
# ('cbmbas', 'CBM BASIC V2'),
# ('ceylon', 'Ceylon'),
# ('cfc', 'Coldfusion CFC'),
# ('cfengine3', 'CFEngine3'),
# ('cfm', 'Coldfusion HTML'),
# ('cfs', 'cfstatement'),
# ('chai', 'ChaiScript'),
# ('chapel', 'Chapel'),
# ('cheetah', 'Cheetah'),
# ('cirru', 'Cirru'),
# ('clay', 'Clay'),
# ('clean', 'Clean'),
("clojure", "Clojure"),
# ('clojurescript', 'ClojureScript'),
("cmake", "CMake"),
# ('cobol', 'COBOL'),
# ('cobolfree', 'COBOLFree'),
("coffee-script", "CoffeeScript"),
("common-lisp", "Common Lisp"),
# ('componentpascal', 'Component Pascal'),
("console", "Console/Bash Session"),
# ('control', 'Debian Control file'),
# ('coq', 'Coq'),
# ('cpp', 'C++'),
# ('cpp-objdump', 'cpp-objdump'),
# ('cpsa', 'CPSA'),
# ('cr', 'Crystal'),
# ('crmsh', 'Crmsh'),
# ('croc', 'Croc'),
# ('cryptol', 'Cryptol'),
("csharp", "C#"),
# ('csound', 'Csound Orchestra'),
# ('csound-document', 'Csound Document'),
# ('csound-score', 'Csound Score'),
("css", "CSS"),
# ('css+django', 'CSS+Django/Jinja'),
# ('css+erb', 'CSS+Ruby'),
# ('css+genshitext', 'CSS+Genshi Text'),
# ('css+lasso', 'CSS+Lasso'),
# ('css+mako', 'CSS+Mako'),
# ('css+mozpreproc', 'CSS+mozpreproc'),
# ('css+myghty', 'CSS+Myghty'),
# ('css+php', 'CSS+PHP'),
# ('css+smarty', 'CSS+Smarty'),
# ('cucumber', 'Gherkin'),
("cuda", "CUDA"),
# ('cypher', 'Cypher'),
# ('cython', 'Cython'),
("d", "D"),
# ('d-objdump', 'd-objdump'),
("dart", "Dart"),
("delphi", "Delphi"),
# ('dg', 'dg'),
("diff", "Diff"),
("django", "Django/Jinja"),
("docker", "Docker"),
# ('doscon', 'MSDOS Session'),
# ('dpatch', 'Darcs Patch'),
# ('dtd', 'DTD'),
# ('duel', 'Duel'),
# ('dylan', 'Dylan'),
# ('dylan-console', 'Dylan session'),
# ('dylan-lid', 'DylanLID'),
# ('earl-grey', 'Earl Grey'),
# ('easytrieve', 'Easytrieve'),
# ('ebnf', 'EBNF'),
# ('ec', 'eC'),
# ('ecl', 'ECL'),
# ('eiffel', 'Eiffel'),
("elixir", "Elixir"),
# ('elm', 'Elm'),
# ('emacs', 'EmacsLisp'),
# ('erb', 'ERB'),
# ('erl', 'Erlang erl session'),
("erlang", "Erlang"),
# ('evoque', 'Evoque'),
# ('extempore', 'xtlang'),
# ('ezhil', 'Ezhil'),
# ('factor', 'Factor'),
# ('fan', 'Fantom'),
# ('fancy', 'Fancy'),
# ('felix', 'Felix'),
# ('fennel', 'Fennel'),
# ('fish', 'Fish'),
# ('flatline', 'Flatline'),
# ('forth', 'Forth'),
# ('fortran', 'Fortran'),
# ('fortranfixed', 'FortranFixed'),
# ('foxpro', 'FoxPro'),
# ('fsharp', 'FSharp'),
# ('gap', 'GAP'),
# ('gas', 'GAS'),
# ('genshi', 'Genshi'),
# ('genshitext', 'Genshi Text'),
# ('glsl', 'GLSL'),
# ('gnuplot', 'Gnuplot'),
("go", "Go"),
# ('golo', 'Golo'),
# ('gooddata-cl', 'GoodData-CL'),
# ('gosu', 'Gosu'),
# ('groff', 'Groff'),
# ('groovy', 'Groovy'),
# ('gst', 'Gosu Template'),
# ('haml', 'Haml'),
("handlebars", "Handlebars"),
("haskell", "Haskell"),
# ('haxeml', 'Hxml'),
# ('hexdump', 'Hexdump'),
# ('hlsl', 'HLSL'),
# ('hsail', 'HSAIL'),
("html", "HTML"),
# ('html+cheetah', 'HTML+Cheetah'),
("html+django", "HTML + Django/Jinja"),
# ('html+evoque', 'HTML+Evoque'),
# ('html+genshi', 'HTML+Genshi'),
# ('html+handlebars', 'HTML+Handlebars'),
# ('html+lasso', 'HTML+Lasso'),
# ('html+mako', 'HTML+Mako'),
# ('html+myghty', 'HTML+Myghty'),
# ('html+ng2', 'HTML + Angular2'),
# ('html+php', 'HTML+PHP'),
# ('html+smarty', 'HTML+Smarty'),
# ('html+twig', 'HTML+Twig'),
# ('html+velocity', 'HTML+Velocity'),
# ('http', 'HTTP'),
# ('hx', 'Haxe'),
# ('hybris', 'Hybris'),
# ('hylang', 'Hy'),
# ('i6t', 'Inform 6 template'),
# ('idl', 'IDL'),
# ('idris', 'Idris'),
# ('iex', 'Elixir iex session'),
# ('igor', 'Igor'),
# ('inform6', 'Inform 6'),
# ('inform7', 'Inform 7'),
("ini", "INI"),
# ('io', 'Io'),
# ('ioke', 'Ioke'),
# ('ipython2', 'IPython'),
# ('ipython3', 'IPython3'),
("ipythonconsole", "IPython console session"),
("irc", "IRC logs"),
# ('isabelle', 'Isabelle'),
# ('j', 'J'),
# ('jags', 'JAGS'),
# ('jasmin', 'Jasmin'),
("java", "Java"),
# ('javascript+mozpreproc', 'Javascript+mozpreproc'),
# ('jcl', 'JCL'),
# ('jlcon', 'Julia console'),
("js", "JavaScript"),
# ('js+cheetah', 'JavaScript+Cheetah'),
# ('js+django', 'JavaScript+Django/Jinja'),
# ('js+erb', 'JavaScript+Ruby'),
# ('js+genshitext', 'JavaScript+Genshi Text'),
# ('js+lasso', 'JavaScript+Lasso'),
# ('js+mako', 'JavaScript+Mako'),
# ('js+myghty', 'JavaScript+Myghty'),
# ('js+php', 'JavaScript+PHP'),
# ('js+smarty', 'JavaScript+Smarty'),
# ('jsgf', 'JSGF'),
("json", "JSON"),
("jsx", "JSX/React"),
# ('json-object', 'JSONBareObject'),
# ('jsonld', 'JSON-LD'),
# ('jsp', 'Java Server Page'),
# ('julia', 'Julia'),
# ('juttle', 'Juttle'),
# ('kal', 'Kal'),
# ('kconfig', 'Kconfig'),
# ('koka', 'Koka'),
("kotlin", "Kotlin"),
# ('lagda', 'Literate Agda'),
# ('lasso', 'Lasso'),
# ('lcry', 'Literate Cryptol'),
# ('lean', 'Lean'),
("less", "LessCSS"),
# ('lhs', 'Literate Haskell'),
# ('lidr', 'Literate Idris'),
# ('lighty', 'Lighttpd configuration file'),
# ('limbo', 'Limbo'),
# ('liquid', 'liquid'),
# ('live-script', 'LiveScript'),
# ('llvm', 'LLVM'),
# ('logos', 'Logos'),
# ('logtalk', 'Logtalk'),
# ('lsl', 'LSL'),
("lua", "Lua"),
("make", "Makefile"),
# ('mako', 'Mako'),
# ('maql', 'MAQL'),
# ('mask', 'Mask'),
# ('mason', 'Mason'),
# ('mathematica', 'Mathematica'),
("matlab", "Matlab"),
# ('matlabsession', 'Matlab session'),
# ('md', 'markdown'),
# ('minid', 'MiniD'),
# ('modelica', 'Modelica'),
# ('modula2', 'Modula-2'),
# ('monkey', 'Monkey'),
# ('monte', 'Monte'),
# ('moocode', 'MOOCode'),
# ('moon', 'MoonScript'),
# ('mozhashpreproc', 'mozhashpreproc'),
# ('mozpercentpreproc', 'mozpercentpreproc'),
# ('mql', 'MQL'),
# ('mscgen', 'Mscgen'),
# ('mupad', 'MuPAD'),
# ('mxml', 'MXML'),
# ('myghty', 'Myghty'),
# ('mysql', 'MySQL'),
# ('nasm', 'NASM'),
# ('ncl', 'NCL'),
# ('nemerle', 'Nemerle'),
# ('nesc', 'nesC'),
# ('newlisp', 'NewLisp'),
# ('newspeak', 'Newspeak'),
# ('ng2', 'Angular2'),
("nginx", "Nginx configuration file"),
# ('nim', 'Nimrod'),
# ('nit', 'Nit'),
# ('nixos', 'Nix'),
# ('nsis', 'NSIS'),
("numpy", "NumPy"),
# ('nusmv', 'NuSMV'),
# ('objdump', 'objdump'),
# ('objdump-nasm', 'objdump-nasm'),
("objective-c", "Objective-C"),
# ('objective-c++', 'Objective-C++'),
# ('objective-j', 'Objective-J'),
# ('ocaml', 'OCaml'),
# ('octave', 'Octave'),
# ('odin', 'ODIN'),
# ('ooc', 'Ooc'),
# ('opa', 'Opa'),
# ('openedge', 'OpenEdge ABL'),
# ('pacmanconf', 'PacmanConf'),
# ('pan', 'Pan'),
# ('parasail', 'ParaSail'),
# ('pawn', 'Pawn'),
("perl", "Perl"),
# ('perl6', 'Perl6'),
("php", "PHP"),
# ('pig', 'Pig'),
# ('pike', 'Pike'),
# ('pkgconfig', 'PkgConfig'),
# ('plpgsql', 'PL/pgSQL'),
("postgresql", "PostgreSQL SQL dialect"),
# ('postscript', 'PostScript'),
# ('pot', 'Gettext Catalog'),
# ('pov', 'POVRay'),
# ('powershell', 'PowerShell'),
# ('praat', 'Praat'),
# ('prolog', 'Prolog'),
# ('properties', 'Properties'),
# ('protobuf', 'Protocol Buffer'),
# ('ps1con', 'PowerShell Session'),
# ('psql', 'PostgreSQL console (psql)'),
# ('pug', 'Pug'),
# ('puppet', 'Puppet'),
# ('py3tb', 'Python 3.0 Traceback'),
# ('pycon', 'Python console session'),
# ('pypylog', 'PyPy Log'),
# ('pytb', 'Python Traceback'),
("python", "Python"),
# ('python3', 'Python 3'),
# ('qbasic', 'QBasic'),
# ('qml', 'QML'),
# ('qvto', 'QVTO'),
# ('racket', 'Racket'),
# ('ragel', 'Ragel'),
# ('ragel-c', 'Ragel in C Host'),
# ('ragel-cpp', 'Ragel in CPP Host'),
# ('ragel-d', 'Ragel in D Host'),
# ('ragel-em', 'Embedded Ragel'),
# ('ragel-java', 'Ragel in Java Host'),
# ('ragel-objc', 'Ragel in Objective C Host'),
# ('ragel-ruby', 'Ragel in Ruby Host'),
# ('raw', 'Raw token data'),
("rb", "Ruby"),
# ('rbcon', 'Ruby irb session'),
# ('rconsole', 'RConsole'),
# ('rd', 'Rd'),
# ('rebol', 'REBOL'),
# ('red', 'Red'),
# ('redcode', 'Redcode'),
# ('registry', 'reg'),
# ('resource', 'ResourceBundle'),
# ('rexx', 'Rexx'),
# ('rhtml', 'RHTML'),
# ('rnc', 'Relax-NG Compact'),
# ('roboconf-graph', 'Roboconf Graph'),
# ('roboconf-instances', 'Roboconf Instances'),
# ('robotframework', 'RobotFramework'),
# ('rql', 'RQL'),
# ('rsl', 'RSL'),
("rst", "reStructuredText"),
# ('rts', 'TrafficScript'),
("rust", "Rust"),
# ('sas', 'SAS'),
("sass", "Sass"),
# ('sc', 'SuperCollider'),
# ('scala', 'Scala'),
# ('scaml', 'Scaml'),
# ('scheme', 'Scheme'),
# ('scilab', 'Scilab'),
("scss", "SCSS"),
# ('shen', 'Shen'),
# ('silver', 'Silver'),
# ('slim', 'Slim'),
# ('smali', 'Smali'),
# ('smalltalk', 'Smalltalk'),
# ('smarty', 'Smarty'),
# ('sml', 'Standard ML'),
# ('snobol', 'Snobol'),
# ('snowball', 'Snowball'),
("sol", "Solidity"),
# ('sourceslist', 'Debian Sourcelist'),
# ('sp', 'SourcePawn'),
# ('sparql', 'SPARQL'),
# ('spec', 'RPMSpec'),
# ('splus', 'S'),
("sql", "SQL"),
# ('sqlite3', 'sqlite3con'),
# ('squidconf', 'SquidConf'),
# ('ssp', 'Scalate Server Page'),
# ('stan', 'Stan'),
# ('stata', 'Stata'),
("swift", "Swift"),
# ('swig', 'SWIG'),
# ('systemverilog', 'systemverilog'),
# ('tads3', 'TADS 3'),
# ('tap', 'TAP'),
# ('tasm', 'TASM'),
# ('tcl', 'Tcl'),
# ('tcsh', 'Tcsh'),
# ('tcshcon', 'Tcsh Session'),
# ('tea', 'Tea'),
# ('termcap', 'Termcap'),
# ('terminfo', 'Terminfo'),
# ('terraform', 'Terraform'),
("tex", "TeX"),
# ('text', 'Text only'),
# ('thrift', 'Thrift'),
# ('todotxt', 'Todotxt'),
# ('trac-wiki', 'MoinMoin/Trac Wiki markup'),
# ('treetop', 'Treetop'),
# ('ts', 'TypeScript'),
# ('tsql', 'Transact-SQL'),
# ('turtle', 'Turtle'),
# ('twig', 'Twig'),
("typoscript", "TypoScript"),
# ('typoscriptcssdata', 'TypoScriptCssData'),
# ('typoscripthtmldata', 'TypoScriptHtmlData'),
# ('urbiscript', 'UrbiScript'),
# ('vala', 'Vala'),
# ('vb.net', 'VB.net'),
# ('vcl', 'VCL'),
# ('vclsnippets', 'VCLSnippets'),
# ('vctreestatus', 'VCTreeStatus'),
# ('velocity', 'Velocity'),
# ('verilog', 'verilog'),
# ('vgl', 'VGL'),
# ('vhdl', 'vhdl'),
("vim", "VimL"),
# ('wdiff', 'WDiff'),
# ('whiley', 'Whiley'),
# ('x10', 'X10'),
("xml", "XML"),
# ('xml+cheetah', 'XML+Cheetah'),
# ('xml+django', 'XML+Django/Jinja'),
# ('xml+erb', 'XML+Ruby'),
# ('xml+evoque', 'XML+Evoque'),
# ('xml+lasso', 'XML+Lasso'),
# ('xml+mako', 'XML+Mako'),
# ('xml+myghty', 'XML+Myghty'),
# ('xml+php', 'XML+PHP'),
# ('xml+smarty', 'XML+Smarty'),
# ('xml+velocity', 'XML+Velocity'),
# ('xorg.conf', 'Xorg'),
# ('xquery', 'XQuery'),
("xslt", "XSLT"),
# ('xtend', 'Xtend'),
# ('xul+mozpreproc', 'XUL+mozpreproc'),
("yaml", "YAML"),
# ('yaml+jinja', 'YAML+Jinja'),
# ('zephir', 'Zephir')
]
# Whether to send out cache headers (Max-Age, Never-Cache, etc.).
CACHE_HEADER = True
# Defines how long pages are cached by upstream Proxies (Max-Age Header).
# This does not affect caching of snippets, their max-age limit is set
# to the expire date.
CACHE_TIMEOUT = 60 * 10
@staticmethod
def get_base_url(request=None):
"""
String. The full qualified hostname and path to the dpaste instance.
This is used to generate a link in the API response. If the "Sites"
framework is installed, it uses the current Site domain. Otherwise
it falls back to 'https://dpaste.de'
"""
if apps.is_installed("django.contrib.sites"):
from django.contrib.sites.shortcuts import get_current_site
site = get_current_site(request)
if site:
return f"https://{site.domain}"
return "https://dpaste-base-url.example.org"
@property
def extra_template_context(self):
"""
Returns a dictionary with context variables which are passed to
all Template Views.
"""
return {
"dpaste_application_name": self.APPLICATION_NAME,
"dpaste_extra_head_html": mark_safe(self.EXTRA_HEAD_HTML),
"dpaste_extra_post_about": mark_safe(self.EXTRA_POST_ABOUT),
"dpaste_extra_post_new": mark_safe(self.EXTRA_POST_NEW),
"dpaste_extra_post_form": mark_safe(self.EXTRA_POST_FORM),
}
```

41
docs/testing.md Normal file
View File

@ -0,0 +1,41 @@
# Testing
## Testing with Tox
---
dpaste is continuously tested online with [Travis](https://travis-ci.org/bartTC/dpaste). You can also run the test suite locally with [tox](https://tox.wiki/en/latest/). Tox automatically tests the project against multiple Python and Django versions.
```bash
$ pip install tox
```
Then simply call it from the project directory.
```bash
$ cd dpaste/
$ tox
```
Example tox output:
```bash
$ 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 :)
```

71
mkdocs.yml Normal file
View File

@ -0,0 +1,71 @@
site_name: Dpaste Documentation
site_author: DarrenOfficial
site_url: https://docs.dpaste.org
site_description: >-
dpaste is a pastebin application written in Python using the Django framework.
You can find a live installation on dpaste.org.
repo_url: 'https://github.com/bartTC/dpaste'
edit_uri: 'https://github.com/DarrenOfficial/dpaste-docs/edit/main/docs'
theme:
include_search_page: false
search_index_only: true
name: material
palette:
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: indigo
accent: red
toggle:
icon: material/lightbulb
name: Switch to light mode
- media: "(prefers-color-scheme: light)"
scheme: default
primary: cyan
accent: red
toggle:
icon: material/lightbulb-outline
name: Switch to dark mode
font:
text: 'Ubuntu'
code: 'Source Code Pro'
features:
- navigation.tabs
# - navigation.tabs.sticky
- tabs
- instantsite
- navigation.tracking
- navigation.expand
# - header.autohide
- content.code.annotate
- navigation.indexes
- navigation.instant
# - navigation.sections
- navigation.top
- search.highlight
- search.suggest
markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.superfences
- pymdownx.tabbed
- pymdownx.keys
- attr_list
- pymdownx.betterem:
smart_enable: all
nav:
- Home: index.md
- Installations: installation.md
- Testing: testing.md
- Management Commands: management_commands.md
- Settings: settings.md
- API: api.md
extra:
social:
- icon: 'fontawesome/brands/twitter'
link: 'https://twitter.com/darrenuselinux'
- icon: 'fontawesome/brands/github-alt'
link: 'https://github.com/darrenofficial'
- icon: 'fontawesome/brands/discourse'
link: 'https://forum.darrennathanael.com'
generator: true
copyright: '&copy; 2013-2021, Martin Mahner; &copy; 2022, Darren Nathanael'