diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2012-10-24 23:16:11 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2012-10-24 23:16:11 +0200 |
| commit | 200ad8c2075802dbb38bbd27dd2f86c39fdb1ce0 (patch) | |
| tree | e66ba3daeead8b25bdf5f42ed5df20f017125840 | |
| parent | 0bf9d11cf26314c7a3285a934c2faf3db50ec9ce (diff) | |
| download | phorkie-200ad8c2075802dbb38bbd27dd2f86c39fdb1ce0.tar.gz phorkie-200ad8c2075802dbb38bbd27dd2f86c39fdb1ce0.zip | |
Part of #6: atom feed for new pastes
| -rw-r--r-- | README.rst | 1 | ||||
| -rw-r--r-- | data/templates/feed-new.htm | 23 | ||||
| -rw-r--r-- | data/templates/list.htm | 4 | ||||
| -rw-r--r-- | www/.htaccess | 2 | ||||
| -rw-r--r-- | www/feed-new.php | 19 |
5 files changed, 49 insertions, 0 deletions
@@ -283,6 +283,7 @@ If you use nginx, place the following lines into your ``server`` block: rewrite ^/([0-9]+)/tool/([^/]+)/(.+)$ /tool.php?id=$1&tool=$2&file=$3; rewrite ^/new$ /new.php; + rewrite ^/feed/new$ /feed-new.php; rewrite ^/list$ /list.php; rewrite ^/list/([0-9]+)$ /list.php?page=$1; diff --git a/data/templates/feed-new.htm b/data/templates/feed-new.htm new file mode 100644 index 0000000..c0d5fa5 --- /dev/null +++ b/data/templates/feed-new.htm @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <title>{{title}}: New pastes</title> + <link href="{{url}}"/> + <link rel="self" href="{{feedurl}}"/> + <id>{{url}}</id> +{% set repo = pastes.repos.0 %} + <updated>{{repo.crdate|date('c')}}</updated> + +{% for repo in pastes.repos %} + <entry> + <id>{{repo.getLink('display', null, true)}}</id> + <title>{{repo.getTitle}}</title> + <updated>{{repo.crdate|date('c')}}</updated> + <link rel="alternate" type="text/html" href="{{repo.getLink('display', null, true)}}" /> + <author> + {% set owner=repo.getOwner() %} + <name>{{owner.name}}</name> + <email>{{owner.email}}</email> + </author> + </entry> +{% endfor %} +</feed>
\ No newline at end of file diff --git a/data/templates/list.htm b/data/templates/list.htm index 0315119..ac3d664 100644 --- a/data/templates/list.htm +++ b/data/templates/list.htm @@ -1,6 +1,10 @@ {% extends "base.htm" %} {% block title %}List of all pastes{% endblock %} +{% block meta %} + <link rel="alternate" type="application/atom+xml" title="New pastes" href="feed/new" /> +{% endblock %} + {% block content %} <div style="height: 1em"></div> <ul class="nav nav-pills nav-stacked"> diff --git a/www/.htaccess b/www/.htaccess index 03bbf60..d18aa34 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -16,6 +16,8 @@ RewriteRule ^([0-9]+)/tool/([^/]+)/(.+)$ /tool.php?id=$1&tool=$2&file=$3 RewriteRule ^fork-remote$ /fork-remote.php RewriteRule ^new$ /new.php +RewriteRule ^feed/new$ /feed-new.php + RewriteRule ^list$ /list.php RewriteRule ^list/([0-9]+)$ /list.php?page=$1 diff --git a/www/feed-new.php b/www/feed-new.php new file mode 100644 index 0000000..a462808 --- /dev/null +++ b/www/feed-new.php @@ -0,0 +1,19 @@ +<?php +/** + * Generate an atom feed with the 10 most recently created pastes + */ +namespace phorkie; +$reqWritePermissions = false; +require_once 'www-header.php'; + +$db = new Database(); +header('Content-Type: application/atom+xml'); +render( + 'feed-new', + array( + 'pastes' => $db->getSearch()->listAll(0, 10, 'crdate', 'desc'), + 'url' => Tools::fullUrl('/'), + 'feedurl' => Tools::fullUrl('/feed/new'), + ) +); +?> |
