RSS
parent
28dff13511
commit
b1b7779309
|
@ -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 {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -5,6 +5,9 @@
|
|||
{% if tag %}
|
||||
<li>/ <a href="/public/tag/{{ tag.slug }}/">{{ tag.name }}</a></li>
|
||||
{% endif %}
|
||||
<li class="rss">
|
||||
<a href="{{ request.path }}?rss">RSS</a>
|
||||
</li>
|
||||
{% endblock %}
|
||||
|
||||
{% block tags %}
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
{% if tag %}
|
||||
<li>/ <a href="/{{ user.username }}/tag/{{ tag.slug }}/">{{ tag.name }}</a></li>
|
||||
{% endif %}
|
||||
<li class="rss">
|
||||
<a href="{{ request.path }}?rss{% if not public %}&api_key={{ request.user.api_key.key }}{% endif %}">RSS</a>
|
||||
</li>
|
||||
{% endblock %}
|
||||
|
||||
{% block tags %}
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
window.api_key = '{{ request.user.api_key.key }}';{% endblock %} </script>
|
||||
{% endblock %}
|
||||
|
||||
{% if has_snipts and not detail %}
|
||||
<link rel="alternate" type="application/rss+xml" title="RSS" href="{{ request.path }}?rss{% if not public %}&api_key={{ request.user.api_key.key }}{% endif %}" />
|
||||
{% endif %}
|
||||
|
||||
<!--[if IE]>
|
||||
<style type="text/css">
|
||||
.group {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>/ {% if public and not public_user %}public{% else %}{{ user.username }}{% endif %}{% if tag %} / {{ tag }}{% endif %} - Snipt</title>
|
||||
<link>http://snipt.net{{ request.path }}</link>{% for snipt in snipts %}
|
||||
<item>
|
||||
<title>{{ snipt.title }}</title>
|
||||
<link>{{ snipt.get_absolute_url }}</link>
|
||||
<description><![CDATA[{{ snipt.code }}]]></description>
|
||||
<pubDate>{{ snipt.created }}</pubDate>
|
||||
<guid>{{ snipt.id }}</guid>
|
||||
</item>{% endfor %}
|
||||
</channel>
|
||||
</rss>
|
Loading…
Reference in New Issue