mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-12-23 23:23:06 +11:00
New settings for private installations
- The site name in the titles and "about" page can be changed from dpaste.de - The Gist feature can be disabled (both the UI and the code that does the POST) - A different URL can be given for jquery(.min).js besides google, such as beside the local static files
This commit is contained in:
parent
66203c18fe
commit
85a02edb8f
5 changed files with 36 additions and 11 deletions
|
@ -34,6 +34,10 @@ behavior without touching the code:
|
|||
String. The full qualified hostname and path to the dpaste instance.
|
||||
This is used to generate a link in the API response. Default: ``https://dpaste.de``
|
||||
|
||||
``DPASTE_SITE_NAME``
|
||||
String. Site name to display in page titles. Default:
|
||||
``dpaste.de``
|
||||
|
||||
``DPASTE_LEXER_LIST``
|
||||
Choices. A tuple of choices of Pygments lexers used in the lexer
|
||||
dropdown. Here is the full `lexer list`_ which is currently used.
|
||||
|
@ -90,6 +94,10 @@ behavior without touching the code:
|
|||
The key of the default value of ``DPASTE_EXPIRE_CHOICES``. Default:
|
||||
``3600 * 24 * 30 * 12 * 100`` or simpler: ``DPASTE_EXPIRE_CHOICES[2][0]``.
|
||||
|
||||
``DPASTE_ENABLE_GIST``
|
||||
Boolean. Whether to display the Gist button for re-pasting to GitHub.
|
||||
Default: ``True``
|
||||
|
||||
``DPASTE_DEFAULT_GIST_NAME``
|
||||
String. The filename used when pasting a snippet on Github Gist.
|
||||
Default: ``dpaste.de_snippet.py``
|
||||
|
@ -98,4 +106,8 @@ behavior without touching the code:
|
|||
String. The filename used when pasting a snippet on Github Gist.
|
||||
Default: ``dpaste.de_snippet.py``
|
||||
|
||||
``DPASTE_JQUERY_URL``
|
||||
String. URL to use for jQuery.
|
||||
Default: ``//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js``
|
||||
|
||||
.. _lexer list: https://github.com/bartTC/dpaste/blob/master/dpaste/highlight.py#L25
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
{% load i18n %}
|
||||
{% load url from future %}
|
||||
|
||||
{% block title %}About dpaste.de{% endblock %}
|
||||
{% block headline %}About dpaste.de{% endblock %}
|
||||
{% block title %}About {{ site_name }}{% endblock %}
|
||||
{% block headline %}About {{ site_name }}{% endblock %}
|
||||
{% block dpaste_nav_about %}active{% endblock %}
|
||||
|
||||
{% block page %}
|
||||
|
@ -12,8 +12,9 @@
|
|||
<div class="row-fluid">
|
||||
|
||||
<p>
|
||||
dpaste is open source. You can find the source, contribute to it and
|
||||
leave ideas on Github: <a href="https://github.com/bartTC/dpaste">github.com/bartTC/dpaste</a>
|
||||
{{ site_name }} is powered by dpaste, which is open source. You can
|
||||
find the source, contribute to it and leave ideas on Github:
|
||||
<a href="https://github.com/bartTC/dpaste">github.com/bartTC/dpaste</a>
|
||||
</p>
|
||||
|
||||
<h3>API</h3>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>dpaste.de: {% block title %}{% trans "New snippet" %}{% endblock %}</title>
|
||||
<title>{{ site_name }}: {% block title %}{% trans "New snippet" %}{% endblock %}</title>
|
||||
<link rel="stylesheet" href="{% static "dpaste/bootstrap/css/bootstrap.min.css" %}">
|
||||
<link rel="stylesheet" href="{% static "dpaste/theme.css" %}">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
@ -28,7 +28,7 @@
|
|||
</div>
|
||||
|
||||
{% block script_footer %}
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
|
||||
<script src="{{ jquery_url }}"></script>
|
||||
<script>
|
||||
jQuery(function($) {
|
||||
$('.autofocus textarea:first').focus();
|
||||
|
|
|
@ -68,8 +68,10 @@
|
|||
{% if snippet.expire_type != 3 %}
|
||||
<a class="btn" href="{% url "snippet_details_raw" snippet.secret_id %}"><i class="icon-align-left"></i> {% trans "View Raw" %}</a>
|
||||
{% endif %}
|
||||
{% if gist %}
|
||||
<a class="btn" href="{% url "snippet_gist" snippet.secret_id %}"
|
||||
rel="nofollow" title="Create a secret Gist"><i class="icon-share"></i> {% trans "Gist" %}</a>
|
||||
{% endif %}
|
||||
{% if snippet.lexer != 'text' %}
|
||||
<a class="btn" href="#" id="toggleWordwrap">Wordwrap</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -24,6 +24,12 @@ from dpaste.models import Snippet, ONETIME_LIMIT
|
|||
from dpaste.highlight import (LEXER_DEFAULT, LEXER_KEYS, LEXER_WORDWRAP,
|
||||
LEXER_LIST, PLAIN_CODE)
|
||||
|
||||
template_globals = {
|
||||
'site_name': getattr(settings, 'DPASTE_SITE_NAME', 'dpaste.de'),
|
||||
'jquery_url': getattr(settings, 'DPASTE_JQUERY_URL',
|
||||
'//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js'),
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Snippet Handling
|
||||
# -----------------------------------------------------------------------------
|
||||
|
@ -50,7 +56,7 @@ def snippet_new(request, template_name='dpaste/snippet_new.html'):
|
|||
return render_to_response(
|
||||
template_name,
|
||||
template_context,
|
||||
RequestContext(request)
|
||||
RequestContext(request, template_globals)
|
||||
)
|
||||
|
||||
|
||||
|
@ -100,12 +106,13 @@ def snippet_details(request, snippet_id, template_name='dpaste/snippet_details.h
|
|||
'lines': range(snippet.get_linecount()),
|
||||
'tree': tree,
|
||||
'wordwrap': snippet.lexer in LEXER_WORDWRAP and 'True' or 'False',
|
||||
'gist': getattr(settings, 'DPASTE_ENABLE_GIST', True),
|
||||
}
|
||||
|
||||
response = render_to_response(
|
||||
template_name,
|
||||
template_context,
|
||||
RequestContext(request)
|
||||
RequestContext(request, template_globals)
|
||||
)
|
||||
|
||||
if is_raw:
|
||||
|
@ -155,7 +162,7 @@ def snippet_history(request, template_name='dpaste/snippet_list.html'):
|
|||
return render_to_response(
|
||||
template_name,
|
||||
template_context,
|
||||
RequestContext(request)
|
||||
RequestContext(request, template_globals)
|
||||
)
|
||||
|
||||
|
||||
|
@ -202,7 +209,7 @@ def snippet_diff(request, template_name='dpaste/snippet_diff.html'):
|
|||
return render_to_response(
|
||||
template_name,
|
||||
template_context,
|
||||
RequestContext(request)
|
||||
RequestContext(request, template_globals)
|
||||
)
|
||||
|
||||
|
||||
|
@ -210,6 +217,9 @@ def snippet_gist(request, snippet_id): # pragma: no cover
|
|||
"""
|
||||
Put a snippet on Github Gist.
|
||||
"""
|
||||
if not getattr(settings, 'DPASTE_ENABLE_GIST', True):
|
||||
raise Http404('Gist creation is disabled on this installation.')
|
||||
|
||||
snippet = get_object_or_404(Snippet, secret_id=snippet_id)
|
||||
data = {
|
||||
'description': getattr(settings, 'DPASTE_DEFAULT_GIST_DESCRIPTION', ''),
|
||||
|
@ -252,7 +262,7 @@ def about(request, template_name='dpaste/about.html'):
|
|||
return render_to_response(
|
||||
template_name,
|
||||
template_context,
|
||||
RequestContext(request)
|
||||
RequestContext(request, template_globals)
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue