]> git.phdru.name Git - phdru.name/phdru.name.git/commitdiff
For urljoin() to remove ".." components baseURL must ends in a slash.
authorOleg Broytman <phd@phdru.name>
Fri, 17 Mar 2006 12:06:34 +0000 (12:06 +0000)
committerOleg Broytman <phd@phdru.name>
Fri, 17 Mar 2006 12:06:34 +0000 (12:06 +0000)
git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@34 7bb0bf08-9e0d-0410-b083-99cee3bf18b8

atom_10.tmpl
make-news.py
news.py
rss_20.tmpl

index 0cc3ce88431f0420b4c2bfa51dcba980a74af465..8c601e03589220f30ac5e1b61c5b2ddc2b3815a2 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="koi8-r"?>
 <feed xmlns="http://www.w3.org/2005/Atom">
   <title>$title</title>
-  <id>$baseURL/news.html</id>
-  <link rel="self" type="application/atom+xml" href="$baseURL/atom_10.xml" />
-  <link rel="alternate" type="text/html" href="$baseURL/news.html" />
+  <id>${baseURL}news.html</id>
+  <link rel="self" type="application/atom+xml" href="${baseURL}atom_10.xml" />
+  <link rel="alternate" type="text/html" href="${baseURL}news.html" />
   <updated>${posts[0].date}T00:00:00Z</updated>
   <author>
     <name>$author</name>
index a654c26720b50253c1475dcd3fe17a6fdb65db8e..2fcb7163c1352e7de1571dc16695992134ee031d 100755 (executable)
@@ -40,7 +40,7 @@ from rss_20 import rss_20
 
 namespace = {
    "title": "Oleg Broytmann's Personal Page - News",
-   "baseURL": "http://phd.pp.ru",
+   "baseURL": "http://phd.pp.ru/",
    "description": "",
    "lang": lang,
    "author": "Oleg Broytmann",
@@ -50,7 +50,8 @@ namespace = {
 
 if lang == "ru":
    namespace["title"] = "Oleg Broytmann's Personal Page - Russian News"
-   namespace["baseURL"] = "http://phd.pp.ru/Russian"
+   namespace["baseURL"] = baseURL = "http://phd.pp.ru/Russian/"
+   for item in news_items: item.baseURL = baseURL
 
 atom_tmpl = str(atom_10(searchList=[namespace]))
 write_if_changed(os.path.join(root, "atom_10.xml"), atom_tmpl)
diff --git a/news.py b/news.py
index b091cbdda47242bc4077e18a14ea3182c35e6df7..38bdf56bfa1289a6031c33cf78479440d3ba9c04 100644 (file)
--- a/news.py
+++ b/news.py
@@ -14,6 +14,7 @@ from datetime import date
 from urlparse import urljoin
 
 class NewsItem(object):
+   baseURL = "http://phd.pp.ru/"
    excerpt = None
    content = None
    categoryList = []
@@ -24,7 +25,7 @@ class NewsItem(object):
       self.rel_link = rel_link
 
    def URL(self):
-      return urljoin("http://phd.pp.ru/", self.rel_link)
+      return urljoin(self.baseURL, self.rel_link)
 
    def rfc822_date(self):
       y, m, d = self.date.split('-')
index 09b646ad3a09cdeee9005b5c96f77a7d54bcaa8c..1ead69cf5e141421027a3379f238a659b2fb568d 100644 (file)
@@ -2,7 +2,7 @@
 <rss version="2.0">
   <channel>
     <title>$title</title>
-    <link>$baseURL/news.html</link>
+    <link>${baseURL}news.html</link>
     <description>$description</description>
     <language>$lang</language>
     <webMaster>$author &lt;$email&gt;</webMaster>