Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added support for embedding.

  • Loading branch information...
commit 58e1b98a7109b6b7d78cc0ac30bbfee35e0b3415 1 parent 682ae8b
@justinvh justinvh authored
View
18 saic/paste/templates/embed.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html lang='en'>
+ <head>
+ <title>GitPaste Embedding</title>
+ <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700|Lato:400,700|Droid+Sans+Mono' rel='stylesheet'>
+ <link rel='stylesheet' media='print' href='{{ STATIC_URL }}/css/base-print.css'>
+ <link rel='stylesheet' media='screen' type='text/css' href='{{ STATIC_URL }}/css/view.css'>
+ <link rel='stylesheet' media='all' type='text/css' href='{{ STATIC_URL }}/css/pygments/{{ theme }}.css'>
+ </head>
+ <body>
+ <div class='paste'>
+ <div>
+ {{ paste.paste_formatted|safe }}
+ </div>
+ </div>
+ </body>
+</html>
+
View
3  saic/paste/templates/paste-view.html
@@ -152,7 +152,8 @@
</div>
<div class='file'>
<div class='file-download'>
- <a title='You should just fork it.' href='{% url paste_raw pk=paste.pk private_key=paste_set.active_private_key %}?download=true'>download</a>
+ <a title='You should just fork it.' href='{% url paste_raw pk=paste.pk private_key=paste_set.active_private_key %}?download=true'>download</a>
+ <a title='Embedding it.' href='{% url paste_embed pk=paste.pk private_key=paste_set.active_private_key %}'>embed</a>
</div>
<div id='file-{{ paste.pk }}'>
{{ paste.filename }} <a href='#file-{{ paste.pk }}'>#</a>
View
1  saic/paste/urls.py
@@ -7,6 +7,7 @@
url(r'^owner/anonymous/', 'user_pastes', name='anon_pastes'),
url(r'^owner/(?P<owner>.+)/', 'user_pastes', name='user_pastes'),
url(r'^paste/(?P<pk>\d+)/adopt/(?P<private_key>[a-zA-Z0-9]+)?/?$', 'paste_adopt', name='paste_adopt'),
+ url(r'^paste/(?P<pk>\d+)/embed/(?P<private_key>[a-zA-Z0-9]+)?/?$', 'paste_embed', name='paste_embed'),
url(r'^paste/(?P<pk>\d+)/edit/(?P<private_key>[a-zA-Z0-9]+)?/?$', 'paste_edit', name='paste_edit'),
url(r'^paste/(?P<pk>\d+)/fork/(?P<private_key>[a-zA-Z0-9]+)?/?$', 'paste_fork', name='paste_fork'),
url(r'^paste/(?P<pk>\d+)/favorite/(?P<private_key>[a-zA-Z0-9]+)?/?$', 'paste_favorite', name='paste_favorite'),
View
12 saic/paste/views.py
@@ -17,7 +17,7 @@
import git
-from django.http import HttpResponse
+from django.http import HttpResponse, Http404
from django.shortcuts import render_to_response, get_object_or_404, redirect
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
@@ -777,3 +777,13 @@ def set_timezone(request):
else:
return render(request, 'template.html', {'timezones': pytz.common_timezones})
+
+def paste_embed(request, pk, private_key=None):
+ theme = request.GET.get('theme', 'tango')
+ filtering = {'pk': pk}
+ paste = get_object_or_404(Paste, **filtering)
+ if (paste.revision.parent_set.private and
+ paste.revision.parent_set.private_key != private_key):
+ raise Http404
+ return render_to_response('embed.html',
+ {'paste': paste, 'theme': theme}, RequestContext(request))
Please sign in to comment.
Something went wrong with that request. Please try again.