Commit b0704f87 authored by svilayphiou's avatar svilayphiou

rss feeds

parent d1ab5668
......@@ -182,6 +182,16 @@ class Pad(models.Model):
def padid(self):
return "%s$%s" % (self.group.groupID, self.name)
@property
def getLastEdited(self):
from datetime import datetime
timestamp = self.epclient.getLastEdited(self.padid)
return datetime.fromtimestamp(timestamp['lastEdited']/1000)
@property
def getFirstLines(self):
return "%s" % (self.epclient.getText(self.padid)['text'][:280])
@property
def epclient(self):
return EtherpadLiteClient(self.server.apikey, self.server.apiurl)
......
{% load wikify %}
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>{{ site_name }}</title>
<link>{{ SITE_DOMAIN }}</link>
<description>Recent activities of this Ethertoff instance.</description>
{% for pad in pads|slice:":10" %}
<item>
<title>{{ pad.display_slug|dewikify }}</title>
<link>{{ SITE_DOMAIN }}{% url 'pad-read' 'r' pad.display_slug %}</link>
<guid>{{ SITE_DOMAIN }}{% url 'pad-read' 'r' pad.display_slug %}</guid>
<pubDate>{{ pad.getLastEdited }}</pubDate>
{% endfor %}
</channel>
</rss>
......@@ -30,6 +30,7 @@ urlpatterns = [
path('', views.home, name='home'),
path('admin/', admin.site.urls),
path('all/', views.all, name='all'), # TemplateView.as_view(template_name = 'all.html')
path('rss.xml', views.rss, name='rss'), # TemplateView.as_view(template_name = 'rss.xml')
path('publish/', views.publish, name='publish'),
path('css-screen/', views.css, name='css-screen'),
path('css-print/', views.cssprint, name='css-print'),
......
......@@ -432,6 +432,15 @@ def publish(request):
def all(request):
return render(request, "all.html")
def rss(request):
from ethertoff.settings import SITE_DOMAIN
context = {
'SITE_DOMAIN': SITE_DOMAIN,
}
return render(request, "rss.xml", context)
def padOrFallbackPath(request, slug, fallbackPath, mimeType):
try:
pad = Pad.objects.get(display_slug=slug)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment