diff --git a/media/css/style.scss b/media/css/style.scss
index 71ad6ff..f36b36c 100644
--- a/media/css/style.scss
+++ b/media/css/style.scss
@@ -242,8 +242,8 @@ header.sub {
li {
display: inline-block;
- max-width: 490px;
line-height: normal;
+ max-width: 490px;
overflow: hidden;
padding: 2px 0 4px 0;
text-overflow: ellipsis;
@@ -265,6 +265,16 @@ header.sub {
margin-right: 3px;
text-shadow: 0 1px 0 #FFF;
}
+ &.rss {
+ float: right;
+
+ a {
+ background: transparent url('/static/images/rss-icon.png') center left no-repeat;
+ display: inline-block;
+ margin-right: 15px;
+ padding-left: 15px;
+ }
+ }
}
}
div.shortcuts {
diff --git a/media/images/rss-icon.png b/media/images/rss-icon.png
new file mode 100644
index 0000000..3f8cdeb
Binary files /dev/null and b/media/images/rss-icon.png differ
diff --git a/snipts/templates/snipts/list-public.html b/snipts/templates/snipts/list-public.html
index a32c6cb..a64afa5 100644
--- a/snipts/templates/snipts/list-public.html
+++ b/snipts/templates/snipts/list-public.html
@@ -5,6 +5,9 @@
{% if tag %}
/ {{ tag.name }}
{% endif %}
+
{% endblock %}
{% block tags %}
diff --git a/snipts/templates/snipts/list-user.html b/snipts/templates/snipts/list-user.html
index 11c4253..713b956 100644
--- a/snipts/templates/snipts/list-user.html
+++ b/snipts/templates/snipts/list-user.html
@@ -7,6 +7,9 @@
{% if tag %}
/ {{ tag.name }}
{% endif %}
+
{% endblock %}
{% block tags %}
diff --git a/snipts/views.py b/snipts/views.py
index 251f85d..549bf86 100644
--- a/snipts/views.py
+++ b/snipts/views.py
@@ -30,7 +30,7 @@ def list_public(request, tag_slug=None):
else:
tag = None
- return {
+ context = {
'has_snipts': True,
'lexers': sorted(get_all_lexers()),
'public': True,
@@ -39,6 +39,12 @@ def list_public(request, tag_slug=None):
'tag': tag,
}
+ if 'rss' in request.GET:
+ context['snipts'] = context['snipts'][:20]
+ return rss(request, context)
+
+ return context
+
@render_to('snipts/list-user.html')
def list_user(request, username, tag_slug=None):
@@ -46,7 +52,7 @@ def list_user(request, username, tag_slug=None):
tags = Tag.objects
snipts = Snipt.objects
- if user == request.user:
+ if user == request.user or (request.GET.get('api_key') == user.api_key.key):
public = False
favorites = Favorite.objects.filter(user=user).values('snipt')
@@ -69,7 +75,7 @@ def list_user(request, username, tag_slug=None):
else:
tag = None
- return {
+ context = {
'has_snipts': True,
'lexers': sorted(get_all_lexers()),
'public': public,
@@ -80,6 +86,12 @@ def list_user(request, username, tag_slug=None):
'user': user,
}
+ if 'rss' in request.GET:
+ context['snipts'] = context['snipts'][:20]
+ return rss(request, context)
+
+ return context
+
@render_to('snipts/detail.html')
def detail(request, username, snipt_slug):
@@ -107,6 +119,7 @@ def detail(request, username, snipt_slug):
tags = tags.order_by('-count', 'name')
return {
+ 'detail': True,
'has_snipts': True,
'lexers': sorted(get_all_lexers()),
'public': public,
@@ -123,3 +136,11 @@ def embed(request, snipt_key):
{'lines': lines, 'snipt': snipt},
context_instance=RequestContext(request),
mimetype='application/javascript')
+
+def rss(request, context):
+ return render_to_response(
+ 'rss.xml',
+ context,
+ context_instance=RequestContext(request),
+ mimetype="application/rss+xml"
+ )
diff --git a/templates/base.html b/templates/base.html
index 2610f90..baefdb5 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -42,6 +42,10 @@
window.api_key = '{{ request.user.api_key.key }}';{% endblock %}
{% endblock %}
+ {% if has_snipts and not detail %}
+
+ {% endif %}
+