Drop Github Gist Export

This commit is contained in:
Martin Mahner 2016-03-24 20:16:34 +01:00
parent 6799f8609f
commit f5cc7fc171
4 changed files with 2 additions and 36 deletions

View file

@ -98,6 +98,8 @@ behavior without touching the code:
Boolean. Whether to display the Gist button for re-pasting to GitHub. Boolean. Whether to display the Gist button for re-pasting to GitHub.
Default: ``True`` Default: ``True``
..warning: This feature was removed in v2.11.
``DPASTE_DEFAULT_GIST_NAME`` ``DPASTE_DEFAULT_GIST_NAME``
String. The filename used when pasting a snippet on Github Gist. String. The filename used when pasting a snippet on Github Gist.
Default: ``dpaste.de_snippet.py`` Default: ``dpaste.de_snippet.py``

View file

@ -67,10 +67,6 @@
{% if snippet.expire_type != 3 %} {% 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> <a class="btn" href="{% url "snippet_details_raw" snippet.secret_id %}"><i class="icon-align-left"></i> {% trans "View Raw" %}</a>
{% endif %} {% 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' %} {% if snippet.lexer != 'text' %}
<a class="btn" href="#" id="toggleWordwrap">Wordwrap</a> <a class="btn" href="#" id="toggleWordwrap">Wordwrap</a>
{% endif %} {% endif %}

View file

@ -15,6 +15,5 @@ urlpatterns = [
url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/?$' % L, views.SnippetDetailView.as_view(), name='snippet_details'), url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/?$' % L, views.SnippetDetailView.as_view(), name='snippet_details'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/delete/$' % L, views.SnippetDeleteView.as_view(), name='snippet_delete'), url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/delete/$' % L, views.SnippetDeleteView.as_view(), name='snippet_delete'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/gist/$' % L, views.snippet_gist, name='snippet_gist'),
url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/raw/?$' % L, views.SnippetRawView.as_view(), name='snippet_details_raw'), url(r'^(?P<snippet_id>[a-zA-Z0-9]{%d,})/raw/?$' % L, views.SnippetRawView.as_view(), name='snippet_details_raw'),
] ]

View file

@ -227,37 +227,6 @@ class SnippetDiffView(TemplateView):
return ctx return ctx
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', ''),
'public': False,
'files': {
getattr(settings, 'DPASTE_DEFAULT_GIST_NAME', 'dpaste.de_snippet.py'): {
'content': snippet.content,
}
}
}
try:
payload = json.dumps(data)
response = requests.post('https://api.github.com/gists', data=payload)
response_dict = response.json()
gist_url = response_dict.get('html_url')
# Github could be down, could return invalid JSON, it's rare
except:
return HttpResponse('Creating a Github Gist failed. Sorry, please go back and try again.')
return HttpResponseRedirect(gist_url)
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Static pages # Static pages
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------